LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Analog Input DAQ Between Rising Edges

Solved!
Go to solution

I am relatively new to LabVIEW, and I am attempting to use a USB-6003 to start/stop analog input DAQ following a digital input. I want to only keep the data points captured between the rising edge of the start and stop signals, but all of the examples I've found continue capturing data after the stop signal until the buffer is full. For my application, I need to start/stop DAQ several times and append each data set to the same text file. I have spent several days trying to figure this out, and none of the discussion posts I've found quite solve my problem. Additionally, I need to use the same digital input to start and stop the DAQ. Attached is the demo program I've been working on along with the subVI's that I've used. 

0 Kudos
Message 1 of 8
(3,027 Views)

I've also tried to use the "acq_graph_voltage_dig" VI I found in an NI tutorial (http://www.ni.com/example/30028/en/), but whenever I try to run it I am given the error message 200452 (shown in attached PNG), telling me that the "Specified property [Ref.TrigType] is not supported by the device or is not applicable to the task." I understand the USB-6003 to have 2 digital trigger inputs (PFI0 & PFI1) at pins P1.1 & P2.0, which I have wired to a couple switches. Do I need to somehow configure my USB-6003 through NI MAX before using those pins as digital triggers?

Download All
0 Kudos
Message 2 of 8
(3,007 Views)

I think I've gotten a lot closer to the product I'm looking for, but with this method I get very few data points. The measurement period is about 1/10 second, but the USB-6003 has a maximum sample rate of 100kS/s so I know that if I programmed this properly I could get a lot of data points during that span of time. Is there any way for me to get my while loop to iterate faster, or do I need to rethink how I'm approaching my DAQ process?

0 Kudos
Message 3 of 8
(2,990 Views)
Solution
Accepted by topic author bend2252

I'm going to assume that you are interested in collecting data continuously (meaning without any gaps between sets of sample, i.e. as though the entire dataset was collected in one huge buffer at one fixed sampling rate).  There are two "timing" considerations in a task such as this -- one is the Sampling Rate, often expressed in kHz, and is the rate that individual samples are acquired.  The other I'll call the "Response Rate" and governs the responsiveness with which you can "turn on" and "turn off" the sampling.  Since most sampling, particularly at high rates, is done in "blocks", say 1000 samples at a time, the Response Rate can be given by Sampling Rate/Block Size.  So if you sample at 1kHz and take 1000 samples, you will get 1 block per second.

 

Now, you can start acquiring Samples at (more or less) any time, but you can only stop acquiring at the end of a Block.  What if you want to take exactly 4.5 Blocks of samples?  Simple, take 5 blocks, and throw away the last half of the last block.  What if you don't know how many block to take, but have a way of reading a "Stop" signal?  Use a Clock that you start when you start sampling, figure out the time between Start and Stop, and use this to discard those values "accidentally" collected after you pushed Stop.  [In your case, you'd measure the time between DAQ rising edges to determine the Stop time].

 

Bob Schor

 

Message 4 of 8
(2,971 Views)

This is really helpful, thank you! It clears up a lot of what I didn't understand about data acquisition in LabVIEW and explains many of the problems I keep running into. I think I can get this thing working now, I'll post my code when I'm finished.

0 Kudos
Message 5 of 8
(2,968 Views)

I've built my program to only capture data between digital input triggers, and it works! The one problem I keep running into, however, is that the system is not very responsive. That is, there is a significant delay between switching off "Switch 1" in real life and LabVIEW realizing that change. The only acquisition mode available to me for digital inputs is "1 Sample (On Demand)" with the USB-6003. How do I get rid of that delay?

0 Kudos
Message 6 of 8
(2,948 Views)

First of all, why are there Express VIs in your code?  You got rid of them for the "tricky part", the A/D input, so why do you need them to read one digital line?  Note that you seem to be outputting a Boolean array -- why?

 

Remember the Principle of Data Flow.  Switch 1 will only be read/reset once per Loop, and (as it is currently written by you) you have no idea when in the loop this happens, it just is one of those things happening in parallel.  I can't tell what your overall loop speed is, but I'm going to guess that the time you wait for Switch 1 to have an effect when you turn it off is close to the loop speed.

 

Bob Schor

0 Kudos
Message 7 of 8
(2,933 Views)

I just hadn't gotten around to breaking down the express VI's for the digital inputs. I ended up putting them in their own loop and now all of my digital inputs have (practically) no delay. The output from the analaog DAQ is not a boolean array but rather an array of doubles. Everything is working the way I want it to, thanks for your help! I've attached the finished VI's to this message.

0 Kudos
Message 8 of 8
(2,919 Views)