richards
02-18-2013, 08:36 PM
It's been awhile since I last experimented with an Arduino and stepper motors, but early this morning (about 1:30 a.m.), I suddenly had an epiphany. I was playing around with timer interrupts, using a tutorial that I found online, when I suddenly realized that the Timer1 library tutorial was using PWM to vary the on/off ratio of an LED. The tutorial also made it possible to use a time delay as short as 0.00002 seconds (20 microseconds) with the on/off ratio settable to any of 1,024 distinct points from all OFF to all ON.
What all of that means is that it would be extremely easy to send pulses to a stepper motor and that the Timer1 library already had a built-in way to send the ON part of a pulse to a Gecko G203v stepper driver and the library made it extremely easy to change the time between pulses.
Long story short, after a few hours I saw the pattern that I wanted on the oscilloscope and an hour after that, I had wired together a power supply, a Gecko G203v sterpper driver, an Oriental Motor PK268-02A stepper motor and an Arduino UNO. Without doing anything exotic, the motor runs at 750 RPM, or 12.5 revolutions per second. Those following along with a calculator know that I'm using a 25,000 pulse per second pulse stream. Of course a stepper motor can't start at that speed, so I've programed the Arduino to start with steps lasting 0.0002 seconds (5,000 pulses per second) and then ramping up to 25,000 steps per seconds.
Faster speeds are certainly possible, but the basic clock rate would have to be changed because at 25,000 steps and above, the granularity of the clock is too course to smoothly ramp the motor. Playing with different clock divisors might get twice that speed, but then all other timing functions of the Ardunio would probably change.
So, now that I have a $30 board running a stepper motor, what can I do? Using three boards connected with an SPI or other serial interface, a master Arduino could easily control a point-to-point CNC machine which would be ideal for drilling shelf-pin holes and construction holes in cabinet panels. That would allow the Shopbot to be dedicated to cutting out the panels without being slowed down by drilling. Another use would be to control a horizontal boring machine. Almost any application that didn't require synchronized movement between motors while they were running could be easily handled without exotic programming. With the various "shields" available, the Arduino(s) could be controlled from anywhere in the world.
Anyway, that's the project for today. I'm going to continue watching the motor spin five revolutions clockwise, pause for 1/2 second and then spin five revolutions counter-clockwise, pause and then repeat. I know, I know, some of you are shaking your head and wondering how a grown man could just sit and watch a stepper motor spin, but that's the wonder of discovery. Not every epiphany is a world-changer, but even the little epiphanies bring out the "little boy" in us and somehow the world seems to be a little brighter and a little better.
What all of that means is that it would be extremely easy to send pulses to a stepper motor and that the Timer1 library already had a built-in way to send the ON part of a pulse to a Gecko G203v stepper driver and the library made it extremely easy to change the time between pulses.
Long story short, after a few hours I saw the pattern that I wanted on the oscilloscope and an hour after that, I had wired together a power supply, a Gecko G203v sterpper driver, an Oriental Motor PK268-02A stepper motor and an Arduino UNO. Without doing anything exotic, the motor runs at 750 RPM, or 12.5 revolutions per second. Those following along with a calculator know that I'm using a 25,000 pulse per second pulse stream. Of course a stepper motor can't start at that speed, so I've programed the Arduino to start with steps lasting 0.0002 seconds (5,000 pulses per second) and then ramping up to 25,000 steps per seconds.
Faster speeds are certainly possible, but the basic clock rate would have to be changed because at 25,000 steps and above, the granularity of the clock is too course to smoothly ramp the motor. Playing with different clock divisors might get twice that speed, but then all other timing functions of the Ardunio would probably change.
So, now that I have a $30 board running a stepper motor, what can I do? Using three boards connected with an SPI or other serial interface, a master Arduino could easily control a point-to-point CNC machine which would be ideal for drilling shelf-pin holes and construction holes in cabinet panels. That would allow the Shopbot to be dedicated to cutting out the panels without being slowed down by drilling. Another use would be to control a horizontal boring machine. Almost any application that didn't require synchronized movement between motors while they were running could be easily handled without exotic programming. With the various "shields" available, the Arduino(s) could be controlled from anywhere in the world.
Anyway, that's the project for today. I'm going to continue watching the motor spin five revolutions clockwise, pause for 1/2 second and then spin five revolutions counter-clockwise, pause and then repeat. I know, I know, some of you are shaking your head and wondering how a grown man could just sit and watch a stepper motor spin, but that's the wonder of discovery. Not every epiphany is a world-changer, but even the little epiphanies bring out the "little boy" in us and somehow the world seems to be a little brighter and a little better.