Instruments and Devices II: Detectors, Oscilloscopes, Multimeters

 

III-1 Introduction: A simple bandstructure description

In this part of the lecture, we will be discussing photodetectors. Photodetectors in their simplest form consist of semiconductors, and can also contain metal-semiconductor or metal-insulator interfaces. In this chapter we will introduce the bare essentials to understand the differences between metals, semiconductors, and insulators. A more comprehensive description will follow in next week’s lectures (part V and/or VI).

 

The term “band” describes a multitude of so-called states (places where electrons can be located) that are very close together energetically, so that they can be regarded as a continuous energy “band”, in which electrons can be located anywhere in space and energy throughout the band.

A “Valence Band” is a band in which electrons are located around an atom. It is the last band that is entirely filled with electrons. Thus, if an electron wants to move to a different state, the electron has to exchange places with another one, since there are no empty states. Therefore, there is no “net” movement (electrons are indiscernible), and no current flows. A “Conduction Band” is a band in which electrons are delocalized (not closely bound to an atom) so that they can move around relatively freely to any adjacent unoccupied states. A conduction band is either empty or partially filled. Thus, there are empty states and a “net” movement of electrons is possible.

Simple pictures for the bandstructure for the three different types of solids (metals, semiconductors, insulators) are shown below:

Figure III-1-1. The bandstructure of metals: the left picture signifies a metal where the conduction band is separated from the valence band, but partially filled. The right picture shows a metal where an empty conduction band overlaps with a valence band. The two cases are macroscopically identical.

Figure III-1-2. The bandstructure of semiconductors and insulators: in both cases, the conduction band is empty and the valence band is filled. The left picture shows a semiconductor; since the energy difference between the states in the conduction band and the valence band are relatively close so that some electrons in the valences band are excited into the conduction band. The conductivity at room temperature is much worse than that of metals – hence the name “semiconductor”. The energy gap between the two bands in the case of an insulator (right picture) is too large to allow any significant amount of conductivity. (The exact borderline between semiconductors and insulators is not perfectly defined; the values in the figure are guidelines)

 

The energy difference between the conduction band and the valence band can be overcome by many sources: thermal energy (T = 300 K, room temperature is equivalent to 0.025 eV), photonic energy (light, X-rays, gamma rays), and incident particles, i.e. protons, neutrons, electrons. The closer the difference between the provided and the required energy is, the higher is the chance that a transition from a lower band to a higher band occurs. Being in a higher state (an “excited” state) is unfavorable for the electron, and it will “relax” into a lower state after a certain “lifetime”.

It should just be noted at this point that the “lack” of an electron in the valence band contributes to the conductivity as well. It should be seen as the remaining electrons having a place to go to. The process is largely equivalent to an electron in the conduction band, but the “ease” with which they move in the respective bands may be different. In some semiconductors the “lack of electron” in the valence band has a higher mobility then the electron in the conduction band, and in some semiconductors the reverse is true. The “lack of an electron” is typically called defect-electron or hole. An electron carries a charge of NEGATIVE 1.6 ´ 10-19 Coulomb, the lack of an electron, a hole, carries a charge of POSITIVE ´ 1.6 10-19 Coulomb. Electrons and holes are often summarized with the term “charge carriers”.

 

III-2 Photodetectors

 

Photodetectors are an essential utility for many optical applications: qualitative and quantitative light intensity measurements, image recognition, video and picture acquisition, and spectral measurements. They come in many varieties, some of which will be discussed below, and are carefully adapted to their application.

The basic principal of any photodetector is that it converts light into electricity, and typically (though not always) the current response is measured. When we discuss the different types of detectors, there are a couple of terms that will be important to describe the dissimilarities.

 

·        Gain describes the ratio of the photocurrent that is detected and the photocurrent that is primarily induced through the absorption of photons (light). Since this definition is a little abstract, it should be noted that this is equivalent to the ratio of the “lifetime” of the electrons (how long they are in the valence band) and the transit time (how long do the electrons need to reach the electrodes). The higher the gain, the more sensitive the detector is.

 

·        Response Time describes the time span that passes between the absorption of a photon and the appearance of the associated current at the electrodes.

 

·        Operating Temperatures defines for which temperature this detector was developed. Since the number of carriers and their mobility varies with the temperature, not every detector will work at every temperature

 

III-3 Photoconductor

 

A photoconductor is the simplest photodetector imaginable. It basically consists of a piece of semiconductor with two electrodes. The choice of semiconductor will determine for which wavelength (= color) the detector will be most responsive. Germanium (Ge) will give infrared sensitivity, Silicon (Si) will respond most to red light, Cadmium Sulfide (CdS) will detect in the green, and Gallium Nitride (GaN) in the blue. The distance between the two electrodes will determine both response time and gain, if the electrodes are close together, the response time will go down and the gain will go up. For photoconductors, the gain can vary from 1 to 1 million, and the response time can vary from 10 nanosenconds (ns) to 1 millisecond (ms).

The basic working principle of the photoconductor is simple. When there is no light, the conductivity is very low (ref. III-1) and no current flows. With incident light, the situation is as follows:

 

Fig. III-3-1. Photoconductor under illumination: the green arrows show photons with enough energy to lift electrons from the valence band into the conduction band. The black arrows show that the two electrons from the valence band will have enough energy after the absorption of the respective photon to be in the conduction band.

 

With electrons in the conduction band and defect-electrons in the valence band (ref. III-1), the conductivity is now substantial. Furthermore, the conductivity will depend directly on the number of absorbed photons, so it makes both a qualitative and quantitative analysis of the incident light beam possible.

The response of the detector is in form of a current – a certain number of electrons passing per second (this is the definition of current). It should be noted that for a photoconductor an applied external voltage (this is called a “bias” !) is necessary to extract the so-called “photocurrent”. Without an applied voltage, the conductivity is still increased, but no current flows and, hence, the absorbed photons are not detected.

For a constant applied external voltage, the current depends linearly on the number of absorbed photons.

 

III-4 Fast Photodiode (p-n)

 

The restriction of the photoconductor – having to have an applied external voltage – is undesirable in some cases, which require detection in a remote location without a constant access to electricity. This is possible with a photodiode.

In order to discuss the photodiode, we need to qualitatively introduce the concept of doping. Basically, doping introduces impurities near the conduction or valence band, making either more electrons available to the conduction band or less electrons (i.e. more “holes”) available to the valence band. The former case is called n-doping and the latter is called p-doping.

A simplified picture of doping is shown below:

Fig. III-4-1. Doping in semiconductors. Both p-doping and n-doping are shown in this figure, for applications only one or the other is used. The energy difference between the doping states and the bands is so small, that thermal excitation at room temperature is enough to add electrons to the conduction band or remove electrons from the valence band, respectively.

 

The geometry of a photodiode is already a lot more complicated than that of a photoconductor. In the simplest case, it consists of a p-doped and an n-doped semiconductor put together. At the contact area between the two semiconductors, the “interface”, the excess electrons on the one side and the lack of electrons on the other side cancel each other out. This is the so-called depletion layer. The depletion layer is the active part in the “p-n” photodiode; it is where the electron in the conduction band and the empty space left in the valence band get separated. This is illustrated below:

 

Fig. III-4-2. P-N photodetector. A photon is absorbed near the depletion layer, and due to the high energy difference, the electron in the conduction band and the now empty state (the hole) in the valence band separate. It should be noted that electrons fall “downwards” in energy, where as holes fall “upwards” in energy. Then, holes move to the left in the p-doped region and electrons to the right in the n-doped region until they are collected at the electrode.

 

The gain of any p-n photodiode is usually designed to be equal to one. The response time greatly depends on the thickness of the depletion layer – the smaller the depletion layer, the smaller the response time. However, since the electron-hole pairs generated by the absorption of a photon only separate in the depletion layer, a photodiode with a small depletion layer is fast, but insensitive.

The typical response time for a p-n photodiode is 0.01 nanoseconds, and the operating temperature is around 300 K (room temperature), since the doping is thermally activated.

To increase sensitivity, a special variety of the p-n photodiode is introduced, the

 

III-5 Sensitive Photodiode (p-i-n)

 

The “i” in “p-i-n” stands for “intrinsic”, meaning that the semiconductor is neither n- nor p- doped. Thus, it is “depleted by nature” and we can customly choose the thickness of the depletion layer. We can increase the sensitivity of the photodiode over several orders of magnitude, but sacrifice response time accordingly.

The response times for p-i-n photodiodes ranges from 0.1 to 10 nanoseconds. The sensitivity is typically 10 to 100 times larger than for the simple p-n photodiode.

 

Fig. III-5-1. P-I-N photodetector: Note the larger “depleted zone” in comparison to a regular p-n photodetector

 

III-6 Metal-Semiconductor Detectors

 

When a semiconductor and a metal are in direct contact, the excessive charge carriers (electrons or holes) will be drawn from the semiconductor into the metal, basically inducing a depleted zone similar to that of a p-n junction. Again, the active zone is around the junction, and the larger the junction, the higher the sensitivity of the detector. Since the light has to go through the metal in this detector, the metal electrode needs to be very thin (around 20 nm, one order of magnitude smaller than the wavelength of visible light) and has to have an anti-reflection coating. The big advantages of metal-semiconductor detector are a very low response time without the expense of sensitivity. This stems from the fact that the charge carrier generation occurs close to one electrode, which makes recombination (the falling “down” in energy of an electrode into a hole) impossible. The schematics are shown below:

 

Fig. III-6-1. Metal – n-type Semiconductor Detector: near the metal – semiconductor interface, the n-doping of the semiconductor is removed, as the electrons are taken by the metal. In the depletion zone near at the interface, photons are absorbed. The electrons are extracted via the n-doped part of the semiconductor, and the holes are immediately removed by the metal. This allows very short response times.

 

The response time is 0.01 nanoseconds, as it was the case for the p-n photodiode, but the sensitivity is higher comparatively speaking.

 

The metal-semiconductor photodetector is used similarly to a regular photodiode and just shows an improved response, albeit it has to be more specifically for certain wavelengths to make sure that the metal electrode is mostly transparent at the chose wavelength, and also to make sure that the semiconductor shows optimum response.

 

However, further down, we will see that sometimes we do not want the response to be a current, but rather packets of charge. This involves the use of a variation of the metal-semiconductor photodetector:

 

III-7 Metal-Insulator-Semiconductor Detectors (MOS Detectors)

 

For this class of detectors, an insulating layer is inserted between the metal and the semiconductor interface. Very often, those insulating layers are metal-oxides or semiconductor-oxides. Thus, they are often called metal-oxide-semiconductor detectors, or MOS detectors. The abbreviation MIS is rarely used. Below is a figure explaining the functionality of the MOS:

Fig. III-7-1. Metal-Oxide-Semiconductor Detector: On the left side you see the charge accumulation (electrons for an n-type semiconductor); a positive voltage is applied to the metal. On the right side the extraction of the charges is shown, with a negative voltage applied to the metal. In both cases the semiconductor acts as ground.

 

It has to be noted at this point that due to the insulator, this system does not conduct a current anymore, even with an applied external voltage and under illumination. The electrons (in the case of an n-doped semiconductor) are still extracted after the illumination of the semiconductor-oxide interface, but the holes stay at the insulator due to the field that stems from the external voltage. Thus, at this interface, a charge is collected – in this case a positive charge.

How can we use that to our advantage? How can we extract the charge? Why do we do this at all?

Well, the first aspect is that we can now let the MOS “sit” in light until it has accumulated enough charge. This is good for low intensity applications that do not need fast responses. We can “integrate” the incoming light flow for a certain time span, until enough light has been absorbed to give us a charge packet large enough for detection. Another incentive is that we can use this to build 2D systems of MOS detectors – this will be discussed in the next chapter.

But how do we extract the accumulated charges? Well, if we apply negative voltage to the n-doped semiconductor (this is called “reverse-bias”), we can extract the positive charge that has been accumulated. The negative voltage attracts the holes.

 

The production of these MOS detectors is not simple. It is a strong necessity to have a very clean interface between the oxide and the semiconductor – any impurities will greatly affect the sensitivity and stability of the MOS. The most common combination is silicon (n- or p- doped) as the semiconductor and SiO2 (silicon dioxide) as the insulator. The interface between those two can be made very clean nowadays and allows for very efficient and stable MOS.

 

III-8 Charge Coupled Devices (CCDs)

 

This type of detector is truly omnipresent these days. You can find them in digital cameras, digital video cameras, even spectrometers, to name some applications. Basically they consist of a one- or two-dimensional array of the previously discussed MOS detectors. This is the simplest and smallest way to build a digital imaging system with a sufficient resolution for today’s applications.

In principle, a CCD is combination of many MOS on a very small area. Thus, it is difficult to connect them individually to measure the charge on each and every MOS in the array – one specific MOS in the array is called “pixel”. So, our problem is that we want to get the information of how much charge is stored in every MOS, but we cannot connect them all with wires, because that would make the CCD too large. To give you an idea, a CCD often has 2 or more “megapixels”, more than 2 million individual MOS detectors on an area of a square inch or even less than that. Additionally, if we want a color image, we need 3 times as many MOS (for red, green, blue), or at least 6 megapixels. Top of the notch digital cameras have even more than that.

Even worse, to minimize “cross-talk” between two MOS pixels – this refers to the case when one MOS has a much higher charge then the ones neighboring it – there are inactive MOS pixels between the active ones. CCDs can have 1 – 3 inactive units per active unit. The former gives better resolution, the latter gives a better contrast. Digital cameras often do not need excellent contrast, whereas spectrometers need to avoid cross-talk above all.

They key to the solution is that MOS detectors that are very close to each other do not have a strong boundary in between them, that there is a way to move the charges around in the system. This is illustrated in Figure III-8-1 below.

During the acquisition of images, there are two periods during an acquisition cycle:

