Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #-----------------------------------------------------------------------------------
- Import minimalmodbus
- #Create an instance of an instrument (Modbus slave)
- #Replace \dev\ttyACM0 with correct device string, 1 is the slave ID
- pwrStrip = minimalmodbus.Instrument(‘\dev\ttyACM0’, 1)
- #Set baudrate to be 9600bps
- pwrStrip.serial.baudrate = 9600
- #in the following method call, 0 is the coil address, 1 means True (0 is False), 5 is the function code for writing a coil
- pwrStrip.write_bit(0,1,5) #activates relay 1 and turns off load controlled by relay 1.
- #similarly,
- pwrStrip.write_bit(1,1,5) #activates relay 2 and turns off load controlled by relay 2.
- pwrStrip.write_bit(2, 1,5) #activates relay 3 and turns off load controlled by relay 3.
- pwrStrip.write_bit(1,0,5) #deactivates relay 1 and turns on load controlled by relay 1.
- #-----------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment