LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

extract boolean value from variant

This is a very simplified version of code, as I just wanted to be able to extract the value from the mechanical switch to be used in the selector.  Although it appears that you can wire the new value directly to the selector in the "Run" case, in my original program, the selector switch is actually in another case.  If I use the propery node, value, I get a variant.  

 

I have to use this stop button.

 

Any help will be greatly appreciated to extract the boolean value out from stop button to be used elsewhere in the selector.

 

Thanks,

hiNi

Download All
0 Kudos
Message 1 of 16
(5,320 Views)

Usually, to transfer data from one case to another, we use a shift register like you are using for your control 1.ctl. Can you create a shift register and wire the stop into it and then read it in the other case from the other side. Your example is a little lacking because you don't show the other cases so it's not clear what the difficulty is. Also, there's no "mechanical switch" just a stop button.

Message 2 of 16
(5,317 Views)

Hello,  can you convert the Stop Button value to a boolen?

0 Kudos
Message 3 of 16
(5,310 Views)

You need to change the mechanical action of the boolean. (Latch action boolean don't allow local variables and are variats for value properties.)

 

Of course you don't even need the value property here, just wire from the terminal. Right?

 

You also don't need the terminal in the stop event, because you can also get the new data from the event data node.

Message 4 of 16
(5,299 Views)

Hello,

 

I have modified the original program to show the extra state where the stop button should become active.  Thanks.

Download All
0 Kudos
Message 5 of 16
(5,292 Views)

As I said, you need to change the mechanical action of the button (e.g. to switch when pressed). A latch action boolean resets when read by the code, so it is very likley never true for a predictable amount of time.

0 Kudos
Message 6 of 16
(5,285 Views)

Hello,  if you are given this in a CLD exam, will you lose points for carrying out your suggested solution?  Thanks.

0 Kudos
Message 7 of 16
(5,279 Views)

Instead of using the property node, just pass the value of the control out of the event structure.  This would be a valid use of the Use Default If Unwired state of the output tunnel.

 

Alternatively (and probably the better option) is to just have the event cases output the enum for which state to go to.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Download All
Message 8 of 16
(5,275 Views)

If you move the stop control to the "check elapsed time" case, you can read it there. The event structure will still work as normal. If you need to read the stop in more than one case, then you might want to consider a different archtecture where you have one loop looking at the control and then send a message to the other elapsed time checking loop using maybe a notifier.

Message 9 of 16
(5,274 Views)

@hiNI wrote:

Hello,  if you are given this in a CLD exam, will you lose points for carrying out your suggested solution?  Thanks.


Which post are you replying to?

0 Kudos
Message 10 of 16
(5,265 Views)