LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

If true condition for a button in labview

For this behavior you will want a latching boolean. Right click, Mechanical Action >> Latch When Pressed.

0 Kudos
Message 21 of 26
(1,339 Views)

You are AWESOMEEE!! This is my code ..weird part is insted of showing the add it shows weird random number! I tried with 2 and 4 insted of showing 4+2 = 6, it showed 20!

0 Kudos
Message 22 of 26
(1,334 Views)

This is what I meant.

 

I'm sort of wondering, what do you think feedback nodes do? It seems like you keep putting them in your code in strange ways, and I don't really know what you are trying to achieve with it.

Message 23 of 26
(1,329 Views)

@HopeH , I did it in a weird way since I wanted to share between blocks. Currently, up & down work seperately but goes in to infinite loop when I run this combined. I used XOR so either up or down but I think it's wrong. how can i say if up do ... then update the current resistance, if down... then update the current resistance

0 Kudos
Message 24 of 26
(1,295 Views)

One way would be to put the second case structure inside the false case of the other sequence structure. You can't use XOR like that.

 

A simpler way would be to use an event structure instead of case structures. I would highly recommend this, it will greatly simplify your code. Learn more about event structures here: http://www.ni.com/white-paper/3331/en/. So, in your case, instead of the two case structure, you will have two event cases in your one event structure.

Message 25 of 26
(1,288 Views)

@Canucks.canucks wrote:

@HopeH , I did it in a weird way since I wanted to share between blocks. Currently, up & down work seperately but goes in to infinite loop when I run this combined. I used XOR so either up or down but I think it's wrong. how can i say if up do ... then update the current resistance, if down... then update the current resistance


Sorry, relatively old thread, but you did not mark anything as solution. Have you done any tutorials since?

 

(Your Xor make absolutely no sense. Xor is not defined for floating point values, so your node will coerce to integers and do a bit-wise boolean operation on the two values. Makes no sense at all here.)

 

You probably want to have the capability to change the resistance in three ways

  1. direct entry into the control
  2. up button
  3. down button

For this, the resistance control needs to be inside the loop. Also, to update the value of a control, you need a local variable.

 

Here is a very simple draft how this could be done.

 

Of course the LabVIEW controls already have up and down buttons and you can set the increment via property nodes. You can even customize the control so these features look like big buttons and no extra code is needed.

 

If you want to keep using separate buttons, here's what you could do. (If you want to continuously increment or decrement when the buttons are held down, change their mechanical action to "switch until released" (similar to a car horn), so modify as needed)

 

 

 

Download All
0 Kudos
Message 26 of 26
(1,231 Views)