Electronic – arduino – basic arduino question – do I need a 555 timer

555arduinointegrated-circuitmotorstepper motor

I have an Arduino (duemilanove) connected to a floppy disk drive and I can happily control the stepper motor using three pins on the ribbon cable to three digital pins of my Arduino (well 2 + the ground!).

I would like to control multiple motors at once, but using one Arduino per motor is going to be costly. I have read a bit about 555 timers. If I wanted to control two motors simultaneously stepping the motors independently of each other from my single Arduino, could this be done with a 555 timer IC for each motor?

The Arduino is "single threaded" so I want a way, I guess, to push the "commands" (signals) for driving the step motors onto another chip. This way the single thread of the Arduino can loop round each chip handing out commands for their attached motor (or maybe a method of queueing?).

I have read a little about interrupts on the Arduino also, but I don't think these will be any use will they?

Best Answer

It can be done with interrupts. Attach an interrupt to a timer, so that it fires regularly (say once a milisecond), and use that interrupt to pop the next command off the top of a queue (could just be an array).

Your main loop then just adds commands to this array.

A single Arduino has 14 IO lines, so the number of motors you can control depends solely on the number of wires needed for each motor.

There are dedicated stepper motor driver ICs that are much better and simpler than using a 555 timer. The floppy drive will be using one (maybe embedded inside another chip). They usually accept simple up/down step signals and convert them into the proper sequence of pulses.

Edit

Example code, using the Timer1 library:

#include <TimerOne.h>

void test()
{
  digitalWrite(5,HIGH);
  delayMicroseconds(100);
  digitalWrite(5,LOW);
}

void setup()
{
  Timer1.attachInterrupt(&test,100000);
}

void loop()
{
}

This will cause digital pin 5 to go high then low once every 100,000µS - you see there is nothing in the main loop at all. Just replace the two digitalWrite() calls with the code to step your motors once. You do not need to specify any inter-step delay in that part of the code - that delay is set by the value of 100000 in the Timer1.attachInterrupt() function. To change the speed of the steps, change that value.