1)     Exposed to light: During this period, the active pixels are kept at a different external voltage than the inactive pixels. This makes sure that the charge accumulates only in the active MOS and does not bleed into an adjacent pixel. In the example in Figure III-8-1, this is shown in part (a). The second pixel is at a higher potential, so all the electrons at the interface are accumulated, while the two adjacent, inactive pixels do not collect any charges. The time span in this mode is called “integration time”, since the charges just add up over time. For low light intensities, high integration times are necessary.

 

Fig. III-8-1. Schematics of a CCD: (a) shows the CCD during image detection and charge accumulation, (b) shows the extraction of the charge

 

2)     After the charge accumulation, it is necessary to extract the charges sequentially. This means that the charges get moved through the rows of the CCD until they get to the last row. This simplifies the wiring tremendously. The extraction is shown in part (b) of Figure III-8-1 above. We now apply a higher voltage to the MOS pixel next to the MOS where the charge was accumulated so that the electrons will be attracted. To make sure that we remove all the charges from the previous pixel, we slowly, not abruptly, decrease the voltage in the former active pixel. Once this is accomplished, the charge has moved one pixel and we repeat this step until we have extracted all the charges in all the MOS. It is important to note that the integration time has to be higher than the extraction time, otherwise the images will be blurry (pixels on the low end of the CCD would be exposed to light from the top pixels), or we will have to use a shutter for the duration of the extraction. Since MOS detectors are reasonably fast, the former is easier to implement and sufficient in most case.

 

Fig III-8-2 below shows the technical implementation of a CCD.

 

Fig. III-8-2. Technical schematics of a CCD: this figure shows how the different pixels are connected to different voltages to allow for the extraction of the charges.

 

It was mentioned earlier that a CCD could be used as a spectrometer. Here, instead of taking a picture (the spatial coordinates), we let the light go past a grating, which diffracts light at different angles depending on the wavelength. So, blue light will hit the CCD detector at a different position then red light. The advantage of such a spectrometer is that it is very fast and efficient, however it broadens sharp peaks, i.e. lasers, and even worse, it does not allow detecting low intensity light that is close in wavelength to high intensity light. This is due to the fact that for low intensity detection we need high integration times, but during the high integration time, the MOS pixel(s) detecting the high intensity light start to bleed into other MOS detectors.

 

III-9 Measuring Electrical Signals

 

Now we have discussed the detectors that convert the information of the light into electrical information. Exactly how do we evaluate the electrical information?

This depends on what we want to measure; if we have an electrical signal that is constant for short times (constant currents are called DC, or direct currents), or if they vary as a sine function with a specific frequency (this is called an alternating current, or AC), then we can employ a multimeter.

If, however, we are interested in the exact shape of the electrical signal as it changes with time, we have to use an oscilloscope. Oscilloscopes are extremely powerful instruments, and the next section will describe the basics of how to use them.

One more thing is important: How do we have to wire the multimeters to measure voltage, current, and both?

1)     Voltage: A voltmeter (multimeter instructed to measure volts) has a high internal resistance. That means that virtually no current will flow through the voltmeter, and therefore it has to be wired in PARALLEL to the device whose voltage we want to measure. Example:

Fig. III-10-1. Voltage measurements

 

2)     Current: An ammeter (multimeter measuring amperes) has a very low internal resistance, and thus has to be wired in SERIES. Example:

Fig. III-10-2. Curent measurements

 

3)     Current AND Voltage: In this case it depends. If our sample were very low-ohmic like the ammeter, measuring the current first would give an inaccurate result for the voltmeter reading. So in that case we have to measure the voltage first, and then the current – see below.

Fig. III-10-3. Current and Voltage measurements for low-ohmic samples

 

 The opposite holds true for a high ohmic sample. In that case, the current has to be measured first, and then the voltage – as shown here:

Fig. III-10-4. Current and Voltage measurements for high-ohmic samples

 

III-10 Oscilloscopes

 

Oscilloscopes come in different varieties and shapes, but typically they can be operated much alike. In the first part of this section, we will focus on exactly how to use an oscilloscope, followed by a brief description on how they work.

 

In Figure III-10-1, you see an HP 54610, a digital storage oscilloscope. Digital just means that all the data that is collected is digitized (meaning, for example, that an input of 4.160 V (= 4,160 mV) will be treated internally as 1000001000000 mV) and can therefore be stored or transferred to a computer readily. Storage means that it can save some pictures that we take – we will come back to this later.

The buttons mostly speak for themselves, but we will introduce the most important ones (going in lines left to right, top to bottom)

 

First we see the product name and a description, HP 54610, 500 Mhz. 500 MHz means that we can measure oscillations with a frequency of up to 500 MHz, or, 2 ns of time passing for a full oscillation. This will suffice for most applications.

 

