Author Topic: Stepper motor is steping futher than intended  (Read 963 times)

0 Members and 1 Guest are viewing this topic.

Offline yashrkTopic starter

  • Frequent Contributor
  • **
  • Posts: 274
  • Country: in
  • A MAKER, AN ENGINEER, A HOBBYIST FOR LIFE
    • My Personal Blog
Stepper motor is steping futher than intended
« on: February 08, 2023, 07:51:14 am »
Hey everyone!

I am using DRV8825 based module to control the a stepper motor. I send 200 pulses i.e. 1 rotation to the motor driver every time a push button is pressed.
Please check wiring diagram attached below.
As this is battery power application I used the Sleep pin to power down the motor when not in use. Motor is currently not attached to anything.

The algorithm look like this:

Get device out of sleep
delay
Set direction
Loop for 200 times:
     step pin high
     delay
     step pin low
     delay
Put device to sleep

The issue I am facing is if I signal motor to do one rotation the motor will do just slightly more than 200 steps over time I can visually see that start position of the motor is shifting froward.

Things I have tried:
-> Checked the code to see if I am stepping 200 and not more
-> Varied delay after putting the device to sleep and varied the delay between steps too
-> Increased current going to the motor using potentiometer on the module

I have narrowed it down the issue to the sleep if I stop the motor driver from sleeping after every rotation i.e. keeping it permanently on, this solves the issue.
But I am not sure what is happening and would love your inputs on the same.


Regards,
Yash
Find me and things I'm working on - https://www.yashkudale.com/
 

Offline Brianf

  • Regular Contributor
  • *
  • Posts: 73
  • Country: gb
Re: Stepper motor is steping futher than intended
« Reply #1 on: February 08, 2023, 08:33:56 am »
When your micro sleeps what does it do with the IO lines? Maybe you need some resistors to make sure that the signals to the DRV do not float and pick up noise.
 

Offline eblc1388

  • Frequent Contributor
  • **
  • Posts: 394
  • Country: gb
Re: Stepper motor is steping futher than intended
« Reply #2 on: February 08, 2023, 08:52:04 am »
...
The algorithm look like this:

Get device out of sleep
delay
Set direction
...

Make sure you wait for 1,700us in the above delay before setting the direction. Or you can set the direction immediately but wait 1,700us before generating the stepping pulses.
 

Offline Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6394
  • Country: fi
    • My home page and email address
Re: Stepper motor is steping futher than intended
« Reply #3 on: February 08, 2023, 09:30:20 pm »
The TI DRV8825 datasheet describes the STEP pin as "Rising edge causes the indexer to move one step. Internal pulldown."

This means you want the STEP pin to idle low, with each step occurring on a rising edge.  Edges on the STEP and DIR pins must be at least 1.9 µs apart (datasheet chapter 7.6 Timing requirements), but otherwise the duration of the high pulse does not matter.  This assumes you use a typical module that does not invert the STEP and DIR signals (as for example optoisolators might).

So, I would suggest the following logic:
  • Set STEP low (0).
  • Set DIR.
  • Pull SLP high, waking up DRV8825.
  • Wait at least 1.7 ms = 1700 µs.
  • For each step:
    • Set STEP high.
    • Wait 2 µs.
    • Set STEP low.
    • Wait (pulse interval - 2µs).
    End loop
  • Wait a sufficient duration for the DRV8825 to complete the step and the stepper motor to move to the new state; I suggest several milliseconds, maybe longer.
    (When in sleep mode, DRV8825 does not drive the motor; if it has sufficient inertia, it could even freewheel forwards one or more steps.)
  • Pull SLP low, putting the driver to sleep.
Pulse interval is inverse of the step rate.  The maximum step rate is 250 kHz = 250 000 s⁻¹, so the minimum pulse interval is 1/250000 s = 0.000004 s = 4 µs.  The microstepping you use, and the particular stepper motor you use, determines what the maximum actual step rate achievable is; if you try too high step rate (too short intervals), the stepper will usually just "buzz" and heat up.
 

Offline jmelson

  • Super Contributor
  • ***
  • Posts: 2775
  • Country: us
Re: Stepper motor is steping futher than intended
« Reply #4 on: February 09, 2023, 02:47:39 am »
When the driver is powered, the coil current holds the rotor at an exact position.  When you shut off the current, the motor can "relax" to a different position.  Then, when you turn the current on again, the motor can jump to a different position than when it was shut off, rather than jmping back to the original position.  If the driver has a reduced current feature, use that rather than turning off all current.
Jon
 
The following users thanked this post: pardo-bsso

