07-24-2017 07:47 AM
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.
// 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?
07-25-2017 10:18 AM
07-25-2017 01:53 PM
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
07-27-2017 02:53 AM
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?
07-31-2017 06:33 PM
What kind of behavior are you seeing? Has anything changed after changing your sample rate, or removing the circuit from your wiring setup?
08-05-2017 02:07 PM
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,
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());
outputTask.Timing.ConfigureSampleClock("", fGen.ResultingSampleClockRate, SampleClockActiveEdge.Rising,
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.