From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

code for incrementing a number after condition executes

HELLO..

 

I am looking for a code to increase by1 if the condtion satisfied , or else condition not satisfied increment should not be done.

for example i have three variables, let us say X & Y& Z

X is continuously varying value .

Y is threshold value(like constant)

FOR FIRST INCREMENT:

if x>=y

z incremented by 1 (onle one time  increment should be happen )

now z=1,

if x<=y

z incremnt should not be done

now z=0.

FOR SECOND INCREMENT:

now Z=1(after the first increment)

again

x>=y

z incremented by 1  (only one time increment should be happen ).

so now z=2

 like that process run continuously untill i stop

Note: the increment should be happen after the condition (x>=y) should go false and should come true and at the time of true state increment should be happen.

 

 

 

0 Kudos
Message 1 of 3
(2,593 Views)

Hi sridhar,

 

if x>=y

z incremented by 1

if x<=y

z incremnt should not be done

What should happen for x==y? Increment or no increment?

Please define your logic without inconsistencies!

 

Some simple pseudocode:

 

IF x>=y THEN
   z:=z+1
ELSE
  z:=z
ENDIF

 

z belongs in a shift register…

If you have problems coding this simple expression consider taking the free online courses for LabVIEW beginners!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 3
(2,581 Views)

increment should happen if x=y

thank you so much for your reply.

i will go through the tutorials first.

 

0 Kudos
Message 3 of 3
(2,565 Views)