Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

NIDCPower: Specified property cannot be set while the task is running. What's the task that's running?

I'm trying to get measurements on a PXIe4139, and I can't set the AperatureTime property.  Here's the exception I get:

Ivi.Driver.IviCDriverException was unhandled
  ErrorCode=0
  HResult=-2146233088
  Message=ModularInstruments.NIDCPower: Specified property cannot be set while the task is running.

Set the property prior to starting the task, or stop the task prior to setting the property.

Property: Aperture Time

 

And the code, in it's entierty...

 

      power = new NIDCPower("PXI5Slot3", false, true);
      power.Outputs["0"].Source.Output.Function = DCPowerSourceOutputFunction.DCVoltage;
      power.Outputs["0"].Source.Voltage.VoltageLevel = voltage;
      power.Outputs["0"].Source.Output.Enabled = true;
      power.Outputs["0"].Measurement.ApertureTime = 0.000001;
      power.Outputs["0"].Measurement.SamplesToAverage = 0;
      while (true)
      {
        var measurement = power.Measurement.Fetch("0", new NationalInstruments.PrecisionTimeSpan(1.0), 1);
        Console.Writeline(measurement.VoltageMeasurements[0]);
        Console.Writeline(measurement.CurrentMeasurements[0]);
      }

What am I missing?

0 Kudos
Message 1 of 2
(2,691 Views)

Hi,

 

 

While I am more directly familiar with LabVIEW's API for the 4139, I believe the error comes from trying to change a setting after you've configured and enabled the output. Try placing the aperture time setting above the enabled line.

 

power.Outputs["0"].Measurement.ApertureTime = 0.000001;

power.Outputs["0"].Source.Output.Enabled = true;

 

Regards,

 

Finch Train

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