LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there this kind of switch

I have one power supply which could be controlled by GPIB, I want to use a toggle switch to turn this power supply ON and OFF in LabVIEW. The LabVIEW program basically is one while loop, in which I am doing some other DAQ tasks until I press STOP button, which will stop the while loop.

Here are what I want to implement and my questions.
1. Whenever I press toggle switch, power supply will be turned ON or OFF. What is the best/simplest way to implement this? What I did is to put a event structure in while loop, but I feel this might not be a efficient way.
2. Whenever I press STOP button, the while loop will stop, power supply will be turned off, and the toggle switch will be in OFF position. Looks like this is not possible to me since the toggle switch is a control not an indicator. Any suggestions?

Thank you very much.

Best regards,

chc
0 Kudos
Message 1 of 5
(2,551 Views)
CHC,

The event structure is a fairly simple way to turn off the power supply.  Especially since you only want it turned on if it is currently off or turned off it it is currently on, so you really only want it to occur when there is a value change in the switch.  You can also use a property node to change the value of the toggle switch.  To do this, on the block diagram, right click on the toggle button control and go to create>>property node>>value.  When you put this node on the diagram, right click on it and click "change all to write".  You can then wire in the value that you want the toggle switch to be.

I hope that this helps.
Brian  
0 Kudos
Message 2 of 5
(2,547 Views)
Set the mechanical action of the switch to Switch When Pressed (or Released, either one).  Use the Value Change event for this boolean control.  When the value changes the event will fire.  Inside the event, wire the switch to a case structure.  The true case can contain code to turn on the power supply.  The false case can contain code to turn off the power supply.  If you want to run the DAQ while the switch is on, put your DAQ code inside a case structure that is inside the Timeout event.  Set the timeout timer to a positive number.  Create a local variable of the switch and wire it to the case structure.  When the switch is true, run the DAQ, when false, do nothing.  You can substitute the local variable with a shift register also.  See attached vi.
- tbob

Inventor of the WORM Global
0 Kudos
Message 3 of 5
(2,543 Views)
Thank you guys very much, looks like the property node is very useful and event structure is very efficient.
0 Kudos
Message 4 of 5
(2,510 Views)
One thing about property nodes.  They are very slow compared to local variables.  I would use a local variable instead of a value property node.  They do the same thing and the local variable is much faster.  Whether using value property nodes or local variables, you should always be aware of the possibility of a race condition, that is reading the variable before a new value is written and vice versa.
- tbob

Inventor of the WORM Global
0 Kudos
Message 5 of 5
(2,491 Views)