Driving Stepper Motors 50 to 1000 steps/sec

martini

New Member
I’ve been experimenting driving a bipolar stepper motor for a robotics project I’m working on. I am using an Alegro A3980 translator/driver chip. This is a very simple device that only requires a step pulse and direction as well as a few discrete components.For my application I need to be able to drive the stepper motor between 50 and 1000 steps per second. Ideally these pulses should at a regular frequency. I’ve tried a number of methods using a 28X1 chip but so far I don’t have an ideal solution.

Method 1
The simplest solution is to generate step pulses from the main program loop, however, it is difficult to control the speed as this depends on the amount of code in the main program loop.

Method 2
I then thought about using the timer interrupt. By over clocking the 28x1 to 16mHz. I’ve been able to get the timer interrupt working at about 500Hz. At this frequency ½ the processing time is spent in the interrupt loop and the other half can be used by the main program loop. This works reasonably well but there is significant timing jitter with interrupt handling. I’ve also noticed that the pause command no longer works in the main program loop which is causing a number of other problems. I would have expected the pause delay to be longer than defined, but the pause command just drops straight out when using fast timer interrupts. I really need to try and get this stepper motor working faster and with less jitter – As far as I can see It can’t be done well using interrupts.

Method 3
The third solution is to use the pwmout command, however, this works too quickly. Even operating with the 4mhz clock, the frequency range seems to be 4KHz to 1Mhz and is far faster than the 50-1000Hz range I need. Is there any way of making the pwmout command work at lower frequencies? Looking at the microchip data sheet it looks like it may be possible to put a pre-scalar counter onto the pwm timer but as far as I can see this only offers a factor of 16. Also I can’t see any way of programming this feature. If all else fails I guess I could add a divide by 1000 counter onto the pwm output but it would be nice to try and keep the design to a single chip.

Method 4
At the moment I’m still working on this one. Any ideas on producing a constant (but programmable) frequency in the range 50 to 1000Hz whilst still allowing a main program thread to run would be appreciated.
 

womai

Senior Member
You could use a second Picaxe and underclock it to e.g. 32 kHz. That would make PWM run reeeeaaaalllly slow. The master Picaxe would do all the processing work and only communicate with the slave to change its PWM settings. The slave could be another 28X1 (can set its internal resonator to a variety of frequencies), or even a simple 08M. The 08M can be set to 32 kHz clock with a single "poke" command, do a Forum search for this.

Wolfgang
 

RBruceM

New Member
The same PIC chip with a true compiled basic would do the trick...

but for the development time convenience and bargain cost of the picaxe, it might be worth adding a few stages of cmos counters to the pwm output to divide down to the timing range you need. Have each counter's overflow clock the next counter.

If this sounds good to you and you need some help with this, let me know.

Wolfgang's idea is a good one too- might be less wiring.


Best Wishes,
Bruce
 

martini

New Member
Thanks for the suggestion. I had already come to this conclusion myself. I've just ordered a MC14060B counter which gives the option of dividing by 256 1024, 2048 to name but a few. Unfortunatley its a another chip so I'll have to bodge the PCB I built.
 
Top