LabVIEW: What is the difference between the mechanical actions "Latch until released" and "Switch until released"?

Kamran Bigdely picture Kamran Bigdely · Aug 19, 2013 · Viewed 14.5k times · Source

In which situations should we use "Latch until released" instead of "Switch until released"?

According to LabVIEW 2011 Help:

Latch until released—Changes the control value when you click it and retains the value until the VI reads it once or you release the mouse button, depending on which one occurs last. You cannot select this behavior for a radio buttons control.

Switch until released—Changes the control value when you click it and retains the new value until you release the mouse button. At this time, the control reverts to its default value, similar to the operation of a door buzzer. The frequency with which the VI reads the control does not affect this behavior. You cannot select this behavior for a radio buttons control.

Answer

J... picture J... · Aug 19, 2013

The documentation explains it clearly enough. Switch Until Released changes the value until you release it. It is possible, however, depending on the complexity of your VI that you push a button and release it before the value is read. In this case there would be no action taken on the new value. Latch until released guarantees that the off/on transition is read at least once.

As for which you would use them for, it depends on your situation. For most buttons where a click initiates an action you would generally use Latch until released - these are buttons where users would expect to click the button to do something or to toggle something, etc. Using Switch until released in these cases would end up with some times where the user would click the button but nothing would happen.

Switch until released is generally used for real-time type controls where you would click and hold the button to sustain an action and then release it to halt the action.

As a general guide, you might think of Latch until released as ideal for discrete operations (one click, one action) and Switch until released for analog actions (action continues while the button is down).