繁体   English   中英

码完后步进电机继续转动

[英]Stepper motor continues turning after code is finished

我正在使用 Python 3.7.3 和 A4988 步进电机驱动器在 Raspberry Pi 4 上使用 Nema17 步进电机。 我运行下面的代码,它工作正常,但是在代码完成后,步进电机继续以某种零星的方式转动。 如何让它在完成代码后停止? 我在下面包含了我正在使用的代码。


# import the library
from RpiMotorLib import RpiMotorLib

#define GPIO pins
GPIO_pins = (17, 27, 22) # Microstep Resolution MS1-MS3 -> GPIO Pin
direction= 24       # Direction -> GPIO Pin
step = 23      # Step -> GPIO Pin

# Declare an named instance of class pass GPIO pins numbers
mymotortest = RpiMotorLib.A4988Nema(direction, step, GPIO_pins, "A4988")


# call the function, pass the arguments
mymotortest.motor_go(False, "Half" , 500, .001, False, .05)

# good practise to cleanup GPIO at some point before exit
GPIO.cleanup()```

P.S I was wondering what would be the best library or way to control a stepper motor? As in, is this the best library to be using or are there better and more precise methods in doing so.

Thank you

也许 GPIO.cleanup 将 gpio 输出置于未定义的浮动状态。 尝试在 GPIO.cleanup 之前将 A4988 置于睡眠模式。 A4988 pdf

我确认 Pi Model 4B v1.4 上的 A4988 存在问题。 Mace是对的,问题来自 GPIO.cleanup()。 例如,在我的情况下,删除github上的 A4988_Nema_Test.py 脚本中的 GPIO.cleanup() 行解决了这个问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM