05-30-2006 03:02 AM
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);}
05-30-2006 07:13 PM