LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Use a logic from for loop to stop do while loop outside

Hello,

It is a fairly simple logic however I don't know how to realize it in Labview. My program has two do-while loop with different iterating rates. One is for data acquisition from hardware; the other loop is for data logging. The data logging loop runs once per 60 sec (I don't need all the data), which is much slower than the 0.01sec time interval of the acquisition loop. I also need to minitor each sample acquired to be smaller than a certain threashold. If there is one sample exceeding that limit the whole acquisition process is considered to be malfunctioning and the data logging loop should reset all the variables calculated from the previous data to zero. And these zero values should be kept until a command is sent to reactivate the logging process. In the mean time, the acquisition loop keeps running.

I need to develop a logic in the acquisition loop to send out a signal to the data logging loop. Note that 1000 samples are read from the buffer per iteration in the do-while loop, and the comparation with limit is performed in a 1000-time for-loop inside that iteration. I am new to Labview and not familiar with function vis. Can anyone give me any advice on this? Thank you.
0 Kudos
Message 1 of 8
(2,688 Views)
Hi. Welcome to the wonderful world of graphical dataflow programming. What you're asking for is fairly general, so I'll suggest first that you take some LV tutorials, either on the web, or using NI's courses. One such tutorial can be found here.
Next, you can use the example finder (Help>>Find examples) to see how logging and acquisition programs should work.
If I understand what you want to do correctly, it sounds like the simplest way would be to use a shift register (search for it) to store the data in the acquisition loop and only transfer it to the logging loop when it's time to log it. Communication between loops can be handled in a variety of ways - from the simple local variable to the more complex mechanisms which can be found in the advanced>>synchronization palette.
I hope these lines help set you on the right path. If you looked through the information and haven't found anything, feel free to post again.

___________________
Try to take over the world!
0 Kudos
Message 2 of 8
(2,671 Views)
Thank you for your reply.

Maybe I didn't explain it clearly. I should have used the word "write to a file" instead of "logging". The data I need to save on a file is some kind of calculation result (like the summation of samples qualifying certain rules) and I need it saved only once every 60 sec. This process has been established and works very well. What I have trouble with is how to reset this calculated value in "saving" loop back to zero when a sample exceeds a input limit or error threadhold. Then keep the value as zero unless a command is sent to restart the calculation. I look forward to your reply. Thank you

Frank
0 Kudos
Message 3 of 8
(2,651 Views)
That depends heavily on you move the data between loops and what kind of flag you're using. I suggest you post the relevant code here, or write specifics about the data transfer mechanism (local variable, queue, with/without shift register). The code would be much better because writing would be like trying to describe a picture. Note that you can only attach one file, so if you have more, save them as an LLB (File>>Save with Options>>Development distribution).

___________________
Try to take over the world!
0 Kudos
Message 4 of 8
(2,641 Views)
Okay, I attached my file here. The programe now is working fine. But I need to add one more function in this program. When any channel fails(any sample in that channel exceeds some limit value), the "pulse" reading in the failed channel restets to 0 and "pulse" readings in other channels are still counting, also the failed channel sends an alarm warning. The physical channel input signals are kinds of 60 HZ sine waves with strong third harmonic distortions.

I look forward to your reply, Thanks.
0 Kudos
Message 5 of 8
(2,638 Views)
I can't look at your code at the moment (no 7.1 on this PC), and when I did I was missing a lot of VIs (no DAQ on that PC) but if I remember correctly, the pulse reading for your channels aren't seperated. Unless you mean each for loop handles a different channel, in which case, it may be advisable to place that code in a subVI or to perform those reading using an array and an outer for loop. If I remember (and understand your code) correctly, you have a select function for the pulse data. What would happen if you added another select function after it with your condition and wired 0 into one case and the wire into the other?
In general, I would highly recommend documenting your code at every step. If you reopen this code in 3 months, you'll see how much it can help. Search this site for "style guide". The LV style guide is a long document with a lot of good tips. It's worth reading.

___________________
Try to take over the world!
0 Kudos
Message 6 of 8
(2,619 Views)
Thanks for your advice. I tried to use the way you mentioned at the very begining, but the results are not satisfied. Thanks any way.
0 Kudos
Message 7 of 8
(2,610 Views)

Hi Frank,

It sounds to me like you had a similar problem to what I am now experiencing, could you post and example of the working code as a jpeg or something i can read with labview 7.0

 

cheers

0 Kudos
Message 8 of 8
(2,470 Views)