LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Acquiring continuous data using an event structure

I am new to labview, having recently taken the Core I and II courses.

 

I am programming a test rig to acquire the linear position of a hydraulic cylinder and plot it over time.  In programming this code, I elected to use an event structure so that when a front panel button is pressed, a certain part of the test is run. 

 

In one particular part of the test, called the Snub Test, I need to measure the position of the cylinder over time and plot it to a graph.  The data acquisition needs to be continuous, however the event structure only allows the loop to run once. 

 

I have attached a portion of my code for reference.

 

Can someone please advise how I can get this data acquisition to run continuously until the user (or a reference trigger) stops the test?

 

Thanks

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

Simply manipulate the timeout and use the timeout case.

 

Here is an old example, but there are probably many more ...


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 2 of 4
(3,129 Views)

A single loop with an event structure is not the best way to go about this. I was unable to open your code as there were some subVI's missing so I cannot appreciate how you have approached this although I will assume you have a vi with a single while loops with an event struct in it!

 

You should study the "Producer/Consumer Design Pattern (Events)" template that ships with LabVIEW.  In case you are unfamiliar, select File>>New. Then expand the Frameworks section and within Design Patterns you will see the template I mentioned.

 

This template will show you how to use an event structure in its own loop to issue commands to a parallel loop which could contain your DAQ code. Typically when an event is called in a producer loop, a command is queued to the consumer loop which allows some form of control over its function (start DAQ, Stop DAQ, Quit for example).

 

As a general rule (which I do break on the odd occasion as feature creep sets in) I never put any code in an event structure other than the code required to call some other code in a parallel loop...that is to say I only use 'Enque Element.vi' within an event structure. Study that template I mentioned, 9 out of 10 programs I write starts with that kind of framework.

 

If you are not familiar with Queues, they are your best friend, get to know them well and soon you will be a strong and powerfull programmer 🙂

 

 

Senior Software Engineer
www.Adansor.com
Message 3 of 4
(3,125 Views)

A few comments to your VI in general:

 

 

  • You changed the stop button to "switch until released", most likely because you fabricated a race condition and did this as a quick fix. The reason is (1) your placement of the stop terminal outside the event structure and (2) the use of a local variable wired to the stop condition. The button terminal of a latch action boolean belong inside it's associated event case! This way it gets read (and reset to false) when the event occurs. In your case, the local variable and the button get read before the event occurs and the loop needs to spin once more at the event that occurs when you release it (true->false). At this point, the local is still true from the earlier event and the loop stops. Correct would be: latch action, stop terminal inside stop case and wired to the stop condition from inside the event. Other cases use the default output (false) and don't stop the loop.
  • Your "equal false" code fragment is just an invert, right? So why complicate things?
  • Why do you need a wait if there is an event structure?
  • ...

 

 

 


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
Message 4 of 4
(3,120 Views)