minimalmodbus
does not provide a way to set multiple coils at once. I cannot find a workaround.
objective:
The modbus protocol description in the datasheet of the SMC LEC 6 controller, see link.
I try to follow the directions from the example starting at page 7 by sending the listed modbus commands using the pyton library minimalmodbus
.
I want to send the command 01 0F 00 10 00 08 01 02 BE 97
but do not find a way to do this with minimalmodbus
. There is not implementation of function code 15 (OF
).
What I tried to do:
I reasoned as follows:
- I want to set multiple coils:
0F
- Starting from position:
00 10
- I want to set 8 coils:
00 08
, or one byte01
- What I want to do is set this byte to value 2 (
02
), or in binary00000010
I thought this could work by setting these positions all separately:
logging.debug('write step')
step_address = int('0010', 16)
bin_2 = [0] * 8
bin_2[6] = 1
for pos, val in zip(list(range(8)), bin_2):
contr.write_bit(step_address + pos, val)
time.sleep(WAIT_TIME)
contr.write_bit(flags['DRIVE'], 1); time.sleep(WAIT_TIME * 5)
The actuator does not move though...
Thanks, Jan