如何使用DRV8825同步两个步进电机..

时间:2019-02-27 14:35:38

标签: python gpio

我当前正在使用此代码,并打开一个新代码。我无法同步两个电机。我怎么称呼这两个步进马达。我想知道如何改变两个电动机的速度。该代码中正确的循环是什么,以使步进器同步。

from  time import  sleep
import  RPi.GPIO as GPIO

DIR  =  20
STEP  =  21
CW  =  1          #THIS IS FOR STEPPER 1
CCW  =  0
SPR  =  2000

DIR1  = 23
STEP1  =  24
CW  = 1            # THIS IS FOR STEPPER 2
CCW  =  0
SPR  =  2000

stepcount =  SPR
delay1 =  0.001
delay =  0.001

for  x  in range(stepcount):
    GPIO.output(STEP, GPIO.HIGH)      #Code for Stepper 1 Clockwise
    sleep(delay)
    GPIO.output(STEP, GPIO.LOW)
    sleep(delay)
sleep(0.5)
GPIO.ouput(DIR, CW)

for  x  in range(stepcount):
    GPIO.output(STEP, GPIO.HIGH)
    sleep(delay)
    GPIO.output(STEP, GPIO.LOW)       #Code for stepper 1 Counter clockwise
    sleep(delay)
sleep(0.5)
GPIO.ouput(DIR, CCW)

for  x  in range(stepcount):
    GPIO.output(STEP1, GPIO.HIGH)
    sleep(delay)
    GPIO.output(STEP1, GPIO.LOW)         # Code for stepper 2
    sleep(delay1)
sleep(0.5)
GPIO.ouput(DIR1, CW1)

0 个答案:

没有答案