LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stop a While Loop after display

Hi all,

 

I'm creating a chirp signal to be displayed in a waveform graph.

 

The frequency of my signal is from 140-20kHz. I want to stop my while loop when the frequency is already 20 kHz and able to display the plot at that frequency. What should I set in my stop condition in the while loop. ASk.png

 

Here is my VI.

 

 

0 Kudos
Message 1 of 10
(3,939 Views)

Here is my VI

0 Kudos
Message 2 of 10
(3,938 Views)

Hi gjjude,

 

Try this one. Probably the solution.

 

sol.JPG 

 

 

 

Regards,

Vijay

0 Kudos
Message 3 of 10
(3,902 Views)

I could be wrong but I'm pretty sure this does exactly the same while cutting down on unnecessary comparisons.

 

loop.png

 

/edit: Okay, I see a difference, the Shift Register would contain a zero if you use the Stop Control to exit the loop. Anyway, the lower equals? comparison can definitely be skipped.

 

0 Kudos
Message 4 of 10
(3,878 Views)

Could you explain how this one works?

0 Kudos
Message 5 of 10
(3,829 Views)

@jamison.suade wrote:

Could you explain how this one works?


(Does it? Does not seen to have much to do with the question....)

 

Sorry, I don't quite understand your problem. Who is modifying the "frequency range" control during the run?

 

In any case, NEVER do "equal" comparisons on floating point numbers. At least, do a "larger or equal" instead of an "equal".

 

And why does the loop need to stop to display the result? I also don't have your toolkit, so I cannot test further.

0 Kudos
Message 6 of 10
(3,812 Views)

@altenbach wrote:

@jamison.suade wrote:

Could you explain how this one works?


(Does it? Does not seen to have much to do with the question....)

 

Sorry, I don't quite understand your problem. Who is modifying the "frequency range" control during the run?

 

In any case, NEVER do "equal" comparisons on floating point numbers. At least, do a "larger or equal" instead of an "equal".

 

And why does the loop need to stop to display the result? I also don't have your toolkit, so I cannot test further.


I strongly belive to altenbach qouted "In any case, NEVER do "equal" comparisons on floating point numbers. At least, do a "larger or equal" instead of an "equal".

 

and I think you don't need the stop button(what the use?) if you want to stop it automatically  when it reach the count 20,

you can do like this 

 

 

freak.png



Thank you & Best regards
syrpimp

=======================================================
“You must continue to gain expertise, but avoid thinking like an expert." -Denis Waitley
0 Kudos
Message 7 of 10
(3,779 Views)

Refer this, I hope you will get some idea about floating point comparision.

 

http://www.ni.com/white-paper/7612/en/

 

http://digital.ni.com/public.nsf/allkb/B01682241DD825948625665100663F61

Munna
0 Kudos
Message 8 of 10
(3,760 Views)

If you want to stop at a certain count which is known before the loop starts, use a for loop.

 

Lynn

0 Kudos
Message 9 of 10
(3,714 Views)

The vi you are using generates a chirp waveform.  if you want the loop to stop when the chirp is at 20hz set up the parameters so that the stop frequency is 20 hz an run the loop once in fact- you dont need a loop at all!


"Should be" isn't "Is" -Jay
0 Kudos
Message 10 of 10
(3,704 Views)