LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Save event boolean at same frequency as data acquisition

Hi all,

 

I have a vi that records and saves analog signals. I recently added in a button (called "event") that I press every time an external event occurs. I want the value of event to be saved along with the analog signals. The value of event shows up in the waveform chart but not in the measurement file that's saved. Instead in the file, the event column is mostly blank except for every 138 samples there's a 0. This makes sense since the samples to read for the DAQ assistant is 138 so I think that the while loop is increasing it's iteration after 138 analog samples have been read. I want the event column to be populated with 0s except when the button is pressed. Does anyone know how I can save the value of event at the sampling rate of the daq assistant instead of every while loop iteration?

 

Thanks!

DAQ + event recording vi.jpg

0 Kudos
Message 1 of 6
(2,417 Views)

You can't. That is to say that you cannot "save the value of event at the sampling rate of the daq assistant instead of every while loop iteration" because the while loop is only iterating once per iteration of the DAQ assist (which is providing the 138 samples). If you don't really care if the boolean value correlates directly with the sample that was taken when the button was pressed, then you could create an array of boolean values (based on the button, 138 to be exact), and add that to your file. But, if you truly want the value of the boolean button each time a data point is taken, you'll need to take your data point by point with the DAQ assistant. Also, I'm not quite sure why you have the select function there, it isn't doing anything.

 

--Ryan S.

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

Thanks Ryan. Yea you're right about the select function! Thanks for pointing that out. It's necessary for the boolean to correlate with the sample. Another option I thought of is saving the time of the button press. It would have to be in elapsed time since the program started running. 

0 Kudos
Message 3 of 6
(2,384 Views)

If the Boolean has to correlate with the sample, then you have a few options:

 

1. Take your data 1 sample at a time so that the Boolean control is queried with each sample.

2. Add another loop, to run in parallel, that monitors the Boolean control and use the Elapsed Time Express VI to know how much time has passed since the beginning of execution. You'd then have to go back later and match the time of each button press with its respective sample.

 

--Ryan S.

0 Kudos
Message 4 of 6
(2,376 Views)

Ideally, all the data would be saved in one file and I wouldn't have to do any post-processing to correlate the boolean to the timing of data acquisition. I had another idea to sample the value of a mouse/foot pedal input at the same rate as data acquistion. How can I interface a mouse/foot pedal with an ELVIS board? And how do I set it up in daq assistant?

 

Thanks!

0 Kudos
Message 5 of 6
(2,365 Views)

Ah, well that certainly simplifies things then. If you're going to be reading the signal, then I'd recommend a simple push switch. Hook up +5V to one side and use a digital input to read the state of the push button. When its open (not pressed) the digital line will read low (off) and when you press the button it will connect the 5V to the digital line and push it high (on). Then just read the two signal at the same rate and merge the signals. If I remember correctly, however, you can only have one DAQ assistant per device (and you can't mix Analog and Digital tasks in one DAQ Assistant) so you may have to use the low level DAQmx API which won't be bad for what you're doing. You can also generate this code (what the DAQ Assistant is currently configured to perform) by right-clicking on the express VI and selecting Generate NI-DAQmx Code. Then just move the Create Channel and Clear Task functions outside of the while loop.

 

--Ryan S.

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