I would like to Sync 2 motors from Arduino commands

Questions about using encoders with the Roboclaw product line
laptophead
Posts: 9
Joined: Mon Oct 16, 2017 5:03 pm

I would like to Sync 2 motors from Arduino commands

Postby laptophead » Wed Jul 18, 2018 3:02 pm

I am using the roboclaw 15A version, great product by the way. In ION Studio, I am able to click the Sync box and move the motors in sync.

I dont need that feature all the time. I would like to be able to do it from the Arduino IDE commands;
Now I am using:

roboclaw130.SpeedAccelDeccelPositionM2(adr130, 6000, 30000, 0, 92763, 1); //Hor Rotation of grip

roboclaw130.SpeedAccelDeccelPositionM1(adr130, 6000, 30000, 0, 92763, 1); //Vertical Rot

The motors get there but en- route the mechanism wobbles all over the place, since the 2 motors encounter various loads along the way.
What would be the command to sync them?
What if they dont have the same Position destination? Can they sync up to a point, and then can one continue to its Position?
Thanks

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

Re: I would like to Sync 2 motors from Arduino commands

Postby Basicmicro Support » Thu Jul 19, 2018 9:06 am

There is a SpeedAccelDeccelPositionMixed comamnds. This will let you set the new position/speed/accel for both motor channels at the same time. This is what we use in IonStudio when tou check the Sync check

In general their targets at any point along the path will be the same(the next position target is updated based on the accel value 300 times a second. However if the tuning of the PID is not good enough you will get the wobble/non linear movement due to changes in load(eg each motor wont reach the new target exactly the same way). You will need to run some tests with this and if they are not staying synced after starting at the same moment with the same speed/accel settings you may need to tweak your PID values.

As for the last part please give an example of what you mean(eg different position targets). If you start two movements from different positions to different positions but the speed and accel arguments are the same the movements should be synced(eg move at the same speed at any given moment) atleast until one or the other reaches its deceleration point(if the distance for the movement isnt the same on both motors one motor will,. start to decel befvore the other motor and stop before the other motor.

You could calculate an appropriate decel value so even with different position distances they stop at the same time but the decel, accel and/or speed settings would need to be different from each other.

laptophead
Posts: 9
Joined: Mon Oct 16, 2017 5:03 pm

Re: I would like to Sync 2 motors from Arduino commands

Postby laptophead » Thu Jul 19, 2018 12:28 pm

Thanks for the timely reply.

I tried:

roboclaw130.SpeedAccelDeccelPositionMixed(adr130, 6000, 30000, 0, 70000, 1);
going to
roboclaw130.SpeedAccelDeccelPositionMixed (adr130, 6000, 30000, 0, 90000, 1);

and it does not compile. I got: class RoboClaw' has no member named 'SpeedAccelDeccelPositionMixed'

It would be nice if your manuals or examples would include examples of syntax commands.

regarding different starting points and ending points:

In the example above both motors will travel 20K pulses in tandem and that is Fine.
However my situation has need for M1 to travel from 50K to 70K and M2 to travel from 70K to 90K.

(It is a robot wrist pouring a cup.)
As you see the distance is the same, but how do I make them sync from different starting points?

Thanks

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

Re: I would like to Sync 2 motors from Arduino commands

Postby Basicmicro Support » Fri Jul 20, 2018 9:18 am

Whenever you need the syntax for a particular arduino library function you need to either look at the bareminimum example which lists the functions in comments at the top of the program or look at the roboclaw.h definition file.

My post from yesterday was jsut from memory and I didnt state the arguments either.

SpeedAccelDeccelPositionM1M2(uint8_t address,uint32_t accel1,uint32_t speed1,uint32_t deccel1,uint32_t position1,uint32_t accel2,uint32_t speed2,uint32_t deccel2,uint32_t position2,uint8_t flag);

laptophead
Posts: 9
Joined: Mon Oct 16, 2017 5:03 pm

Re: I would like to Sync 2 motors from Arduino commands

Postby laptophead » Thu Aug 09, 2018 12:27 pm

thanks a lot for the clarifications.

The syntax worked, here it is for other users:
I replaced:
roboclaw130.SpeedAccelDeccelPositionM1(adr130, 6000, 30000, 0, HorizGrip, 1); //Vertical Rot
roboclaw130.SpeedAccelDeccelPositionM2(adr130, 6000, 30000, 0, HorizGrip, 1); //Hor Rotation of grip

with one line :
roboclaw130.SpeedAccelDeccelPositionM1M2(adr130, 3000, 30000, 0, HorizGrip,, 3000, 30000, 0, HorizGrip,1);

The results are still not good, The two motors are still way out of sync en- route, but they end up in the correct position like before.
The 2 motors do start at the same place and the pulses to be covered are the same.

I tried lower speeds and they wobble all over even more...
Please help.

Thanks

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

Re: I would like to Sync 2 motors from Arduino commands

Postby Basicmicro Support » Fri Aug 10, 2018 9:19 am

This probably indicates a tuning issue. You need to confirm each motor will move properly on their own(eg with specified speed/accel settings and then test both together. Graph the movement in IonStudio to see the error relative to each other or to see if single motor movement is smooth. If it isnt smooth then you still have work to do on your PID settings. I recommend calling in if you need help with tuning.

laptophead
Posts: 9
Joined: Mon Oct 16, 2017 5:03 pm

Re: I would like to Sync 2 motors from Arduino commands

Postby laptophead » Fri Aug 10, 2018 6:58 pm

I went into tuning, and improved it a bit, added more P and more I. Works a lot better, I guess it needs power to keep up the task.

It still not moving like is a one assembly but, good enough for now. Finally there are no 2 soldiers that walk in perfect cadence.

Great product , the roboclaw.

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

Re: I would like to Sync 2 motors from Arduino commands

Postby Basicmicro Support » Mon Aug 13, 2018 10:07 am

Call in if you want some help tuning or if you want a second oppinion on if your current tuning is the best you can expect.


Return to “Velocity and Position Control”

Who is online

Users browsing this forum: No registered users and 1 guest

cron