- Code for running 3 stepper motors with raspberry pi
-
Member
Code for running 3 stepper motors with raspberry pi
Hi,
I wan to run 3 stepper motors with raspberry pi and:
https://www.ebay.com/itm/5x-DRV8825-...53.m2749.l2649
https://www.ebay.com/itm/SALE-Wantai...53.m2749.l2649
Its a special CNC-machine so I cant use some CNC-software + I want to learn how to program. I cant find any example how to write the code in python, so i ask anyone here if they know any example?
As I understand the drivers has auto sequence for the motors so I dont need to program that. If I can get the answer to write the code for 1 full turn for 3 motors at the same time I think I can figure out the rest.
Thanks!
Similar Threads:
-
-
Hi esod, use this code, and repeat for other 2 motors :
import RPi.GPIO as GPIO
import time
# Variables
delay = 0.0015
steps = 30
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
# Enable pins for IN1-4 to control step sequence
coil_A_1_pin = 13
coil_A_2_pin = 5
coil_B_1_pin = 23
coil_B_2_pin = 24
# Set pin states
GPIO.setup(coil_A_1_pin, GPIO.OUT)
GPIO.setup(coil_A_2_pin, GPIO.OUT)
GPIO.setup(coil_B_1_pin, GPIO.OUT)
GPIO.setup(coil_B_2_pin, GPIO.OUT)
# Function for step sequence
def setStep(w1, w2, w3, w4):
GPIO.output(coil_A_1_pin, w1)
GPIO.output(coil_A_2_pin, w2)
GPIO.output(coil_B_1_pin, w3)
GPIO.output(coil_B_2_pin, w4)
try:
while True:
for i in range(0, 50): $
setStep(1,0,1,0)
time.sleep(delay)
setStep(0,1,1,0)
time.sleep(delay)
setStep(0,1,0,1)
time.sleep(delay)
setStep(1,0,0,1)
time.sleep(delay)
sleep(0.01)
finally:
GPIO.cleanup()
- Code for running 3 stepper motors with raspberry pi
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules