LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

run a vi just one time

Hi

I have a while loop and I want to run another vi just one time when  a condition in my while loop becomes true.

For example I want to send just one email when my input variable is between 4and 5.My loop may run N times and my condition may be olways true but I want to run the other VI or another while just one time 

 

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

Create a flag to indicate whether the email subVI has run or not.  The flag is just a boolean in a shift register.  It does not need an indicator.  Initialize it to false. On each iteration of the main while loop test the flag.  If false, test the input variable.  If true, call the subVI and set the flag to true.  On all iterations after this the flag will be true and the input variable will not be tested and the subVI will not be called, because those things only happen when the flag is false.

 

Lynn

0 Kudos
Message 2 of 12
(4,864 Views)

hello,

see attachement

 

-> johnsold , don't feel offensed your idea is correct, it just because when starting with Labview is not easy to put even a good idea on screen

 

Regards

 

Tinnitus

 

CLAD / Labview 2011, Win Xp
------------------------------------------------------
Mission d'une semaine- à plusieurs mois laissez moi un MP...
RP et Midi-pyrénées .Km+++ si possibilité de télétravail

Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
Don't forget to valid a good answer / pensez à valider une réponse correcte
0 Kudos
Message 3 of 12
(4,853 Views)

You can use the "First Call?" vi to run the code the first time it is called.  From the help:  

 

Indicates that a subVI or section of a block diagram is running for the first time. The First Call? function returns TRUE only the first time you call it after you click the Run button.

 

Find it on the synchronization palette.

-cb

0 Kudos
Message 4 of 12
(4,827 Views)

many thanks for help

I have tried shift register and first call function but  there is still one problem.when my input variable is between 4 and 7 using both methods my sub vi will be called and start running just for one time and never run again after that but  what I would lilke is :if my input variable is between 4 and 7 my sun vi start running one time then if I enter 8 nothing happen but if I enter a value between 4 and 7 again it starts running just for one time again.so everytime the condition is true (after a false condition) my subvi starts running just for one time again.

 

 

0 Kudos
Message 5 of 12
(4,804 Views)

???

 

did you try the vi posted ?

 

Regards

 

Tinnitus

 

 

CLAD / Labview 2011, Win Xp
------------------------------------------------------
Mission d'une semaine- à plusieurs mois laissez moi un MP...
RP et Midi-pyrénées .Km+++ si possibilité de télétravail

Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
Don't forget to valid a good answer / pensez à valider une réponse correcte
0 Kudos
Message 6 of 12
(4,797 Views)

yes Tinnitus

 

My problem with your vi is :My input might be between 4,8 for maybe 5 minutes.with your vi ,on the first iteration the value of is flag is false and my input is between 4 and 8 so it send a email.on teh second iteration the flag becomes true so no email but after that because my input value is still between 4 and 8 the flag become false again and another email will be sent so it will send 100 emails until I change the value to something out of this boundary.This is mot what I need

I want to send just one email even if my input is between 4 and 6 for 1 hour  ,then send nothing if teh input value is not between 4 and 8 and then send another email again if my input value becomes for example 5

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

yes

 

there was a logical error

 

new attached vi should works correctly

 

CLAD / Labview 2011, Win Xp
------------------------------------------------------
Mission d'une semaine- à plusieurs mois laissez moi un MP...
RP et Midi-pyrénées .Km+++ si possibilité de télétravail

Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
Don't forget to valid a good answer / pensez à valider une réponse correcte
0 Kudos
Message 8 of 12
(4,777 Views)

Thanks tinnitus

it is still the same.u know instead of inputing a random value to In range function input a constant number like 6 then u will see it send email with no stop.while as I said I would like to send email just one time.As I said my input might be remain constant(between 4 and 😎 for about 10 minutes.using your VI it rapidly send email but if we change it to a random input value your vi will works perfectly.I think in this situation the First Call function works better because afetr first call ,the values becomes false and the subvi will not run again 

but as I change my input value to 10 and again to something between 4 and 8 it will not send an email again because the first call function value remain false

  

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

 

i did the operation you said with the last vi and it works 

 

 

alert.jpg

 

 

 

 

it send email the first time it enter the range and only a new one if it goes out and enter again in the range

 

that what you asked,  no ?

 

 

 

 

 

 

Regards

 

Tinnitus

 

 

 

 

 

 

CLAD / Labview 2011, Win Xp
------------------------------------------------------
Mission d'une semaine- à plusieurs mois laissez moi un MP...
RP et Midi-pyrénées .Km+++ si possibilité de télétravail

Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
Don't forget to valid a good answer / pensez à valider une réponse correcte
0 Kudos
Message 10 of 12
(4,768 Views)