Offline yashrkTopic starter

  • Frequent Contributor
  • **
  • Posts: 274
  • Country: in
  • A MAKER, AN ENGINEER, A HOBBYIST FOR LIFE
    • My Personal Blog
Re: Stepper motor is steping futher than intended
« Reply #5 on: February 09, 2023, 01:44:25 pm »
When your micro sleeps what does it do with the IO lines? Maybe you need some resistors to make sure that the signals to the DRV do not float and pick up noise.

That's an interesting take. It has pull up / pull down internal resistors. And it wasn't the issue because it worked if sleep pin is always high.

Make sure you wait for 1,700us in the above delay before setting the direction. Or you can set the direction immediately but wait 1,700us before generating the stepping pulses.

I had the same instinct and like I mentioned in the main post I also played around with the delay but that didn't help.

When the driver is powered, the coil current holds the rotor at an exact position.  When you shut off the current, the motor can "relax" to a different position.  Then, when you turn the current on again, the motor can jump to a different position than when it was shut off, rather than jmping back to the original position.  If the driver has a reduced current feature, use that rather than turning off all current.
Jon

No the shifting is significant enough that it can be more than 4-5 steps.




The way I solved it was to basically give 2ms delay after getting the module out of sleep. Then giving almost 1ms delay between the step high and step low. Finally putting the device to sleep immediately after.

Yes 1ms delay between the step high and step low if I want low current draw. And I tried 0.5ms with higher current draw. As speed wasn't an issue I didn't try even faster rotation speeds.





The TI DRV8825 datasheet describes the STEP pin as "Rising edge causes the indexer to move one step. Internal pulldown."

This...

I am intrigued by your though process Nominal Animal, I will try it out and keep you updated. I will be comparing the current consumption as well.
Find me and things I'm working on - https://www.yashkudale.com/
 

Offline TomKatt

  • Frequent Contributor
  • **
  • Posts: 352
  • Country: us
Re: Stepper motor is steping futher than intended
« Reply #6 on: February 09, 2023, 01:48:38 pm »
I doubt this plays a role since you are talking full complete revolutions, but I'd also look into what happens during sleep if you are using fractional stepping instead of full steps.  The stepper will likely move to the nearest full cog step if power is removed while it's in a fractional position between full steps.
Several Species of Small Furry Animals Gathered Together in a Cave and Grooving with a PIC
 

Offline yashrkTopic starter

  • Frequent Contributor
  • **
  • Posts: 274
  • Country: in
  • A MAKER, AN ENGINEER, A HOBBYIST FOR LIFE
    • My Personal Blog
Re: Stepper motor is steping futher than intended
« Reply #7 on: February 18, 2023, 06:20:45 pm »
The TI DRV8825 datasheet describes the STEP pin as "Rising edge causes the indexer to move one step. Internal pulldown."

This means you want the STEP pin to idle low, with each step occurring on a rising edge.  Edges on the STEP and DIR pins must be at least 1.9 µs apart (datasheet chapter 7.6 Timing requirements), but otherwise the duration of the high pulse does not matter.  This assumes you use a typical module that does not invert the STEP and DIR signals (as for example optoisolators might).

So, I would suggest the following logic:
  • Set STEP low (0).
  • Set DIR.
  • Pull SLP high, waking up DRV8825.
  • Wait at least 1.7 ms = 1700 µs.
  • For each step:
    • Set STEP high.
    • Wait 2 µs.
    • Set STEP low.
    • Wait (pulse interval - 2µs).
    End loop
  • Wait a sufficient duration for the DRV8825 to complete the step and the stepper motor to move to the new state; I suggest several milliseconds, maybe longer.
    (When in sleep mode, DRV8825 does not drive the motor; if it has sufficient inertia, it could even freewheel forwards one or more steps.)
  • Pull SLP low, putting the driver to sleep.
Pulse interval is inverse of the step rate.  The maximum step rate is 250 kHz = 250 000 s⁻¹, so the minimum pulse interval is 1/250000 s = 0.000004 s = 4 µs.  The microstepping you use, and the particular stepper motor you use, determines what the maximum actual step rate achievable is; if you try too high step rate (too short intervals), the stepper will usually just "buzz" and heat up.

After implementing the code according to the mentioned algorithm, following are the observation:
Starting from 2uS delay in between steps and low to maximum current limit. There was basically no movement till 300uS. Motor started moving with delay of 350uS with noise and vibration but the current consumption was 560mA. And after doing current limiting minimum current required was 210mA - 270mA.

Anyway I was not able to reproduce the issue which I was getting on the original hardware.
But with this test I wanted to check what would be the maximum speed I can run the motor and how much current it will consume. Answer to that is 428 RPM at 210mA.
Find me and things I'm working on - https://www.yashkudale.com/
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf