Weird issue here... If I create a Modbus I/O server in a LabVIEW project, bind a shared variable to a holding register, write to the shared variable, flush, and read back, the value returned in an immediate readback is NOT the value I previously wrote. I've attached an example snippet.
In this example, PLC Command Complete is TRUE coming in. I write a FALSE to it. I flush the shared variable buffer. I read back PLC Command Complete. When I do this, PLC Command Complete will return TRUE (???), and after 100ms or so, return FALSE. How is this possible??
If anyone has any idea as to what's going on, I would greatly appreciate it!
This inquiry might be better suited for our Industrial Communications forum page. That forum is the landing page for most modbus questions, as users with more exposure to modbus browse it.
Aside from that, I have two additional questions that might help in troubleshooting -
1. Try reading / probing the error wire. There might be warnings on it that are not normally passed to the user interface.
2. What is the IO update rate for the IO server? This behavior might be explained by a slow update rate.
Have a nice day,
Couple of points.
First, your screenshot shows network shared variables, not single process!
Next, network shared variables take time to update (much longer than NI tell you!) If you knock up a little timing noddy to set a variable and then loop reading that variable until the transition comes through you get results like this (runnng from the programming environment, I've not tried with a compiled exe):
Network shared variable, no flush - approx 20ms (NI say is should be 10)
Network shared variable, flush buffer - very fast (faster than the ms clock resolution) but still took between 14 and 20 iterations of my loop before the change percolated through (certainly not what you would expect)
Single Process variable - instant (even without the flush)
This has caused me so many problems in the past (my own race conditions are bad enough without NI throwing in extra ones with this unexpected behaviour) that I try to avoid network shared variables now.
Change yours to single process and you should be fine (or do they need to be NS?)