Software :  Reprap Forums The fastest message board... ever.
Here is where to chat about software. RepRap host stuff, PIC/Arduino firmware, AoI, and related stuff. 
Stepper Motor Help
Posted by: Antonio Garcia ()
Date: November 03, 2009 03:19AM

Hello,

I'm trying to build a 3-axis CNC milling machine using an Arduino and three RepRap Stepper Motor Driver boards (v2.3).

I've got the stepper motors to work, but I can't seem to produce an Arduino sketch that has control over the stepper motors with sufficient granularity. Basically, I can't seem to be able to get the stepper motors to turn a single step. The steppers are rated at 200 steps per revolution, but it seems to take somewhere around 460 "steps" (as done by the code fragment below) to execute a complete turn.

void do_step(byte step_pin)
{
  digitalWrite(step_pin, HIGH);
  delayMicroseconds(5);
  digitalWrite(step_pin, LOW);
}

Any advice for what I'm doing incorrectly?

Many thanks.

Options: ReplyQuote
Re: Stepper Motor Help
Posted by: stephen george ()
Date: November 03, 2009 03:29AM

Hi there

Have you got the board set to half steps?

The 1.1 and 1.2 boards have a jumper setting.

regards

Stephen

Options: ReplyQuote
Re: Stepper Motor Help
Posted by: Antonio Garcia ()
Date: November 03, 2009 03:49AM

It seems to be the case that the only adjustable element on the v2.3 stepper motor driver is the potentiometer to adjust current flow.

Even if it were set to half-steps, would that explain why it's off by so much?

Also, what sorts of delays and waits need to happen between steps? In my testing of things, it seems to be the case that I need to wait a minimum of 1000 microseconds between steps.

If it makes any difference to the matter, the motor is wired in bipolar serial.

Thanks

Options: ReplyQuote
Re: Stepper Motor Help
Posted by: quadshop ()
Date: November 03, 2009 06:21AM

There should be 400 steps/rotation, assuming the 2.3 driver and a "standard" 1.8 degree/step motor.

You may be skipping steps. One thing I found is that they can only go at a certain speed - if you try to drive them faster, they start skipping. For me (using the NEMA 17 steppers from Makerbot, and the 2.3 stepper drivers) it is about 550 uS/step for 12V, and around 400 uS/step for a 24V supply (the 24V supply I was using didn't generate much current though, as it was just what I had laying around for testing).

That max speed is dependent on voltage of the supply - more voltage means you drive more current through the stepper (steppers have a fixed resistance). More current = stronger magnetic field, meaning you are generating more force, accelerating the innards of the stepper faster. Try to step too fast, and the shaft doesn't move a full "click" before you try to move it again.

Options: ReplyQuote
Re: Stepper Motor Help
Posted by: Antonio Garcia ()
Date: November 03, 2009 05:26PM

Thank you for your reply.

I've played around with it a bit more, and I can say that it really doesn't appear to be skipping any steps. I have it turn a full revolution and back again, and it's stopping and reversing in exactly the same spot, so I'm fairly sure that it's not skipping steps. Also, the motion and sound it makes is continuous and smooth.

The steppers in question are rather on the large side ( [www.motioncontrolproducts.co.uk] ) and have rather a high inductance, so it does take them around 1000 microseconds per step (if I drop it below this, they start skipping).

If they're not skipping, and I'm giving enough time for them to step, then why does it take around 550 "steps" for the motor to turn a complete revolution?

Is it possible that the stepper motor drivers are trying to cycle the coils too quickly? (I'm just guessing here - I'm a software person, and don't really know much about hardware, as you can see)

Any other ideas or suggestions for what could be the problem?

Cheers

Options: ReplyQuote
Re: Stepper Motor Help
Posted by: quadshop ()
Date: November 06, 2009 04:32PM

Based on your link, it should be exactly 400 steps/revolution. Have you actually tried measuring the exact number of steps for one rotation? Maybe that would give you some insight. For instance, if it was 800 steps, or 600 steps (exactly), then you would have something to go on.

I seem to remember reading somewhere about if your stepper goes two steps forward and one step back, even through you are driving it one direction, you have a wiring problem. I think that was for 8-wire motors though. But perhaps it is something bizarre like that?



Also, what is your setup/hold time on driving the stepper? The stepper driver chip has a specification for how long signals are supposed to be high or low before they change. This applies between pins too - for instance, there is a delay you have to follow between when you change the direction pin and when you change the step pin. It is on page 6 of the datasheet at [www.allegromicro.com]

What this means is you need to have *some* delay (at least theoretically) between (for instance) changing the direction of the stepper and issuing the step command. Also, the step pin has to be high for at least one microsecond. If you have no delays at all, then you might set it from low->high then high->low too quickly. My board runs at 16MHz clock, which means 62.5 ns/cycle. I don't know how many cycles it takes to set a pin in AVR assembly, but if it is less than 16 cycles, then you *might* be violating the setup/hold times in the A3982 datasheet.

I think I wait a full millisecond when I change direction before doing anything else, and have a hold time of 20 microseconds or so (just an arbitrary-ish number) for the actual step pulse (followed by lots more waiting to make sure it doesn't skip).

Options: ReplyQuote
Re: Stepper Motor Help
Posted by: Triffid_Hunter ()
Date: November 06, 2009 05:17PM

Quote
quadshop
My board runs at 16MHz clock, which means 62.5 ns/cycle. I don't know how many cycles it takes to set a pin in AVR assembly, but if it is less than 16 cycles

unlike PIC, AVR core runs at crystal frequency, so it takes just 1 clock to set or clear an output

Options: ReplyQuote
Re: Stepper Motor Help
Posted by: Antonio Garcia ()
Date: November 10, 2009 05:18PM

Hello,

Thank you for your help - it was simply an issue of timing. Due to the high inductance of the motor, and especially since I'm driving it with a 12V power supply, there needs to be a significant wait between steps.

Options: ReplyQuote


Your Name: 
Your Email: 
Subject: 
This forum powered by Phorum.