2
\$\begingroup\$

I have 4 on/off motors running individually (call them M1, M2, M3, M4) and 4 ping sensors (call them X1, X2, X3, X4) with a board placed in front of the motors and sensors. As the motors move forward towards the board, I want to keep them all within say 2 inches of each other, so as one motor gets more than 2 inches ahead, I want to turn it off until it's back to within half an inch of the other motors. Currently, I am looping through all 4 motors, seeing which is the slowest and seeing if the others are ahead by more than 2" and shut the ones that are off, however, I feel like there is a better way to do this since if the "slow motor" changes quickly, it can effect the error calculations, but I'm not sure where to start. Can anyone give me a better way to solve this loop?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

There are many ways to attack this, and the best solution depends on details you haven't told us.

If these motors don't need to move smoothly, then it can be as simple as turning off or turning down the ones in front, and maybe boosting the ones in back.

Another approach is to control each motor independently such that each motor is always within 1 inch of its desired position.

Yet another approach is to pick one as the guiding motor, then have a control loop keep each of the remaining motors within 2 inches.

A lot depends on what kind of position and speed feedback you have, and what kind of position and/or speed control you have over the motors.

\$\endgroup\$
1
  • \$\begingroup\$ Sorry, I should have been more specific. The motors are on/off motors, not PWM. And the sensors are just analog that tell how far the motor is from the board while moving forward. My main goal is for all motors to hit the board at the same time. The motors have no speed control besides on/off and no speed monitoring. That's why I've been seeing which is the furthest away = "slow motor" and if the others get too far ahead, I'll shut them down until they close back in with the "slow" one. \$\endgroup\$
    – biggi_
    Commented Mar 17, 2016 at 20:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.