• c# app to retrieve 2 CH data from DSA72004B simultaneously

    Hi

    I managed to use one of the sample code in https://github.com/tektronix/Programmatic-Control-Examples/tree/master: CurveQueryWinforms to retrieve data from a DSA72004B scope.
    Some part of the c# code is like the following:

                    // Open connection to the instrument: GPIB0::1::INSTR
                    scope = GlobalResourceManager.Open(txtVisaRsrcAddr.Text) as IMessageBasedSession;
                    // Good practice to flush the message buffers and clear the instrument status upon connecting.

                    scope.Clear();
                    scope.FormattedIO.WriteLine("*CLS");

                    // Query the instrument ID and display
                    scope.FormattedIO.WriteLine("*IDN?");
                    txtInstrumentID.Text = scope.FormattedIO.ReadLine().Trim();
                    Application.DoEvents(); // Allows the UI to update before this method returns

                    Console.WriteLine("IDN? --> " + txtInstrumentID.Text);

                    // Setup the data transfer settings
                    scope.FormattedIO.WriteLine($"DATa:SOUrce CH1,CH2"); 
                    Console.WriteLine($"DATa:SOUrce {dropDownCH.Text}");

                    //scope.FormattedIO.WriteLine("DAT:ENC RIB");     // Signed Binary LSB Format
                    scope.FormattedIO.WriteLine("DATa:ENCdg RIBinary");

                    //scope.FormattedIO.WriteLine("DATA:WIDTH 2");    // 2 bytes per point
                    scope.FormattedIO.WriteLine("WFMOutpre:BYT_Nr 2");

                    scope.FormattedIO.WriteLine("DATa:STARt 0");
                    scope.FormattedIO.WriteLine("DATa:STOP 20000");

                    // Query horizontal scaling factors
                    scope.FormattedIO.WriteLine("WFMO:XINCR?");

                    double xinc = Double.Parse(scope.FormattedIO.ReadString());
                    scope.FormattedIO.WriteLine("WFMO:XZEro?");
                    double xzero = Double.Parse(scope.FormattedIO.ReadString());
                    scope.FormattedIO.WriteLine("WFMO:PT_OFF?");

                    long pt_off = Int64.Parse(scope.FormattedIO.ReadString());
                    scope.FormattedIO.WriteLine("WFMO:XUNit?");

                    string xunits = scope.FormattedIO.ReadString().Trim();
                    Console.WriteLine("x: " + xunits);

                    // Query vertical scaling factors
                    scope.FormattedIO.WriteLine("WFMO:YMUlt?");
                    double ymult = Double.Parse(scope.FormattedIO.ReadString());
                    scope.FormattedIO.WriteLine("WFMO:YZEro?");
                    double yzero = Double.Parse(scope.FormattedIO.ReadString());

                    scope.FormattedIO.WriteLine("WFMO:YOFf?");
                    double yoff = Double.Parse(scope.FormattedIO.ReadString());

                    scope.FormattedIO.WriteLine("WFMO:YUNit?");
                    string yunits = scope.FormattedIO.ReadString();

                    Console.WriteLine("y: " + yunits);

                    // Fetch the raw waveform data

                    scope.FormattedIO.WriteLine("CURVE?");
                    Console.WriteLine("cmd: CURVE?");

                    long ret_val, ret_val1;
                    short[] rawData = new short[4000];
                    short[] rawData1 = new short[4000];

                    ret_val = scope.FormattedIO.ReadLineBinaryBlockOfInt16(rawData, 0);
                    Console.WriteLine("getting data ... " + ret_val);
                    //ret_val1 = scope.FormattedIO.ReadLineBinaryBlockOfInt16(rawData1, 2);
                    //Console.WriteLine("getting data ... " + ret_val1);

    In the data source command, I can specify two channels: CH1,CH2.
    But scope.FormattedIO.ReadLineBinaryBlockOfInt16(rawData, 0); only gives me the data of CH1.
    I wonder
    1. I guess the scope should be able to pass me the data of the two channels, isn't it? Since it can show two channels' data at the same time. 
    2. what API function shall I use to get the data? This may have something to do with NI.VISA library.
    3. My code works when I use GPIB cable to link the scope to my computer. When I connect them with LAN cable, the TCPIP address method never works. What is the trick to use LAN connection?
    Thanks.
  • c# app to retrieve 2 CH data from DSA72004B simultaneously

    Hi

    I managed to use one of the sample code in https://github.com/tektronix/Programmatic-Control-Examples/tree/master: CurveQueryWinforms to retrieve data from a DSA72004B scope.
    Some part of the c# code is like the following:

                    // Open connection to the instrument: GPIB0::1::INSTR
                    scope = GlobalResourceManager.Open(txtVisaRsrcAddr.Text) as IMessageBasedSession;
                    // Good practice to flush the message buffers and clear the instrument status upon connecting.

                    scope.Clear();
                    scope.FormattedIO.WriteLine("*CLS");

                    // Query the instrument ID and display
                    scope.FormattedIO.WriteLine("*IDN?");
                    txtInstrumentID.Text = scope.FormattedIO.ReadLine().Trim();
                    Application.DoEvents(); // Allows the UI to update before this method returns

                    Console.WriteLine("IDN? --> " + txtInstrumentID.Text);

                    // Setup the data transfer settings
                    scope.FormattedIO.WriteLine($"DATa:SOUrce CH1,CH2"); 
                    Console.WriteLine($"DATa:SOUrce {dropDownCH.Text}");

                    //scope.FormattedIO.WriteLine("DAT:ENC RIB");     // Signed Binary LSB Format
                    scope.FormattedIO.WriteLine("DATa:ENCdg RIBinary");

                    //scope.FormattedIO.WriteLine("DATA:WIDTH 2");    // 2 bytes per point
                    scope.FormattedIO.WriteLine("WFMOutpre:BYT_Nr 2");

                    scope.FormattedIO.WriteLine("DATa:STARt 0");
                    scope.FormattedIO.WriteLine("DATa:STOP 20000");

                    // Query horizontal scaling factors
                    scope.FormattedIO.WriteLine("WFMO:XINCR?");

                    double xinc = Double.Parse(scope.FormattedIO.ReadString());
                    scope.FormattedIO.WriteLine("WFMO:XZEro?");
                    double xzero = Double.Parse(scope.FormattedIO.ReadString());
                    scope.FormattedIO.WriteLine("WFMO:PT_OFF?");

                    long pt_off = Int64.Parse(scope.FormattedIO.ReadString());
                    scope.FormattedIO.WriteLine("WFMO:XUNit?");

                    string xunits = scope.FormattedIO.ReadString().Trim();
                    Console.WriteLine("x: " + xunits);

                    // Query vertical scaling factors
                    scope.FormattedIO.WriteLine("WFMO:YMUlt?");
                    double ymult = Double.Parse(scope.FormattedIO.ReadString());
                    scope.FormattedIO.WriteLine("WFMO:YZEro?");
                    double yzero = Double.Parse(scope.FormattedIO.ReadString());

                    scope.FormattedIO.WriteLine("WFMO:YOFf?");
                    double yoff = Double.Parse(scope.FormattedIO.ReadString());

                    scope.FormattedIO.WriteLine("WFMO:YUNit?");
                    string yunits = scope.FormattedIO.ReadString();

                    Console.WriteLine("y: " + yunits);

                    // Fetch the raw waveform data

                    scope.FormattedIO.WriteLine("CURVE?");
                    Console.WriteLine("cmd: CURVE?");

                    long ret_val, ret_val1;
                    short[] rawData = new short[4000];
                    short[] rawData1 = new short[4000];

                    ret_val = scope.FormattedIO.ReadLineBinaryBlockOfInt16(rawData, 0);
                    Console.WriteLine("getting data ... " + ret_val);
                    //ret_val1 = scope.FormattedIO.ReadLineBinaryBlockOfInt16(rawData1, 2);
                    //Console.WriteLine("getting data ... " + ret_val1);

    In the data source command, I can specify two channels: CH1,CH2.
    But scope.FormattedIO.ReadLineBinaryBlockOfInt16(rawData, 0); only gives me the data of CH1.
    I wonder
    1. I guess the scope should be able to pass me the data of the two channels, isn't it? Since it can show two channels' data at the same time. 
    2. what API function shall I use to get the data? This may have something to do with NI.VISA library.
    3. My code works when I use GPIB cable to link the scope to my computer. When I connect them with LAN cable, the TCPIP address method never works. What is the trick to use LAN connection?
    Thanks.