07-12-2010 08:43 PM
Hi,
I'm trying to read digitalized values from a potentiometer connected NI USB-6211. I have the potentiometer's VDD pin connected to port 10 on the ADC, the output pin connected to port 15, and the ground pin connected to port 28. I can see the correct potentiometer output in Signal Express (0-5V).
Now I'm trying to read these output values using C#. I'm trying to use sample code that was installed along with LabView Signal Express - the sample code's name is AcqOneVoltageSample, for reference. The device specified in the code is Dev1/ai0. However, the output values from this sample code is a bit higher than 10V. The same value remains regardless of the position of the potentiometer. It seems that while I can see correct potentiometer output in LabView Signal Express, I can't get the C# API to achieve the same results.
I was wondering if someone could post a simple, short code snipped of how to read voltage values from USB-6211 using C#. Any other tips would be appreciated as well
07-13-2010 02:53 PM
Hi Daniel 2887,
It sounds like your card could be railing at 10.7 Volts. Your card has a maximum of 10VDC, but can return a value up to 10.7V. If you signal is above 10.7V, it will still display as 10.7V and will not change until it drops below this value. A good option might be to use the device in differential setup. Instead of connecting your Ground signal form the potentiometer to pin 28 (AI GND), let's connect to pin 16 (AI 8, AI0-) and ensure the device is is differential mode. This can be done by replicating the following in your c# example code whre the "+'s" are:
//Create a virtual channel ++++++
myTask.AIChannels.CreateVoltageChannel(physicalChannelComboBox.Text,(
Best,
"",AITerminalConfiguration.Differential),Convert.ToDouble(minimumValueNumeric.Value),Convert.ToDouble(maximumValueNumeric.Value),AIVoltageUnits.Volts);05-21-2012 05:47 PM
Hello Adam,
I have a NI USB6341 and would like to read the data from a computer using C#. I tried the C# code I wrote but cannot access the device. Do you have some C# example code? The vid and pid of the device are 0x3923 and 0x74f8 repectively; Thank you.
05-22-2012 12:01 PM
Hi RobotLab,
Here is an interactive tutorial in C# and an example project:
Data Acquisition in C# .NET Interactive Tutorial Code - Developer Zone
Good luck!
05-22-2012 01:58 PM
Hey RobotLab,
If you have DAQmx with Visual Studio support installed, there are C# examples installed on your machine. You can access them by going to Start >> Programs >> National Instruments >> NI-DAQ >> Text-Based Code Support >> .NET x.x Examples.