Sunday, 22 August 2010

Step by Step

After taking some calming medication to bring down my excitement, it is time for a test setup. Who would own an Arduino and stepper motors and leave them in the cupboard? Impossible !

Basically, the chain of command is PC >> USB >> Arduino >> G251 >> Stepper. Nothing fancy, no complex programming, just a simple constant step rate. A simple program creates one half-pulse per millisecond (wait for getmillis() to change, then toggle output, stir and repeat).

I added a current-limiting 1kOhm resistor to the G251 to keep the maximum current down to 1A. At this time I don't intend to drive the stepper at high power and I didn't want to take the time to connect the G251 to cooling fins, which you'd need at 3.5A.

The main challenge actually was to find the right cables. I realised that all my electronics cables are of the 'tiny' sort. In the end, an old power cord had to be sacrificed as a trip to Jaycar would have taken too long.

The image below lets you see the beauty of the very first setup. Prizes can be won if you can tell if the stepper motor is actually moving at the time the picture was taken. Yes, the Arduino program is loaded and running. It's a technical challenge, not a trick question.


Arduino, G251, and Stepper in action...

With hardware at hand a large number of new sub-projects await...
  • Write a proper interrupt-driven driver routine for the Arduino.
    • Learn the guts of the Arduino "operating system"
    • Learn the finer details of the Atmel microcontroller.
  • Investigate G-Code programming on and Arduino. Some people have done some of it, but I may want to start from scratch - just because I can.
  • Create a construction plan for the cnc router. There is one in my head, but that ain't enough.
  • Put it all together (I almost forgot)

11 comments:

Justin Templar said...

I am going to say yes it is moving, only because the red LED is on on the G251. Am I right?

Thomas said...

Nope :-) . The question remains: Running or not running ?

Andy said...

Nice setup. I hope to have something running similar in the next several days- I'm just waiting for a power supply to arrive via UPS.

Thomas said...

Andy, I'd be curious how loud your power supply is. I find mine fairly noisy compared to computer PSUs. Obviously this will be irrelevant once it's in the shed with a router running, but it's a bit distracting sitting in the room while programming.

Anonymous said...

Ooh! I want to play. I'm going to say it's not moving because the flat on the shaft is not blurred and you probably don't have enough light to capture it cleanly if it is moving.

/Daryl

Thomas said...

LoL. Nope again. The question remains open.

Hint: The solution is electronic in nature, not photographic.

Thanks for playing...

Anonymous said...

well it looks like the step pin on the gecko is wired to the an arduino pin that has an LED indicator light. Since that light is on, it is sending a HIGH signal and moving the motor?

curious about your approach to use getmillis() -- why not just use delayMicroseconds? Be interested to see your code?

Thomas said...

Well, that's the closest anyone has come to a solution, and I think it's time to give away the answer.

If you haven't had a go at the question, then don't read on.

But I know you will anyway...

Refer to the manual for the Gecko G251. Terminal 11 is the "Disable" pin, which forces all windings to zero when shorted to ground. On the image, this pin is the second one from the bottom. It is connected via a red wire, breadboard, orange wire (my emergency stop at the time) to GND on the Arduino (green wire) and signal GND on the G251 (black wire).
Therefore, disable is grounded, and the stepper is not moving.

Thanks for playing.

Thomas

Thomas said...

Hi Anonymous

Regarding 'getMillis()..': Sorry, I don't have the code anymore. It was just a couple of lines I threw together literally in a minute or two to do a test run and it wasn't meant to be robust or well-engineered.

Thomas

Anonymous said...

Bust after all I see? Shame really, I was gonna ask what program you decided to use with your arduino to read the g-code or was your plan something totally different?

Thomas said...

Anonymous: The plan is to write my own software to translate a subset of g-code into step signals. I'm considering the following options, depending on what computational complexity I might face:
a) g-code on Arduino
b) g-code to intermediate language on PC, then final step control on Arduino
c) g-code on STM32 72MHz Microcontroller

I've also played with a non g-codeapproach for specialty shapes that don't come from any CAD software.

Thomas