Author Topic: Sanity check regarding stepper motors  (Read 1738 times)

0 Members and 1 Guest are viewing this topic.

Offline branjbTopic starter

  • Contributor
  • Posts: 16
  • Country: us
Sanity check regarding stepper motors
« 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.
 

Offline jdraughn

  • Regular Contributor
  • *
  • Posts: 106
Re: Sanity check regarding stepper motors
« Reply #1 on: February 23, 2017, 10:23:30 pm »
Are you starting from zero, or one?  >:D
 

Offline branjbTopic starter

  • Contributor
  • Posts: 16
  • Country: us
Re: Sanity check regarding stepper motors
« Reply #2 on: February 24, 2017, 04:12:20 am »
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?
 

Online BrianHG

  • Super Contributor
  • ***
  • Posts: 7726
  • Country: ca
Re: Sanity check regarding stepper motors
« Reply #3 on: February 24, 2017, 08:13:18 am »
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.
 

Offline electr_peter

  • Supporter
  • ****
  • Posts: 1301
  • Country: lt
Re: Sanity check regarding stepper motors
« Reply #4 on: February 24, 2017, 09:29:08 pm »
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?
 

Offline Cerebus

  • Super Contributor
  • ***
  • Posts: 10576
  • Country: gb
Re: Sanity check regarding stepper motors
« Reply #5 on: February 25, 2017, 04:05:39 am »
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.
Anybody got a syringe I can use to squeeze the magic smoke back into this?
 

Offline radar_macgyver

  • Frequent Contributor
  • **
  • Posts: 697
  • Country: us
Re: Sanity check regarding stepper motors
« Reply #6 on: February 25, 2017, 04:30:52 am »
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.
 

Offline innkeeper

  • Supporter
  • ****
  • Posts: 615
  • Country: us
Re: Sanity check regarding stepper motors
« Reply #7 on: February 25, 2017, 07:29:56 am »
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.....
Hobbyist and a retired engineer and possibly a test equipment addict, though, searching for the equipment to test for that.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf