01-28-2018 07:34 AM
Hello to everyone.....!!
I had made a VI in which one LED is ON at a time by keeping all other low at the same time... VI works OK but when i try to use this VI as subVI its not working.....kindly help. i am also attaching VI with post....
Solved! Go to Solution.
01-28-2018 10:02 AM
You are misunderstanding the operation of event structures.
You have a value change event that will execute either when a user changes the value of the control via the front panel, or your VI changes the value by writing a value to a Value(Signalling) property node of that control.
You are doing neither. You are passing in a value via the subVI's connector panel.
What are you really trying to do here? It seems like you are creating a homemade version of a set of radio buttons.
01-28-2018 02:58 PM
@Saqib51 wrote:
I had made a VI in which one LED is ON at a time by keeping all other low at the same time... VI works OK but when i try to use this VI as subVI its not working.....kindly help. i am also attaching VI with post....
No, your VI also allows none at a time. How should the subVI handle the situation when two LEDs are being changed between calls? What should the state be before it is called (all FALSE? Wait for first call and use that?, State from the previous run in the same session? etc.).
Is the front panel of this subVI hidden or interactive?
Here's a quick draft that could give you some ideas. The "not equal" finds the first changed LED and the rest updates the indicators as needed. Depending on your needs, you might want to initialize the feedback node with a suitable value. (Note that I don't write back the final value to the inputs, because these will be overwritten by the next call anyway. You need to handle that in the caller if needed. Personally, I would change the inputs to an array of three booleans. Less clutter!
(Note that there is no need for sequences, local variables, or event structures. The event structure belongs into the toplevel UI if needed.)
01-30-2018 11:04 AM
Well thankx for replying.....well its seems i am not able to explain my issue....i have three Boolean LED....if i click at first LED all other LEDs goes to OFF position and when i click on second LED , LED one and three becomes OFF....and so on..... this seems to be simple but do not know why i am not able to do,,,,for reference sample out...
Boolean-1 Boolean-2 Boolean-3
1 0 0
0 1 0
0 0 1
i need this type of functionality that i want to achieve....
01-30-2018 11:16 AM
You have actually explained quite well what you are trying to do, and simply confirmed it with your latest post. Radio buttons are the way to go. Refactor your code to use them if you need to, because they are very simple to use. No sense re-inventing the wheel.
01-30-2018 11:33 AM
@Saqib51 wrote:
i need this type of functionality that i want to achieve....
Yes, that's just a radiobutton control as has been mentioned. No code needed.
By just loooking at the radiobutton in the palette, you might not realize how powerful and flexible they are.
A radiobutton is just a container that can only contain booleans of any number, shape or form. Whenever one is turned on, all others will go off.
The data itself is like an enum, with the labels of all the booleans in the order they are in the container (you can change the order if needed).
Basically, all you need to do is drop a radiobutton control, then drop your three booleans in it and remove the existing booleans. See also this idea.
01-30-2018 11:38 AM
Think about it. You want a state machine.
IF A then NOT (B & C)
ELSE IF B then NOT (A & C)
ELSE IF C then NOT (A & B)
ELSE {No change}
There are multiple ways to achieve this; however, this can easily be done with a few events (Make sure to handle the on & off-states when working on Boolean change)
01-30-2018 11:38 AM
01-30-2018 11:48 AM