AnsweredAssumed Answered

N6705B: unable to use Measurement.FetchArray method of IVI-COM driver

Question asked by dcc on Oct 26, 2016
Latest reply on Nov 1, 2016 by dcc

I have a Keysight N6705B which I am trying to control from C# through the IVI-COM driver.

 

I am trying to write simple trigger & fetch test on one of the channels of the power supply unit.

 

FetchArray() method results always in a COM Exception (VI_ERR_TM) while the Fetch() command does work!. I have also seen that I can retrieve the points of the triggered measurement using FETC:ARR? (@1), which I suspect is what the FetchArray() method should be doing under the hood...

 

I suspect that either I do not understand what I have to do to use this method or there is a bug in FetchArray implementation of the IVI-COM driver.

 

I would appreciate if someone would tell me if my C# sample code looks fine.

 

Keysight IO Libraries, IVI-COM driver and IVI-COM all downloaded and installed for no more than 2 weeks ago on a "clean" computer without any other kind of IVI or VISA related software installed.

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Agilent.AgilentN67xx.Interop;

namespace N6705BFetchArrayBug
{
    class Program
    {
        static void Main(string[] args)
        {
            var driver = new AgilentN67xx();
            driver.Initialize(
                "TCPIP0::192.168.0.35::5025::SOCKET",
                false,
                true,
                "Cache=false,Simulate=false");

            var o = driver.Outputs.get_Item(driver.Outputs.get_Name(1));
            var m = driver.Measurements.get_Item(driver.Measurements.get_Name(1));
            var io = driver.Systems.IO;

            driver.Utility.Reset();
            o.VoltageLevel(20, 0.444);
            o.Enabled = true;
            Console.WriteLine("\nChannel Enabled. Press any key to continue");
            Console.ReadKey();
            Console.WriteLine();

            m.Configure(
                AgilentN67xxMeasurementTypeEnum.AgilentN67xxMeasurementVoltage,
                0,
                3,
                0.01);
            m.TrigSource = AgilentN67xxTriggerSourceEnum.AgilentN67xxTriggerSourceBus;
            m.TrigInitiate();
            driver.Measurements.SendSoftwareTrigger();
            driver.Systems.WaitForOperationComplete(10000);

            // Fetching a scalar works
            var scalar = m.Fetch(
                AgilentN67xxFetchTypeEnum.AgilentN67xxFetchVoltage,
                AgilentN67xxWindowTypeEnum.AgilentN67xxWindowTypeNone);
            Console.WriteLine("scalar: " + scalar.ToString("0.00"));

            // Fetching ARRAY through SCPI & I/O Passthrough API works...
            io.WriteString("FETC:ARR:VOLT? (@1)", true);
            var arrayThroughSCPI = (float[])io.ReadList(
                Ivi.Visa.Interop.IEEEASCIIType.ASCIIType_R4, ",");
            Console.WriteLine("arrayThroughSCPI: " + String.Join("; ",
                arrayThroughSCPI.Select(x => x.ToString("0.00"))));

            // But the FetchArray results in VI_ERR_TMO
            try
            {
                io.IO.Timeout = 5000; // I have tried to set it to 20000 also
                var arrayThroughMethod = m.FetchArray(
                    AgilentN67xxFetchTypeEnum.AgilentN67xxFetchVoltage);
                Console.WriteLine("arrayThroughMethod: " + String.Join("; ",
                    arrayThroughMethod.Select(x => x.ToString("0.00"))));
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                Console.WriteLine("arrayThroughMethod: Using m.FetchArray() failed!");
                Console.WriteLine("\tError: 0x"
                    + e.HResult.ToString("X") + "\tError Message: " + e.Message);
            }

            driver.Close();
            Console.WriteLine("Program terminated. Press any key to exit");
            Console.ReadKey();
        }
    }
}

 

Program Output:


Channel Enabled. Press any key to continue


scalar: 0,44
arrayThroughSCPI: 0,44; 0,44; 0,44
arrayThroughMethod: Using m.FetchArray() failed!
    Error: 0x80040015    Error Message: VI_ERROR_TMO: A timeout occurred
Program terminated. Press any key to exit

 

Thank you very much in advance.

 

Dcc

Outcomes