- Pololu1376: take enums as variable id
- stirrerPololu1376: Make for robust against motor cable plug
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from contextlib import contextmanager
|
||||
from components import AStirrer
|
||||
from pololu1376 import Pololu1376
|
||||
from pololu1376 import *
|
||||
import time
|
||||
import serial
|
||||
|
||||
@@ -41,9 +41,16 @@ class StirrerPololu1376(AStirrer):
|
||||
print("Set speed to {} %".format(speed))
|
||||
|
||||
def _on_process(self):
|
||||
print("STATUS :")
|
||||
self.drv.print_vars()
|
||||
|
||||
#s print("STATUS :")
|
||||
# self.drv.print_vars()
|
||||
status = self.drv.get_variable(Varid.STATUS)
|
||||
limit_status = self.drv.get_variable(Varid.STATUS_LIMIT_STATUS)
|
||||
print("Status={:02X}".format(status))
|
||||
if status & 0x01 == 0x01:
|
||||
if limit_status & 0x01 == 0x01:
|
||||
print("Recover after motor error!")
|
||||
self.drv.go()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
s = StirrerPololu1376(dt=1.0, params={'port': "/dev/ttyACM0", 'speed': 115200})
|
||||
@@ -77,5 +84,13 @@ if __name__ == '__main__':
|
||||
s.set_speed(50)
|
||||
time.sleep(3.0)
|
||||
|
||||
print("Continious operation increasing speed")
|
||||
for speed in range (25, 75, 5):
|
||||
s.set_duty_cycle(1.0)
|
||||
s.set_speed(speed)
|
||||
for d in range(0,3,1):
|
||||
s.process()
|
||||
time.sleep(1.0)
|
||||
|
||||
print("Leaving context")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user