From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble with setting constant DC voltage for AO on 6052E with DAQmx

Hi, I'm new to using DAQmx so this probably has an obvious solution I am overlooking--

I am writing a program using Measurment Studio and DAQmx in C# to control an electrophysiology setup, and one of the tasks I need to do is to send a constant DC voltage on an analog out line. I know I could do this by generating a constant waveform and running the task forever, but it seems that there should be an alternative method. I have a 6052E DAQ board, so I looked at the E series documentation and it says that this sort of task is typically done using on demand timing by sending a single sample to the board. This is the code I am using to try to do this:

        /// <summary>
        /// <c>SetHoldingPotential(double vhold)</c> sets the cell holding potential to <c>vhold</c> mV.
        /// </summary>
        /// <param name="vhold">The new holding potential, in mV.</param>
        public void SetHoldingPotential(double vhold)
        {
            try
            {
                _CurrentTask = new Task("Set Holding Potential");
                _CurrentTask.AOChannels.CreateVoltageChannel(VHoldAO,"VHold",VHoldMin, VHoldMax, AOVoltageUnits.Volts);
                // No timing set up, just sending one sample with software timing
                _CurrentTask.Control(TaskAction.Verify);
               
                AnalogSingleChannelWriter writer = new AnalogSingleChannelWriter(_CurrentTask.Stream);
                double output = vhold*this.VoltageOutScalingFactor;
                writer.WriteSingleSample(true,output);
                _CurrentTask.Dispose();
            }
            catch(DaqException e)
            {
                System.Windows.Forms.MessageBox.Show("Amplifier: " + e.Message);
            }
        }


When I call this method, I see the amplifier I have hooked up to the AO go up in voltage, but then it very quickly resets to the original voltage. I noticed that one of the properties of AOChannels is IdleOutputBehavior, but if I try to set that then I get a DAQmx error telling me the property is not supported. Any ideas on what I am doing wrong?

Thanks,

Stephen Helms
0 Kudos
Message 1 of 2
(2,748 Views)

Stephen,

You are correct in that to achieve that effect you simply need to write a single value to that analog out and the board will continue to output that value until you either change that value with another write command, or reset the board. You can see this behavior in Measurement and Automation Explorer (MAX) using the test panels. Run the test panels for analog output, select a DC value and close the test panels. Your board will continue to output that value until you reset the board, or change it to something else.


So code wise simply setup your task as normal, then write your value, and you should be done. Make sure you aren’t resetting the board and it should continue to output your voltage.

-GDE

0 Kudos
Message 2 of 2
(2,731 Views)