Hi Guys,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.

Thanks everyone!

Lucio43

Attachments:

File comment: Video showing the project working with Arduino, the debug window is showing the wrong numbers from the encoders, this arduino scketch by the way is not trying to adjust the motors is just moving it and this is why I need help..!

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:

Code:

task main() //Assume encoderA is the 'master' motor, and you want to synch the other motors to it.{ int speedB; speedB=motor[motorA]=50;

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:

Code:

speedB=motor[motorA]=50;

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).