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 script
#1
I have make a script to av ventilation system, but I cant get register 12, 13, 109, 115, 792 to work, it dont respond. All the other work. The LM4 start on 0, therefore all the adress i -1


{"product_code":"Swegon_Gold","mapping":[
{ "name": "A-Alarm", "bus_datatype": "bool", "type": "discreteinput", "address": 12,"bus_address":27137},    
{ "name": "B-Alarm", "bus_datatype": "bool", "type": "discreteinput", "address": 13,"bus_address":27138}, 
{ "name": "DX comp1", "bus_datatype": "bool", "type": "discreteinput", "address": 109,"bus_address":27139},    
{ "name": "DX comp2", "bus_datatype": "bool", "type": "discreteinput", "address": 115,"bus_address":27140},        
{ "name": "supply", "bus_datatype": "float16", "type": "inputregister", "address": 63, "value_multiplier": 0.01, "units": "C" ,"bus_address":27141},
{ "name": "exhaust", "bus_datatype": "float16", "type": "inputregister", "address": 65, "value_multiplier": 0.01, "units": "C" ,"bus_address":27142},
{ "name": "intake", "bus_datatype": "float16", "type": "inputregister", "address": 72, "value_multiplier": 0.01, "units": "C" ,"bus_address":27143},
{ "name": "setpointt", "bus_datatype": "float16", "type": "register", "address": 131, "value_multiplier": 0.01, "units": "C" ,"bus_address":27144, "writable":1},
{ "name": "Supply air", "bus_datatype": "float16", "type": "inputregister", "address": 36, "value_multiplier": 0.01, "units": "%" ,"bus_address":27145},
{ "name": "Extract air", "bus_datatype": "float16", "type": "inputregister", "address": 37, "value_multiplier": 0.01, "units": "%" ,"bus_address":27146},
{ "name": "Start/stopp", "bus_datatype": "float16", "type": "register", "address": 792,"bus_address":27149}
]
}


In the manual for the modbus it stand:
1x0013 A-alarm active Any alarm with priority class A active
1x0014 B-alarm active Any alarm with priority class B active
1x0110 COOL DX compressor 1 input Digital input status
1x0116 COOL DX compressor 2 input Digital input status
4x0793 Communication operation level 0=auto, 1=total stop, 2=low speed, 3=high speed, 4=normal stop, 5=extended normal stop.

Is there som how now what I do wrong?
Reply
#2
You can try reading data from a resident script. Just make sure that you disable RTU in modbus mapper, otherwise it will not work. Also you need to change script parameters like port name, baud, slave id etc. Once script finishes you will see the result in Logs tab.

Code:
require('luamodbus')
mb = luamodbus.rtu()

-- open serial connection, set correct port name, baud and parity
mb:open('/dev/RS485', 38400, 'E', 8, 1, 'H')
mb:connect()

-- set slave ID
mb:setslave(10)

res, err = mb:readinputregisters(792)

-- close serial connection
mb:close()

log(res, err)
Reply
#3
Thank you, I have try that, but when i go to the log the messige is: * arg: 1* nil* arg: 2* nil, what Is this mean?
Reply
#4
First rule when working with modbus devices - take a usb to rs485 converter (possibly isolated) and check addresses with modbus tester on laptop. Bus sniffing is also something worth learning, same as reading modbus without software decoder.

Never take the documentation or the tech's word for granted - until the device responds to you via your laptop. I had situations when the documentation and the field tech both say'd the same, but in the end I made the changes in the 3rd party device SW to made it speak modbus.

Address 4x0793 is modbus function 3 (read holding register). Are you sure it's configured correctly in LM? It can be confusing when the address is 4x for function 3 and 3x for function 4.
Reply


Forum Jump: