AnsweredAssumed Answered

VI_ERROR_TMO Error during DIGitize (Low Repetitive Waveform)

Question asked by guoxuknight on Jan 29, 2012
Latest reply on Jan 30, 2012 by bret

My experiment setup:

Device: Agilent DSo5032A
Connection: Scope -> USB <- PC
Language: C#
Goal: Capture waveforms and store them on the PC disk
Channels: I have two channels in use. Channel 1 the measurements; Channel 2 the trigger (very low repetitive).
Problem Description: I reuse the VISA example C# code in the Programmer's Guide following the Init -> Capture -> Analyze steps. After I modified the Init step which can correctly control the scope to display the measurements under the trigger (normal mode). But when I test the capture step (commented the Analyze step) and the program executes "oscp.DoCommand(":DIGitize CHANnel1");", it will report  "*** VISA Error Message : VI_ERROR_TMO: A timeout occurred".

My questions:
1. How to solve the timeout problem in the capture step?

2. Since I have embedded this scope control codes in the loop of my SW application, is there an easier way that when I can see the right waveforms shown in the screen, I can directly save the waveforms into the disk given that I can insert wait cycles to allow enough time to transfer the date from scope to disk and then continue the loop?

You may find my SW below:

"my loop"

"my execution"

                oscp = new
                VisaInstrument("USB0::2391::6003::MY47150538::0::INSTR"); // DSO5032A@SES-Lab

            catch (System.ApplicationException err)
                Console.WriteLine("*** VISA Error Message : " + err.Message);

            catch (System.SystemException err)
                Console.WriteLine("*** System Error Message : " + err.Message);
            catch (System.Exception err)
                System.Diagnostics.Debug.Fail("Unexpected Error");
                Console.WriteLine("*** Unexpected Error : " + err.Message);


private static void Initialize()
        oscp.DoCommand("*RST"); // Reset the to the defaults.
        oscp.DoCommand("*CLS"); // Clear the status data structures.
        oscp.DoCommand(":CHANnel1:PROBe 10");
        oscp.DoCommand(":CHANnel2:PROBe 10");
        oscp.DoCommand(":CHANnel1:RANGe 0.4");//50mv/div
        oscp.DoCommand(":CHANnel2:RANGe 8");//1.0v/div

        oscp.DoCommand(":CHANnel1:DISPlay 1");
        oscp.DoCommand(":CHANnel2:DISPlay 2");

        oscp.DoCommand(":CHANnel1:OFFSet 3.15");//3.15v
        oscp.DoCommand(":CHANnel2:OFFSet 1");//1v

        oscp.DoCommand(":TIMebase:RANGe 2e-6");//200ns

        oscp.DoCommand(":TIMebase:REFerence CENTer");

        oscp.DoCommand(":TIMebase:POSition -6e-7");

       oscp.DoCommand(":TRIGger:EDGE:SOURCe CHANnel2");

        oscp.DoCommand(":TRIGger:SWEep NORMal");

        oscp.DoCommand(":TRIGger:MODE EDGE");

        oscp.DoCommand(":TRIGger:EDGE:SLOPe POSitive");

private static void Capture()
    oscp.DoCommand(":ACQuire:TYPE NORMal");
    oscp.DoCommand(":ACQuire:COMPlete 100");
    oscp.DoCommand(":DIGitize CHANnel1");

private static void Analyze()
     byte[] ResultsArray; // Results array.
    int nLength; // Number of bytes returned from instrument.

     oscp.DoCommand(":WAVeform:FORMat BYTE");
     oscp.DoCommand(":WAVeform:POINts 1000");

    Console.WriteLine("Reading preamble.");
    double[] fResultsArray;
    fResultsArray = oscp.DoQueryValues(":WAVeform:PREamble?");

    double fFormat = fResultsArray[0];
    double fType = fResultsArray[1];
    double fPoints = fResultsArray[2];
    double fCount = fResultsArray[3];
    double fXincrement = fResultsArray[4];
    double fXorigin = fResultsArray[5];
    double fXreference = fResultsArray[6];
    double fYincrement = fResultsArray[7];
    double fYorigin = fResultsArray[8];
    double fYreference = fResultsArray[9];

    // Read waveform data.
    nLength = oscp.DoQueryIEEEBlock(":WAVeform:DATA?", out ResultsArray);
    Console.WriteLine("Read waveform data ({0} bytes).", nLength);

    if (File.Exists("c:\\scope\\data\\waveform.csv"))
    StreamWriter writer =

    for (int i = 0; i < 1000; i++)
    writer.WriteLine("{0:E}, {1:f6}",
    ((float)i - fXreference) * fXincrement + fXorigin,
    ((float)ResultsArray[i] - fYreference) * fYincrement + fYorigin);



Thanks a lot!