Logic Machine Forum
Write Multiple Registers at once - 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: Write Multiple Registers at once (/showthread.php?tid=3086)



Write Multiple Registers at once - iJAF - 31.12.2020

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


RE: Write Multiple Registers at once - Daniel - 31.12.2020

Datatype define how many registers are read/written. Int16 is one register, int32 two and so on.


RE: Write Multiple Registers at once - iJAF - 31.12.2020

(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


RE: Write Multiple Registers at once - admin - 31.12.2020

This is not possible via profile, you have to use a script instead


RE: Write Multiple Registers at once - iJAF - 31.12.2020

(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


RE: Write Multiple Registers at once - admin - 31.12.2020

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