Fig III-10-1. An HP 54610 Oscilloscope: On the left side, the display shows the currently measured waveform and the currently active menu that can be used with the buttons below. Interestingly, this picture shows the “refresh” of the screen. The very top of the screen has just been drawn, and the bottom half is still glowing from the last drawing. The rest is about to cede illumination.

 

Next are three buttons summarized as “Measure”. Their labels are “voltage”, “time”, “cursors”. Pushing them brings up new menus on the bottom of the display. They are rarely used, so we will omit the more details here.

Next are four buttons in the group “storage”. “Run” starts the storing of the waveforms shown on the screen (it will bring up a menu as well where one can define how many waveforms want to be stored, etc.), “Stop” stops the storing process. “Autostore” starts the storing as well, and you will not have to select any options in the “Run” menu. Finally, “Erase” will delete all the stored data. Storing data is most useful to perform mathematical operations on with modules that can be plugged into the oscilloscope.

Below the measure group, there are two important buttons: “Display” and “Autoscale”. If we do not know what kind of signal we measure, “Autoscale” will search for it for us and display the waveform relatively well. From there, we can display the picture better ourselves. “Display” brings up a new menu on the screen where we can set the waveforms to be displayed as they are measured, or to have them averaged. Averaging is important to remove the noise from low current spectra. The oscilloscope can average 8, 64, or 256 times. Acquisition will take longer, but will be smoother.

 

Fig III-10-2. An HP 54610 Oscilloscope – the control panel magnified

Next is the group summarized as “Horizontal”. The top knob allows us to move the image on the screen to the left or to the right, so we can center it. The button “Main/Delayed” is rarely used. The knob “Time/Div” allows to alter the resolution of the x-axis. In the above picture, you see two identical waveforms. If we only wanted to see one, we would turn the knob to the left, if we wanted to see more, we would turn the knob to the right.

The next group “Trigger”, is complicated, but still very important. Basically the trigger will tell the oscilloscope when one oscillation (one waveform) is complete and a new one starts. There are two standard possibilities: 1) We can tell the oscilloscope that, for instance, when the current we measure goes from 50 mA (the lowest point) to 51 mA (slightly higher), a new waveform has started and a trigger should be sent. The oscilloscope will send a trigger to itself then and acquire the waveform. This works well but we need to have some information about the input signal. 2) We can use an “external trigger”, a reference signal that has the same frequency as our signal. Very often in optoelectronics we can do that, and this will be the easiest possible setup. You can change between those two and other alternatives by pressing the source button.

Finally, the vertical group is relevant for the y-axis, or the signal we put on the input. There are two inputs, so we can display two waveforms at the same time, or show the first minus the second input. Again, with Volt/Div we can select how large we want the signal to be on the screen, and with position we can move it up and down.

 

Figure III-10-3 shows how to set a trigger impulse on the oscilloscope. However, we need to discuss the trigger in more detail. Basically, the trigger is a relict from old analog oscilloscopes and would not necessarily be needed with digital oscilloscopes. It makes it easier though to determine the exact frequency of the waveform to be displayed and therefore the trigger mechanism is kept. Especially with an external trigger displaying the waveform is much easier.

Fig III-10-3. Schematics of trigger operations on a waveform, when the trigger is caused by exceeding a certain voltage (1st method). Alternatively, the trigger pulses UT could just come from an external reference (2nd method).

 

III-11 Multimeters

 

Multimeters have been around in physics for quite some time now. They used to be analog and employed electrical fields (when measuring voltages) or magnetic fields (when measuring currents). Nowadays, they are always digital, that means that the input is transformed into binary data and is then processed. Most of them have an “Autorange” setting, meaning that we only have to select the right input (AC current, DC current, AC voltage, DC voltage) and the instrument selects the right range for us. Figure III-11-1 shows an “old” Keithley 175 multimeter, Figure III-11-2 shows a new “top-of-the-notch” Keithley 2000 multimeter. Both can have the range selected the range manually, or can be set to be “auto-ranging”.

Both also have the capability to send the data to an attached computer, which will use in the lab part quite frequently.

Just a reminder: Select DC whenever the signal is constant (a photodiode illuminated by a steady flow of light, or the voltage of a battery), select AC when the signal is a sinusoidal wave (measuring the voltage from the electricity outlet).

Important Note: Both multimeters feature a red and black input (plus and minus in DC, signal and ground in AC), which is secured with a fuse. This fuse will blow if there are high currents running through the multimeter. In such cases, the white “10 AMPS” has to be used instead of the red input. However, during the lab you will never handle anything higher than tens of milliamps, so you will never need to use this input.

