LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing changing data to subVI via reference: always missing newest input value

Solved!
Go to solution

Hi everyone,

 

I am having a problem I cannot find the solution for. I searched the forum and google, but I couldn't find an explenation. Hopefully you can help!

In the attached project there is the "main.vi", which I use to control an industrial manufacturin mashine. On the frontpanel I have a cluster called "manual control". Whenever I change a value in the cluster an event is triggered to execute the "manual control" case in the "Wirbelschicht_main.vi" [called "FBC (Fluid bed control)" in the main.vi block diagram]. In this case, the data from the cluster is updated via a reference. The order to execute the "Manual control" case is passed in a queue.

 

 

When I change the value of, for example, "InAirTempSet" from 0 to 5 and then from 5 to 9, I would expect the numbers in the subvi to update in the same manner (first from 0 to 5, and with the next click from 5 to 9). What I see is that the update process in the subviis always one step behind. Meaning, I change the value from 0 to 5 in the main.vi and nothing happens. Then I change the number to 9 and 5 in the subvi 5 is received. Only when I change the number in the main.vi another time, the 9 is passed to the subvi.

 

What is the reason for this and how can I fix this? 

 

Thank you!

Qbach

0 Kudos
Message 1 of 4
(2,901 Views)
Solution
Accepted by topic author Qbach

This is expected behavior. You read the value of control reference concurrently to waiting for the queue command. That means that once the queue command ("Manual control") is received, the value was already read a long time ago.

 

In order to prevent such race conditions, pass the data using the queue instead of reading it asynchronuously with property nodes. You are running into a race condition here because this is exactly what your code instructs the application to do!

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 4
(2,896 Views)

I love programming because the program does exactly what you tell it to do; I hate programming because the program does exactly what you tell it to do.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 3 of 4
(2,889 Views)

...putting it that way makes absolute sense. I'll wire it into a queue. Thank you!

 

@billko: I will steal that and make it my motto. More likely the second part 😉

0 Kudos
Message 4 of 4
(2,852 Views)