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.

TCP Modbus
#1
Information 
Hello,

I'm trying to make a connection with Modbus TCP slave device.

I tried to do so with scripts (you can see it below) and visual mapper.
In visual mapper I tried many different combinations in device profile, but couldn't get right value:

Code:
{ "name": "Input 1", "bus_datatype": "float16", "type": "register", "address": 128, "datatype": "float16", "value_multiplier": 1, "units": " C" },
{ "name": "Input 1", "bus_datatype": "uint16", "type": "register", "address": 128, "datatype": "float16", "value_multiplier": 1, "units": " C" },
{ "name": "Input 1", "bus_datatype": "int16", "type": "register", "address": 128, "datatype": "int16", "value_multiplier": 1, "units": " C" }
and etc..

Full script (IP address of device is corrent - 192.168.1.210, port - 502, slave ID - 20):
Code:
require('luamodbus')

if not mb then
    mb = luamodbus.tcp()
    mb:open('192.168.1.210')
    mb:connect()
end

-- verbose output and select slave number 10
mb:setdebug(true)
mb:setslave(20)

-- read input from reg 1 to 5, get slave-specific data
local result = mb:readregistervalue(128, dt.float16)
grp.write('14/1/0', result, dt.float16)


local value = mb:reportslaveid()
alert(value)

-- close serial connection
mb:close()
Reply
#2
Are you sure it's float16 on ModBus side? float16 is KNX-specific datatype and I've only seen one ModBus AC unit which has it as register value. Also, second mb:readregistervalue() parameter must be a string, not a dt.something. Do you have documentation for your ModBus device?
Reply
#3
(21.03.2017, 14:34)admin Wrote: Are you sure it's float16 on ModBus side? float16 is KNX-specific datatype and I've only seen one ModBus AC unit which has it as register value. Also, second mb:readregistervalue() parameter must be a string, not a dt.something. Do you have documentation for your ModBus device?

Yes, here it is

Now I try to read jus a outdoor temp. to get started. In the documentation its 129 address, but I'm trying with all 128, 129 and 130 to be sure Smile
Reply
#4
Datatype should be "float32", you also might have to set "read_swap" property as stated here: http://openrb.com/docs/modbus.htm
Reply
#5
(21.03.2017, 14:42)admin Wrote: Datatype should be "float32", you also might have to set "read_swap" property as stated here: http://openrb.com/docs/modbus.htm

Can I use this property in script or only in visual mapper?
If yes, how?
Reply
#6
You can use in both, but first you need to figure out correct byte/word order by using this in your script:
Code:
v1 = mb:readregistervalue(128, 'float32', 'n')
v2 = mb:readregistervalue(128, 'float32', 'b')
v3 = mb:readregistervalue(128, 'float32', 'w')
v4 = mb:readregistervalue(128, 'float32', 'bw')
log(v1, v2, v3, v4)

One of the values in logs should be correct.
Reply
#7
Thanks a lot! It works!
Reply
#8
(22.03.2017, 07:38)leondias Wrote: Thanks a lot! It works!

Hi leondias, I also trying to config Ping2. Can you share json with me?)
Reply
#9
(21.03.2017, 14:39)leondias Wrote:
(21.03.2017, 14:34)admin Wrote: Are you sure it's float16 on ModBus side? float16 is KNX-specific datatype and I've only seen one ModBus AC unit which has it as register value. Also, second mb:readregistervalue() parameter must be a string, not a dt.something. Do you have documentation for your ModBus device?

Yes, here it is

Now I try to read jus a outdoor temp. to get started. In the documentation its 129 address, but I'm trying with all 128, 129 and 130 to be sure Smile

I try do the same, but with writable addresses (315, 513, 533, 771, 1050).

Please, can someone help?
Reply
#10
Are you trying to make a profile or use scripts? In any case you need to subtract 1 from documented address, so 315 becomes 314 and so on.
Reply
#11
(29.11.2017, 13:09)admin Wrote: Are you trying to make a profile or use scripts? In any case you need to subtract 1 from documented address, so 315 becomes 314 and so on.

I trying with profile. With read only addresses it works without subtract.
Reply
#12
For writable addresses you have to add "writable": true
Reply
#13
(29.11.2017, 13:35)admin Wrote: For writable addresses you have to add "writable": true

My code:

Code:
   {
     "name": "Start/Stop",
     "bus_datatype": "bool",
     "datatype": "float32",
     "type": "register",
     "address": 315,
     "writable": 1,
     "value_custom": {
       "0": "Stop",
       "1": "Start",
     "read_swap": "n"
     }
   },
Reply
#14
datatype must be int16 or uint16, also try address 314
Reply
#15
(29.11.2017, 15:54)admin Wrote: datatype must be int16 or uint16, also try address 314

Thanks! It's working. Trying the same for 771 (770). No luck(
Reply
#16
What value are you getting? Try setting read_swap to b, datatype should be set to uint16, bus_datatype can be float16 and set value_multiplier to 0.01
Reply
#17
(29.11.2017, 17:15)admin Wrote: What value are you getting? Try setting read_swap to b, datatype should be set to uint16, bus_datatype can be float16 and set value_multiplier to 0.01

Thank you! Setting value_multiplier to 0.01 helped.

For everyone who use Komfovent Ping2 (modbus gateway for Komfovent ventilation AHU) my profile in attachment.

Attached Files
.json   Komfovent_Ping2.json (Size: 2.48 KB / Downloads: 38)
Reply
#18
Hi, help, please solve the problem. It is necessary to send a command to the infrared module using the Modbus TCP/IP protocol.
Team 01 02 00 00 00 0B 01 10 04 4F 00 02 04 00 03
Where 01 02 00 00 00 0B - MBAP header
01-number of the device in the network ID
10-function command FC
04 4F -address
mb: writeregisters (1103,0, 3) does not work.
With the help of programm Modbus Pool, commands are sent and executed)
Reply
#19
Try adding mb:setslave(1) before writeregisters
Reply
#20
Hi!

A Komfovent DOMEKT REGO-400PE-AC-C4 recuperator with C4-plus automation is installed in my house.
According to the documentation (https://www.vortvent.nl/wp-content/uploa...N-2016.pdf) port settings 19200-8E1, slave_id = 20 , registrs 1000-1362.
Experimentally discovered that in fact the registers start at 10000.
Maybe someone has a complete list of registers and their purpose for C4-plus?

Thanks.
Reply


Forum Jump: