LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

trigger a loop to execute when pulse is received

Solved!
Go to solution

Hi I have a simple operation that I need to execute however I cannot figure out how to perform it.  I have a signal that goes high (or true, I can make it either) for one iteration then returns low (or false).  I need this high signal to trigger the start of a loop which remains on until it receives a signal to turn it off after the function inside executes.  In a circuit point of view, I was thinking to use a D-flip-flop which takes in the pulse and the output remains high until it receives a signal to clear it, turning off the loop.  I can use either a case structure or while loop as my loop, but I just need to know if there is a way to continuously run a loop upon receives a single pulse.  Thanks for any suggestions. 

0 Kudos
Message 1 of 12
(4,561 Views)

Hi,

 

If I understand you correctly, you want to run a loop once a pulse is received.  You could put two loops in series, the first loop stops and dataflow then allows the other loop to run, continuously, till it is stopped.

 

There are many ways to start a loop, based on another signal.  For example using notifiers and semaphores.

 

Really, there are many ways to do this, but in context of your program there are probably 'best' ways to do it. 

 

Can you provide some sample code?

-------
Mark Ramsdale
-------
0 Kudos
Message 2 of 12
(4,560 Views)

I am trying to do almsot the exact same thing. 

If I put 2 loops in series, say one to start a measurement, and another one to process the obtained data. how do i trigger the next loop to start after the first loop has finished finished? 

I have multiple data being spat out of the first loop. So I want to process it only after it has finished the enitre loop.

 

0 Kudos
Message 3 of 12
(4,551 Views)

Thanks Mike for the suggestions.  I attached a simple example of what I am trying to do.  I basically have to trigger a loop to run for x iterations once the character * is sent by enabling the true statement.  There is a continuous data stream coming in, so I need to trigger the loop to run only when the * character is sent.      

0 Kudos
Message 4 of 12
(4,548 Views)
Solution
Accepted by topic author baseball07

Put the inner while loop in a case structure.  The main loop skips the inner loop ( inside a T/F case) until the case selector goes to T, by running an empty F case.  Once the trigger goes to T then the inner loop will complete before the outer loop moves to another iteration.

-------
Mark Ramsdale
-------
Message 5 of 12
(4,540 Views)

Hi Entangler

 

Use an error wire to connect the two series loops.  The second loop will not execute till the first is complete.

 

Read up on data flow for LabVIEW 🙂

-------
Mark Ramsdale
-------
0 Kudos
Message 6 of 12
(4,539 Views)

Got it thanks, I will try it.

0 Kudos
Message 7 of 12
(4,536 Views)

Oh Yeah, add a time delay in both loops, maybe 50ms.

-------
Mark Ramsdale
-------
0 Kudos
Message 8 of 12
(4,534 Views)

Hi Mark.

Thanks for the advice. I am learning the basics of notifiers.

I created a program using notifiers and everything was working smoothly except when I try clicking on the cancel button that comes out of the while loop. The error occurs at the release notifier. 

It says that the input parameter is invalid and that if the input is a path, it might contain a character not allowed by the OS such as ? or @.

However when i highlight the execution, everything runs smoothly until I press cancel which exits from the while loop and goes to the release notifier function. And thats when the error pops up. Even if i enable force destroy, i get the same error.

Any suggestions?

0 Kudos
Message 9 of 12
(4,522 Views)

Hi,

 

I haven't used notifiers a lot to answer right off the top of my head.  Can you post the sample code?  Also, you might open a new question about this so other folks can take a look too

 

( this post is marked as solved, so probably not a lot of traffic.)

 

-------
Mark Ramsdale
-------
0 Kudos
Message 10 of 12
(4,501 Views)