From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Using NI-DAQ 6008 concurrent analog input and output

Hi,
I am using NI DAQ USB -6008. I tried to generate sinusoidal wave and it is running.  when i generate sinusoidal wave, i want to read the signal from the analog input. My test board generate pulse according to coming signal. Therefore i must read and write proccess concurrently. The sinusoidal signal i try to generate f=100Hz, Amplitude = 5V. I write code in C#.  the signal generator function and analog port read function is given below;
thanks...
 

public

void SinusSignalGenerator(double amplitude, double frequency, int LoopTime)

{

Task SignalGeneratorTask = new Task();

double[] data = new double[1000];

double freq;

double amp;

freq = frequency / 1000;

if (freq > 0.2)

freq = 0.2;

amp = amplitude;

if (amp > 2.4)

amp = 2.4;

for (UInt32 i = 0; i < 1000; i++)

data[i] = amp *

Math.Sin((double)i * Math.PI * 2 * freq) + amp;

SignalGeneratorTask.AOChannels.CreateVoltageChannel(

"Dev1/AO0", "", 0, 5, AOVoltageUnits.Volts);

AnalogSingleChannelWriter writer = new AnalogSingleChannelWriter(SignalGeneratorTask.Stream);

while (LoopTime-- != 0)

// for (int j = 0; j <= LoopNumber; j++ )

writer.WriteMultiSample(

true, data);

}

 

 

double

AnalogPortRead(string PortName)

{

Task TestTask = new Task();

TestTask.AIChannels.CreateVoltageChannel(PortName,

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

TestTask.Control(

TaskAction.Verify);

NationalInstruments.DAQmx.

AnalogMultiChannelReader reader = new AnalogMultiChannelReader(TestTask.Stream);

SourceArray = reader.ReadSingleSample();

return (double)SourceArray.GetValue(0);

}

0 Kudos
Message 1 of 2
(2,800 Views)
Hello TASKINSEN,

Are you trying to synchronize your AI and AO lines?   If you are trying to synchronize the two lines, you can refer to the shipping example SyncAIAO_DigStart under C:\Program Files\National Instruments\MeasurementStudioVS2003\DotNET\Examples\DAQmx\Synchronization\Multi-Function\SyncAIAO_DigStart\Cs.  Since this code is shipped with the NI-DAQmx driver and is pre-written and commented, I think that will be a better starting point than having me write out the code here Smiley Very Happy

If that is not what you are trying to do, post again and we'll try to help you out.

Regards,
Micaela N
National Instruments
0 Kudos
Message 2 of 2
(2,785 Views)