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 help
#1
When using LM5 for Modbus communication, if the resident script queries the register status while the event script is writing to the register, it may not be possible to write to the register. How can this be better resolved?
Reply
#2
Use profiles.
Reply
#3
(22.04.2026, 09:36)admin Wrote: Use profiles.

Are there any examples for reference?
Reply
#4
Profiler app: https://forum.logicmachine.net/showthread.php?tid=5911
Profile reference: https://kb.logicmachine.net/misc/modbus-profile/
Profile examples: https://forum.logicmachine.net/showthread.php?tid=839
Reply
#5
I use a JSON file to map MODBUS. At first, I couldn't actively read it; it could only automatically send values to KNX when they changed. Is there any solution?
Reply
#6
What do you mean by "actively read it"? In Modbus device settings you specify poll interval - all registers that are mapped to group addresses will be read every X seconds. Mapped group address values will be updated if the Modbus value differs from the current value.
Reply
#7
(22.04.2026, 09:42)admin Wrote: Profiler app: https://forum.logicmachine.net/showthread.php?tid=5911
Profile reference: https://kb.logicmachine.net/misc/modbus-profile/
Profile examples: https://forum.logicmachine.net/showthread.php?tid=839

Hello, I’m currently working on a project that requires connecting multiple Modbus device systems. I plan to use a gateway to transmit JSON scripts for each system via the TCP protocol, yet I’m quite worried this may lead to excessive communication load. Is this concern justified?
Reply
#8
You can specify poll interval for each Modbus device. This value controls how often all Modbus datapoints that are mapped to group addresses are read. Increasing the poll interval lowers the overall system load.

"Value send delta" option should be configured correctly for all registers. Increasing this value reduces the number of object writes.
Reply
#9
[Image: c6084723be4c51def881ca719e8bcf8f.EW2Xy]I need your help to create a Modbus integration for an air conditioner. Register 11 is used to select the indoor unit, and registers 12-16 correspond to the functions of the selected indoor unit. For example, if you enter 3 in register 11, then registers 12-16 represent the functions of indoor unit 3. Can this be written as a JSON file for the gateway to control each indoor AC unit? Currently we use event scripts and resident scripts for control, but control packets are often lost, requiring a second operation. Looking forward to your reply, thanks!
Reply
#10
If you need to change the unit number dynamically then you should use scripts with a single write of multiple registers. The Modbus device might only handle a small number of parallel TCP connections which leads to communication issues.

Try logging the result of connect/write:
Code:
mb = require('luamodbus').tcp() mb:open('192.168.1.1', 502) res, err = mb:connect() if res then   res, err = mb:writeregisters(1, 2, 3)   if not res then     log('write failed', err)   end   else   log('connection failed', err) end mb:close()
Reply
#11
(09.07.2026, 06:40)admin Wrote: If you need to change the unit number dynamically then you should use scripts with a single write of multiple registers. The Modbus device might only handle a small number of parallel TCP connections which leads to communication issues.

Try logging the result of connect/write:
Code:
mb = require('luamodbus').tcp() mb:open('192.168.1.1', 502) res, err = mb:connect() if res then   res, err = mb:writeregisters(1, 2, 3)   if not res then     log('write failed', err)   end  else   log('connection failed', err) end mb:close()

The air conditioner communicates via the gateway's 485 interface using wired communication. Currently, I have placed the register reading in the resident script and the register writing in the event script. There has been a problem with communication conflicts between the event script and the resident script during use, causing the event script not to execute actions. Is there a good solution for this?
Reply
#12
Use mbproxy for RS485 communication. Enable and configure RTU1 in Modbus tab. Then use this in scripts:
https://forum.logicmachine.net/showthrea...8#pid39898
Reply


Forum Jump: