- fixed stirrer test

This commit is contained in:
jens
2020-12-17 17:50:58 +01:00
parent a26378d533
commit 4c4373d49a
+28 -24
View File
@@ -28,10 +28,10 @@ class StirrerPololu1376(AStirrer):
@contextmanager
def remote_open(self):
try:
self.on_activate(True)
self.activate(True)
yield None
finally:
self.on_activate(False)
self.activate(False)
def ser_send(self, cmd):
self.ser.write((cmd + '\r\n').encode())
@@ -46,7 +46,11 @@ class StirrerPololu1376(AStirrer):
return 0
def on_activate(self, enable):
self.ser_send("go")
if enable:
self.ser_send("go")
else:
self.ser_send("X")
print("on_activate {}".format(enable))
def on_set_speed(self, speed):
@@ -56,28 +60,28 @@ class StirrerPololu1376(AStirrer):
if __name__ == '__main__':
s = StirrerPololu1376({'dt': 1.0, 'port': "/dev/ttyACM0", 'speed': 115200})
s.activate(True)
print("Set some speeds")
s.set_speed(50)
time.sleep(2)
s.set_speed(20)
time.sleep(2)
s.set_speed(50)
time.sleep(2)
with s.remote_open():
print("Pulsed operation, duty cycle = 50%")
s.set_duty_cycle(0.5)
s.set_cycle_time(10)
for i in range(1, 30):
s.process()
time.sleep(1)
print("Set some speeds")
s.set_speed(50)
time.sleep(2)
s.set_speed(20)
time.sleep(2)
s.set_speed(50)
time.sleep(2)
print("Pulsed operation, duty cycle = 20%")
s.set_duty_cycle(0.2)
s.set_cycle_time(10)
for i in range(1, 30):
s.process()
time.sleep(1)
print("Pulsed operation, duty cycle = 50%")
s.set_duty_cycle(0.5)
s.set_cycle_time(10)
for i in range(1, 30):
s.process()
time.sleep(1)
print("Pulsed operation, duty cycle = 20%")
s.set_duty_cycle(0.2)
s.set_cycle_time(10)
for i in range(1, 30):
s.process()
time.sleep(1)
s.activate(False)