position control of a non linear movement

Questions about using encoders with the Roboclaw product line
NicolasD
Posts: 3
Joined: Wed Mar 06, 2019 12:28 pm

position control of a non linear movement

Postby NicolasD » Wed Mar 06, 2019 12:58 pm

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

User avatar
Basicmicro Support
Posts: 1132
Joined: Thu Feb 26, 2015 9:45 pm

Re: position control of a non linear movement

Postby Basicmicro Support » Thu Mar 07, 2019 9:52 am

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.

NicolasD
Posts: 3
Joined: Wed Mar 06, 2019 12:28 pm

Re: position control of a non linear movement

Postby NicolasD » Tue Mar 12, 2019 11:30 pm

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

User avatar
Basicmicro Support
Posts: 1132
Joined: Thu Feb 26, 2015 9:45 pm

Re: position control of a non linear movement

Postby Basicmicro Support » Wed Mar 13, 2019 10:10 am

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.

NicolasD
Posts: 3
Joined: Wed Mar 06, 2019 12:28 pm

Re: position control of a non linear movement

Postby NicolasD » Thu Mar 14, 2019 10:57 pm

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

User avatar
Basicmicro Support
Posts: 1132
Joined: Thu Feb 26, 2015 9:45 pm

Re: position control of a non linear movement

Postby Basicmicro Support » Fri Mar 15, 2019 9:55 am

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.


Return to “Velocity and Position Control”

Who is online

Users browsing this forum: No registered users and 1 guest