Fig. III-11-1. Keithley 1xx series of multimeters: the bottom row allows to select between AC and DC, select Volts as an input, Ohms, Amps, respectively. The other six buttons select the range, the last one amongst those will select “Autorange”, or 10 MW in the case of resistance measurements (not autorange possible).

 

Fig III-11-2. Keithley 2000 Multimeter: The dark gray round buttons select the type of measurement desired (Volts DC/AC, current DC/AC, regular ohmmeter, high sensitivity ohmmeter with 4 connectors). Next to those buttons the range can be selected, or the round autorange button can be used.

Computer Aided Measurements

 

III-12 Basics of Data Acquistion with a PC

 

Measurements in physics are commonly are very repetitive routine. You once design a measurement and then you will want to do it many times. Also, as we want to often measure small signals very exactly, long waiting times are involved, and a human equipped with a stopwatch, pen, and paper is hardly the most accurate thing in the world. Twenty years ago, the most common measurements with graphic displays were executed with primitive analog oscilloscopes (one could only trace the signal from the screen) and data plotters – analog instruments with a pen. If we wanted to perform operations on these data, we had to manually enter them into a calculator.

With the advent of digital instruments and PCs in parallel, very early on it was clear that it would be of advantage to be able to measure data and store it directly – so that we can average data (increased accuracy), perform operations on it (integration, differentiation, Fourier-transformations, etc), store or print it. For example, the picture below shows how one would go about to measure photocurrent automatically (photocurrent could mean that we take the photodiode from page 4 and attach it to a multimeter set to current measurement mode):

Fig III-12-1. A PC controlling a monochromator via RS-232 and an Ammeter via GPIB (see below for definitions); the semiconductor could be a photoconductor, photodiode, or MOS (see earlier chapters)

Interestingly enough, two of the earliest standards are still around in almost their original form, part of the reason being that the data flow was kept constant over the years – maybe with the exception of detailed imaging applications. The other reason is that measurement instruments are extremely expensive and therefore are kept for many years. Standards that quickly change obsolete themselves quickly.

Let’s begin with the older and more widely used standard:

 

III-13 EIA-232 or RS-232

 

Believe it or not, RS-232, or EIA-232 (after Electronic Industries Association, the committee devising the standard) goes back to the early 1960’s. Back then some companies had big and powerful (by 60’s standards, of course) computers, so-called “Mainframes”. These were expensive and many coworkers had to share one machine. As such, the employees had very simple data entering and monitoring utilities (just a monitor and keyboard), a so-called “Terminal”, that allowed them to enter data and receive results. However, there was no standard for the signals and cables involved in this, and so every company had their own standards.

With more and more terminals and connections needed, this became a problem, and so the EIA conceived the first data-exchange cable protocol. They specified which pins had to carry what specification, defined the voltages used (to this day 5V, much higher than the logical voltages in CPUs or motherboards). During the years, some pins were added to improve functionality and to allow higher signal speeds (starting from 300 bit/s to over 100,000 bits/s today, equivalent to 37.5 to 12,000 characters per second). The basic functionality stays the same – and (almost) every PC on this planet still has one.

Also, 99% of all monochromators (see lecture II) and 90% of all measurement instruments still feature a serial port (typically along with an IEEE-488 port).

The standardized pinout from the latest RS-232 definition, RS-232E is shown below.

Fig. III-13-1. Pinout of the RS-232E standard: Important are the “Transmitted Data” and “Receive Data” – the actual data lines, and “Clear to Send” and “Request to Send”. The rest just adds functionality, for example “Ring Indicator” is used when a modem wants to tell the PC that there is an incoming call.

 

Let’s discuss what the Pins are used for in a simple scenario (which applies to 90 % of all cases). The first question that arises is the transfer speed used, in bit/s. Most scientific instruments use 9600 bit/s. When in doubt, this is a good value to start. Some instruments actually have an autobaud function – meaning that the first character you transmit is a specific one, typically ‘*’. If the device guesses the baud rate correctly (corresponding to bit/s), then it will see the ‘*’ and send one back. That way the computer knows the baud rate is accepted and communication can begin. Otherwise, we repeat.

Before communicating, we need to open a serial port. This will depend on the programming language, for Visual C, I added a definition list of commands in the Appendix III-14 (below).

 

// **********************

// Open a Serial Port

// **********************

int com_port = 2;

int baud_rate = 9600;

 

Open (com_port, baud_rate);

// **********************

 

This actually only initializes the serial port on the computer side, and clears the communication buffer. It will not send anything over the serial port, yet.

When we want to send something, we issue a:

 

// **********************

// Send Data

// **********************

char command[] = “Init”;

 

SendData (command, strlen(command));

// **********************

 

