Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Does SampleRate matter? C# programming problem

Solved!
Go to solution

I am using PCI-6221 which has 250kS/s and C# for programming.

 

Can i change the sample rate to speed up or speed down, when I get one sample from AnalogSingleChannel ? 

 

In c# programming, here is my way to read one sample from AnalogSingleChannel:

 

private Task AnalogTask = new Task();

private AnalogSingleChannelReader myAnalogReader;

AnalogTask.AIChannels.CreateVoltageChannel("Dev1/ai0", "",

AITerminalConfiguration.Rse, 0 , 5, AIVoltageUnits.Volts);

 

AnalogTask.Control(
TaskAction.Verify);

myAnalogReader = new AnalogSingleChannelReader(AnalogTask.Stream);

double data = myAnalogReader.ReadSingleSample();

 

The last sentence takes about 1.7ms in my computer.

 

Is there some way to speed up, like using AnalogTask.Timing.ConfigureSampleClock(....)

 

 

0 Kudos
Message 1 of 3
(2,857 Views)
Solution
Accepted by topic author timinmanchester

Hello timinmanchester,  

 

When you are acquiring a single sample you are requesting Windows to ask our card for a sample, then the card has to get the sample through the multiplexer and the ADC and then back to Windows again, for it to display the value back to you. The weakest link in this process being Windows, you can have timing for this process anywhere between 1 and 10ms, so 1.7ms is very good! You will not be able to use the Sample Rate or Clock in this instance as they are to configure Continuous Acquisition/Mode – where you acquire constantly until you choose to stop, or Finite Acquisition/Mode – where you pre-select the number of samples you want to acquire in total. By Sample Rate we mean samples per second, therefore you will need to acquire more than one sample in order to use this feature. With a single sample acquisition, the speed is only dependant on the speed of execution of the application.

You can try Continuous Acquisition and choose how many samples you get per second, and this would significantly improve your speed, as your card is fully capable of higher speeds – 250kS/s! The card gets into acquisition and essentially uses a buffer to send the data back to your PC in bulks, so Windows don’t interfere in the acquisition until you stop.

 

I hope this helps,

Kind Regards,

Michael S.
Applications Engineer
NI UK & Ireland

Message Edited by sahpek on 11-21-2008 11:56 AM
0 Kudos
Message 2 of 3
(2,841 Views)
THANK YOU
0 Kudos
Message 3 of 3
(2,835 Views)