AnsweredAssumed Answered

3458A C DINT

Question asked by lhornburg Employee on May 10, 2013
Latest reply on May 10, 2013 by lhornburg
Attached are two programs that do the same thing.  One is written in C# using Visa Com, the second using C# and Visa.

The purpose of this program is to take a handful of readings using the data type DINT.  Why would you want to use DINT?  It is the fastest method for removing data with all 8.5 digits of resolution.  From the user's manual page 135:

• For DCV digitizing, you should use the SINT memory/output format when
the integration time is   1.4μs. Use the DINT memory/output format when
the integration time is >1.4μs. (These formats are discussed in detail in
Chapter 4.)

To achieve the fastest possible transfer of samples to reading memory and/or the
controller, you can use the SINT output/memory format for integration times up to
10.8u s. However when the integration time is >1.4 us, the A/D converter is
producing more bits of resolution than can be accommodated by the SINT format
(the least significant bit(s) are discarded). Whenever using the SINT
output/memory format with integration times >10.8u s, the multimeter must
convert the data coming from the A/D converter and cannot maintain the
high-speed mode. You should use the DINT memory/output format (which is
compatible with the high-speed mode) when the integration time is >10.8u s.

Program 1:

using System;
using System.Collections.Generic;
using System.Text;
using Ivi.Visa.Interop;

namespace DINT_3458A
    class Program

        public static void Main()
            StringBuilder strDataCommand = new StringBuilder();
            string instAddress = "GPIB0::22::INSTR";
            ResourceManagerClass oRm = new ResourceManagerClass();
            FormattedIO488Class oFio = new FormattedIO488Class();

            //Open session for instrument.
            oFio.IO = (IMessage)oRm.Open(instAddress, AccessMode.NO_LOCK, 2000, "");
            oFio.IO.Timeout = 10000;   //set timeout to 10 seconds

            //Reset instrument
            oFio.WriteString("RESET", true);

            //Query Idendity string and report.
            oFio.WriteString("END ALWAYS", true);   //Set endline termination so you can retrieve data from instrument
            oFio.WriteString("ID?", true);  // Identify Instrument and print to screen
            string strResult = oFio.ReadString();

            Console.WriteLine("Instrument Identity String: " + strResult);

            //Turn off memory, take data directly over bus
            oFio.WriteString("MEM OFF", true);

            // Specify DATA FORMAT
            oFio.WriteString("MFORMAT DINT", true);
            oFio.WriteString("OFORMAT DINT", true);

            //Configure the instrument
            oFio.WriteString("DCV 10", true);
            oFio.WriteString("TRIG AUTO", true);
            oFio.WriteString("NRDGS 5", true);  //Set number of readings per trigger to desired value
            oFio.WriteString("NPLC 1", true); //Set desired number of NPLCs, increase for greater accuracy

            oFio.WriteString("ISCALE?", true);  //Get scale value so you can convert DINT data

            double scale = 0;
            string scalestring;

            scalestring = oFio.ReadString();
            scale = double.Parse(scalestring);//Convert string result to double

            oFio.WriteString("END ON", true);  //Have to use END ON with multiple readings
            oFio.WriteString("TARM SGL", true); //Triggers the instrument 1 time then becomes hold

            byte[] rawdata = new byte[22];  //size should be at least nrdgs*4 +2
            double[] scaleddata = new double[5];   //size should be at least nrdgs

            //Read the DINT data
            rawdata = oFio.IO.Read(22);    //nrdgs*4 + 2

            byte[] tempBuffer = new byte[4];

            //Convert the DINT reading data and scale it with ISCALE then output to screen

            for (int i = 0; i < 5; i++)
                tempBuffer[3] = rawdata[i * 4];
                tempBuffer[2] = rawdata[i * 4 + 1];
                tempBuffer[1] = rawdata[i * 4 + 2];
                tempBuffer[0] = rawdata[i * 4 + 3];
                scaleddata[i] = System.BitConverter.ToInt32(tempBuffer, 0) * scale;

            Console.WriteLine("Measurement Finished\n");

            Console.WriteLine("Press any key to close...");