Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieving GPIB Instrument error as c# exception

Goal

 

Get any errors from the GPIB card or Agilent DMM.

 

For example, if a command string has a syntax error, say " TRIG:COUNT,1" instead of the correct " TRIG:COUNT 1", I want to capture that error.

 

Setup

 

Windows 7 Pro 64 bit

Visual Studio 2015, creating a Windows executable in c#.

NI-488.2 14.0

NI-488.2 Runtime 14.0.1

NI-488.2 Support for .NET 4.5

NI PCI-GPIB card, using driver 14.0.0.49152

Agilent 34970A DMM/Switch Unit, GPIB address 10

 

Current State

 

  1. I can successfully run the SimpleReadWrite.2012 example that is included with the NI-488.2 Driver:
    1. http://digital.ni.com/public.nsf/allkb/9D74098B0AFB1D2286256EF40063B3E2
    2. Driver installs these examples in: C:\Users\Public\Documents\National Instruments\NI-488.2\Examples\DotNET4.5
  2. GPIB card (interface) errors are captured and show up in my MessageBox
  3. GPIB instrument (device) errors are not seen by the SimpleReadWrite.2012 example.

 

Testing

 

  1. To test for GPIB card (interface) errors, I disconnected the cable or used the wrong GPIB address. These errors were seen as exceptions by the SimpleReadWrite.2012.
  2. To test for GPIB instrument (device) errors, I malformed the SCPI command (example:  "ROUT:CHAN: DELAY 1" , with a space between the ":" and "DELAY"). This malformed command does show an error on the front panel of the Agilent DMM/Switch, but the software does not see it.

 

I am not very experienced with OO/.NET, so this is hopefully a simple oversight on my part.

 

I am used to using the "classic" ibfind and ibdev commands and returning and checking the value of ibsta to get the error conditions. I have attached a screenshot of the Intellisense of the device.write command, showing the Exceptions for this call:

  • GpibException
  • ObjectDisposedException
  • DllNotFoundException
  • EntryPointNotFoundException
  • ArgumentException
  • InvalidOperationException

I thought the last two items above would pass thru any GPIB instrument command issues, but maybe I misunderstand the purpose.

 

If more information is required, I will supply.

 

 

Pete_SDI

 

 

0 Kudos
Message 1 of 9
(5,369 Views)
You have not read the instrument's programming manual, apparently or not studied standard GPIB communication. You need to just issue the ERR? command to the instrument and read the results. The sending software has absolutely no way to tell if your command is not correct.
0 Kudos
Message 2 of 9
(5,353 Views)
Additionally, if you don't want to use any of the existing drivers for the 34970, you should at least look at them. You should also use VISA and not the low level ib* commands. You would have something portable to all other physical connections.
0 Kudos
Message 3 of 9
(5,345 Views)

Mr. Knutson,

 

Thank you for the information; I apologize for my ignorance with these newer approaches.

  

I may not be an expert in the instrument manual, but I am trying to determine if the error lines on the GPIB have been set, which I thought would happen if there was a syntax error on the command sent to the instrument (I thought the instrument would set an the 2-byte status (ibsta?), then I could send the ERR? query).

 

I wasn't intending to use the low level ib* commands, but the serialPort class from the System.IO.Ports & NationalInstruments.NI4882. I am not clear if these are using VISA or not.

 

Pete

 

 

0 Kudos
Message 4 of 9
(5,330 Views)
VISA is not exactly new. It has been around for about 25 years. Is your experience really older than that? The code for the 34970 drivers from both NI and Keysight are based on the VISA standard. Calls to NI4882 just tired you to one vendor and to one physical connection type.
0 Kudos
Message 5 of 9
(5,324 Views)

No arguments about VISA being new.

 

I have had problems with vendor-specific instrument drivers in the early 2000s (and the vendor specific versions of VISA, NI vs Tek, vs Agilent), but I am willing to try the NI 34970 VISA driver.

 

If I do, should I be using the VisaNS interface (the .NET approach)?

 

Or do you have another suggestion for using the VISA driver within a c# project?

 

Pete_SDI

0 Kudos
Message 6 of 9
(5,313 Views)
There is a tutorial at http://www.ni.com/tutorial/4562/en/ that might help you. I have not checked to see if Keysight has an IVI-C, IVI-COM, or IVI-NET driver.
0 Kudos
Message 7 of 9
(5,300 Views)

Dennis,

 

Thank you for your help.

 

I'm working to increase my understanding of the returned status when sending a GPIB command in the new VS Classes for GPIB (NationalInstruments.NI4882, System.IO.Ports.SerialPort) versus the old way (ibwrt).  This newer way is using VISA underneath, I believe.

 

I'm pretty sure that the old way would show an argument error (for example, EARG (4), as shown in http://digital.ni.com/public.nsf/allkb/2FA525A8585A92E9862566EE002A3755), but I'm having a problem seeing the error (exception?) when using device.Write.

 

I will update this thread as a figure things out.

 

 

0 Kudos
Message 8 of 9
(5,100 Views)
A syntax error in the instrument command did not ever cause an EARG error. You always had to and always will have to query the instrument itself to see if the command was properly parsed. No GPIB or VISA driver could possibly contain each and every command set for each and every instrument made. Your expectations are very unreasonable. You will have to set your own error after querying the instrument. It's that simple.
0 Kudos
Message 9 of 9
(5,075 Views)