Programmatically synchronizing two motors

Discussion specific to the intelligent brick, sensors, motors, and more.
Post Reply
alexgd
Posts: 3
Joined: 18 Oct 2010, 16:49

Programmatically synchronizing two motors

Post by alexgd »

Hi everybody,

nice to find a substitute to the old NXTasy forum (where I was named Enciladus).

I am currently working on a LEGO Mindstorms project and I am programming the robots using nxtOSEK and Eclipse. I have to use a language that supports classes. As I have noticed so far, there is no function implemented, that enables to servos to drive synchronized like the OnFwdSync method in NXC. I need this, because the variation of the motors from each other is getting to big.

Could you give me some suggestions perhaps? I have tried to read out the tacho count and adjust the speed of the slow motor manually, but therefore I have to know what distance the robot drove, which is rather difficult to know, since the robot drives on different surfaces.

I think one good way would be to read out the currently applied voltage of the servo and adjust them, but I can't see a way with the ECRobot API which nxtOSEK uses.

I would be glad for any suggestions you guys might have.

Greetings, Alex
schodet
Posts: 139
Joined: 29 Sep 2010, 11:21
Contact:

Re: Programmatically synchronizing two motors

Post by schodet »

alexgd wrote:I am currently working on a LEGO Mindstorms project and I am programming the robots using nxtOSEK and Eclipse. I have to use a language that supports classes. As I have noticed so far, there is no function implemented, that enables to servos to drive synchronized like the OnFwdSync method in NXC. I need this, because the variation of the motors from each other is getting to big.
Could you give me some suggestions perhaps? I have tried to read out the tacho count and adjust the speed of the slow motor manually, but therefore I have to know what distance the robot drove, which is rather difficult to know, since the robot drives on different surfaces.
You can use a PID controller to make the difference between the two motors tacho count null.

Basically:

Code: Select all

error = left_count - right_count
power_diff = kP * error   # this is a P controller, it may be sufficient, or you can add I and D.
power_left = power - power_diff
power_right = power + power_diff
That is actually what is done in the LEGO firmware.
LEGO things http://ni.fr.eu.org/lego/ - NXT Improved Firmware (GCC) http://nxt-firmware.ni.fr.eu.org/ - Other robots http://apbteam.org
alexgd
Posts: 3
Joined: 18 Oct 2010, 16:49

Re: Programmatically synchronizing two motors

Post by alexgd »

thanks a lot!

I will give it a try.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 0 guests