AnsweredAssumed Answered

511, RS-232 framing error, -410, Query INTERRUPTED

Question asked by jond on Dec 3, 2010
Latest reply on Mar 4, 2014 by MattC
Hello,

Hopefully someone can help me out.  I am new to programming for the E3631a

I am trying to power up my E3631A and measure the current draw.   My code is C# running in .Net 4.  I appear to connect and can interact some, but I get the following error.

ErrorQuery: 511, RS-232 framing error
ErrorQuery: -410, Query INTERRUPTED

I am connected via RS-232.

The meter is setup 9600 baud, none, 8 bits.

My IO.OptionString is currently "Timeout = 2000 ; SendEndEnabled = TRUE ; TerminationCharacter = 10 ; TerminationCharacterEnabled = TRUE ; BaudRate = 9600 ; DataBits = 8 ; EndIn = ASRL_END_TERMCHAR ; EndOut = ASRL_END_NONE ; FlowControl = ASRL_FLOW_NONE ; Parity = ASRL_PAR_NONE ; RequestToSendState = 1 ; DataTerminalReadyState = 1 ; StopBits = ASRL_STOP_ONE ; MaximumQueueLength = 1000 ; ReplacementCharacter = 255 ; XONCharacter = 17 ; XOFFCharacter = 19"


My code is as follows.  The trace output follows the code.  The output of my code is

System Ready
Connecting to the Power Supply
Getting Outputs
Setting voltage levels 1
AgilentE36xx: Instrument error detected.  Use ErrorQuery() to determine the error(s).
Driver: Agilent.AgilentE36xx.Interop.AgilentE36xxClass, Initialized True
ErrorQuery: 511, RS-232 framing error
ErrorQuery: -410, Query INTERRUPTED
ErrorQuery: 0, No error
Driver Closed


        void MeasureCurrentDraw()
        {
            Agilent.AgilentE36xx.Interop.AgilentE36xx driver = null;

            try
            {
                // Create driver instance
                driver = new Agilent.AgilentE36xx.Interop.AgilentE36xx();
                Log("Connecting to the Power Supply");
                string resourceDesc = "ASRL1::INSTR";
                string standardInitOptions = "QueryInstrStatus=true";
                string driverSetupOptions = "DriverSetup= Model=, Trace=true";
                driver.Initialize(resourceDesc, true, true, standardInitOptions + "," + driverSetupOptions);

                if (driver.Initialized)
                {
                    driver.System.DisableLocalControls();

                    // Get Output1 object.  get_Name(1) returns "Output1".
                    Log("Getting Outputs");
                    IAgilentE36xxOutput pOutput1 = driver.Outputs.get_Item(driver.Outputs.get_Name(1));
                    IAgilentE36xxOutput pOutput2 = driver.Outputs.get_Item(driver.Outputs.get_Name(2));
                    IAgilentE36xxOutput pOutput3 = driver.Outputs.get_Item(driver.Outputs.get_Name(3));
                    // Set output voltage.
                    Log("Setting voltage levels 1");
                    pOutput1.ApplyVoltageCurrent(5.2, 2.8);
                    Log("Setting voltage levels 2");
                    pOutput2.ApplyVoltageCurrent(15, 0.9);
                    Log("Setting voltage levels 3");
                    pOutput3.ApplyVoltageCurrent(-15,0.5);

                    Log("Enabling Outputs");
                    // Enable all outputs
                    driver.Outputs.Enabled = true;

                    Log("Sleeping for 2 seconds");
                    Thread.Sleep(2000);

                    Log("Measuring the current draw 1");
                    // Measure the output voltage
                    currentDraw[1] = pOutput1.Measure(AgilentE36xxMeasurementTypeEnum.AgilentE36xxMeasurementCurrent);
                    Log("Measuring the current draw 2");
                    currentDraw[2] = pOutput1.Measure(AgilentE36xxMeasurementTypeEnum.AgilentE36xxMeasurementCurrent);
                    Log("Measuring the current draw 3");
                    currentDraw[3] = pOutput1.Measure(AgilentE36xxMeasurementTypeEnum.AgilentE36xxMeasurementCurrent);

                    Log("Disabling the outputs");
                    // Disable all outputs
                    driver.Outputs.Enabled = false;

                    // Check instrument for errors
                    int errorNum = -1;
                    string errorMsg = null;

                    while (errorNum != 0)
                    {
                        driver.Utility.ErrorQuery(ref errorNum, ref errorMsg);
                        Log(String.Format("ErrorQuery: {0}, {1}", errorNum, errorMsg));
                        driver.System.WaitForOperationComplete(1000);
                    }
                    Thread.Sleep(2000); //Sleep for 2 seconds to allow voltages to die out.
                    driver.System.EnableLocalControls();
                }
                else
                {
                    Log("Driver failed to initialize");
                }
            }
            catch (Exception ex)
            {
                Log(ex.Message);
                // Check instrument for errors
                try
                {
                    Log(String.Format("Driver: {0}, Initialized {1} ", driver, driver.Initialized));
                    if (driver != null && driver.Initialized)
                    {
                        int errorNum = -1;
                        string errorMsg = null;

                        while (errorNum != 0)
                        {
                            driver.Utility.ErrorQuery(ref errorNum, ref errorMsg);
                            Log(String.Format("ErrorQuery: {0}, {1}", errorNum, errorMsg));
                        }
                    }
                }
                catch (Exception ex2)
                {
                    Log("error while catching exception");
                    Log(ex2.Message);
                }
            }
            finally
            {
                if (driver != null && driver.Initialized)
                {
                    // Close driver
                    driver.Close();
                    Log("Driver Closed");
                }
            }
        }



