View Single Post
  #3   Spotlight this post!  
Unread 02-02-2011, 14:22
billbo911's Avatar
billbo911 billbo911 is offline
I prefer you give a perfect effort.
AKA: That's "Mr. Bill"
FRC #2073 (EagleForce)
Team Role: Mentor
 
Join Date: Mar 2005
Rookie Year: 2005
Location: Elk Grove, Ca.
Posts: 2,355
billbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond reputebillbo911 has a reputation beyond repute
Re: Make motors run the same speed using encoders

Quote:
Originally Posted by siggy2xc View Post
does anyone have any ideas on how to use encoders to make the motors run at the same speed when going straight? I'm currently working on a code to make the robot go the same direction as you press the joystick no matter which way it is facing and this seems to be the biggest problem since the robot will drift left or right. I'm having a hard time with this since the motors shouldn't be running at the exact same speed when pressing slightly left or right.

(We will be using arcade drive)

Any help would be appreciated
Robot Casserole - Team 1736
If I understand what you are asking, you want to have the robot drive straight when a button is pressed, regardless of which direction the robot is facing. Is this correct?

Now, assuming it is correct....

According to your title, you have encoders connected to you drive train. Again assuming here, one on the left and one on the right.

Start with a case structure. Wire the Y channel bypass the structure. In the False state, the X will pass through the structure to the Arcade mode. When the "button" is pressed, switch the case structure. In the True state, the X channel will be replaced inside the case structure.

Here is where it gets a little complicated.

The first time through the loop after the button is pressed, initialize the counter for both encoders. From that point on, as long as the button remains pressed, the X value to the Arcade mode becomes the difference between the counts of the left and right encoders. You will need to "GAIN" this value to maintain smooth and not over responsive control. You will also need to limit the output to the Arcade mode to between -1 and +1. You might also need to invert the sign so that the code corrects in the right direction.

The bottom line is, the correction to direction is based on the difference between the counts of the encoders.
__________________
CalGames 2009 Autonomous Champion Award winner
Sacramento 2010 Creativity in Design winner, Sacramento 2010 Quarter finalist
2011 Sacramento Finalist, 2011 Madtown Engineering Inspiration Award.
2012 Sacramento Semi-Finals, 2012 Sacramento Innovation in Control Award, 2012 SVR Judges Award.
2012 CalGames Autonomous Challenge Award winner ($$$).
2014 2X Rockwell Automation: Innovation in Control Award (CVR and SAC). Curie Division Gracious Professionalism Award.
2014 Capital City Classic Winner AND Runner Up. Madtown Throwdown: Runner up.
2015 Innovation in Control Award, Sacramento.
2016 Chezy Champs Finalist, 2016 MTTD Finalist

Last edited by billbo911 : 02-02-2011 at 15:12.
Reply With Quote