Lab GPIB instrument guide

This guide gets you started using the course lab setup

GPIB instrument interface in MATLAB

On the course web-page under 'resources' you'll find a file containing a MATLAB script function 'GPIBexample.m'. Copy it to your working directory in your home directory. If you open MATLAB on your lab (!) Linux computer from the directory where you have stored GPIBexample.m, you can look at the function in an editor when you type 'edit GPIBexample.m' or by double clicking it in the left column where the content of your active directory is displayed. Have a good look at the code! You can use it as a template to make your own matlab functions that run the instruments and collect results. You can also run that function by typing 'GPIBexample', but first turn on the 4 GPIB instruments at your work bench: the scope HP54622, the multimeter HP34401, the waveform generator HP33120 and the voltage source HPE3631.
 
  When you run GPIBexample it tests whether the GPIB card and drivers are properly installed on your computer (they should be!) and will give an error message if they aren't. It also calls a command that adds the search path (specifying the directories where matlab should look for functions other than the active directory) to contain the path to the GPIB functions: therefore you should run this function at least once after having started MATLAB!  You can read up on what that function does automatically on the NANO wiki page on GPIB, in case you do want for some reason to perform the steps mentioned in this paragraph manually.

To test that your setup works you can short the 6V output of voltage source to the input of the multimeter, and the output of the waveform generator to a scope probe on the scope plugged in into channel 1. The matlab function 'GPIBexample' will program the waveform generator to produce a saw tooth waveform of 2kHz and 2V amplitude (4V peak-to-peak). If shorted to the scope, you should see that waveform there on the display. It will be read from there into matlab and plotted in figure 1 on your computer. Furthermore, the function will program the voltage source to put out voltages from 0V to 1V in 0.1V steps on the 6V output. Those voltages are then read via the multimeter back into matlab. Figure 2 should then plot the intended output of the voltage source vs the measured voltage from the multimeter. If everything works out well, this should result in a graph with a straight line from (0,0) to (1,1).
 
  To get a list of functions you can use to talk to one instrument, type for example 'HP33120' and then hit the 'TAB' key. This gives you a list of all functions starting with that string to choose for autocomplete. For a short help text type for example 'help HP33120_SetDCOffset'.

Known issues:

  • Driver 'tnt4882' is not present on the machine.

The GPIBexample-function gives an error message to that effect. Solution: reboot your machine with some of the lab devices (scope, waveform generator, multimeter etc.) switched on.

  • Voltage source does not source the voltage it shows when controlled by GPIBexample.

So the voltage is shown on the display, but is not measured by the multimeter. That's an error in the original version of GPIBexample: the voltage has not only be set but the output has to be turned on by HPE3631_operate. Alternatively you can also first manually turn the output on with the appropriate key on the instrument and only then run GPIBexample. However, note that once you have used the matlab GPIB functions, this instrument blocks the keys and pushing them will no longer have any effect. You can hit the 'shift' key (with the text 'local' underneath) to revert back to manual/local control.

  • Some waveform generators show double the amplitude and offset from what they are actually programmed to do.

This is only apparent when you observe that output on the scope. So if you have such a waveform generator you simply need to half 'offset' and 'amplitude' in your programming.

  • GPIB error message on the code line that tries to HP54622_Autoscale.

This may occure when the Scope displayed a 'low battery' error message and initiated a factory reset. After that the GPIB interface is no longer able to talk to the scope on its default address, since the factory reset sets that GPIB address to another number than what the MATLAB GPIB interface expects. You need to reset that number on the scope: push the 'Utility' button, select I/O, then set the 'address' to 24.

  • Scope seems to display waveform that is 10x smaller than expected

This happens when the scope probes' internal pre-amplifcation is not identified correctly. Some of the probes do pass on a 10x higher signal to the scope proper and the scope should recognize those scope probes correctly, but does not always do so. In that case it can help removing and reconnecting the propes at the scope. Observe the value V/div displayed per channel on the top of the scope display. It may for example 'flicker' between 200mV and 2V in that case. WIggle the connection a bit and try to make it settle on the correct value there.

Published Mar. 9, 2023 9:30 AM - Last modified Mar. 9, 2023 9:30 AM