AnsweredAssumed Answered

Agilent 34972ACErrors when trying to read temperature data

Question asked by estivalg on Nov 26, 2015
Latest reply on Dec 3, 2015 by lhornburg
Hello!

I'm trying to get an Agilent 34972A working on a temperature acquisition through IP connexion:
_4 channels used
_C# software

The code has been primarily written by someone who left the company and he left us some bugs to work on (Lucky Us)
It tries to read the temperature data but sometimes:
_fail on configuration (MyAgilent34972.FResistance.Configure through MyAgilent34972.Scan.Initiate) with error -401 query interrupted
_fail on values read (MyAgilent34972.Scan.Fetch) with error -401 query interrupted ou "Unexpected response from instrument"
To make things worse, it usually works fine but sometimes it make this error -401.

I thought that maybe, the Agilent device didn't have enough time to handle the commands so I try adding System.Threading.Thread.Sleep between commands.
No good, as it still get the same error but had a new one: timedout.

I looked for an Agilent 34972A API C# Reference on the Internet but didn't find something usable (I found this 
http://www.element14.com/community/docs/DOC-27638/l/34970a-34972a-programmers-reference-help
on SCPI programming, this http://www.keysight.com/upload/cmc_upload/All/34970-90009_quick_ref.pdf also but nothing on C#)

I'm pretty sure I'm doing something wrong but without a C# reference, I don't know the thing(s) I'm doing wrong.

Any clue(s)?

Thanks in advance

Code:
using Ivi.Driver.Interop;
using Agilent.Agilent34970.Interop;

        IAgilent34970 MyAgilent34972;
        string[] Channel34972A = new string[]
        {
            "102",
            "103",
            "104",
            "105",
        };
        bool b_Connected;

         b_Connected = false;
         string standardInitOptions = "Cache=true, InterchangeCheck=false, QueryInstrStatus=true, RangeCheck=true, RecordCoercions=false, Simulate=false";
         try
         {
             MyAgilent34972 = new Agilent34970();
             MyAgilent34972.Initialize("TCPIP0::192.168.0.11::INSTR", false, false, standardInitOptions);
             b_Connected = MyAgilent34972.Initialized;

         }
         catch (Exception error)
         {
            MessageBox.Show(error.ToString(), "Agilent 34972A");
           }
          if (b_Connected == true)
          {
               string str_channelList = Channel34972A[0] + ":" + Channel34972A[Channel34972A.Count() - 1];

               try
               {
                    MyAgilent34972.FResistance.Configure(str_channelList, 10, 0.001);
                    MyAgilent34972.Scan.SweepCount = 1;
                    MyAgilent34972.Scan.IntervalScanSetup(str_channelList, 1, 1);
                    MyAgilent34972.Scan.Initiate();
               }
               catch (Exception exc)
               {
                    int errorCode=0;
                    string errorString="";
                    MyAgilent34972.Utility.ErrorQuery(ref errorCode,ref errorString);
                    MessageBox.Show("config :" + errorCode.ToString()+", "+errorString);
                    
               }
          }
          string[] str_value = new string[Channel34972A.Count()];
          string[] str_valueDegC = new string[Channel34972A.Count()];

          if (b_Connected == true)
          {
               try
               {
                    MyAgilent34972.Scan.Initiate();
                    MyAgilent34972.System.WaitForOperationComplete(10000);

                    str_value = MyAgilent34972.Scan.Fetch();
                    for (int i = 0; i < str_value.Count(); i++)
                    {
                         double d_value = Convert.ToDouble(str_value[i].Replace('.', ','));
                         str_valueDegC[i] = d_value.ToString();
                    }
               }
               catch (Exception error)
               {
                    MessageBox.Show("reading from agilent: " + error.ToString());
               }

          }  

Outcomes