Tektronix Technical Forums are maintained by community involvement. Feel free to post questions or respond to questions by other members. Should you require a time-sensitive answer, please contact your local Tektronix support center here.

How to check if a command is successfuly executed in GPIB

Models 2400, 2401, 2410, 2420, 2425, 2430, 2440, 6430
Post Reply
Sean87
Posts: 5
Joined: October 15th, 2011, 1:10 pm
Country: Netherlands

How to check if a command is successfuly executed in GPIB

Post by Sean87 » October 27th, 2011, 12:33 am

Hi all,

This is my first post here on KEITHLEY forum and I am looking forward to learn a lot from you guys. Cheers!

I am trying to make a remote software to communicate with Model 2400 SMU (And later I am going to expand it to 7001 switch and 6485 -). At the moment I can communicate with instrument using the program I made in Visual C# and it works fine, but the problem is I could not figure out a way to check if a command was really successful or not (the only way now avilable to me is just listening to buzzer!).

I think that commands which does not end with '?' does not return anything. Is that right?

Here is my code for execution of commands:

Code: Select all

        /// <summary>
        /// Execute and returns a single command
        /// </summary>
        /// <param name="command">command to be executed</param>
        /// <param name="flush">Flush and End</param>
        /// <returns>Responce if avilable, if not, string.empty</returns>
        public string ExecuteCommand(string command, bool flush = true)
        {
            try
            { 
                if (command.EndsWith("?")) //Command ends with '?' which indicates there should be a reply from instrument
                {
                    this.Device.WriteString(command, flush);
                    DoTimer(); //Delay 1000ms
                    return Device.ReadString();
                }
                if (!command.EndsWith("?")) //Command does NOT end with '?' which indicates there is no reply from instrument
                {
                    this.Device.WriteString(command, flush);

                    if (Device.ReadString() == null || Device.ReadString() == string.Empty) //What to do with commands which does not return anything?
                    {
                        return command + "\tExecution Failed!";
                    }

                    return command + "\tExecuted Successfuly.";                    
                }
            }
            catch (SystemException ex)
            {
                Error.Add("Command Execute failed!", ex.Source, ex.Message);
                return "Command Execute failed!";
            }

            return string.Empty; //Command does not return anything so retuning empty 
        }
Plesae let me know if you need more details. And FYI I am using Agilent 82357A GPIB and usinc Ivi.Visa.Interop as COM

Regards,
Sean.

Andrea C
Keithley Applications
Keithley Applications
Posts: 1390
Joined: October 15th, 2010, 10:35 am
Country: United States
Contact:

Re: How to check if a command is successfuly executed in GPI

Post by Andrea C » November 10th, 2011, 5:44 am

Hi Sean,

Good question!

First you are correct that if the command does not end with a question mark, then there is no expectation of a response from the instrument.

For the case where you are sending commands that do not terminate with a question mark, you can still obtain information about the outcome of the command processing.
The Status Structure of the instrument can give you an indication if an error condition has occurred (due to a command syntax error for example).

In the 2400 Manual, there is a simple example in Table 15-4. And then the following page gives an elaboration about what each bit within the event register is indicating.

Andrea

Post Reply

Return to “2400 Series SourceMeter”

Who is online

Users browsing this forum: No registered users and 3 guests