Fix relays
This commit is contained in:
2
dyn4.py
2
dyn4.py
@@ -661,7 +661,7 @@ def serial_loop(dev_fn):
|
|||||||
d['TrqCurrent'] = dmm.read_TrqCurrent()
|
d['TrqCurrent'] = dmm.read_TrqCurrent()
|
||||||
|
|
||||||
if True:
|
if True:
|
||||||
dmm.set_speed(-30)
|
dmm.set_speed(0)
|
||||||
|
|
||||||
time.sleep(.5)
|
time.sleep(.5)
|
||||||
d['Speed'] = dmm.measure_speed()
|
d['Speed'] = dmm.measure_speed()
|
||||||
|
6
main.py
6
main.py
@@ -11,6 +11,7 @@ import asyncio
|
|||||||
import aiomqtt
|
import aiomqtt
|
||||||
import serial
|
import serial
|
||||||
import glob
|
import glob
|
||||||
|
import time
|
||||||
|
|
||||||
import dyn4
|
import dyn4
|
||||||
import relays
|
import relays
|
||||||
@@ -23,8 +24,8 @@ dmm1 = None
|
|||||||
dmm2 = None
|
dmm2 = None
|
||||||
|
|
||||||
|
|
||||||
MOTOR_EN1 = 0
|
MOTOR_EN1 = 1
|
||||||
MOTOR_EN2 = 1
|
MOTOR_EN2 = 2
|
||||||
|
|
||||||
def enable_motors():
|
def enable_motors():
|
||||||
logging.info('Enabling both motors...')
|
logging.info('Enabling both motors...')
|
||||||
@@ -195,6 +196,7 @@ def task_died(future):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
enable_motors()
|
enable_motors()
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
|
|
||||||
|
@@ -7,10 +7,10 @@ DEVICE_ADDR = 0x10
|
|||||||
bus = smbus.SMBus(DEVICE_BUS)
|
bus = smbus.SMBus(DEVICE_BUS)
|
||||||
|
|
||||||
def relay_on(num):
|
def relay_on(num):
|
||||||
bus.write_byte_data(DEVICE_ADDR, num, 0x00)
|
bus.write_byte_data(DEVICE_ADDR, num, 0xFF)
|
||||||
|
|
||||||
def relay_off(num):
|
def relay_off(num):
|
||||||
bus.write_byte_data(DEVICE_ADDR, num, 0xFF)
|
bus.write_byte_data(DEVICE_ADDR, num, 0x00)
|
||||||
|
|
||||||
def test():
|
def test():
|
||||||
while True:
|
while True:
|
||||||
@@ -25,4 +25,6 @@ def test():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
test()
|
#test()
|
||||||
|
relay_off(1)
|
||||||
|
relay_off(2)
|
||||||
|
Reference in New Issue
Block a user