Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling record button (on/off) using physical toggle switch

I've got a program that collects data from multiple thermocouples and records their behavior over time. The program has a "RECORD' button that turns on if pushed once, and off if pushed again. I need to actuate this record button using a toggle switch (a physical one, not one inside LabView). The toggle switch is already connected and working, and I'm able to access it from LabView using DAQmx task name. My question is, what's the best way to wire it to the record button so that it actuates it when pushed, and turns it off when pushed a second time. Fairly brand new to labView here.

0 Kudos
Message 1 of 6
(6,530 Views)

Do you also need the software Record button to work or will it just be an indicator?

 

What happens if one user presses Record very close to the same time another user toggles the physical switch? Does the recording turn on and off very quickly? Will the users be confused?

 

What I am saying is that having both hardware and software switches to do the same thing may be confusing or may create situations where the system does not behave in the manner which the users expect.

 

1. If the hardware switch will be the only control, change the Record button on the front panel to a boolean indicator to show status.

2. If there is no possibility of confusion but both need to be controls, use a local variable of the Record button. Write the value of the external switch to the local. While the use of local variables is generally discouraged, this can be one of the few valid uses for them.

3. If you think both should be controls but you cannot preclude the simultaneous usage, then you really should review the requirements to see if there may be a better way to do what you need.

 

Lynn

0 Kudos
Message 2 of 6
(6,505 Views)

The setup will be such that there is no risk of one user pushing the button at the same time as another actuates the switch. Both the switch AND the button are needed in this case. And yes, the recording software needs to be functional.

 

I'm still not sure how to "write the value of the external switch to the local", as you suggested. Could someone provide some simple sample code?

0 Kudos
Message 3 of 6
(6,503 Views)

You said that you are able to read the state of the external switch from the DAQmx VIs. Wire the output of the DAQmx Read to the local variable of Record. If the data is not boolean, you will need to convert it to a boolean first.

 

Here is a little example. It uses a random number to simulate the DAQ read of the external switch. Note that the button tends to reset quickly because of the local variable.

 

Lynn

0 Kudos
Message 4 of 6
(6,480 Views)

Thanks, Lynn. I think I've almost got it. I'm just having trouble converting the data being output by the DAQmx task to Boolean. Any tips on how to do that?

0 Kudos
Message 5 of 6
(6,474 Views)

How do you have the task configured? I think there are several options for the output format. The conversion process may depend on which you have selected.

 

Lynn

0 Kudos
Message 6 of 6
(6,447 Views)