View unanswered posts | View active topics It is currently Fri Jul 01, 2016 2:31 am

 Page 1 of 1 [ 13 posts ]
 Print view Previous topic | Next topic
encoders and synchronizing motors
Author Message
Rookie

Joined: Thu Apr 28, 2011 8:52 pm
Posts: 2
encoders and synchronizing motors
Working on an FTC robot for competition tomorrow and would like to find some way to synch our drive motors together. We are thinking about using the encoders but have no idea how to do that using robotc. Any help will be greatly appreciated.

Thu Apr 28, 2011 10:35 pm
Guru

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1523
Re: encoders and synchronizing motors
Are you trying to make the robot to go straight? If so try the following. Basically, the difference of the left and right encoder values becomes your correction factor. The bigger the difference the bigger the correction (i.e. Proportional PID control). The difference is multiplied to a proportional scale factor (Kp). You need to fine tune this value to make the correction smooth. Then you apply the calculated correction to the left and right motors. If the encoders are running with the same values, the difference is zero. Then no correction will happen. If the right wheel runs faster, you will have a positive correction that will make the left motor turn faster and the right motor turn slower and vice versa.
 Code:#define BOUND(n, l, h)  (((n) < (l))? (l): ((n) > (h))? (h): (n))#define Kp              0.1     //you may need to tune thisvoid Drive(int drivePower){    int turnPower = nMotorEncoder[rightMotor] - nMotorEncoder[leftMotor];    turnPower = BOUND((int)(turnPower*Kp), -10, 10);    motor[leftMotor] = BOUND(drivePower + turnPower, -100, 100);    motor[rightMotor] = BOUNT(drivePower - turnPower, -100, 100);}task main(){    nMotorEncoder[leftMotor] = 0;    nMotorEncoder[rightMotor] = 0;    while (true)    {        Drive(50);        wait1Msec(10);    }}

Last edited by MHTS on Sat Apr 30, 2011 11:40 am, edited 1 time in total.

Fri Apr 29, 2011 1:13 am
Rookie

Joined: Thu Apr 28, 2011 8:52 pm
Posts: 2
Re: encoders and synchronizing motors
thank you very much. That is basically what we are trying to do... We have been having difficulty getting the robot to go straight in autonomous mode so this will definitely help. The code we are using in autonomous mode requires the robot to turn so I am assuming that I will have to add this block as needed. Please correct me if I am wrong. My programming skills are lacking and its kind of like the blind leading the blind...

Sat Apr 30, 2011 11:29 am
Guru

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1523
Re: encoders and synchronizing motors
If you want to do other things in autonomous, please refer to this discussion thread.
viewtopic.php?f=52&t=3152

Sat Apr 30, 2011 11:32 am
Rookie

Joined: Fri Oct 21, 2011 11:14 pm
Posts: 9
Re: encoders and synchronizing motors
One question I have is that if we are going to four wheel drive a robot, would it be necessary to put encoders on each wheel?
Thanks.

Fri Oct 21, 2011 11:21 pm
Moderator

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Re: encoders and synchronizing motors
While it is hard to speak without knowing the specifics of your drive, if it is a 4 wheel tank drive, then generally no. You would only really need one encoder on either side of the robot.

_________________
sudo rm -rf /

Fri Oct 21, 2011 11:40 pm
Guru

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1523
Re: encoders and synchronizing motors
 hongyeus wrote:One question I have is that if we are going to four wheel drive a robot, would it be necessary to put encoders on each wheel?Thanks.

Are you talking about 4-wheel drive or 4-motor drive? Most of the time, people have 4-wheel drive but only one motor for each side. The two wheels on each side are usually chained to the same motor. So typically, you have one encoder on each side. If you truly have 4-motor drive, then the question is: are the two motors on one side synchronized by a chain? If so, you still need only one encoder for each side. If you don't have a mechanism to synchronize the wheels on one side, you may have a problem. In that case, you may need one encoder for each motor just for synchronizing the speed. Normally, there is no benefit of 2 unsynchronized motors on one side unless you have a mecanum drive train. Mecanum allows your robot to go sideway. In that case, you also need 4 encoders, one on each wheel so you can calculate the net movement of the robot.

Sat Oct 22, 2011 1:49 am
Moderator

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Re: encoders and synchronizing motors
 Quote:Normally, there is no benefit of 2 unsynchronized motors on one side unless you have a mecanum drive train

I would disagree with this statement. Many teams use this configuration to gain more speed and pushing power. Having the motors unsychronized does not have too much of in effect in driver control mode (except if your robot is experiencing a lot of slippage). And I have been able to program fairly accurate PID control using only two encoders on a 4 motor tank drive.

_________________
sudo rm -rf /

Sat Oct 22, 2011 9:24 am
Guru

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1523
Re: encoders and synchronizing motors
You can still use 4 motors for the 4 wheels to gain speed but using a chain to link them will make sure the two wheels on one side is always running the same speed. You could run them independently but then you will have to put encoders on the two wheels of the same side and use software to monitor their speeds to make sure they are in sync. I am not saying it's not doable with just two encoders for 4 motors but I personally don't see benefits of doing that.

Sat Oct 22, 2011 9:44 am
Moderator

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Re: encoders and synchronizing motors
You're right, that chaining the two motored wheels together on each side is in general a better idea then leaving them independent. I'm just saying that if chaining is not an option (some teams either don't have room, or find that it over complicates their chassis to chain the wheels), and only two encoders are available, then good results can be achieved with just two encoders on unchained wheels.

_________________
sudo rm -rf /

Sat Oct 22, 2011 11:04 am
Rookie

Joined: Fri Oct 21, 2011 11:14 pm
Posts: 9
Re: encoders and synchronizing motors
All right, thanks so much, and yes sorry I was referring to 4-motor tank drive. I will see if I can chain the motors on each side together.

Thanks!

Sat Oct 22, 2011 12:22 pm
Rookie

Joined: Fri Oct 21, 2011 11:14 pm
Posts: 9
Re: encoders and synchronizing motors
I actually have another question about chaining the two motors on each side together... If the two motors chained together did run at different powers, wouldn't this in effect increase the resistance and literally "force" the motors to run together? Would there be any negative impacts of doing this?

Sat Oct 22, 2011 3:21 pm
Guru

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1523
Re: encoders and synchronizing motors
First, when you chain 2 motors together, make sure your code will program the same power to them. So then the speed difference should be minimal if any. The motors can take that stress produced by the difference. To the motor, this is just a slight variant in its loading. It is equivalent to a weight difference on all the four wheels or even different friction on the wheels, then one of the motors will work slightly harder than the other one. So this is normal stress. Even if you don't chain them together, assuming the wheels don't slip, you will have the same effect (one wheel running faster and takes more load).

Sat Oct 22, 2011 4:50 pm
Display posts from previous:  Sort by
 Page 1 of 1 [ 13 posts ]

Who is online

Users browsing this forum: No registered users and 1 guest

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning