So I wrote another program that can run stepper motor nema 34 using leadshine DM860 driver and this is the example of my code:
import time import pigpio START_DELAY=580 FINAL_DELAY=480 STEP=1 GPIO=20 pi = pigpio.pi() pi.set_mode(GPIO, pigpio.OUTPUT) pi.set_mode(21, pigpio.OUTPUT) pi.set_mode(26,pigpio.INPUT) pi.set_mode(16,pigpio.INPUT) #pi.write(21,1) pi.wave_clear() statee = 0 run = True try: while run == True: pi.write(21,statee) pi.wave_clear() wf= offset = pi.wave_get_micros() for delay in range(START_DELAY, FINAL_DELAY, -STEP): wf.append(pigpio.pulse(1<<GPIO, 0, delay)) wf.append(pigpio.pulse(0, 1<<GPIO, delay)) for i in range(500): wf.append(pigpio.pulse(1<<GPIO, 0, FINAL_DELAY)) wf.append(pigpio.pulse(0, 1<<GPIO, FINAL_DELAY)) for delay in range(FINAL_DELAY, START_DELAY, STEP): wf.append(pigpio.pulse(1<<GPIO, 0, delay)) wf.append(pigpio.pulse(0, 1<<GPIO, delay)) pi.wave_add_generic(wf) wid2 = pi.wave_create() #pi.wave_send_once(wid2) pi.wave_send_using_mode(wid2, pigpio.WAVE_MODE_ONE_SHOT_SYNC) if pi.read(26) == 0: pi.wave_tx_stop() run = False if pi.read(16) == 0: pi.wave_tx_stop() run = False time.sleep(0.7429) if statee == 0: statee = 1 elif statee == 1: statee = 0 except KeyboardInterrupt: print ("\nCtrl-C pressed. Stopping PIGPIO and exiting...") pi.wave_tx_stop() pi.stop()
It runs without code error but sometimes the stepper motor when moving got random long delay even I already decrease the value from
time.sleep() (with the range between
FINAL_DELAY value is 100 and
time.sleep() value depend how smooth movement).
When I use
time.sleep() value like the example code (the lowers speed) sometime the raspberry pi got power cut (stepper motor stop moving and lcd monitor show blank screen with text 'no signal'). So, is the problem realy cause from my code? I already update pigpiod to v68.
This is how it is wired:
I use jumper wires (using male to male and female to female, because I dont have male to female jumper wires) between driver to raspberry pi 3 and connection between DIR- and PUL- using ordinary copper wire.
This is the pulse width modulation result that I check using piscope:
NEMA34 bipolar stepper motor specification:
- Holding torque 5.9 Nm
- Step angle 1.8°
- Resistance / phase 0.33±10% Ω
- Inductance / phase 3.00±20% mH
- Max load axial 65 N
- Max load radial 200 N
DM860 leadshine with an output current of 1.0 - 7.2A , and an input voltage of 24 - 80 VDC. I have the driver configured with 24V power supply.
This is the driver current and pulse/rev setting: