Synchronizing Stepper Motors

Hi everyone!

I'm trying to set up a remote controlled overhead camera system. I have found a self contained cable camera system that already has it's own control/drive system that would cover one axis of travel, however I need to travel about two axis.

If you take a look at the diagram, the arrows indicate the direction of travel I need to achieve. The cables and the camera trolley are running perpendicular to the desired 2nd axis of travel. Also drawn in the diagram is a catwalk where we would service the overhead camera system.

I need help with writing code to synchronize two stepper motors together in order to evenly move both ends of the cable camera system. This is to avoid stretching and compressing the guide cables. I know there is a way to nest one function into another so that if one motor moves a step the other one moves a step but I am not sure how to code that. Also I am planning on using two separate Pololu A4988 drivers to drive each separate motor. One more thing, if anyone has a great idea for code to throw into the setup function that would reset the positions of the motors (maybe by contact switch to indicate a position zero) that would also be very helpful.

I appreciate all of your advice! Thank you!!

The MultiStepper class of the AccelStepper library may be useful.

code to throw into the setup function that would reset the positions of the motors

That is called "homing". It is how you establish the zero for each axis. Usually each axis will have a limit switch and one runs the motor to the switch to home. The switch can be a mechanical, optical or hall effect switch.

Image from Original Post so we don't have to download it. See this Simple Image Posting Guide

...R

lordski61:
I know there is a way to nest one function into another so that if one motor moves a step the other one moves a step

If all you ever want to do is make both motors do steps at the exact same time then the simplest thing is probably to connect both drivers to the same Arduino I/O pins for step and direction.

On the other hand if the motors need to move different numbers of steps in the exact same time things are a little more complex. For example, motorA moves 83 steps in the time it takes motorB to move 172 steps.

The Multistepper version of the AccelStepper library is designed for this - but, alas, it does not use acceleration.

However it is not all that difficult to write your own code to make the motors move in sync. The way I have done it is, for a particular move, calculate the interval between steps for each motor, then find the highest common factor for the two time values. For example, suppose the slow motor needs a step every 130 millisecs and the fast motor needs a step every 38 millisecs then the HCF is 2 (I think). So set up a timer (using micros) that triggers every 2 millisecs and every 19th tick move the fast motor and every 65th tick move the slow motor.

And this Simple acceleration code illustrates how acceleration can be applied.

...R

PS ... if you need performance avoid using floating point maths as it is very slow on an Arduino.

I think you will have a problem if a stepper misses a step due to friction or whatever and you never know the absolute positions at startup .

I think I would go with gear dc motors with encoders on the shaft for power . There is a commercial “servo” control system that uses this and keeps the two motors in step and maintains the wire tension. Someone might know ? Something like MVT ??

hammy:
I think you will have a problem if a stepper misses a step due to friction or whatever and you never know the absolute positions at startup .

That does not seem to be a problem with many 3D printers - the trick is to choose a sufficiently powerful motor.

...R

You can wire two steppers to the same driver, each winding separately in series, so that both motors
get the exact same currents - steppers are current driven. This approach assumes no miss-stepping
happens, and that the structure is rigid enough that on power up the system is already symmetrical enough.

To check for any miss-stepping you'd need absolute encoders on both motors, then you'd need separate
drivers so the code can correct for errors at start up or due to miss-steps.

If you want to move things fast then servo motors are a far better approach.