I followed these instructions to drive a couple of stepper motors from a Raspberry Pi 4B and two DRV8825 drivers.
I made the board, plugged in the 16 pin drivers, wrote a Python script to instruct the motors and got frustrated as one driver (or motor) is dead and the other makes the motor buzz, but doesn't move, and got very hot (melted the PTEG 3D printed base.) The motor heats very fast, very hot.
For full step (no mode pins connected). I have sleep and reset bridged and always HIGH. They are connected to the Raspberry Pi’s 3.3 V power pins.
Motor:
According to the motor datasheet, it can take maximum 1500 PPS when loaded and 850 unloaded.
I'm using time.sleep()
between GPIO changes, adjusted by benchmarked error
# A Pulse implies full period. which needs to be 50% duty cycle, so signal to GPIO doubles this freq.
# target sleep: 1/(2*1500) = 0.0.0003333333333333333
# 1/(2*1500)*.73 = 0.00024333333333333333
# >>> benchSleep(1/(2*1500)*.73)
# slept 0.0003504753112792969 seconds
# slept 0.0003421306610107422 seconds
# Actual sleep differs by net avg 9.664361317952476e-05 or 39.71655336144853%; \
# with std dev 2.3774077176703874e-06 or 0.9770168702755017%;
# Actually slept on avg 0.00033751328786214195 or 138.72309406582076%; \
# with std dev 5.701971382635937e-06 or 2.3435969513505697%;
LOADED_MAX_PPS = 1500
LOADED_SLEEP_HIGH_LOW = 0.0002433
# target sleep: 1/(2*850) = 0.000588
# >>> benchSleep(0.000496)
# slept 0.0006048679351806641 seconds
# slept 0.0005941390991210938 seconds
# Actual sleep differs by net avg 9.250990549723315e-05 or 18.50198109944663%; \
# with std dev 2.652120187789779e-06 or 0.5304240375579559%;
# Actual sleep differs by net avg 0.0005880355834960938 or 118.55556118872857%; \
# with std dev 3.174699532262383e-06 or 0.6400603895690288%;
NOLOAD_MAX_PPS = 850
NOLOAD_SLEEP_HIGH_LOW = 0.000496
The buzz pitch changes between NOLOAD_MAX_PPS
and LOADED_MAX_PPS
but the motor still does nothing. It is bipolar (4 wires), but according to the tutorial the driver abstracts that, I only think in terms of step+direction pins.
Any hint in the right direction is greatly appreciated.
Driver:
Driver Power supply
HiLetgo 5pcs XL6009 Boost Module that takes 12V from a 12V battery/DC-power supply and outputs 24V. (I plan to run everything from a 12V 7A battery: steppers, Raspberry Pi, drivers.) I got the boards from Songhe and Hiletgo
Each driver has a 330 uF electrolytic capacitor, rated 36 V.
Yellow: Direction Blue: Step Orange: Sleep + reset (always HIGH)
Edits
Current limiting.
After fixing the current limit to 1/2 of previously set (to 250 mA), I still get erratic behavior. I also found a great Arduino forum post on the basics of steppers, where the HIGH to the driver STEP pin is very short (10-20 us) compared to the LOW (small duty cycle, most videos/pages out there suggest 50% duty), having the LOW’s sleep time driving the frequency.
I refined my Python code to address this, but still no luck. The motor is quieter, though.
On the scope I see two issues:
- Terrible noise of up to 3 V at ~130 kHz. I am thinking of a filtering capacitor but haven’t seen anyone using that on the STEP pin.
- The DIR pin pulls down when the STEP pin pulls down. Not in code, not intended.
Power sources & Noise.
I noticed the noise is present only when DC power source is connected, bypassing the boost converter (12 V -> 24 V -> VMOT), When the 12 V battery is connected instead, the motor is silent, and moves inconsistently but in one direction (when DIR is LOW, DIR HIGH has the issue of DIR pulling down when STEP pulses, see images below). Code is sending a train of 50 pulses when I press a cursor key (left/right).
15 us HIGH STEP Pulses; DIR LOW; 190 steps per second.
15 us HIGH STEP Pulses; DIR HIGH; 190 steps per second. See how DIR drops when STEP Pulses. Closeup
High freq noise (130 kHz) when 24 V DC wall-plugged Power supply is on. Motors get the buzz.
Setup. see only black marker. Brown is irrelevant. I sue alternative power sources 12 V battery or 24 V DC wall-plugged power supply.
Parts: HiLetgo XL6009
Magically works now.
As my soldered board was glitching on STEP HIGH & DIR HIGH, I decided to rebuild it on a breadboard. In the breadboard the signals on scope where very clean, but motor didn’t move/buzz at all. So I wired back my soldered board, now it hoes clockwise and counterclockwise, with minimal noise in the STEP & SIR signals. Not sure what was wrong on the soldered one before unplugging/plugging back and what was wrong on the breadboard to have motors dead.