|Robot TC synchronize 4 dc motors with quad. encoders+arduino
|Page 1 of 1|
|Author:||lucio43 [ Thu Feb 07, 2013 7:43 pm ]|
|Post subject:||Robot TC synchronize 4 dc motors with quad. encoders+arduino|
I'm tryng to have 4 dc motors connected to 4 quadrature encoders to move at the same exact speed where one of the motors is the main one and the other are following and correcting the position
to "catch" the first one.
Let's say we have a rectangle made in Plywood and I'm connecting the 4 corners with 4 steelcables going to a pulley .....to the motors+quadrant encoders.
I want to memorize(where possible) the first position and then from there move the rectangle up and down in a parallel position from the original position memorized.
I'm attaching a video to show you the project as it is now, the 4 motors are running but the encoders are not showing me the same numbers=not the same position and speed.
Let's say I have a 4 wheeled robot and I want it to move straight, is the same thing I'm tryng to do with my rectangle goin up and down keeping it parallel.
I just downloaded the RobotC software and any help guy will be so greatly appreciated about an eventual code.
|Author:||JohnWatson [ Fri Feb 08, 2013 5:54 pm ]|
|Post subject:||Re: Robot TC synchronize 4 dc motors with quad. encoders+ard|
The tricky part may be setting up and reading the encoder values, depending on how they work exactly. Once they are set up, though, you can use something similar to an autostraighten program (short example below) to 'synchronize' the motors together:
You would have to repeat the process for the encoders/speeds of the other two motors as well. Also, you may want to put in an 'acceptable range', for instance, if the encoder counts are within 1 count of each other; this will prevent the motor speed from 'flip-flopping between a value that is 1 higher or 1 less than the desired encoder count. It's a bit tricky to do, but you definitely have the right idea.
I would focus on setting up the encoders in ROBOTC and normalizing their values first, then using them to control the motor speeds. We have done some testing with programming a mechanical encoder you may want to look into as well. Keep us updated on the progress of this project!
Edit: Looking through this again, I did make an error with the previous code:
Needs to be outside of the infinite while loop; otherwise, it will reset speedB to 50 everything the loop executes (which is quite often, in the matter of milliseconds).
|Page 1 of 1||All times are UTC - 5 hours [ DST ]|
|Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group