LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus I/O Server Shared Variable Not Updating Immediately After Flush

Hi everyone,

 

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??

 

Some notes:

  1. The shared variable is NOT network buffered.
  2. The slave is NOT altering the value of this variable; only this snippet of code is.
  3. Altering the refresh rate of the Modbus server does not affect the outcome.

If anyone has any idea as to what's going on, I would greatly appreciate it!

0 Kudos
Message 1 of 3
(3,003 Views)

Hi Mercuri,

 

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,

Andrew T.
"His job is to shed light, and not to master" - Robert Hunter
0 Kudos
Message 2 of 3
(2,939 Views)

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?)

0 Kudos
Message 3 of 3
(2,897 Views)