What does SendData do? It first sets Pin 8 (RTS)– indicating it requests to send the data. It then waits until the other side sets Pin 7 (CTS) to 1 – indicating the “clear to send” the data. It then sends the data. There is no real termination to the data. Some instruments expect only a certain length, or expect a certain character and they will then consider the command to be complete.

If the command we send to the instrument (e.g. “Read X”), the instrument will upon receipt of the command get the value X we wanted and try to send it back to us. It will set Pin 8 (RTS) to one and will wait patiently until we are ready. When we are ready, we use the following commands:

 

 

 

// **********************

// Receive Data

// **********************

char data[15];  // empty string

 

ReadData (data, 15);

// **********************

 

This will set Pin 7 (RTS) to 1 if Pin 8 (CTS) is already 1. The port will then receive the data and again wait for some sign that the communication is over.

 

So, if this RS-232 standard is so universal, then why does not everybody use it for everything? Well, it has got a couple of drawbacks:

·        For every instrument that we want to attach to the PC, we need one interface. And although we can get up to 8 or 16 serial ports on a PC with some tricks, most commonly we have two. Not enough for full-scale measurement automation.

·        One line for data transmission and one line for data reception means that we can only send one bit at a time – which is largely limiting the flow of data.

·        No standardized termination means we have to “guess” or “know” when the other side has finished communicating.

However, one big advantage is that in principal one can transmit and receive via the RS-232 at the same time.

 

Devices typically controlled via RS-232 are: Monochromators and filter wheels, although most instruments sport one along with a GPIB port (see below) as well.

The inherent drawbacks inspired a non-profit organization, the “Institute for Electrical and Electronics Engineers”, IEEE, already in the early 1970’s to come up with a much faster, yet very versatile standard:

 

III-14 IEEE-488 or GPIB

 

This new bus was then called IEEE-488 after the inventing organization (Institute for Electrical and Electronics Engineers), but is now commonly called GPIB, the “General Purpose Interface Bus”. The name says it all, at least in the 80’s there were many instruments using the GPIB. Among the list: printers, oscilloscopes, tape drives, multimeters, plotters, adjustable voltage and current sources, lock-in amplifiers, etc. The big advantage is that with one GPIB interface, we can control up to 30 instruments – more than you will normally use in a lab environment. Also, it now has eight (instead of one) signal lines, so at the very list it is eight times faster than the RS-232. Because of very strict shielding and cable length requirements (four and a half yards between instruments, whereas RS-232 can easily go for 20 yards), the data transfer speeds are much higher.

One of the advantages is its versatility. Although the GPIB is typically controlled by the GPIB interface in the computer, it would for example be possible for an oscilloscope to communicate directly with a printer.

There is one important drawback of the GPIB in respect to the RS-232: The “Send Data” lines and “Receive Data” lines are identical. That means that only one instrument on the bus can “talk” at one specific instant.

You see that many devices on one bus that only allows one device to talk at any give time requires a lot more order and control as opposed to the RS-232, where either side can pretty much decide when it is ready to transmit data (Request To Send) or when it is ready to receive data (Clear To Send).

As such, any GPIB interface in a computer will immediately assume the position of a “CIC”, the controller in charge. The CIC acts as a controlling medium, it establishes who is allowed to talk when, and who has to listen. The only thing that the “authority-less” instruments can do is to signal that they require attention: They assert the RQS line, the “ReQuest Service” line. Let us look at the pinouts first, and then discuss the functions:

Fig. III-13-1. IEEE-488 pinout. Note that DIO1 – DIO8 are the actual pins that carry the data.

 

Let’s discuss the functionality of the pins with some pseudo code. We will use the interface language for National Instruments’ GPIB cards, following the language standard NI 488.2; another well-known standard is HP’s SICL (standard interface command language) which behaves similarly but is not as intuitive. All pseudo code will be C / C++ like.

 

// **********************************

// Interface Init

// **********************************

int board=0;     // we can have up

//to four boards per PC 0..3

SendIFC(board);

// **********************************

 

With this command, the GPIB interface card in the PC will change Pin 9 (IFC) from 0 to 1, signaling the devices that there is a CIC, which will manage the bus, and that they should clear all buffers that may have some garbage in it after being turned on.

The next step depends on if your program always knows which instruments are attached and what address they have, you can proceed without the following commands. If you do not know the address of the instruments, then we need to determine at which address there are listeners:

 

// **********************************

// Find Listeners

// **********************************

int loop;

int max_inst=12;

Addr4882_t all_addresses[30];

Addr4882_t all_instruments[max_inst];

 

For (loop=1; loop <= 30; loop++)

{

    all_addresses[loop] = loop;

}

void FindLstn (board, all_addresses, all_instruments, max_inst);

 

// **********************************

 

