Posts: 55
Threads: 18
Joined: Jun 2017
Reputation:
1
31.12.2020, 09:52
(This post was last modified: 31.12.2020, 10:04 by iJAF.)
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
Posts: 4643
Threads: 24
Joined: Aug 2017
Reputation:
207
Datatype define how many registers are read/written. Int16 is one register, int32 two and so on.
------------------------------
Ctrl+F5
Posts: 55
Threads: 18
Joined: Jun 2017
Reputation:
1
(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
Posts: 7758
Threads: 42
Joined: Jun 2015
Reputation:
447
This is not possible via profile, you have to use a script instead
Posts: 55
Threads: 18
Joined: Jun 2017
Reputation:
1
(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
Posts: 7758
Threads: 42
Joined: Jun 2015
Reputation:
447
TCP should be ok this way, for RTU there's proxy library to use scripts together with profiles
|