12-06-2005 10:19 AM
12-07-2005 10:08 AM
03-20-2006 07:32 AM
03-21-2006 10:42 AM
03-22-2006 04:53 AM
I reinstalled the driver and I still can't get the examples to compile. Let me be more specific about what I am doing.
I tried to compile the example file C:\Program Files\National Instruments\MeasurementStudioVS2003\DotNET\Examples\DAQmx\Analog Out\Generate Voltage\GenVoltageUpdate\Cs\MainForm.cs using the c# compiler that comes standard with XP. In my case this is located at C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\csc.exe.
I get the following error : the type or namespace 'DAQmx' does not exist in the class or namespace 'NationalInstruments'
Thanks for your help.
Peter
03-23-2006 11:24 AM
Peter,
C:\Program Files\National Instruments\MeasurementStudioVS2003\DotNET\Assemblies\Current\NationalInstruments.DAQmx.dll
Try adding that reference, and see if that helps out at all.
-GDE
03-26-2006 05:25 AM
Dear GDE,
Referencing the assemblies solved the problem. Thanks.
I had to put NationalInstruments.Common.dll and NationalInstruments.DAQmx.dll in the same directory as my code to get it to compile. When I did this with the example programs provided by National Instruments they did not compile. I am not sure why. The examples programs are quite long because they are windows applications. I just want to set and read voltages so I wrote the short program below which I did get to compile.
using System;
using NationalInstruments.DAQmx;
class daq{
public static void Main() {
//Set the voltage of analog output AO0 on Dev1 to 2.33 Volts
Task writeAO0Task = new Task();
writeAO0Task.AOChannels.CreateVoltageChannel("/Dev1/ao0", "aoChannel",-10, 10, AOVoltageUnits.Volts);
AnalogSingleChannelWriter AO0writer = new AnalogSingleChannelWriter(writeAO0Task.Stream);
AO0writer.WriteSingleSample(true, 2.33);
//Read the voltage at analoginput AI0 on Dev1
int samplefrequency = 100000;
int numberofsamples = 10000;
Task readAI0Task = new Task();
readAI0Task.AIChannels.CreateVoltageChannel("/Dev1/ai0","aichannel", (AITerminalConfiguration)(-1),-10,10,AIVoltageUnits.Volts);
readAI0Task.Timing.ConfigureSampleClock("",samplefrequency, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, numberofsamples);
readAI0Task.Control(TaskAction.Verify);
AnalogSingleChannelReader AI0reader = new AnalogSingleChannelReader(readAI0Task.Stream);
double [] data = AI0reader.ReadMultiSample(numberofsamples);
double avg = 0;
double avgsquared = 0;
for (int i=0; i<numberofsamples; i++) {
avg = avg + data[i];
avgsquared = avgsquared + data[i]*data[i];
}
double stddev = System.Math.Sqrt(avgsquared/numberofsamples-avg*avg/(numberofsamples*numberofsamples));
avg=avg/numberofsamples;
Console.WriteLine("The voltage at Dev1/AI0 is "+avg+" +/- "+stddev);
writeAO0Task.Dispose();
readAI0Task.Dispose();
}
}