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,731 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,719 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,703 Views)