Monday, August 2, 2021
python to control the stepmotor nema11
#finally it works! the wait time has to be finetuned to prevent the wobbling
import RPi.GPIO as GPIO
from RpiMotorLib import RpiMotorLib
import time
################################
# RPi and Motor Pre-allocations
################################
#
#define GPIO pins
GpioPins=[21,22,23,24]
# Declare a instance of class pass GPIO pins numbers and the motor type
#mymotortest = RpiMotorLib.A4988Nema(direction, step, (21,21,21), "DRV8825")
mymotortest = RpiMotorLib.BYJMotor("Mymotorone", "Nema")
#mymotortest = RpiMotorLib.A4988Nema(direction, step, (21,21,21), "A4948")
for i in range(5):
time.sleep(1)
mymotortest.motor_run(GpioPins, 0.0002, 1600, True, False, "full", .05)#pins, wait, steps, ccwise, verbose, steptype,inidelay
time.sleep(1)
mymotortest.motor_run(GpioPins, 0.0003, 1600, False, False, "full", .05)#pins, wait, steps, ccwise, verbose, steptype,inidelay
GPIO.cleanup() # clear GPIO allocations after run
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment