This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Modbus write multiple register
#1
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
Reply
#2
You can force function #16 for single write like this:
Code:
mb:writemultipleregisters(33822,32)
Reply
#3
Perfect, works like a charm!

Thank you
Reply


Forum Jump: