Multiple stepper motor control sequence.

Hi guys. I'm looking for some help regarding a stepper motor project I have going on. I'll try to keep it short so not to hit you guys with a wall of text. Please ask if you need additional information.

About the project: I need to control 10 to 15 Bipolar stepper motors. These will move forwards and backwards with a set number of steps to open and close hatches. I've succesfully made circuits using two pins layout with L293 drivers and I have also verified this works with a bit of test code (http://www.tigoe.net/pcomp/code/circuits/motors/stepper-motors).

About the code: I need these motors to move forwards with a fixed number of steps in a sequence. Ie, if triggered, Motor01 will move forward 200 steps, delay 2000ms, Motor02 move forward 200 steps, delay 2000ms, Motor03 and so on.. And I also need a code where I can run this sequence backwards, ie Motor01 move backwards 200 steps. But, and here is where it gets complicated, I need this to be foolproof. I need to be able to abort the sequence AND to continue the sequence from where I aborted. So I guess I need to save what states the motors are in. For instance, if Motor01 has allready been moved forwards it has to be skipped.

This will be controlled using 2 inputs on the Arduino, 1 for the open (forwards) sequence and 1 for the close (backwards) sequence. This too needs to be foolproof where if both inputs are high, nothing happens. Same goes for if both are low. Also, if both of them goes high while one sequnce is running, this should be counted as an abort.

I have low programming experience (next to zero), and can only look at examples to try and get something working. But this kinda got too complicated for me, so I'm hoping for some help here. Is there any way I can get this working?

To sum up (short version):

10-15 bipolar motors, with 2 pin L293 circuits (Motor01Pin1 and Motor01Pin2) and 2 states (Motor01.step(100) and Motor01.step(-100)). 2 switches, open and close (triggers for forwards and backwards sequences).

I'm looking for as much help I can get on this, as I am really clueless at the moment. Cheers in advance. Have a great weekend!

Regards, Espen.

I need these motors to move forwards with a fixed number of steps in a sequence. Ie, if triggered, Motor01 will move forward 200 steps, delay 2000ms, Motor02 move forward 200 steps, delay 2000ms, Motor03 and so on.

This is easy enough to do. An array of pins number/motor instances would make it easy.

The delay()s, though, if you use them will make the switches unresponsive. So, don't use it.

Look at the blink without delay example, for guidance on using millis() to perform actions at specified times.

The loop function would then read the switches, and decide that the sequence could continue, or not. If so, determine if it is time to execute the next step/move to the next motor. If not, you know where to begin reversing the sequence from.

What are the hatches for? What could trigger a need to abort the opening of a hatch midway? Why is it necessary to close them in reverse order with no knowledge of where the hatch is?

I'd think that some limit switches for each hatch would be a better idea than just assuming some number of steps is needed to open them.

Hi PaulS, cheers for the reply.

I will check out the millis() function, thanks for the tip!

The reason for not using limit switches is just because of limited number of pins and time. I want the circuit to be as simple as possible. The motor rotates around a screw shaft that opens and closes the hatch, so it will be easy to set a number of steps to open and close.

The hatches will be the bottom of containers hanging up in the air, opening them will release the content falling 30 feet to the ground. For safety reason, I will need the ability to abort if someone would walk under the containers, risking getting hit by falling objects.

There's no need for them to close in exact reverse order. But because of limited power supply, they have to be closed 1 by 1.