09-04-2013 04:44 PM
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 }
09-04-2013 04:51 PM
09-05-2013 10:25 AM
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.
09-05-2013 04:00 PM
I went ahead and made another thread. Thank you.