Page 1 of 1

position control of a non linear movement

Posted: Wed Mar 06, 2019 12:58 pm
by NicolasD
Hi everyone,

We are using a 2x7A motor controller to drive two motors with quadrature encoders on an arduino micro controller

The two motors need to follow two non linear movements (sinusoidal). Those movements are different but should be time synchronized.

We tried positon and distance functions without any good results...The movements are not smooth.
As the movement is non linear the speed and position should change following the mathematics functions.
Is the distance function can be used to do that? Does it automatically adjust the speed according the updated distance that follow the non linear law?

An advice to code it properly?

Thanks for your support

Re: position control of a non linear movement

Posted: Thu Mar 07, 2019 9:52 am
by Basicmicro Support
To execute a non-linear movement you will need to update the positions regularly(how often will depend on how smooth you need your movement and how dynamic the movement is).

You can use the accel and decel arguments to provide more accurately interpolation of the movement between position commands. Basically you will be producing straight lines instead of curves if you graph the movement(think a facteted sine wave).

Before doing any of that though you need to make sure your tuning is solid(eg simple straight line movements are accuratge.

Re: position control of a non linear movement

Posted: Tue Mar 12, 2019 11:30 pm
by NicolasD
Thanks for your support.

So I just need to use the distance function: SpeedAccelDistanceM1(address, accel, speed, distance, flag)

And update the accel, speed, distance of each motor using a timer, right?

Thanks

Re: position control of a non linear movement

Posted: Wed Mar 13, 2019 10:10 am
by Basicmicro Support
The distance commands can be buffered. Eg send several and as the distance is reach for the earlier command the next command will start to execute. You can also use the GetBuffers command to determine when the last buffered command is executing so you can send more distance commands to the buffer.

Re: position control of a non linear movement

Posted: Thu Mar 14, 2019 10:57 pm
by NicolasD
Yes I know about the buffer function. But as I need to synch two drives, using the buffer function I could have a difference between the commands sent and executed between the two motors, no? That's why I thought to use a timer.
Thanks

Re: position control of a non linear movement

Posted: Fri Mar 15, 2019 9:55 am
by Basicmicro Support
You dont need to use many buffered commands. I would recommend, for your requirements, always sending the next command, buffered, a bit before the previous command completes. This way your new command will start exactly on the end of the last command.

Otherwise I would suggest using non-distance commands. Using distance without buffereing the commands will either work exactly the same as the non-distance speed commands(assuming your new command is sent before the distance runs out) or you could end up sending your new command late. When a distance command finishes while at a non-zero speed, the controller will automatically calculate a new decel rate that will stop the motor in 1 second. This could cause you problems if your timing or calculations are off and you sned your new command late.