Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Best error handling for visa calls?

We are using some handlers we've devloped for power supply handling (over GPIB). The power supplies are SCPI and use SCPI/GPIB commands. The handlers use the NI visa api's Read() and Write() functions to send the commands.  They work fine, for the most part, and we've been using them for a number of years.

 

However, we're hearing reports that there may have been a few times that commands were not executed on the power supply and our handler did not report back any error.

 

So, I'm trying to update these handlers to add a little error checking to make them more robust and hopefully we'll catch this error if it happens again.

 

 

 

For error handling, I've come up with 3 solutions and tried all 3. I find some benefits and drawbacks with each and hoped I could get your opinions about error handling as I'm not overly familiar with some of the methods.

 

Method 1:

Set the Event Status Enable register to catch all events (or all that I care about).

Read status byte (STB?) after each command and check the event bit and then event status bit if event bit set.

 

Drawback1: I have one power supply that does not implement this correctly and a second type that appears to not be working correctly either.

Drawback2: Errors are generic. I'll know if I got, for example, a DDE (Device Dependant Error), but I won't know more detail than that.

 

 

 

Method 2:

 After each command sent, read the error queue with the System:Error? query.

 

Drawback: It seems I get a lot of messages back in this method that aren't real errors. It's very "noisy" and I have no way to distinguish real errors from "noise" messages like "query interrupted" and such.

 

Method 3:

Check the return code of the Visa Read() and Write() commands. At first I didn't think this was very robust, but after seeing the list of errors here, I'm beginning to think that these might be more robust and detailed than Method 1. However, I'm not sure.

 

 

 

 

So is method 3 as robust as it looks, or is there a combination/comprimise I can make, or another method I did not mention which is best to trap errors from Visa Reads/Writes to these GPIB power supplies? Keep in mind that the handlers work for a number of different power supplies and its likely that some things may be implemented differently between supplies....so its best to stick with somethind standard that will work on all power supplies.

 

0 Kudos
Message 1 of 6
(7,878 Views)

Hi KingTermite,

 

Method 3 is a pretty robust method.  I would recommend that you use this one.

Cheers,
Kelly R.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 6
(7,857 Views)

Hi Kelly. Thanks for your response.

 

I had a meeting with some co-workers yesterday to discuss the issue. They did not like the method of using return value from the Visa calls because the error list appear to all be interface type errors. It doesn't have any errors that indicate overcurrent, overvoltage, etc.......

 

Am I wrong? Is that a full list? Can I get power supply status from the visa read/write return value?

0 Kudos
Message 3 of 6
(7,855 Views)

Hi KingTermite,

 

To catch the more power supply driven errors, you could use one of the more generic methods (e.g. method 1 or 3, though I still would recommend method 3) to catch that an error occurred.  You could then query the instrument with an error? command (check your manual for the specific command) to see what the exact cause of the error is.

 

 

Cheers,
Kelly R.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 6
(7,827 Views)

Hi KingTermite,

 

I hope you will got answer of the question and may be implemeted something .It was really a nice discussion .I am also facing the same issue where I am communicating with different instrument using  GPIB communication and RS 232 too.

 

Can you share and discuss about the implementation of your initiative.

 

Best Regards

Regards:

Vaibhav Kanchan
Sr. Engineer
NI Certified LabVIEW Developer(CLD)
NI Certified TestStand Developer(CTD}
0 Kudos
Message 5 of 6
(6,783 Views)

Hi KingTermite,

 

I hope you will got answer of the question and may be implemeted something .It was really a nice discussion .I am also facing the same issue where I am communicating with different instrument using  GPIB communication and RS 232 too.

 

Can you share and discuss about the implementation of your initiative.

 

Best Regards

Regards:

Vaibhav Kanchan
Sr. Engineer
NI Certified LabVIEW Developer(CLD)
NI Certified TestStand Developer(CTD}
0 Kudos
Message 6 of 6
(6,783 Views)