Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Data acquisition AO and AI simultaneous by DAQ 6343 with Visual C# code

Hi i have a question about using the daq and the code to control it

I'm using 1 analog channel AO0 for generation of sinus from 10Hz to 3kHz (10, 30, 50, 100, 500, 750, 1000, 3000)(Hz). This signal enters to electronic circuit, from the circuit i have two outputs, they are connected to AI2 and AI3.

 

from the examples i took some code

to generate and measure all 3 channels simultaneously, i'm using finite mode for the sampling AI.

code:

// Create the master and slave tasks
 inputTask = new Task("inputTask");
 outputTask = new Task("outputTask");


// Configure both tasks with the values selected on the UI.
inputTask.AIChannels.CreateVoltageChannel("Dev2\ai2:3, "", AITerminalConfiguration.Rse, 
inputMinValue, inputMaxValue, AIVoltageUnits.Volts); // Configure timing specs SAMPLERATE = 5000 * 2; RATE = 5000; //samples per channel /s
inputTask.Timing.ConfigureSampleClock("", SAMPLERATE, SampleClockActiveEdge.Rising,
SampleQuantityMode.FiniteSamples, RATE); outputTask.AOChannels.CreateVoltageChannel(Generator_AO, "", inputMinValue,
inputMaxValue, AOVoltageUnits.Volts); // Verify the tasks inputTask.Control(TaskAction.Verify); outputTask.Control(TaskAction.Verify); FunctionGenerator fGen = new FunctionGenerator(outputTask.Timing, FREQ, SamplesBuffer.ToString(),
CyclesBuffer.ToString(), "Sine", Voltage_GenSinus.ToString()); outputTask.Timing.ConfigureSampleClock("", fGen.ResultingSampleClockRate, SampleClockActiveEdge.Rising,
SampleQuantityMode.FiniteSamples, SamplesBuffer); output = fGen.Data; writer = new AnalogSingleChannelWriter(outputTask.Stream); writer.WriteMultiSample(false, output); // Officially start the task outputTask.Start(); inputTask.Start();
reader = new AnalogMultiChannelReader(inputTask.Stream); data = reader.ReadWaveform(output.Length);//reader.ReadWaveform(5000); dataToDataTable(output, data, ref inputDataTable, group_index); inputTask.Stop(); outputTask.Stop();

variables RATE = 5000 (samples per channel), SAMPLERATE = RATE * 2

i know that sample rate must be at least multiply 2 of measured frequency. everything works fine

up to 100Hz

at frequency bigger from 100Hz i have ten periods of sinus  of results

 

SampleBuffer for sinus from 10hz to 100hz is 5000 and from 500hz to 3000hz is 1000

why this happen, this is can not be changed at work of the task

 

the graph of the measurement of high freq is the last one

 

tech spec for this daq input 500kS/s

output is 900kS/s

 

why at the first line it not measuring the signal as it must be done like at low freqs?

0 Kudos
Message 1 of 6
(3,529 Views)

Hi Arbo,

 

  • If you remove the circuit from the equation and wire AO0 directly to AI2 or AI3, do you see the same behavior?
  • If you try to generate this same signal in the Test Panel in NI MAX, do you see the same behavior?
  • Have you tried increasing the sample rate in your code?

 

Nick B.

Applications Engineer

National Instruments

 

0 Kudos
Message 2 of 6
(3,482 Views)

thanks for some tips i will test it tommorow

 

but let me understand

the sample rate for generation sinus it's not depends of sample rate of measured signal , i can do 5000 samples per buffer for AO0 and for measured signal AI2-3 i can set 10000 or 200000 samples?

 

tech documents says that AI can be up to 500kS/s this is 500 000 samples per channel

and AO can be setup up to 900kS/s

0 Kudos
Message 3 of 6
(3,478 Views)

as i understand update rate is 900kS/s

 

if i want to generate sinus wave with frequency of 3kHz i must    divide 900kS/s / 3kHz = 300 Samples per buffer will be the right value?

 

when i measure AI2 and AI3 with 500kS/s i can do this at  same Sample rate? or i need to minimize it for the NI 6343 DAQ tech spec?

0 Kudos
Message 4 of 6
(3,464 Views)

Hi Arbo,

 

What kind of behavior are you seeing? Has anything changed after changing your sample rate, or removing the circuit from your wiring setup?

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

hi

yes i checked the performance of the DAQ without electronic circuit and the acquisition is doing very well. after connection of the circuit again i did these changes to the appropriate functions

1. RATE= is a samples per channel per buffer

inputTask.Timing.ConfigureSampleClock("", 100000.00, SampleClockActiveEdge.Rising, 
SampleQuantityMode.FiniteSamples, RATE);

2. SamplesBuffer = 1000/5000 , CyclesBuffer = 5 Voltage_GenSinus = 0.01

FunctionGenerator fGen = new FunctionGenerator(outputTask.Timing, FREQ, SamplesBuffer.ToString(), 
CyclesBuffer.ToString(), "Sine", Voltage_GenSinus.ToString());

3.

outputTask.Timing.ConfigureSampleClock("", fGen.ResultingSampleClockRate, SampleClockActiveEdge.Rising, 
SampleQuantityMode.FiniteSamples, SamplesBuffer);

the problem was , that i thought that sampling rate of output sinus generation is different from input task measured signal from outputs of electronic circuit.

 

0 Kudos
Message 6 of 6
(3,393 Views)