Electronic – Closed Loop 4 Sensor Control System

control systempid controllersensor

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?

Best Answer

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.