Logic Machine Forum
Modbus write multiple register - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Gateway (https://forum.logicmachine.net/forumdisplay.php?fid=10)
+--- Thread: Modbus write multiple register (/showthread.php?tid=1299)



Modbus write multiple register - ecodom - 19.03.2018

Hi to all,

I have to write a single register to a device that only supports Function 16

If I use this it's not working

Code:
--COMANDO ON/OFF
 mb:writeregisters(33822,32)

but if I add another register it'll works
Code:
--COMANDO ON/OFF
 mb:writeregisters(33822,32,0)

I suspect that the function automatically switches between function 6 and 16 based on the number of registers it has to write.

I know it makes little sense to use MultipleRegister to write a single register but that's the way the device works and I can't change it so I just want to know if is it possibile to "force" function 16 passing only one register.

Thank you


RE: Modbus write multiple register - admin - 19.03.2018

You can force function #16 for single write like this:
Code:
mb:writemultipleregisters(33822,32)



RE: Modbus write multiple register - ecodom - 19.03.2018

Perfect, works like a charm!

Thank you