3 stepper motor driver with variable speed setup

I have a Duemilanove board with atmega328P. I need to drive 3 stepper motor drivers with variable speeds. I want to use the 3 timer/counters, each to drive a stepper motor. I've been reading some guides and one of them mentioned that timer 0 is used for internal arduino functions like millis() and delay().

I tried to find where those functions are used, but i have no luck, are they used in either serial(), rs232, I2C, or SPI apis?

also would there be a better way to drive 3 stepper motors with changing speeds by changing prescaler values?

It is more usual to generate steps for stepper motors in software, using one of the timers as a time reference. The two 8 bit timer/counters can only generate frequencies of about 61Hz and above (using a 16MHz clock), which is probably too fast for your stepper motors anyway.

Interesting, I have thought about manually generating the waveform in software, but how would i keep accuracy while driving 3 motors at the same time? wouldn't the software have to switch between sending out each pulse?

Hyperian:
Interesting, I have thought about manually generating the waveform in software, but how would i keep accuracy while driving 3 motors at the same time? wouldn't the software have to switch between sending out each pulse?

Yes, but that's not hard to do, unless you are trying to get the processor to do other time-critical work at the same time - and even then it may be quite straightforward to switch the stepper outputs on a tick interrupt. What else do you want the arduino to do?

Tick interrupt? i was thinking about using interrupts but i don't know how to fit that into the implementation.

the arduino will also need to calculate angles and things so it will know how much to turn the motors.

It sounds like you essentially have two tasks for the Arduino to perform:

  1. Monitor inputs and calculate angles and required steps;

  2. Drive the stepper motors to the positions previously calculated.

If you don't need to do both at once (i.e. you can ignore further inputs until yo have moved the stepper motors to the positions calculated from the last set of inputs), then you can perform these one after the other. However, if you need to accept further inputs while the stepper motors are moving, then you need to perform both at the same time. In the absence of a real-time operating system (which the Arduino is probably not powerful enough to support), and seeing that driving the stepper motors requires changing the outputs at regular timed intervals but very little calculation or data manipulation, probably the simplest soltion is to execute the stepper motor task for short periods at regular intervals, which can be done using a tick interrupt. It also depends on the rate or rates of the stepper motor pulses you need to generate, because you will only be able to generate pulse rates that are sub-multiples of the tick interrupt rate by this method.

So right now I have 17PM-K103 stepper motors and A4988 driver. I am trying to make the drive code that would do this. http://spectrum.ieee.org/automaton/robotics/robotics-software/042910-a-robot-that-balances-on-a-ball

I am not quite sure what type of code structure i should use to drive various frequencies to the driver chip. tick interrupt? straight code? with PWM? without PWM?

I would have thought you could drive the stepper motors at a fixed pulse rate to make that device, in which case you can easily use a tick interrupt to schedule the pulses. For that motor, a 1ms or 2ms tick should be OK. However, I am not an expert in this area, so you might want to see what others suggest.