EEVblog Electronics Community Forum
Electronics => Projects, Designs, and Technical Stuff => Topic started by: branjb on February 23, 2017, 10:07:09 pm
-
Hey EEVblog, quick question about steppers.
Question: I have a stepper motor with 1.8 degrees per step, so 200 steps for a full revolution. When I hook the step output up to my pulse counter, I count 201 pulses instead of 200 for one full revolution, though through software I am pretty sure I am only generating 200 pulses. I'm wondering where I am brain farting and counting this extra pulse from.
Pulse counter is set up to count pulses on rising edge.
My timer is set up @ 1MHz and counts up from cnt to period, with period being 5000. When cnt reaches period, it toggles the timer output. Each toggle also generates an interrupt which I use to increment current steps taken. If I want to take 200 steps, I count 400 interrupts since I am toggling.
What am I missing here that has my pulse counter read 201 pulses, when I think I am telling my uC to generate 200 pulses? I can also confirm that my stepper motor is doing a full 360 revolution with the current set up.
-
Are you starting from zero, or one? >:D
-
Are you starting from zero, or one? >:D
I thought about this hard because I still don't understand why it displays 201 instead of 200.
The pulse counter starts at 0, on the first pulse, it increments to 1, the second pulse it increments to 2, and so forth.. until the pulse counter displays 201.. right?
Doesn't this mean regardless what my software is doing, 201 actual pulses (or steps) have come out of my micro. But this is not consistent with what I am observing on the motor; it rotates exactly 360 degrees each time. As well, my micro should be coded to send exactly 200 pulses, and this is what I am observing.
So why would my pulse counter be displaying 201 when only 200 pulses were sent?
-
Just as a test, set your counter to count on the falling edge instead of the rising edge. It may also be possible as your software starts up, port initialization may drive a pulse in the nanoseconds, not long enough for the stepper motor to register, but the counter sees and counts this pulse.
-
How do you generate pulses? Do you have a scope to test voltage levels - is it clean? I suspect there maybe something to do with pulse counter over-counting "fake" pulses.
Suggestion - try running back and forth for small amount (not full 360 degrees or 200 pulses,but only 20 pulses in one direction and then 20 in another). Does the problem persist with such setting?
-
What moves the motor, the edge or the plateau? Answer that question, remember that you are counting edges, stare at a picket fence for a while and you will have your answer.
-
Easy way to check if it's an off-by-one: run multiple revolutions. If after 5 revolutions you get a count of 1001, you have an off-by-one error. If you have a count of 1005, you have a weird stepper motor.
-
are you positive, negative or level triggering the counter for the pulse?
and if it is level triggered, is it triggering ont he low, or the high.....