Logic Machine Forum
Modbus Profile Write Errors - 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: Modbus Profile Write Errors (/showthread.php?tid=5258)



Modbus Profile Write Errors - jmir - 20.02.2024

Hi,

We've an installation where there are two modbus RTU slaves connected to port 1.
These devices only allow single register read/write and its max timeout is 2.1 seconds.
Reading works pretty well using 3 timeout seconds, but when writting sometimes it returns "Write failed: Operation timed out"

When this happens what does modbus mapper do? Try to write it again?
If not, on next reading poll will KNX object be updated to previous value (read from modbus) or will it remain as it has been written?
Is there any way to be sure that the value has been written?

How are writes managed? Are it done after the slave reading poll? Or is it interrupted and the write is done and then readings resumed?

Thanks


RE: Modbus Profile Write Errors - admin - 21.02.2024

The mapper writes only once. No retry is done in case of an error. Next write is triggered when new group write happens. Writes do not interrupt reading.
As a workaround you can resend the values periodically: https://forum.logicmachine.net/showthread.php?tid=1878


RE: Modbus Profile Write Errors - jmir - 21.02.2024

(21.02.2024, 14:42)admin Wrote: The mapper writes only once. No retry is done in case of an error. Next write is triggered when new group write happens. Writes do not interrupt reading.
As a workaround you can resend the values periodically: https://forum.logicmachine.net/showthread.php?tid=1878

And is there any way to know to which register is the error refered? To resend it only when necessary....


RE: Modbus Profile Write Errors - admin - 21.02.2024

You can create a profile with two definitions per each register - control (write-only) and status (read-only). Then you can compare control and status values and act accordingly.


RE: Modbus Profile Write Errors - jmir - 21.02.2024

(21.02.2024, 14:58)admin Wrote: You can create a profile with two definitions per each register - control (write-only) and status (read-only). Then you can compare control and status values and act accordingly.

Ok i'll try it.

Thanks!


RE: Modbus Profile Write Errors - jmir - 21.02.2024

(21.02.2024, 14:58)admin Wrote: You can create a profile with two definitions per each register - control (write-only) and status (read-only). Then you can compare control and status values and act accordingly.

Are delays applied to writes? If for example 3 writes to different registers are queued how are they managed? Because it seems that this device only accepts one write for second...


RE: Modbus Profile Write Errors - jmir - 22.02.2024

Hi,

I've been doing some tests using a modbus sniffer and it seems that after reads, writes are done without any delay and I think that's why the slave can't manage it... Is there any way add a delay between writes?


RE: Modbus Profile Write Errors - Daniel - 22.02.2024

In profiles there is only read delay option. You can use modbus proxy script for writing and handle it there.


RE: Modbus Profile Write Errors - jmir - 22.02.2024

Do you have any mbproxy functions list? And how to use them?


RE: Modbus Profile Write Errors - Daniel - 22.02.2024

Some examples here
https://forum.logicmachine.net/showthread.php?tid=839&pid=22637#pid22637


RE: Modbus Profile Write Errors - jmir - 22.02.2024

Hi,
I've done some tests using this code:

Code:
mbproxy = require('mbproxy')
mb = mbproxy.new()
mb:setslave(1)
log('write')
local a=mb:writemultipleregisters(48094, 1)
log('a: '..a)
local b=mb:writemultipleregisters(48092, 480)
log('b: '..b)

I don't know how to add a delay between them... It seems that both are queued and executed when polling cycle is finished (sometimes the second one is written on the next cycle...) and sometimes writemutipleregisters returns nil (is it when value has not been written?)

I need to manage some kind of writting queue, writing registers one by one (using function 16) with 1 second delay between them...

Don't know if it's possible in some way....


RE: Modbus Profile Write Errors - Daniel - 22.02.2024

Use os.sleep(1) between writes