Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
FEATURE ARTICLE Roger Johnson & Chris Lentz 2-D Optical Position Sensor p Surprisingly, it isn’t too difficult or expensive to build a twodimensional optical position measurement system. In this article, Roger and Chris show you how to do it. All you need is a PIC, LCD, and some analog gadgets to get moving on the perfect PSD project. Circuit Cellar, the Magazine for Computer Applications. Reprinted by permission. For subscription information, call (860) 875-2199, or www.circuitcellar.com. Entire contents copyright ©2001 Circuit Cellar Inc. All rights reserved. www.circuitcellar.com osition sensitive detectors (PSD) have been around in various forms for over 30 years, working quietly in the background of CD/DVD focus and tracking controls, heat-seeking missile guidance systems, and metrology instruments such as range sensors and 3-D laser trackers. Basically, the PSD gives the analog coordinates of a spot of light on its surface. We’ve designed many optical measurement systems that involve lasers, complex lens designs, sophisticated electronics, computers, and motion control. The PSD is a small but important part of these systems. We were wondering if there was a project that would emphasize PSD technology without the added complexity of other systems. Hardware and on-line stores now sell high-quality laser tools for $40 and up. The basic tool is a laser pointer that’s integrated with a bubble level (i.e., a laser level). This laser beam is projected parallel to the base of the level and establishes a datum; it transfers the line of sight that’s established by the beam with the aid of a position detector. In addition, a laser level can create lines/planes that are plumb and perpendicular to the level planes, which is ideal for construction purposes. CIRCUIT CELLAR® The majority of these tools don’t offer an accurate way to determine the center of the laser beam, so most people just use their eyes. This method is adequate for a good number of construction purposes; however, there are many situations in which more accuracy is required. Some of the detectors included with these tools can measure the position of the laser beam to about one thirty-second of an inch, but there aren’t any high-accuracy sensors to determine the exact location of the laser beam. It dawned on us that such a system would be the perfect PSD project. In this article, we’ll describe the operation of a unique optical sensor and its incorporation into a practical two-dimensional position measurement system. The sensor is a lateraleffect photodiode, which is a special member of the family of optical PSDs. Our system consists of a microprocessor, LCD, some analog electronics, a typical medium-area PSD, and a four-channel, 12-bit A/D converter. The result is an instrument that has a position resolution of onefortieth the diameter of a strand of human hair. We’ll describe how PSDs operate, explain how they’re used, and present you with a specific application. Note that we teamed a PSD with a PIC16F873 microprocessor to produce an instrument that gives the 2-D coordinates of a laser beam on its active surface with a resolution of 0.0001″, an accuracy of 0.001″, and a measurement range of ±0.2″. With this sensor and a laser level, you can measure the straightness, flatness, angle, centration, and parallelism of virtually any surface. To persuade those of you who want such an instrument, our set of PCBs and the PSD are offered at cost. The rest of the project requires inexpensive electronics. You may download the code and board files for the project from the Circuit Cellar ftp site. LATERAL-EFFECT PHOTODIODE The lateral-effect photodiode is a 2-D PSD that generates photocurrents proportional to the position and intensity of the centroid of light on the active area. Two-dimensional Issue 152 March 2003 1 PSDs have sensing areas ranging from less than 0.05″ in diameter to more than 1 square inch. There are three basic types of PSDs: duolateral, tetralateral, and pincushion tetralateral. For additional information about these PSDs, visit the Hamamatsu web site. In addition, there are several other useful sources on the ’Net. Use PSD as a keyword and try your own search! electrode pair is inversely proportional to the distance between the incident spot of light and electrodes. But, this PSD’s complex structure also makes it the most expensive. TETRALATERAL TYPE The PSD shown in Figure 2a has a single resistive layer and four electrodes on the front surface of a photodiode and a fifth lead that provides a bias. The signal photocurrent is divided into four parts that are used to generate the position signal; because of this, it has only half the theoretical resolution of a duolateral type. The equivalent circuit in Figure 2b shows how the four signals interact with each another on one surface. This PSD also has distortion that’s greater on the perimeter. Nevertheless, it’s less expensive, features a simple bias scheme, smaller dark current, and faster response time than a duolateral type. Its position formulas are different than the duolateral type’s formulas, too. DUOLATERAL TYPE The duolateral PSD shown in Figure 1a consists of N-type silicon substrate with two resistive layers separated by a PN junction. The front side has an ion-implanted P-type resistive layer with ohmic contacts on two sides. The backside has an ion-implanted N-type resistive layer with two contacts at opposite ends placed orthogonally to the contacts on the front side. (On a single-axis PSD, the electrodes are placed at opposite ends of one P-type resistive layer.) The equivalent circuit shows how each position signal is divided into two parts by the two resistive layers (see Figure 1b). Because the position signal is divided only into two parts, the duolateral PSD has the highest positiondetecting ability of all the sensor types. The resistivity of the ionimplanted layers is extremely uniform, so the photocurrent for each PINCUSHION TYPE The PSD shown in Figure 3a is an improved version of the basic tetralateral type. It gets its name from the surface contacts that have a large radius rather than straight sides. Viewed from above, the four contacts look like a pincushion. This subtle X X’ b) a) RP X Y P D CJ RSH X' Y' RP Y' Y Figure 1a—The duolateral 2-D PSD has a resistive layer on both sides of a substrate that acts as a PN junction. This type of PSD is the most accurate, has the highest resolution, and is the most expensive—the two resistive layers being the main reason. This type of PSD has only four leads; biasing it is more complicated than the other types of PSDs. b—The interelectrode shunt resistance, RSH , affects frequency response; usually it’s in the neighborhood of 5 to 20 kΩ. In addition, the larger the PSD’s area, the larger the junction capacitance (CJ ) and the slower the frequency response. 2 Issue 152 March 2003 CIRCUIT CELLAR® change greatly improves the extent of the high-linearity region over the tetralateral type while still retaining simple signal processing and biasing. The position equations are the same as the ones for the plain tetralateral type. Finally, the equivalent circuit in Figure 3b shows how the surface electrodes are placed at the four corners instead of the four sides. The PSD will operate at a low frequency in this application. The shunt and positioning resistance and the junction capacitance give a definite limit on how fast they can respond to modulated light. Generally, larger devices are slower than smaller ones; applied bias voltage increases speed, but does so at the expense of dark current. Typical upper-frequency limits are well in excess of 20 MHz. And, if signal-integration schemes are used, PSDs can respond to 100-ps pulses. The position resolution of a PSD is the minimum detectable displacement of a spot of light on the detector’s surface; it is dependent on detector area, light intensity, bandwidth, and temperature. This application will use a low bandwidth, relatively high intensity, and low noise to give good resolution. Position nonlinearity is defined as the geometric position error divided by the detector length; it is measured within 80% of the detector length. In addition, position nonlinearity is typically better than 0.05% for a single-axis PSD, approximately 0.3% for a duolateral type, 1% for a pincushion PSD, and 2 to 3% for a tetralateral type of PSD. It should be emphasized that the PSD is not an imaging sensor. Unlike a CCD sensor, the PSD cannot detect any structure of the pattern of light falling on it. Instead, it senses only where the centroid, or center of “mass,” of the light pattern is falling on it. By design, this is usually a laser beam or small point of light imaged by a lens; it’s not a limitation. Alternatively, if the PSD is flooded in light except for a small dark spot or stripe, it can detect the position of that feature. PSDs are easy to interface—requiring only a few op-amps to produce signals—so it’s no wonder this sensor is used in a variety of applications. www.circuitcellar.com a) b) X Y X Y Rp X' Y' X' Y' P viewed at an angle different from that of the laser axis, the imaged spot of light walks back and forth across a detector as the distance to the surface changes. The position equations for a tetralateral/pincushion PSD are depicted in Figures 4e and f. Note that x and y are the photocurrents flowing from the PSD’s terminals. The denominator term is proportional to the total incident power. Handily, because the position value requires the sum term, the PSD can easily sense optical power. The instantaneous power is displayed with x and y position data. RSH D C J POSITION EQUATIONS Bias Bias When light falls on the PSD, the photocurrent collected by an electrode is inversely proportional to the distance between the incident position and the electrode. Several of the equations in Figure 4 relate the photocurrents I1 and I2 collected by the electrodes with position along the detector, where L is the active length of the PSD and I0 is the total photocurrent. In Figures 4a and b, you see the equations of a 1-D PSD for the two photocurrents with respect to the center of the detector. For these two equations, L is the active length of the PSD, x is the position of the centroid of the light falling on its surface, and I0 is proportional to the incident power. Figure 5 illustrates the coordinates used in describing the terms; the dot indicates the centroid of a light spot. The difference of the two photocurrents is proportional to the position and intensity of the centroid of light striking the detector. As you can see in Figure 4c, dividing the difference of the photocurrents by their sum cancels the I0 term and yields a normalized position value that’s independent of incident optical power. Note that n is a dimensionless position value that ranges from –1 to 1 (i.e., –1 ≤ n ≤ 1). You can solve for x with the equation in Figure 4d. Figure 2a and b—The 2-D tetralateral type of PSD has a single resistive layer on only one surface. The bias electrode is a dedicated lead on the rear of the substrate; it makes biasing simple. A higher reverse bias causes a reduction in the junction capacitance and higher frequency response, but also causes higher dark current. This type of PSD has the worst accuracy—typically a 3 to 6% position error near the perimeter of the device. TYPICAL APPLICATIONS As continuous position sensors, PSDs are unparalleled. Compared with discrete element detectors, such as the charge-coupled device (CCD) sensor, the PSD features nanometer positioning resolution, sub-microsecond response times, simple interface circuits, and high reliability. Optical alignment, involving a laser beam that’s used as a reference line, is the most common application for a PSD. The PSD is mounted on the system being tested (e.g., the wobbling of a shaft, the straightness of machine tool axis, or an aircraft fuselage that’s being assembled). PSDs are also used in more lethal applications. In heatseeking missile systems, a PSD that’s sensitive to IR radiation is located at the focal point of a lens that’s mounted behind a cleardomed window on the front of the missile. After the missile is launched, the outputs of the PSD drive the missile’s fin actuators to keep the IR energy centered on the PSD all the way to the target (i.e., the jet exhaust of an aircraft). The scanning laser level is a more down-to-earth application. In this instance, remote optical targets that contain a 1-D PSD pick up a spinning, level laser beam. These systems are used for pouring concrete and installing ceiling tiles in addition to laying pavement. Note that PSDs are also used in non-contact distance sensors, which incorporate optical triangulation to measure the range to a target surface. The sensor actively projects a laser spot onto a surface. When the spot is www.circuitcellar.com b) a) CIRCUITRY If you decide to build this system, the layout is important for the detector pre-amps and ADC. A ground plane-type board is recommended. We decided to design a PCB because it makes development much easier (see Figure 6). To limit noise pickup, the distance between the PSD and pre-amps should be no more than 1″ (see Figure 7). The four-channel 12-bit ADC should be well bypassed and located near the gainstage amps. Our circuit was laid out on two PCBs. We used a small pre-amp module for the pincushion 10 mm × 10 mm Hamamatsu S5991-01 lateraleffect photodiode and the larger one for the rest of the circuitry. Power comes from the two AA alkaline batteries that we mounted underneath the main board. The batteries drive an efficient charge-pump regulator and voltage inverter for operating the rail-to-rail op-amps. We recommend Linear Technology LT1490s. All of the op-amps use 0.1% precision resistors (these tolerances must be used for measurement accuracy); the rest of the component tolerances are standard. For biasing this PSD, R9 is omitted, and R8 is 100 Ω. The design of this instrument assumes a laser Y X RP Sensitive surface X' Y' P D CJ Bias Figure 3a and b—The 2-D pincushion type of PSD is really a tetralateral type that uses shaped electrodes to increase its linearity near the perimeter. It has the same simple biasing requirements as the tetralateral PSD, but only suffers from positioning errors of approximately 1%. CIRCUIT CELLAR® Issue 152 March 2003 3 POWER DATA a) = b) = – g) The power of the incident beam is proportional to the aforementioned sum signal, S = X1 + X2 + Y1 + Y2. The optical power (in milliwatts) is obtained via the equations in Figures 4h and i, where S is in A/D counts, G is the gain of the second stage, and R is the responsivity of the PSD in amps per watt. Rf is the value of pre-amp feedback resistors. h) c) i) d) e) j) f) k) n–1 n–1 FIRMWARE n–1 n–1 Figure 4—Study these equations carefully. In addition to the position equations a through f, we’ve included the equations for the following: g—the feedback resistor; h and i—the optical power; and j and k—the algorithm for the low-pass filter. pointer of less than 5 mW of power (most operate in the 2- to 3-mW range) and a PSD wavelength responsivity of 0.40 A/W. The first-stage pre-amp gain must be set so that a 5-mW pointer can’t saturate it. Also, this type of PSD divides the total photocurrent seen by each lead by four. Finally, the rail-to-rail pre-amps will saturate when the output reaches 5 V. The feedback resistor value is determined by the equation depicted in Figure 4g. Therefore, the pre-amp gain resistors should be no larger than 10 kΩ. You must allow for ambient light, which will force Rf to be smaller. Four 0.1%-tolerance, 2.4-kΩ resistors were finally selected. The second gain stages U7 and U8 invert the negative output from the pre-amps and offer a means to change the overall gain if a lowerpower pointer is to be used. Note that the PSD used here will become nonlinear if the power density on its surface exceeds 3 W/cm2. The typical 2- to 3-mW laser level has a beam diameter of roughly 3 mm and a power density 70 times less than this limit. Saturation will occur when milliwatt power levels are focused to small spots on the PSD surface. The outputs of the second stages go through 10-Hz, anti-aliasing, lowpass filters and are input to a Microchip MCP3204 four-channel, 4 Issue 152 March 2003 12-bit analog-to-digital converter. Tactile push buttons serve to initiate the nulling functions and to change display modes. A MAX232 sends position data to an external device. Finally, a 2 × 16 LCD that’s addressed in nibble format and based on the Hitachi HD44780 controller is used as the display. SIGNAL PROCESSING The four photocurrents are turned into voltages by the pre-amps and then converted into 12-bit values. Remembering that the normalized position value (n) always ranges from –1 to 1, the problem is how to convert it to dimensional units. So, the first question to ask is: what resolution is desired? Our goal for this instrument was 0.0001″ resolution (2.5 µm). Because the measurement range from the center of the PSD is L/2, 5 mm or 0.1968″, multiply the normalized position value by 1968—the largest position that can be sensed in units of tens of thousandths of an inch. Now, we’ll recap. To display data with 0.0001″ resolution, the PSD signals are processed by: obtaining X1, X2, Y1, and Y2 from the 12-bit ADC and bounds check for high and low; calculating the numerators in Figures 4e and f; multiplying the numerators by 1968; dividing both results by the sum signal (i.e., S = X1 + X2 + Y1 + Y2); and discarding the remainder. CIRCUIT CELLAR® The firmware for this project was written in C using a CCS compiler. The main task is interrupt driven from Timer0 and continually acquires data from the four-channel ADC, solves the position equations, and then displays the data. The Mode and Null push buttons are polled to determine if the operator has pressed them. There are additional points that must be emphasized. The low-pass filter on the outputs of all four gain stages won’t completely remove the strong 120-Hz optical noise signal created by room lights. We also wanted the PSD to be able to produce good results without the use of an optical filter. The firmware implements a first-order infinite impulse response (IIR) low-pass filter. The algorithm for this type of low-pass filter is given in Figure 4j. Note that Cn is the current filter output, and Cn–1 is the previous filter output. Rn is the current input to the filter, and Rn–1 is the previous input to the filter. Finally, f is the 3-dB breakpoint frequency of the filter in hertz, and T is the sample period in seconds. For this filter, the sample period was 10 ms, and the 3-dB breakpoint was 5 Hz. Thus, the algorithm becomes a simple one with two coefficients (see Figure 4k). The actual code fragment is: filter = ((signed int32) olddata * coefs.a) + (((signedint32) newdata + (signedint32) lastsample) * coefs.b); olddata = (signed long int) (filter >> 15); The two coefficients were multiplied by 32,768 before being multiplied by www.circuitcellar.com L I1 I2 X I2 – I1 2X = L I2 + I1 Sensitive surface Figure 5—Take a look at the coordinates we’ve used to describe the terms. Note the dot that indicates the centroid of a light spot. the delayed terms. Then, the result was shifted to the right by 15. This software filter effectively reduces the induced optical noise to low levels. Even under extremely intense lighting, the displayed position is rock steady. NULL AND MODE The process is continuously grabbing the four ADC values. You can pick one of two ways to display this data. Position Display mode shows X and Y displacement in inches, as well as laser power. Voltage Display mode shows the raw voltages in millivolts of the four ADC values. Pressing the Mode switch toggles between these two displays. Because the PSD is sensitive to the centroid of the light pattern on it, any light other than the laser will cause errors. A voltage-nulling process solves the problem. This stores the background values of the four signals without the laser on the PSD. Subsequent position calculations first subtract these stored values. The voltage-nulling process is initiated at power-up, or at any other time, by pressing the Null button in Voltage Display mode. There is also a position-nulling (i.e., zeroing) process that forces the current laser position to be 0.0000 in X and Y. This is handy for observing small changes from a starting point. To initiate the process, press the Null button in Position Display mode. The power in the laser beam is displayed on the right-hand side of the upper line of the LCD. If the bounds checking done during the ADC acquisition process indicates values that are too high (i.e., 0FFF from any A/D conversion result) or too low (i.e., less than 0.05 mW), then the right side of the lower line will display “DETSAT” or “LOWSUM.” This means that the detector is saturated or the sum signal is too low. The RS-232 serial port transmits data at the same rate as it is written to the LCD screen. The format in Position mode is: <X data>, <Y data> Figure 6—The 2-D optical position sensor uses two op-amps in each leg of the PSD. The first stage is located near the PSD, and the voltage generated is negative with respect to ground. The second stage is located on the main board. It inverts the signal from the pre-amp stage back to a positive voltage for the 12-bit ADC. www.circuitcellar.com CIRCUIT CELLAR® Issue 152 March 2003 5 carriage return line feed. The format in Voltage mode is: <X1 data>, <X2 data>, <Y1 data>, <Y2 data> carriage return line feed. With no parity and 1 stop bit, the data rate is 9600 bps. nate indicates a deviation from flatness. For precise applications, the detector is placed in a mount (see Photo 1). We performed some accuracy tests on the system and found it to be within 1% over the LINEARITY entire measurement range. This pincushion PSD will The PSD was securely fixed show some nonlinearity near to a precision translation the perimeter. The conversion stage and moved in increequations assume the PSD is ments. At 0.1000″ the dislinear over its entire range. play indicated 0.0993″, The on-board EEPROM can Photo 1—A laser level and the 2-D optical position sensor measure the flatness which wasn’t bad at all! The store correction coefficients of a surface. Note the four-digit resolution. The main board is only a little larger stages were positioned with and use them to extend the than the LCD. The PSD connected to the system is located in the mount with a micrometers that have linear range all the way to the filter. The Hamamatsu PSD is shown in the foreground on the pre-amp PCB. 0.0005″ resolution; therefore, edges. Doing so, however, this result is consistent with our requires the scanning of the detector MORE APPLICATIONS ability to accurately position the in precise steps over its entire surface A typical application, precisely stages by hand. area and recording all of the errors. measuring the flatness of a surface, Probably the most common appliThis entails precision translation is depicted in Photo 1. The source is cation is to simply mount the PSD stages and is beyond the scope of this a low-cost torpedo laser level. First, to monitor the relative movement project. If you’re interested in doing the laser level is placed on the surbetween the laser beam and PSD. this, mapping in 0.020″ increments face and turned on. The PSD is This setup can measure the moveand storing a gain and offset factor brought next to the level and zeroed. ment of a mirror, the bending and applied to measurements in each When the PSD is scanned along the twisting of a structure caused by increment segment works well. surface, any change in the Y ordi- 6 Issue 152 March 2003 CIRCUIT CELLAR® www.circuitcellar.com loads or thermal upsets, and so on. If the PSD is moved along a single surface, a surface and edge, or is mounted on a moving mechanism, all of the position data should lie in a straight line. If it is not, then the extent of deviation from a straight line should be measured by analyzing the data. This technique is performed to measure the straightness of travel for machine tools, the straightness of shafts, and so on. The PSD usually has to sit in a mount that is suitable for the job at hand. The precision mount that you can see in Photo 1 is used for measuring the straightness and flatness of surfaces and edges. LOOKING FORWARD The purpose of this article was to present you with a 2-D optical sensor that you can use with standard laser tools and pointers. In addition to the advantage of being inexpensive, the sensor has a resolution of 0.0001″ and an accuracy of better than 1%. At some point in the near future, we would like to linearize the PSD even further. To achieve this, we plan on mapping the entire surface of the sensor and storing correction coefficients in the EEPROM. Furthermore, we will probably vary the sample rate, perform different types of signal averaging, and make the electrical center of the mounted PSD coincident with its mechanical center by using a two-step calibration technique. If you were to use other 2-D sensors, all that would change is the preamp resistors (for use with different optical power) and the position equations. In addition, note that silicon PSDs can measure position at near-IR wavelengths, and InGaAs PSDs are available in telecom wavelengths (i.e., 1300 through 1500 nm). As you know, there are other options if you’re interested in this type of opti- cal measurement system but don’t want to invest the time required to make a board. For instance, you can purchase the unpopulated, two-board PCB along with the Hamamatsu PSD for $175. I Roger Johnson is a physicist and senior electro-optical engineer working in the Seattle area. He earned degrees from The University of Washington and The University of Illinois at Champaign-Urbana, and has been designing precision, non-contact, optical measurement systems for 17 years. His interests include miniature optical systems, precision motion control, and instrument design. You may reach him at [email protected]. Chris Lentz is a Washington-based senior electronics designer. For the past 17 years, Chris has been developing hardware and software for electro-optic and electro-mechanical systems. His interests include miniature sensors, tinkering, and supporting science teachers by designing and demonstrating electronic instruments for students. You may reach Chris at [email protected]. PROJECT FILES To download the code, go to ftp.circuitcellar.com/pub/Circuit_ Cellar/2003/152/. SOURCES PCB Set with S5991-01 PSD Aculux (425) 378-0567 www.aculux.com PSDs Hamamatsu Corp. (908) 231-0960 www.usa.hamamatsu.com LT1490 Op-amps Linear Technology Corp. (408) 432-1900 www.linear.com Figure 7—The first and second stages must use micropower rail-to-rail op-amps (LT1490s are used here). A programming port is located at J3 for downloading and flashing the PIC16C873 processor. The gain resistors in the second stages R12 through R19 and those in the pre-amp stages should be 0.1%-tolerance types to achieve the better than 1% accuracy that’s possible with the PSD. www.circuitcellar.com CIRCUIT CELLAR® PIC16F873 Microcontroller Microchip Technology, Inc. (480) 786-7200 www.microchip.com Issue 152 March 2003 7