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.

Write Multiple Registers at once
#1
Hi,

I have a Modbus equipment that requires that 3 continuous registers must be written in the same operation ( Modbus Function Code 16 ).

Code:
...
{"name":"UI_1 Cmd Modo Func RAW"   ,"bus_datatype":"8","type":"register","datatype":"int16",     "address":33,   "read_swap":"n","writable":1 },
{"name":"UI_1 Cmd Modo Fan RAW"    ,"bus_datatype":"8","type":"register","datatype":"int16",     "address":34,   "read_swap":"n","writable":1 },
{"name":"UI_1 Cmd Setpoint"       ,"bus_datatype":"8","type":"register","datatype":"int16",     "address":35,   "read_swap":"n","writable":1 },

Is this possible to do this ?

Thank you
Reply
#2
Datatype define how many registers are read/written. Int16 is one register, int32 two and so on.
------------------------------
Ctrl+F5
Reply
#3
(31.12.2020, 11:35)Daniel. Wrote: Datatype define how many registers are read/written. Int16 is one register, int32 two and so on.


Sorry, I think I didn't make myself understood.

I need to write these 3 registers in the same Write Operation ( FC16).

This way writes correctly, but one after the other:
Code:
...
{"name":"UI_1 Cmd Modo Func RAW"   ,"bus_datatype":"8","type":"register","datatype":"int16",     "address":33,   "read_swap":"n","writable":1 },
{"name":"UI_1 Cmd Modo Fan RAW"    ,"bus_datatype":"8","type":"register","datatype":"int16",     "address":34,   "read_swap":"n","writable":1 },
{"name":"UI_1 Cmd Setpoint"        ,"bus_datatype":"8","type":"register","datatype":"int16",     "address":35,   "read_swap":"n","writable":1 },


So, you are telling me that if I use just one variable with the "datatype":"int48" will it work ?

Thank you
Reply
#4
This is not possible via profile, you have to use a script instead
Reply
#5
(31.12.2020, 12:04)admin Wrote: This is not possible via profile, you have to use a script instead

Humm OK

Something like this ?

Have you got some documentation about the writeregisters method ?
Code:
require('luamodbus')
mb = luamodbus.tcp()
mb:open('192.168.0.1', 502)
mb:connect()

mb:writeregisters(???)

mb:close()


I have other TCP slaves via mapper. This script will be Event based. Can the communications work in parallel without trouble ?

Thank you
Reply
#6
TCP should be ok this way, for RTU there's proxy library to use scripts together with profiles
Reply


Forum Jump: