LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Data Acquisition: Sampling rate control

Hello Forum,

 

Hardware/Software:

LabView 2009

PCI-MIO-16E-1

SCB-68 shielded I/O connector block

 

I'm constructing a VI to read mainly two types of samples:  pressure transducers and microphones.  The pressure transducers don't need to have a very high sampling rate, while the microphones may need to sample up to 60 KHz.  I searched in the Find Examples and found the Acq One Sample.vi.  It seems fairly straight forward.  Could I put a loop around it and control the sampling rate with a timer?  I don't have much experience with LabView, but I feel that this might not be fast enough for the microphone samples. 

 

I read ( https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000P7KdSAK&l=en-US ) about using DAQmx Timing in conjunction with DAQmx Read.  It seems like that might be faster and better suited for what I need.

 

The sensors (microphone and pressure transducers) are subjected to gas flows at and above sonic speeds..  We have the proper transducers and microphones, so the only issue is with writing the code to acquire samples.  There is no need to take pressure samples at very high rates, but the microphones need to sample very quickly in order to capture the events (shockwaves, etc.) that occur over a very short time span.

 

I would like to create a base code that could be modified to acquire either the pressure or microphone samples by selecting the input channel and sampling rate from controls on the front panel.  For example, say I'm running an experiment in which I want to acquire data from 2 pressure transducers and 2 microphones.  I'd like to be able to copy the base code and paste 4 instances into a new VI.  I could then select the specific channels, telling each instance of code which sensor it will be acquiring data from and the corresponding sample rate.

 

This is only how I imagined it.  If there is a more efficient and simpler method to accomplish this, I'd love to hear about it.  Also, I dish out Kudos like I have an unlimited supply.  I will also click the Kudos button at least twice, possibly even three times.  You'll still only get one Kudos per response, but it's the thought that counts, right? 

 

Thanks for your help.  As a bonus, the first response gets 4 Kudos clicks. 

0 Kudos
Message 1 of 6
(5,566 Views)

dZack,

 

Check out THIS example. You should always set your sampling rate outside of the loop, since reinstating your sampling rate every time the loop runs will cause the loop to run slower and reserve your CPU for longer. With that said, there are a few points I should touch on:

 

A pressure transducer is very often a bridge-based sensor. We have specific devices that supply the necessary excitation for bridge based sensors and read that data in ratiometric form that would be better suited to read this kind of data.

 

Another note is that microphones are usually piezoelectric devices, meaning that they require a current excitation and convert a change in charge to a voltage. You will need a signal conditioner with the microphone (it may be built into your microphone) in order to use this with a DAQ device. We do have devices specifically meant for microphone measurements though that provide the appropriate signal conditioning. You can find more about this here:

 

Making Sound Pressure Measurements with NI LabVIEW

 

Likewise, we have examples on our website and in the NI Example Finder that will provide you all you need to take pressure and microphone measurements. Let me know if you have any more questions about any of this.

 

Best,

Jason M.
Applications Engineer
National Instruments
Message 2 of 6
(5,535 Views)

Thank you very much for the thorough reply, as promised you received your 4 Kudos clicks.  I haven't had a chance to investigate everything you said, but it sounds promising.  I shall likely return with more questions, but thanks again.

 

The pressure transducers are piezoelectric as well.  They are used with an Endevco 136 dc amp.  Is that considered a signal conditioner?  

All of the equipment is in working order.  The only thing that doesn't work is the LabView program written in an earler version of LabView.  Our newer version won't run it.  Hence, my task of learning LabView to write a new program.  I tried looking at the old code, but I need more knowledge of LabView, ergo, I'm here on the forum.

 

Take it easy,

 

dZ 

0 Kudos
Message 3 of 6
(5,513 Views)

dZack,

 

If your signal conditioner is able to condition your piezoelectric signal into a +/- 10 V signal, then you should be all set to take measurements. The first thing you will want to do it check in MAX if you can read a good signal. You can easily do this with a Voltage Task. After that, you can either port the task over to LabVIEW, or simply add a scale to THIS example. Then you should be all good to go.

 

Best,

Jason M.
Applications Engineer
National Instruments
Message 4 of 6
(5,472 Views)

Jason,

 

Thanks again for your help and patience.

 

I ended up using the Sample Clock and DAQmx Read to acquire samples.  As of now, I don't have the mics or transducers connected.  I'm acquiring noise, just to get the VI to function.


What I've done so far:

I made a stacked sequence with the same acquisition code block (Sample Clock, DAQmx Read), but with a different task selected for each frame.  For example, the first task (pressure trans) contains channels ai1, 2, and 3, while the second (mics) contains ai4, 5, and 6.  This allows me to sample the first task at one rate and the second at a different rate.  Can I create one task that has all 6 channels, but different rates for each or is the stacked sequence the way to go?  I tried running it without the stacked sequence, but LabView won't run two instances of DAQmx Read at the same time.  I get the following error:

 

"Error -50103 occurred at DAQmx Read (Analog 2D DBL NChan NSamp).vi:3

Possible reason(s):
NI Platform Services:  The specified resource is reserved. The operation could not be completed as specified."

 

I've attached the VI described above.  As far as the tasks go, assume I'm using Task1 for the first frame and Task2 for the second.  Task1 has channels ai1,2, and 3, set to RSE.  Task2 has ai4,5, and 6, also set to RSE.  Both are set to N Samples.  (Question: I experimented and decided that setting the number of samples and rate from MAX plays no role when setting the same values from the program.  Is that correct?) 

 

The sequence would run within a loop.  Do you think this could work, or is there something I'm overlooking?

 

Thanks again.

 

****EDIT:  I was reading back over and I see that I should set my sampling rates outside the loop.  I would move the Sample Clock outside the sequence and loop to fix this.

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

Jason,

 

I've made some adjustments to the VI (included) and I have some new questions.

 

Let's assume Task1 is for the mics and Task2 for pressure.

I set the Samples Per Channel (SPC), Rate, and Sample Read Rate (SRR) to the following:  6000, 60 kHz, 6000, and 20, 1 kHz, -1 for the first (Task1) frame and second (Task2) frame, respectively.  I set the SRR, for task 2, to -1 since the number of samples is low.  I read that it should be set to 1/10 the value of the Rate to avoid over/underwrite errors and that a value of -1 (or unwired) takes each sample, as it's acquired, from the hardware buffer to software buffer.  Since each run of Task2 produces 60 samples (3 channels x 20 samples), would setting the SRR for Task2 to 60 be more efficient?  I also discovered that if I set the SPC to a value larger than SRR, I get the following error:

 

"Error -50103 occurred at DAQmx Read (Analog 2D DBL NChan NSamp).vi:2
Possible reason(s):
NI Platform Services:  The specified resource is reserved. The operation could not be completed as specified.
Task Name: Pressure ch ai4 5 6"

The easy fix is keep the SPC less than or equal to SRR.

 

Regarding setting the rates outside of the loop:  If I move the Sample Clock VI outside of the loop, I get the same error as above (50103).  To fix that, I put the Sample Clock back inside the structures.  With the Sample Clock inside, but the values coming from outside, will that still slow the operation as you mentioned earlier?

 

Thank you.

 

 

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