From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timed structure for output in producer consumer data acquisition

Hello LabVIEW community,

 

I have a bit of a problem.  I am writing a program that is primarily for data aquisition but has a few control features as well.  I need the program to aquire and write several channels of data at a relitively high speed.  The program does this fine ( in the top 3 loops fo the program).  I need the program to also send a seires of two output signals in response to a particular condition.  When a certain channel registers a value of above a specified number, I need an output channel to write an anologue signal for 225 seconds and then a signal of a differnt value to the same channel untill the condition occurs again (not for several hours).

 

 I put this action in a timed structure inside of a case structure. The case structure and timed structure are inside of a second consumer loop.  I have no idea if this is ligitimate.  This event takes much longer than any of the other loops which run at 1 or 2 seconds. When I exicute the program with "highlight exexutuion" this longer (case/ timed ) loop never executes. I asssume this has to do with the mismatch in time scales of this loop and the other loops in the program.  I also didn't really understand the help information on timed structures, so its possible that I just need better/ different inputs to the timed stuctures.  

 

If anyone can see any obvious problem in the code or suggest a better way to do the output function I would really appreciate the help.  My code is attached.   

 

Thanks,

 

Jo

0 Kudos
Message 1 of 2
(2,590 Views)

I can't figure out how to fix your code, but I can point out the things I see wrong with it.

 

 

1.  You are dequeueing elements from the same queue in the same loop.  In one you are not taking the element, and in parallel, you are taking an element.  I see that in your bottom two loops.  Why?  That code won't execute until the queue gets two elements in it.  And which dequeue gets it first and which gets it second is an arbitrary race condition.  So there is no certainly of order (first 4 vs. last 4 currents in the one loop), or which gets kept and which gets discarded (in the other loop.)

 

2.  You are creating and/or clearing DAQ tasks in every loop iteration.  Tasks should be created before a loop, used inside the loop (read or write), then cleared once the loop is done.  Anything else is wasteful, time consuming, and could lead you to run out of resources.

 

3.  You are using the STOP function which is pretty much like hitting the abort button on the toolbar.  No program should ever stop that way.  All loops should exit gracefully.

 

4.  You have a data dependncy between your bottom two loops because of the boolean wire running from one to the other.  That bottom loop will only run once (if the value is True), or run forever (if the value is false).

 

5.  Use of the dynamic datatype.  You are taking waveforms, converting them to a blue wire, then coercing them into another datatype such as just displaying a scalar in an indicator.  A lot of unnecessary conversions there.

 

6.  Your thermometer indicators have a digital display you can make visible.  Then you won't need the separate numeric indicator to display the value.

 

7.  For loop that runs only 1 time because of the constant wired to the N terminal.  Get rid of the For Loop.

 

8.  Check your spelling.  The word "Temperatures" on the graph, and one instance of "distillate" is missing an "l".

 

Until all of these problems are fixed, it is not worth talking about timing of timed structures.  Some of these problems were discussed in your other thread.  http://forums.ni.com/t5/LabVIEW/producer-consumer-missing-channels/m-p/3159757#M911255   But now it seems like you've made things even more complicated without fixing the basic problems.

0 Kudos
Message 2 of 2
(2,572 Views)