Basically, what this command does is to send a command to one address after the other asking for some input. When there is no response, then that address is marked “dead”. If there is a response, then the address is added to the array all_instruments. At the end of the command, max_inst will contain the number of instruments found.

With this step, we already encountered two important behaviors “Talk” and “Listen”. Let’s discuss them. We have already established that the computer GPIB card is the CIC, the controller in charge. So, every other GPIB card will wait for the CIC to do something.

First, the CIC will make Pin 11 (ATN) equal to 1. Every interface will now carefully listen what comes next. Via the data pins DIO1 – DIO8 comes the important information:

Bit

DIO8

DIO7

DIO6

DIO5

DIO4

DIO3

DIO2

DIO1

Meaning

0

TA

LA

Address

Address

Address

Address

Address

 

DIO7 will be 0 (because the CIC is talking, no one else should), DIO6 will be 1 (one instrument is supposed to listen) and DIO1 – DIO5 will binary encode the address. 00101 = 5, 01011 = 11, etc). So with the whole command being 00101001 we tell device 9 to listen to the CIC. All other instruments will now relax – they don’t need to do anything.

The CIC now makes Pin 11 (ATN) equal to 0 – no more commands. It will make Pin 6 (DAV) 1, signaling that data is following. In reality, this data is a command in itself (gimme the status byte), but at interface level, it is just data. This “data” is sent byte by byte all the while Pin 6 is equal to 1. When all the bytes are transferred, Pin 6 is set to 0 again (no more data), and Pin 5 (EOI) is briefly switched to 1. This is the end of the sending.

Next, the CIC will want to get the status byte back. It sets itself automatically into listener mode, but first it tells instrument 9 to be the talker now, by first making Pin 11 (ATN) 1 again, and sending 01001001 over DIO1 – DIO8. As soon as Pin 11 is set to 0 again, the instrument with the address 9 will set Pin 6 (DAV) equal to 1 (it wants to transmit data now, i.e. the status byte) and send the status byte over DIO1-DIO8. After the transmission, (DAV) Pin 6 is set to zero and Pin 5 (EOI) is briefly set to 1.

This may sound slow, but it actually happens very fast. Above routine will most likely take a couple of milliseconds and will depend mostly on how fast the instrument readies the status byte for transfer.

 

Now we have a list of all listening devices, we want to make sure that they are all in remote mode (so no one can tamper with them while we use them):

 

// **********************************

// Make instruments remote and reset

// **********************************

EnableRemote(board, all_instruments);

DevClearList(board, all_instruments);

// **********************************

 

EnableRemote will put all devices in “remote” mode, and DevClearList resets all attached devices and clears all communications buffers, so we do not receive any garbage data.

 

This is it. We are now free to communicate with all attached devices. The following is a very short function that provides basic communication with a GPIB interface:

 

// **********************************

// Basic Communications

// **********************************

void raw_io(char *rw, unsigned short len, unsigned short act, unsigned short addr)

{

unsigned int i;

int board =0;

     if (act & 1)

     {

          Send(board, addr,rw, strlen(rw), NLend);

          if ((ibsta) & ERR)

          {

              if (strcmp(rw, "*IDN?")) return;

              else gpiberr ("GPIB Error in rawread,1");

          }

     }

     if (act & 2)

     {

Receive(board, (Addr4882_t) addr, rw, len, STOPend);

     }

    

     if (act & 2)

     {

          for (i=0; i < len; i++)

          {

              if (rw[i] == 13) rw[i]=0;

              if (rw[i] == 10) {rw[i]=0;break;}

          }

          rw[len-1]=0;

     }

}

// *********************************

 

 

III-14 Appendix (a class for communication with a serial interface)

 

This is just the definition file – it gives us some idea how to use the class. For the complete source code, email me separately.

 

// Serial.h

 

#ifndef __SERIAL_H__

#define __SERIAL_H__

 

#define FC_DTRDSR       0x01

#define FC_RTSCTS       0x02

#define FC_XONXOFF      0x04

#define ASCII_BEL       0x07

#define ASCII_BS        0x08

#define ASCII_LF        0x0A

#define ASCII_CR        0x0D

#define ASCII_XON       0x11

#define ASCII_XOFF      0x13

 

class CSerial

{

 

public:

    CSerial();

    ~CSerial();

 

    BOOL Open( int nPort = 2, int nBaud = 9600 );

    BOOL Close( void );

 

    int ReadData( void *, int );

    int SendData( const char *, int );

    int ReadDataWaiting( void );

 

    BOOL IsOpened( void ){ return( m_bOpened ); }

 

protected:

    BOOL WriteCommByte( unsigned char );

 

    HANDLE m_hIDComDev;

    OVERLAPPED m_OverlappedRead, m_OverlappedWrite;

    BOOL m_bOpened;

 

};

 

#endif