Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading data from USB-4431 in raw ADC values with timestamps in C#

Currently I am using following method to read data from 1-4 channels:

taskReader = new Task("AI");
reader = new AnalogMultiChannelReader(taskReader.Stream);
taskReader.AIChannels.CreateVoltageChannel(devices, "Reader1", AITerminalConfiguration.Pseudodifferential, 0, 10, AIVoltageUnits.Volts);
taskReader.Timing.ConfigureSampleClock("", samplerate, SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples, numberOfSamples);
...
reader.BeginReadMultiSample(numberOfSamples, readerCallback, taskReader);
...
ReadData = reader.EndReadMultiSample(ar);
...

So it reads certain amount of data, processes it, starts again, and repeats this as long as needed.

 

I have now two problems (I googled and searched this forum, but did not quite get the information):

First, how to do same as above but using raw ADC values instead of volts?

Found some information about AnalogWaveForm...

 

Second, is it possible to add timestamp to every sample sequence, [0] = "timestamp", [1] = ch0 adc value, [2] = ch1 adc value...

About this I got the impression that it would not be possible, but I should take the time from the BeginReadMultiSample and then calculate from it sample by sample.

 

Thanks in advance and apologies about possible newbie questions.

 

0 Kudos
Message 1 of 3
(2,318 Views)

Hi jareunan,

 

When you mention that you are trying to get raw values. This is very much dependent on how you have setup your ADC. If you are set to volts then you will be reading in DBL values from your ADC. 

 

With regards to timestamp, if you read an analogue waveform then you will be reading the values, the start time and the time between samples (frequency of samples). This allows you to get a timestamp for each value.

 

The following is a good overview of using DAQmx with C; http://www.ni.com/tutorial/5409/en/#toc3

 

I would also suggest that you work directly from examples: http://digital.ni.com/public.nsf/allkb/3C04CE1E58F8621B8625700B006B7859

 

These are always a good starting point for applications and allow you to read around it in more detail.

 

Kind Regards,

 

Matt Fergusson 

AE UK 

 

0 Kudos
Message 2 of 3
(2,292 Views)

Sorry for late reply.

I am calculating the time stamps now between the sample and it is good enough.

Also adc / voltage values are now ok.

Thank you for the reply.

0 Kudos
Message 3 of 3
(2,132 Views)