LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Single-End Analog Input

I am trying to read a voltage using an analog input on a NI USB-6008. I have tried using a Differential and it worked, however, I am constrained and would prefer to use Single-End to read the voltage. However, when I create an instance of an AnalogSingleChannelReader with a Terminal Coniguration of any type other than Differential, it still operates like a Differential. Any ideas as to why this isn't working? And yes, I do know that the Terminal Configuration currently is configured for a Differential in the code.

 

public class AnalogInput
    {
        #region Import Dlls
        [DllImport("NationalInstruments.Common.dll")]
        static extern void Import1();
        [DllImport("NationalInstruments.Common.Native.dll")]
        static extern void Import2();
        [DllImport("NationalInstruments.DAQmx.dll")]
        static extern void Import3();
        #endregion

        #region Private Fields
        Task oTask = new Task();
        string ChannelString = "";
        #endregion

        #region Constructor
        public AnalogInput(AnalogInputChannels Channel)
        {
            ParseInputChannel(Channel);
            oTask.AIChannels.CreateVoltageChannel(ChannelString, "Channel", AITerminalConfiguration.Differential, 0, 10, AIVoltageUnits.Volts);
        }
        #endregion

        #region Public Methods
        public double Read()
        {
            AnalogSingleChannelReader oReader = new AnalogSingleChannelReader(oTask.Stream);
            double Data = oReader.ReadSingleSample();
            return Data;
        }
        #endregion

        #region Private Methods
        void ParseInputChannel(AnalogInputChannels Channel)
        {
            switch (Channel)
            {
                case AnalogInputChannels.In0:
                    ChannelString = "Dev1/ai0";
                    break;
                case AnalogInputChannels.In1:
                    ChannelString = "Dev1/ai1";
                    break;
                case AnalogInputChannels.In2:
                    ChannelString = "Dev1/ai2";
                    break;
                case AnalogInputChannels.In3:
                    ChannelString = "Dev1/ai3";
                    break;
                case AnalogInputChannels.In4:
                    ChannelString = "Dev1/ai4";
                    break;
                case AnalogInputChannels.In5:
                    ChannelString = "Dev1/ai5";
                    break;
                case AnalogInputChannels.In6:
                    ChannelString = "Dev1/ai6";
                    break;
                case AnalogInputChannels.In7:
                    ChannelString = "Dev1/ai7";
                    break;
            }
        }
        #endregion
    }

 

 

Single-End.png

0 Kudos
Message 1 of 4
(2,444 Views)
I don't see any LabVIEW code.;)

Perhaps you meant to post to a different board? You can click on Options> Report to Moderator and ask to have it moved.
0 Kudos
Message 2 of 4
(2,441 Views)

I agree that you should either request that your post be moved to the LabWindows/CVI forum (that could take awhile to occur) or to go ahead and repost your question in the other forum, which may be faster.  We have a very active community base and many who watch specific forums which makes it very effective when posting questions on our forums. Have a great day.

Alex D
Systems Engineer
Academic Research
National Instruments
0 Kudos
Message 3 of 4
(2,397 Views)

I went ahead and made another thread. Thank you.

0 Kudos
Message 4 of 4
(2,379 Views)