Quantcast
Channel: LabVIEW topics
Viewing all articles
Browse latest Browse all 69281

Single-End Analog Input

$
0
0

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


Viewing all articles
Browse latest Browse all 69281

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>