PDA

View Full Version : More fun with an Arduino and stepper motors



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.

garyc
02-18-2013, 08:46 PM
Mike...
This is a great and fun sounding project. Thanks for posting. Even better than that, it is fantastic to see you back doing some tinkering on the forum. You have been missed my friend.

Brady Watson
02-18-2013, 09:54 PM
Mike, thanks for posting this. I always appreciated you sharing your R&D. If for nothing else, it was fun to hear about your discoveries.

I too am glad to see you posting again.

-B

rcnewcomb
06-17-2013, 01:39 PM
Someone is now developing a drag-n-drop graphical programming interface for Arduino. Details are available here: http://www.modk.it/

It might make working with the programming language a bit easier for some. I have an 8 year old nephew who is REALLY into robots, and this makes it more accesible for him.

http://www.modk.it/images/screenshots/blocks_view_800x600.png

dana_swift
06-17-2013, 05:05 PM
Randall- that is an interesting way to do things! Makes it easy! Kind of simpler version of LabView.

The Arduino DUE has gotten my attention. Its a really nice 32bit Arm CPU. It is not the same CPU series as other Arduinos, this one has much more capability, including the ability to host Linux.

The DUE has a debug connector the other Arduinos don't have. The CPU manufacturer, Atmel, offers a FREE, full development environment and an in system debugger hosted on Microsofts Visual Studio. The bad news is the JLink adapter for the debugger costs about $99.00, but it works really well. One adapter can be used with any of Atmel's ARM base CPUs. That adapter costs about $1000 for other CPU's, that is quite a deal.

The bad news is the manual for the CPU is over a thousand pages long.. lots of tedious reading. But if you treat it just like any other Arduino you can skip the manual.

D

khaos
06-17-2013, 07:53 PM
So Mike, with a smaller stepper it would not be out of the question to make a stepper drive a tool changer.

I am also interested in making a lazy Susan type of mount that would be open seeking or 3 way toggle controlled (CW/off/CCW). I want to drive this from a windows tablet or phone so if there is a better way to drive this directly from windows, I am all ears.

I was a NEC ET-1589 in the service so I have seen a circuit or two. :eek:

I would be very interested in the nitty gritty of what you are doing to get it working.

-Joe

GeneMpls
06-18-2013, 07:19 AM
Dana- have you looked at the Raspberry Pi? There is another newer one
that is more computer-like but the name escapes me now. Gene

dana_swift
06-18-2013, 09:11 AM
Gene- I am quite familiar with the Raspberry Pi. Its a very interesting board with a HUGE problem. In order to get the CPU documentation for it, you MUST sign a non-disclosure agreement with Broadcom.

All you can do with the Pi is run Linux. Linux is a horrible platform for interfacing to I/O for beginners. Its hostile to experts to write access to the low level features of the Pi.

The CPU info for the DUE is free download, its wide open, complete with a free real time operating system, or can be run bare-metal if desired. The Arduinos all run bare-metal, which makes them extremely open. Usually that makes writing code for them very difficult, but the Arduino "wiring" system, simplifies the process to where technophobes are finding it easy to do.

Shopbot did for CNC what Arduinos have done for embedded computers. Drop the price and make the functionality complete for industrial level applications. Both have brought their technology within the budgets of individual, rather for commercial, education, or just fun.

When computers cost $30, lots of things become possible.

If you remember the name of the other computer you were thinking of- let me know.

D