LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing the data to other while loop

Hi

     I have application, 3 while loops as below

  1. First loop rate is 10ms to getting the data from DAQ
  2. Second loop(rate is 10ms) use the current data from first loop
  3. Third loop(rate is 100ms) use the current data from first loop

 

Loop2,3 use only the current data from loop1(not every data from loop1). Right now I’m using the local variable to passing these data but it quite not good.

            I also not sure function queue is suitable for this problem? Please advise, thank you.

0 Kudos
Message 1 of 15
(2,614 Views)
0 Kudos
Message 2 of 15
(2,589 Views)

Can you provide a little more information on what you mean when you say, "Right now I’m using the local variable to passing these data but it quite not good." While this is not the way I would do it I do believe that as you've described what you're trying to do it should work. 

 

I would suggest that if you're not concerned with data loss then you should run the second loop at a slower rate. 

 

Posting code showing how you've implemented the loops would be beneficial.

0 Kudos
Message 3 of 15
(2,582 Views)

@SabariSaravanan.M wrote:

Try out this functionality, It'll help you!

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000kFGfSAM


Thank you, I will try.

0 Kudos
Message 4 of 15
(2,579 Views)

Because of the Principle of Data Flow, LabVIEW can do things "in parallel", i.e. all three loops can run at the same time without explicit "clocking" (but all running at their own speed).

  • Loop 1 is a Producer -- it is getting data from DAQmx (I'm assuming -- you failed to post code) and probably "wakes up" every 10 ms when data appear.
  • Loop 2 is a "Consumer" -- it takes all of the data from Loop 1 and "does something with it" (but does it pretty fast, probably finishing within 10 ms.
  • Loop 3 is a "Partial Consumer" -- it takes the current data from Loop 1, does a lot of processing, and doesn't worry about getting all of these data.
  • To send data from Loop 1 to Loop 2, use a Queue, a loss-less means of transport between parallel loops.
  • To send data from Loop 1 to Loop 3, use a Notifier, which is a "lossy" method of sending the "last" data put on the Notifier by the Producer.

One piece of Useful Information we get when you post your code is we can tell what version of LabVIEW you are using.  You didn't post, you didn't mention it, so I won't tell you about Stream Channel Wires and Tag Channel Wires ...

 

Bob Schor

0 Kudos
Message 5 of 15
(2,570 Views)

Use Channel Wires.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 6 of 15
(2,559 Views)

@Bob_Schor wrote:

Because of the Principle of Data Flow, LabVIEW can do things "in parallel", i.e. all three loops can run at the same time without explicit "clocking" (but all running at their own speed).

  • Loop 1 is a Producer -- it is getting data from DAQmx (I'm assuming -- you failed to post code) and probably "wakes up" every 10 ms when data appear.
  • Loop 2 is a "Consumer" -- it takes all of the data from Loop 1 and "does something with it" (but does it pretty fast, probably finishing within 10 ms.
  • Loop 3 is a "Partial Consumer" -- it takes the current data from Loop 1, does a lot of processing, and doesn't worry about getting all of these data.
  • To send data from Loop 1 to Loop 2, use a Queue, a loss-less means of transport between parallel loops.
  • To send data from Loop 1 to Loop 3, use a Notifier, which is a "lossy" method of sending the "last" data put on the Notifier by the Producer.

One piece of Useful Information we get when you post your code is we can tell what version of LabVIEW you are using.  You didn't post, you didn't mention it, so I won't tell you about Stream Channel Wires and Tag Channel Wires ...

 

Bob Schor


I agree that this is the right way to do it, but if he's not concerned with data loss (the original question says use current value) then, while a poor way to accomplish the task, the approach that he's using should "work." My guess is that the problem is that he needs loop 2 to be lossless.

0 Kudos
Message 7 of 15
(2,558 Views)

I did, indeed, assume Loop 2 processes all the data, which informed my response.  On the other hand, if Loops 1 and 2 both nominally run at 10 ms, then processing all the data should be "safe".  I assumed that Loop 1 had a DAQ device, so that the timing was "known" (and the loop always took 10 ms), while Loop 2 had a "Wait" function, and I assumed that without the Wait, it would take less than 10 ms (big assumption, Bob), so a true Producer/Consumer Design was "safe".  Of course, one should test one's assumptions, hard to do without seeing the code (and running it) ...

 

Bob Schor

Message 8 of 15
(2,537 Views)

After I verify my code carefully, loop1(Acquire DAQ loop should no probrem). So I have now 2loops to fogus loop A, loop B

Loop A(loop rate 10ms) ; produce the data, I use notifier for Prs1PSupply and the other I still use local variable. I checked already actual time by tick count is correct 10ms

Loop B(loop rate 200ms) ; getting all current data from loop A to record every 200ms

The problem

1.When I use Notifier function is actual loop rate of LoopB is 250ms(it should be 200ms), but the data is correct

2.If I not use Notifier function(Use only local variable) actual loop rate of LoopB is 200ms(correct), but the data is wrong(data is repeat periodically)

Please give me some guide or what I mistake?


@Bob_Schor wrote:

I did, indeed, assume Loop 2 processes all the data, which informed my response.  On the other hand, if Loops 1 and 2 both nominally run at 10 ms, then processing all the data should be "safe".  I assumed that Loop 1 had a DAQ device, so that the timing was "known" (and the loop always took 10 ms), while Loop 2 had a "Wait" function, and I assumed that without the Wait, it would take less than 10 ms (big assumption, Bob), so a true Producer/Consumer Design was "safe".  Of course, one should test one's assumptions, hard to do without seeing the code (and running it) ...

 

Bob Schor


ALoop.pngBLoop.png

0 Kudos
Message 9 of 15
(2,508 Views)

It's difficult to troubleshoot your code with only pictures of part of the code. What's going on in the other frames of that stacked sequence? What changes CntrAvgInput so that the values actually get updated (or do they also get updated, just differently, in the other case?). I suspect that you're actually only updating these values every 250 ms.

 

If you could zip a copy of your code and upload it you would get much better help.

0 Kudos
Message 10 of 15
(2,494 Views)