Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading digitalized potentiometer values from NI USB-6211 using C#

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

0 Kudos
Message 1 of 5
(4,066 Views)

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);

Adam
Academic Product Manager
National Intruments
0 Kudos
Message 2 of 5
(4,052 Views)

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.

 

0 Kudos
Message 3 of 5
(3,703 Views)

Hi RobotLab,

 

Here is an interactive tutorial in C# and an example project:

 

Interactive Tutorial

 

Data Acquisition in C# .NET Interactive Tutorial Code - Developer Zone

 

Good luck!

Regards,

Jared R.
Precision DC Product Support Engineer
National Instruments
0 Kudos
Message 4 of 5
(3,690 Views)

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.

Steven K.
National Instruments
Software Engineer
0 Kudos
Message 5 of 5
(3,680 Views)