LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simultaneous Execution of For Loop and While Loop

Hi guys,

 

I was wondering if anyone could explain to me how LabVIEW runs parts of a VI in terms of sequencing.  I am trying to create a simple sinusoidal signal using the simulate signal block and I want to be able to step up its amplitude in an automated fashion.  To do this I figured I could just use a for loop that increments the amplitude and feeds the new amplitude to the simulate signal block.  When I run it however, the signal does not update the amplitude until after the for loop has been through all of its iterations.  Only then does the signal update with the last value of the amplitude that the for loop had iterated to.  I am pretty new to LabVIEW, so I'm unsure how to change this so that the signal will update in real time with the values the for loops outputs.  I attached a picture of my VI for reference.  I'm not sure if this is even the most efficient way to go about this, so any help is much appreciated.  Thanks!

0 Kudos
Message 1 of 4
(2,541 Views)

Your verifies the data flow concepts in LabVIEW: There is a wire going from the For Loop to the While Loop. This wire gets its data when the For Loop finishes, thus the While Loop cannot start execution before the For Loop finishes.

Using a notifier is an appropriate approach to solve your task.  Have a look at the LabVIEW Examples, see menu Help >> Find Examples ...  . There, search for "notifier" and have a look at the "General Notifier Example" which does exactly what you are trying to achieve.

With regard to your JPG: Do you know LabVIEW's feature "Create Vi Snippet ..." that you can reach from the menu Edit?  These VI Snippets are PNGs that everyone can see here in the forum and(!!!) you can use them in LabVIEW.

Message 2 of 4
(2,521 Views)

Thanks for the response.  I implemented the notifiers and it seems to have partially fixed the problem.  Now when I run the VI it updates the amplitude on every iteration of the for loop.  The only problem that I have now is that the while loop that houses the "simulate signal" block stops execution immediately after the amplitude has been updated.  My goal is to get the signal to continuously run while updating the amplitude in real time so that I can watch the waveform change.  Currently it will update the amplitude, then freeze the waveform with the updated amplitude and subsequently wait for a new amplitude to be passed before updating again.  I'm assuming this occurs because of the "wait on notification" block that is used to receive the notification from the for loop.  Is there any way to either modify these notifiers to allow for a real time passage of data and simultaneous execution of the while loop, or is there some other type of data passing method that would work better to achieve that end?  I have attached my updated VI as a VI snippet like you suggested.  Thanks for the help!

0 Kudos
Message 3 of 4
(2,495 Views)

Wire a zero into the timeout terminal of the Wait on Notification function.

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