11-02-2007 02:50 PM
[DllImport("nidaqmxbase.dll")]
public static extern int DAQmxBaseCreateTask(string taskName, out TaskHandle taskHandle);
// int32 DAQmxBaseCreateTask (const char taskName[ ], TaskHandle *taskHandle);
[
DllImport("nidaqmxbase.dll")] public static extern int DAQmxBaseCreateAIVoltageChan(TaskHandle taskHandle, string physicalChannel, string nameToAssignToChannel, int terminalConfig, double minVal, double maxVal, int units, string customScaleName); // int32 DAQmxBaseCreateAIVoltageChan (TaskHandle taskHandle, const char physicalChannel[ ], const char nameToAssignToChannel[ ], int32 terminalConfig, float64 minVal, float64 maxVal, int32 units, const char customScaleName[ ]);[
DllImport("nidaqmxbase.dll")] public static extern int DAQmxBaseStartTask(TaskHandle taskHandle); // int32 DAQmxBaseStartTask (TaskHandle taskHandle);[
DllImport("nidaqmxbase.dll")] public static extern int DAQmxBaseReadAnalogF64(TaskHandle taskHandle, int numSampsPerChan, double timeout, System.UInt32 fillMode, out double readArray, System.UInt32 arraySizeInSamps, out int sampsPerChanRead, out System.UInt32 reserved); // int32 DAQmxBaseReadAnalogF64 (TaskHandle taskHandle, int32 numSampsPerChan, float64 timeout, bool32 fillMode, float64 readArray[], uInt32 arraySizeInSamps, int32 *sampsPerChanRead, bool32 *reserved);[
DllImport("nidaqmxbase.dll")] public static extern int DAQmxBaseStopTask(TaskHandle taskHandle); // int32 DAQmxBaseStopTask (TaskHandle taskHandle);[
DllImport("nidaqmxbase.dll")] public static extern int DAQmxBaseClearTask(TaskHandle taskHandle); // int32 DAQmxBaseClearTask (TaskHandle taskHandle);private void Form1_Load(object sender, EventArgs e)
{
TaskHandle taskHandle = 0; double data; int pointsread; int DAQmx_Val_Volts = 10348; // VoltsSystem.
UInt32 reserved;
DAQmxBaseCreateTask(
"",out taskHandle);DAQmxBaseCreateAIVoltageChan(taskHandle,
"/Dev1/ai0", "", -1, -5, 5, DAQmx_Val_Volts, null);DAQmxBaseStartTask(taskHandle);
DAQmxBaseReadAnalogF64(taskHandle, 1, 1, 0,
out data, 1000,out pointsread, out reserved);DAQmxBaseStopTask(taskHandle);
DAQmxBaseClearTask(taskHandle);
textBox1.Text =
Convert.ToString(data);
11-02-2007 03:19 PM - edited 11-02-2007 03:19 PM
Hi henrique-
You should use NI-DAQmx- it supports your device on Windows 2000. The most recent version is NI-DAQmx 8.6, available here. The other benefit of using NI-DAQmx is that a .NET API is provided so you do not need to import functions directly from the ANSI .dll.
Once you install NI-DAQmx you can find .NET-based examples in this directory ( C:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\DotNET2.0 ) or similar. I would recommend this example ( C:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\DotNET2.0\Analog In\Measure Voltage\ContAcqVoltageSamples_IntClk\cs ) to help get up and running with the NI-DAQmx API.
Hopefully this helps-
Message Edited by Tom W [DE] on 11-02-2007 03:20 PM
11-02-2007 09:57 PM
11-07-2007 01:08 PM
11-07-2007 01:12 PM
Hi henrique-
That's great- thank you for the follow-up.
11-16-2007 01:18 PM
11-16-2007 01:50 PM - edited 11-16-2007 01:50 PM
//Plot Multiple Channels to the textboxes
...
Additionally, you could consider increasing performance of the task by calling Start on task.control once before entering your read processing loop. This will help to eliminate the overhead of starting and stopping the task with each iteration of the loop.
Hopefully this helps-
11-16-2007 01:57 PM
Ok, i will try that on monday and then come back with the feedback.
Thanks.
11-19-2007 08:39 AM - edited 11-19-2007 08:39 AM
11-21-2007 09:41 AM