LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to change value of a variable by comparison?

Solved!
Go to solution

Hi everyone,

 

I have 2 (x and y)local variables that are calculated by some formula, then I want to say if x > y then x=y. I want to know how to make x=y in labview

 

thanks

0 Kudos
Message 1 of 12
(3,332 Views)
Solution
Accepted by topic author valdi

Valdi,

 

Why not try something like this:

 

X Greater than Y.png

 

I did use a local variable but it replaces it with a property node when you turn it to a snippet... 

Regards

Andy
_______________________________________

"To 'G' and not to 'C', this is not a question!"
Message 2 of 12
(3,331 Views)

Loving the long wires! But don't they mean the data will take longer to travel along them Smiley Wink

 

-CC

----------------------------------------------------------------------------------------------------------------------------
"If anyone needs me, I'll be in the Angry Dome!"


Message 3 of 12
(3,319 Views)

Thanks a lot, I was close to it but didn't use a property node. But your idea does the job.. thanks a lot

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

The snippet kept squashing everything! Smiley Mad  lol besides I was told from a reliable source that its not the size of your wires, its how you use them! 

Regards

Andy
_______________________________________

"To 'G' and not to 'C', this is not a question!"
Message 5 of 12
(3,311 Views)

Or like this:

coerce-xtoy.png

0 Kudos
Message 6 of 12
(3,306 Views)

You seem to be using local variables as "variables", which is a bit odd for LabVIEW. Try to get away from this text programming mentality. 😄

Feel free to post your code.

 

Anyway, here's what you could do.

 

 

0 Kudos
Message 7 of 12
(3,295 Views)

your solution works too.... thanks!

 

do you suggest anything rather than local variables, because now ive started to have problems as i have many local variables of the same variable and it seems that its confusing the program or slowing it or something...any suggestions?

0 Kudos
Message 8 of 12
(3,269 Views)

Valdi,

 

By the sounds of things you are encountering what is referred to as 'race conditions'. As a rule of thumb try to use terminals and wires where possible, this avoids breaking the data flow paradigm and ultimately will help you debug. 

Regards

Andy
_______________________________________

"To 'G' and not to 'C', this is not a question!"
0 Kudos
Message 9 of 12
(3,265 Views)

valdi wrote:

do you suggest anything rather than local variables, because now ive started to have problems as i have many local variables of the same variable and it seems that its confusing the program or slowing it or something...any suggestions?


Local variables are very rarely needed, except for UI features. In LabVIEW, you should think of the wire being the variable while terminals are tunnels to the surface to interact with the user.

 

If your code needs to keep track and update values, you could use a shift register in your loop to do read..modify..write, etc. There is no need to involve the front panel in a value that changes every nanosecond.

 

It is difficult to give more detailed advice without seeing some code. Feel free to attach a simplified version of what you are doing.

0 Kudos
Message 10 of 12
(3,241 Views)