Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Oversampling using NiDaq

Hi All,
I'm currently using  NIDAqPad 5015 and VC++.NET/Measurment Studio setup.
I have a task configured to take 40 000 Voltage readings readings ( i.e. finite setup)
triggered using an irregular external clock  which in reality is nothing more than piece of hardware which alters the voltage and signals to take a new reading.
In theory it triggers 1000 times per sec but in practise it varies as there are acceleration and deceleration components to the external clock generator and as the speed of it can be changed.
I  need to oversample this reading so that instead of reading one value on every rising edge of the external clock I read somewhere in region of 300. (Note the hardware will only ever send exactly 40000 trigger pulses. none of them in same location)
I suppose that one way of doing this is to set up a finite task (to take 300 samples at  a very high frequency and use the external clock as an external trigger instead)
but then I run into the issue of trying to extract the data and average it before the next trigger is sent.
Is there a better and more elegant solution that this that anyone can think off?
Thanks.
Eddie
0 Kudos
Message 1 of 5
(4,193 Views)
Hi there,
 
So as I understand it you are planning on taking approximatley 300,000 samples a second using the 6015 (I Assume you mean a 6015 as we don't make 5015's)?
The DAQPad 6015 is only able to do measurements of up to 200,000 samples a second, therefore it would not be possible to do as you are asking.
 
How many channels are you reading in at a time and what kind of calculations are you planning on taking?
Do you need the data to be averaged in realtime or would it be possible to take the 40,000 x 200 samples, write them to a binary file, and then comple the calculations afterwards?
 
Post back and I'll have a look into it further
 
AdamB
NI UK & Ireland
Applications Engineering Team Leader | National Instruments | UK & Ireland
0 Kudos
Message 2 of 5
(4,169 Views)
Hi Adam,
Thanks for that reply. I'm a bit miffed that I missed the obvious thing of sampling at an impossible rate :-). Still other things have persuaded me that this was an impossible way of doing things. However, furthering the discussion my task setup is below
this->AIChannels.CreateVoltageChannel(_T("Dev1/ai0"), _T("Voltage0"), DAQmxAITerminalConfigurationDifferential, dV0min, dV0max, DAQmxAIVoltageUnitsVolts);
this->AIChannels.CreateVoltageChannel(_T("Dev1/ai1"), _T("Voltage1"), DAQmxAITerminalConfigurationDifferential, dV1min, dV1max, DAQmxAIVoltageUnitsVolts);
this->Timing.ConfigureSampleClock(_T(""), 3000, DAQmxSampleClockActiveEdgeFalling, DAQmxSampleQuantityModeFiniteSamples, 300);
this->Triggers.StartTrigger.ConfigureDigitalEdgeTrigger(_T("PFI0"), DAQmxDigitalEdgeStartTriggerEdgeFalling);
where this pointer is the CDaqmxTask based class.

To answer your other questions, in this task I’ll be using only two analog inputs ( in future other tasks controlling other i/o channels will be added to run simultaneously  to this task) from processing point it does not have to be in real-time and yes the typo reduced a Daq-pad 6015 to 5015.
So taking into account what you have said, I am now attempting to set up the oversampling in a way that the aforementioned 40k pulses are used as post-acquisition triggers.
I.e.
  • Set up voltage channel to acquire continuously at a max rate (to ensure oversampling)
  • Set up the external triggers as events.
    • On each event extract ~200 samples from the acquisition buffer (the trigger frequency is not guaranteed to be exactly 1KHz and may drift).
    • Average these sampled values and store the result.
In a document I found on the NI website (attached) it mentions that I can use cyclic buffering in this case to ensure that all data is stored. Assuming that I’ve set up a voltage channel to acquire continuously at a rate of 200KHz:
  • What is the best way of extracting the ~200 samples from the acquisition buffer?
  • Can I configure the trigger on PFI0 to generate events which I can use to timestamp the data acquisition?
  • Would I have to use a digital in channel instead of the PFI0?
  • What is the best way to ensure that I do get cyclic buffering?
  • Most importantly, can I do all of this using DaqMX?

I am most grateful for your opinions.
Eddie

0 Kudos
Message 3 of 5
(4,166 Views)
Hi Tom,
 
Just so you know, you will only be able to actually aquire the data at a TOTAL rate of 200KS/s.  This means that if you have 2 inputs you will be sampling at 100KS/s per input and with three: 66KS/s etc etc.
 
This all said and done, you need to consider the idea of actually just setting up a finite aquisition (~100KHz) as you have done and try to avoid the trigger coming in before the finite aquisition has finished.
 
This way there shouldn't be any real problems with the cyclic buffer and you will not need to worry about overwriting data.
PFIO will work fine with this method (again in the way you have written) and a timestamp will only be needed for the start of aquisition after each trigger.
 
I would also suggest that you have a look in the following folder on your harddrive:
C:\Program Files\National Instruments\NI-DAQ\Examples\Visual Basic 6.0C:\Program Files\National Instruments\NI-DAQ\Examples\
In here there should be some good examples on ways in which you can gain the functionality you require.
 
They are all named with reference to their function and so you should be able to find a good starting point.
You are looking for Triggered, AI, finite samples.  ((DAQsingleBufAnalogTrig.MAK, SCANsingleBufAsync.MAK or DAQsingleBufExtTrig.MAK))
 
I hope this helps
 
AdamB
Applications Engineering Team Leader | National Instruments | UK & Ireland
0 Kudos
Message 4 of 5
(4,144 Views)

Hi Adam,

Thanks for your help it's great to get some confirmation of this.

 

Gratefully

Eddie

0 Kudos
Message 5 of 5
(4,141 Views)