LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timer output sent to shared variable

I'm using a simple countdown timer but now I want to send the countdown time out through a shared variable to another VI.  I made a simple example to test with where I tried to write the time to the shared variable and then read back to a numeric indicator but it doesn't work.  What am I doing wrong with it.

 

Thanks for the help

Danny
0 Kudos
Message 1 of 6
(3,371 Views)

Your "Numeric 2" is not a parallel process to the data being generated in the while loop. You need another while loop - put "Numeric 2" in the new while loop, and it should work. However, there are better ways of communicating out of a loop than shared variables - such as Queues or Notifiers.

Richard






0 Kudos
Message 2 of 6
(3,357 Views)

I have attached an example of many ways to communicate from one loop to another (and some of these work for one VI to another). I am making no claims as to which one is "the best" - they all have their strengths, except maybe the global.  Smiley Tongue  Regarding the Shared Variable - I have never used it outside of networked variables with Real Time, so it is not in this example.

 

you need all three VI's.

Richard






Download All
Message 3 of 6
(3,353 Views)

Broken Arrow,  Great example.  Thank you for your help.

Danny
0 Kudos
Message 4 of 6
(3,342 Views)

Broken Arrow,  I ran into another problem and was thinking maybe this is why you didn't think shared variables would be best for this code.  I included a second while loop to receive the data as you had suggested and that worked without a problem.  But I ran into a problem when I tired to stop both loops.  If I don't stop the loops together the data passes between loops without any problem.  When I stop both loops together the data does not pass to the top loop.  Is this because i'm not stopping the loops correctly, or is this the result of using shared variables? In the end, the timer will be it's own subVI and the code will be used on a RT cFP system. 

 

Thank you for the help.

Danny
Download All
0 Kudos
Message 5 of 6
(3,316 Views)

Now you have a loop inside a loop, so your process is not parallel, it's nested. try to write the code without that inner loop. (It's not the Shared Variable's fault).

Richard






0 Kudos
Message 6 of 6
(3,299 Views)