<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="file:\\C:\Program Files (x86)\IVI Foundation\IVI\Components\Agilent Technologies\trace.xslt"?>
<TraceRecords>
<Method Name="InstrPrintf" Interface="CDriverIOManager" StartTime="10:09:44" Thread="7692" EndTime="10:09:45" ExecutionTime="01">
<Parameter Name="strCommand" Direction="In" Value="*IDN?"/>
<Parameter Name="cchDesired" Direction="In" Value="1024"/>
<Parameter Name="&amp;bstrResult" Direction="Out" Value="HEWLETT-PACKARD,E3631A,0,2.1-5.0-1.0&#xA;"/>
</Method>
<Method Name="InstrPrintfNoPoll" Interface="CDriverIOManager" StartTime="10:09:45" Thread="7692" EndTime="10:09:45" ExecutionTime="00">
<Parameter Name="strCmd" Direction="In" Value="SYST:REM;*OPC?"/>
</Method>
<Method Name="FormattedReadNumber" Interface="CDriverIOManager" StartTime="10:09:45" Thread="7692" EndTime="10:09:45" ExecutionTime="00">
<Parameter Name="bFlushToEnd" Direction="In" Value="true"/>
<Parameter Name="lTimeout" Direction="In" Value="5000"/>
<Parameter Name="pValue" Direction="Out" Value="1"/>
</Method>
<Method Name="Reset" Interface="IIviDriverUtility" StartTime="10:09:45" Thread="7692" EndTime="10:09:45" ExecutionTime="00">
<Method Name="InstrQuery" Interface="CDriverIOManager" StartTime="10:09:45" Thread="7692" EndTime="10:09:45" ExecutionTime="00">
<Parameter Name="strCommand" Direction="In" Value="*RST;*OPC?"/>
<Parameter Name="plResult" Direction="Out" Value="1"/>
</Method>
</Method>
<Method Name="get_Initialized" Interface="IIviDriver" StartTime="10:09:45" Thread="7692" EndTime="10:09:45" ExecutionTime="00">
<Parameter Name="val" Direction="Out" Value="-1"/>
</Method>
<Method Name="get_System" Interface="IAgilentE36xx" StartTime="10:09:45" Thread="7692" EndTime="10:09:45" ExecutionTime="00">
<Parameter Name="val" Direction="Out" Value="&lt;interface&gt;"/>
</Method>
<Method Name="DisableLocalControls" Interface="IAgilentE36xxSystem" StartTime="10:09:45" Thread="7692" EndTime="10:09:46" ExecutionTime="01">
<Method Name="InstrPrintfNoPoll" Interface="CDriverIOManager" StartTime="10:09:45" Thread="7692" EndTime="10:09:45" ExecutionTime="00">
<Parameter Name="strCmd" Direction="In" Value="SYST:REM;*OPC?"/>
</Method>
<Method Name="FormattedReadNumber" Interface="CDriverIOManager" StartTime="10:09:45" Thread="7692" EndTime="10:09:46" ExecutionTime="01">
<Parameter Name="bFlushToEnd" Direction="In" Value="true"/>
<Parameter Name="lTimeout" Direction="In" Value="5000"/>
<Parameter Name="pValue" Direction="Out" Value="1"/>
</Method>
</Method>
<Method Name="get_Outputs" Interface="IAgilentE36xx" StartTime="10:09:48" Thread="7692" EndTime="10:09:48" ExecutionTime="00">
<Parameter Name="val" Direction="Out" Value="&lt;interface&gt;"/>
</Method>
<Method Name="get_Outputs" Interface="IAgilentE36xx" StartTime="10:09:48" Thread="7692" EndTime="10:09:48" ExecutionTime="00">
<Parameter Name="val" Direction="Out" Value="&lt;interface&gt;"/>
</Method>
<Method Name="get_Name" Interface="IAgilentE36xxOutputs" StartTime="10:09:48" Thread="7692" EndTime="10:09:48" ExecutionTime="00">
<Parameter Name="Index" Direction="In" Value="1"/>
<Parameter Name="val" Direction="Out" Value="Output1"/>
</Method>
<Method Name="get_Item" Interface="IAgilentE36xxOutputs" StartTime="10:09:48" Thread="7692" EndTime="10:09:48" ExecutionTime="00">
<Parameter Name="Name" Direction="In" Value="Output1"/>
<Parameter Name="val" Direction="Out" Value="&lt;interface&gt;"/>
</Method>
<Method Name="get_Outputs" Interface="IAgilentE36xx" StartTime="10:09:48" Thread="7692" EndTime="10:09:48" ExecutionTime="00">
<Parameter Name="val" Direction="Out" Value="&lt;interface&gt;"/>
</Method>
<Method Name="get_Outputs" Interface="IAgilentE36xx" StartTime="10:09:48" Thread="7692" EndTime="10:09:48" ExecutionTime="00">
<Parameter Name="val" Direction="Out" Value="&lt;interface&gt;"/>
</Method>
<Method Name="get_Name" Interface="IAgilentE36xxOutputs" StartTime="10:09:48" Thread="7692" EndTime="10:09:48" ExecutionTime="00">
<Parameter Name="Index" Direction="In" Value="2"/>
<Parameter Name="val" Direction="Out" Value="Output2"/>
</Method>
<Method Name="get_Item" Interface="IAgilentE36xxOutputs" StartTime="10:09:48" Thread="7692" EndTime="10:09:48" ExecutionTime="00">
<Parameter Name="Name" Direction="In" Value="Output2"/>
<Parameter Name="val" Direction="Out" Value="&lt;interface&gt;"/>
</Method>
<Method Name="get_Outputs" Interface="IAgilentE36xx" StartTime="10:09:48" Thread="7692" EndTime="10:09:48" ExecutionTime="00">
<Parameter Name="val" Direction="Out" Value="&lt;interface&gt;"/>
</Method>
<Method Name="get_Outputs" Interface="IAgilentE36xx" StartTime="10:09:48" Thread="7692" EndTime="10:09:48" ExecutionTime="00">
<Parameter Name="val" Direction="Out" Value="&lt;interface&gt;"/>
</Method>
<Method Name="get_Name" Interface="IAgilentE36xxOutputs" StartTime="10:09:48" Thread="7692" EndTime="10:09:48" ExecutionTime="00">
<Parameter Name="Index" Direction="In" Value="3"/>
<Parameter Name="val" Direction="Out" Value="Output3"/>
</Method>
<Method Name="get_Item" Interface="IAgilentE36xxOutputs" StartTime="10:09:48" Thread="7692" EndTime="10:09:48" ExecutionTime="00">
<Parameter Name="Name" Direction="In" Value="Output3"/>
<Parameter Name="val" Direction="Out" Value="&lt;interface&gt;"/>
</Method>
<Method Name="ApplyVoltageCurrent" Interface="IAgilentE36xxOutput" StartTime="10:09:48" Thread="7692" EndTime="10:09:50" ExecutionTime="02">
<Parameter Name="VoltageLevel" Direction="In" Value="5.2"/>
<Parameter Name="CurrentLimit" Direction="In" Value="2.8"/>
<Method Name="InstrPrintf" Interface="CDriverIOManager" StartTime="10:09:48" Thread="7692" EndTime="10:09:50" ExecutionTime="02">
<Parameter Name="strCmd" Direction="In" Value="APPL P6V, 5.2, 2.8"/>
</Method>
</Method>
<Method Name="get_Initialized" Interface="IIviDriver" StartTime="10:09:50" Thread="7692" EndTime="10:09:50" ExecutionTime="00">
<Parameter Name="val" Direction="Out" Value="-1"/>
</Method>
<Method Name="get_Initialized" Interface="IIviDriver" StartTime="10:09:50" Thread="7692" EndTime="10:09:50" ExecutionTime="00">
<Parameter Name="val" Direction="Out" Value="-1"/>
</Method>
<Method Name="get_Utility" Interface="IIviDriver" StartTime="10:09:50" Thread="7692" EndTime="10:09:50" ExecutionTime="00">
<Parameter Name="val" Direction="Out" Value="&lt;interface&gt;"/>
</Method>
<Method Name="ErrorQuery" Interface="IIviDriverUtility" StartTime="10:09:50" Thread="7692" EndTime="10:09:51" ExecutionTime="01">
<Parameter Name="ErrorCode" Direction="InOut" Value="-1"/>
<Parameter Name="ErrorMessage" Direction="InOut" Value=""/>
<Method Name="InstrPrintf" Interface="CDriverIOManager" StartTime="10:09:50" Thread="7692" EndTime="10:09:51" ExecutionTime="01">
<Parameter Name="strCommand" Direction="In" Value="SYST:ERR?"/>
<Parameter Name="cchDesired" Direction="In" Value="1023"/>
<Parameter Name="&amp;bstrResult" Direction="Out" Value="+511,&quot;RS-232 framing error&quot;&#xA;"/>
</Method>
<Parameter Name="ErrorCode" Direction="InOut" Value="511"/>
<Parameter Name="ErrorMessage" Direction="InOut" Value="RS-232 framing error"/>
</Method>
<Method Name="get_Utility" Interface="IIviDriver" StartTime="10:09:51" Thread="7692" EndTime="10:09:51" ExecutionTime="00">
<Parameter Name="val" Direction="Out" Value="&lt;interface&gt;"/>
</Method>
<Method Name="ErrorQuery" Interface="IIviDriverUtility" StartTime="10:09:51" Thread="7692" EndTime="10:09:51" ExecutionTime="00">
<Parameter Name="ErrorCode" Direction="InOut" Value="511"/>
<Parameter Name="ErrorMessage" Direction="InOut" Value="RS-232 framing error"/>
<Method Name="InstrPrintf" Interface="CDriverIOManager" StartTime="10:09:51" Thread="7692" EndTime="10:09:51" ExecutionTime="00">
<Parameter Name="strCommand" Direction="In" Value="SYST:ERR?"/>
<Parameter Name="cchDesired" Direction="In" Value="1023"/>
<Parameter Name="&amp;bstrResult" Direction="Out" Value="-410,&quot;Query INTERRUPTED&quot;&#xA;"/>
</Method>
<Parameter Name="ErrorCode" Direction="InOut" Value="-410"/>
<Parameter Name="ErrorMessage" Direction="InOut" Value="Query INTERRUPTED"/>
</Method>
<Method Name="get_Utility" Interface="IIviDriver" StartTime="10:09:51" Thread="7692" EndTime="10:09:51" ExecutionTime="00">
<Parameter Name="val" Direction="Out" Value="&lt;interface&gt;"/>
</Method>
<Method Name="ErrorQuery" Interface="IIviDriverUtility" StartTime="10:09:51" Thread="7692" EndTime="10:09:51" ExecutionTime="00">
<Parameter Name="ErrorCode" Direction="InOut" Value="-410"/>
<Parameter Name="ErrorMessage" Direction="InOut" Value="Query INTERRUPTED"/>
<Method Name="InstrPrintf" Interface="CDriverIOManager" StartTime="10:09:51" Thread="7692" EndTime="10:09:51" ExecutionTime="00">
<Parameter Name="strCommand" Direction="In" Value="SYST:ERR?"/>
<Parameter Name="cchDesired" Direction="In" Value="1023"/>
<Parameter Name="&amp;bstrResult" Direction="Out" Value="+0,&quot;No error&quot;&#xA;"/>
</Method>
<Parameter Name="ErrorCode" Direction="InOut" Value="0"/>
<Parameter Name="ErrorMessage" Direction="InOut" Value="No error"/>
</Method>
<Method Name="get_Initialized" Interface="IIviDriver" StartTime="10:09:51" Thread="7692" EndTime="10:09:51" ExecutionTime="00">
<Parameter Name="val" Direction="Out" Value="-1"/>
</Method>
<Method Name="Close" Interface="IIviDriver" StartTime="10:09:51" Thread="7692"/>
</TraceRecords>  

Outcomes