Wednesday 5 April 2017

Final updates on driving stepper motors with pololu A4988 boards and pigpio

Nearly a year ago I blogged about my experiences with driving stepper motors from a Raspberry Pi. This was very much just a step towards writing my own telescope mount driving software.

In the meantime I found that although I was getting 800 full steps a second, it tended to stall at random intervals - typically after a couple of minutes, so reliability was not that great. It looked pretty likely that this was linux failing to run my pigpio script on time, resulting in occasional glitches in the timing which were enough to stall the motor.

I now have a version of the driver using waves (in fact 'wave_send_using_mode') and this delivers much better reliability at higher step rates.

I've put the demo code on github here.

It took a bit of messing about. I initially intended to use wave chains, but as I wanted to properly control the ramp up (and ramp down) for smooth transitions, my waves were getting rather large and with the added requirement to control 2 motors with subtly different settings at the same time, I was going to need far too much wave data to handle in this way.

So I have written this to generate waves on the fly, with 2 loaded and one ready to go in the code. This runs 1 stepper in double step mode on a Pi 2B quite happily at 1000 full steps per second (so 4000 wave transitions per second). My motors don't quite want to go this fast - about 900 is the max rate they reliably run at.

As a wave finishes, it is deleted and a new one created and tacked on the end.

Now, back to making goto work.........