LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to run a continuous measurement VI in the background and access the measured data in a main VI?

Solved!
Go to solution

Hello everyone,

 

I have been learning the class with LabVIEW, and I have created a "MonitorVoltage" class. The code is in the attachment (you can run "ContinousVoltageMonitoring.lvlib").

With this class I want to monitor a static voltage (using DAQmx) and store the value if the voltage is outside predefined limits.

I also want to be able to access the measured voltage outside the "monitoring" VI while the measurement is on going (which means the voltage is inside the limits).

 

So basically, I have few main methods:

  • Update Limits.vi 
    • To update the min/max expected voltage
  • Create Measurement Task.vi
    • To create the virtual channel and then the task, based on the physical channel, sampling rate, and the duration of the voltage averaging (before comparing to limits)
  • Start Measurement.vi
    • To run the task, measure continuously the voltage, and stop the task if the voltage becomes outside the limit
  • End Measurement.vi
    • Which can be used to kill the "Start Measurement.vi" even if the voltage is inside the limits, and then clear the task
  • Read averageValue.vi
    • This is a data member access VI to get the "average voltage" which is continuously updated by "Start Measurement.vi".

 

Additionally I have a "TestWithEvent.vi" (which is not part of the class), to be able to test my class.

 

So my issue is that "Start Measurement.vi" is blocking as long as the voltage is inside the limits. So I cannot call "End Measurement.vi" to stop the measurement, or "Read averageValue.vi" to get the latest "average voltage" measured in "Start Measurement.vi".

I know I can use an invoke node to call a VI so that it is not blocking, but i don't know how to do it with a parameter (the instance of my class).

Even if the invoke node would be successful, during the runtime of "Start Measurement.vi", I don't think I would really get the latest "average voltage" by calling "Read averageValue.vi".

Indeed I think the instance of my class (with the latest "average voltage") would not be propagated outside of the "Start Measurement.vi" as long as the VI doesn't end.

 

Does anyone know what would be the proper way to reach my goal? Being able to access "average voltage" while "Start Measurement.vi" is on going?

Best regards,

Ludovic

0 Kudos
Message 1 of 4
(1,307 Views)
Solution
Accepted by topic author Lchar

I would recommend you use run Start Measurement VI outside of the main loop. Use User Event or Notifier to wait for the stop command. Use Data Value Reference to pass data between the Measurement and main loops.

-------------------------------------------------------
Control Lead | Intelline Inc
Message 2 of 4
(1,248 Views)

Thanks for the tips! I haven’t heard about DVR before but after reading a bit about it, that’s definitely what I need. 
My end goal will be to use this class/VI through TestStand and DVR sounds helpful for that. 
However it’s still quite fuzzy how to use that properly, do you have some good code example or articles which would describe how to use DVR with class instances? Otherwise I will make my own tests and probably create a new post for my DVR related questions. 

0 Kudos
Message 3 of 4
(1,216 Views)

Actually, I could understand how to use DVR with classes (at least one way).

I continue on a different post dedicated to the DVR questions, it can be found here:
https://forums.ni.com/t5/LabVIEW/Data-value-reference-DVR-how-to-write-and-read-without-using-IPE/td...

It also contact my updated LabVIEW code with DVR.

Thank you again!

Message 4 of 4
(1,173 Views)