|
September 2002
An A simple, sensor-based instrument you can build yourself derives speed data by measuring the time between two optical events.
Ed Ramsden, Lattice Semiconductor Corp.
My secondary goal was to demonstrate how programmable digital and analog ICs can be used to inexpensively implement a measurement and instrumentation system constructed with tools and materials readily available to or obtainable by a hobbyist. There are four major subsystems in this instrument (see Figure 1): the user interface, sensor interface/receiver, counter/display logic, and master control logic.
The user interface consists of a 7-digit LED numeric display that shows the elapsed time; several status LEDs; and two pushbutton switches, reset and arm. Pressing reset clears the display; arm tells the device to wait for the first beam to be broken. Detailed descriptions of the other three subsystems will be provided further on. Complete schematics of this project can be seen as Web Figure 1 and Web Figure 2.
Sensor Interface/Receiver
Pulsing the beams makes them easier to detect in the presence of constant background light. Additionally, the pulses driving each channel are out of phase with one other to reduce the possibility of interchannel crosstalk. For high brightness, the LED is not driven directly by the output of the master control complex programmable logic device (cPLD) but rather by a discrete transistor switch that can provide up to 100 mA of drive current. Strongly illuminating the LED is desirable because a greater optical signal both increases the maximum allowable range between the LED and photodiode receiver, and also results in less false triggering. When no object is blocking the optical path between the IR LED and the photodiode, the photodiode will generate a small current proportional to the incident light. The photodiode current is then converted to a voltage signal (waveform B) by a load resistor. Blocking the DC component of the detected signal with a high-pass filter reduces the influence of incident ambient light, and also facilitates detecting the incoming pulses by comparing them to a fixed threshold. Because the input signal may be measured in millivolts and may also contain a significant amount of high-frequency noise, amplifying this signal and filtering out the noise can provide a more suitable signal on which to perform a comparison (waveform C). When a suitable threshold is provided, the result of the comparison is a digital signal that corresponds to the pulse train driving the LED for that channel when the beam path is clear (waveform D), and is low when the beam path is blocked. The implementation of each channel’s receiver is shown in Figure 3.
Other than a few discrete components to perform I-V conversion from the photodiode and AC coupling, all of the signal processing functions are performed by a Lattice Semiconductor ispPAC20 programmable analog IC. Two gain/filtering stages are used to boost and clean up the incoming signal, and threshold detection is implemented by one of the device’s comparators, with the actual threshold level being set by an onchip D/A converter. Although this device allows the user to reconfigure the signal path to perform a variety of functions, its major strength in this application is its ability to vary the signal path parameters. Gain, filter corner frequencies, and the threshold trip point can be adjusted electronically, without jumpers, DIP switches, or component resoldering. In addition, the IC’s configuration and all parameter settings are stored permanently in E2CMOS nonvolatile memory, so no additional circuitry is needed to configure the device at power-on.
Digital Subsystems The logic for this instrument was split between two Lattice Semiconductor MACH4 cPLD devices (ispM4A5-64/32). Each can implement logic designs with up to 64 flip-flops and several hundred logic gates. This partitioning decision was driven mainly by packaging options—these particular cPLDs come in a PLCC package (PLCC44). While Lattice Semiconductor makes cPLDs that could easily integrate this whole system many times over in a single device, using many of these larger devices would have required either fabricating a circuit board or buying relatively expensive socket or chip adapters. Either of these options would have violated the spirit of a do-it-yourself project. Because sockets for PLCC44 packages are inexpensive, and, more to the point, I happened to have some handy, cPLDs in this package got used. As it turned out, although the design had to be partitioned between the two devices, the split could be made relatively cleanly, with only a few interconnections between the two cPLDs.
In addition to the clock signal for incrementing the counter, we will need to start, stop, and reset it (to begin a new measurement cycle). Whenever the ENABLE_COUNT input is high, the counter will increment once every millisecond; when it is low, the counter will hold its present count. A high level on the RESET_COUNT line will reset the count back to 00:00.000 regardless of whether it is enabled or not. Because a 7-digit LED display uses 49 segments (not counting the decimal points), and the cPLD that I chose provides only 32 I/O pins, I needed a time-multiplexed technique to drive the display. In a multiplexed display, each digit is controlled by one output line, while all the control lines for corresponding segments (A–G) are tied together. Each digit in the display is activated in sequence one at a time, and the segments corresponding to the activated digit are driven and illuminated. By sequencing the digits sufficiently fast, it is possible to make it appear that all of them are being continuously displayed. Several functions are required to implement a multiplexed display system. First, there must be a way to scan through the display digits. This function is provided by a divide-by-8 counter that is also used to generate the 1 kHz timing signal. Its output is used to direct several activities. The first is digit selection, which is accomplished by a 3–8 decoder. At the same time, an 8–1 multiplexor is used to route the data from the appropriate digit in the counter to a BCD-to-7 segment decoder, which converts the binary-coded-decimal (BCD) data representing the digits into a pattern that will light the appropriate segments on the LED displays (e.g., converts 1001 to 9). For aesthetic reasons, it is nice to blank leading “0” digits in the display, meaning that 4.734 s is displayed as 4.734, not 00:04.734. This makes our instrument a little bit more user friendly, and not looking like a countdown timer from a cheesy spy movie. To do this, I included blanking logic to look at the leading three digits (tens of minutes, minute, tens of seconds) and will selectively disable them depending on which ones are zero. When a digit is to be blanked, this circuit signals the BCD-to-7 segment decoder to shut off all of the segments. Additionally, an external blanking signal from the master control cPLD can shut off all the digits through the BLANK_DISPLAY input line. Another nice feature is to have the counter stop counting once it reaches its maximum count (59:59.999). This provides a clear indication that the maximum time has expired, which might not be obvious if we simply let it roll over to “0.” To do this, terminal count detect logic looks at the output of all the digits, and signals the master control cPLD when this maximum count occurs through the OV_FLAG output line.
The IR LEDs are driven with a 25 µs pulse every 100 µs, each LED being pulsed at a different time. The pulse generator circuit sequences the LED pulses and also determines when to sample the detected signals coming from the analog receiver channels. Because the received signal may contain spurious noise that can create false pulses, or suppress valid ones, incorporating some simple digital filtering into the missing pulse detectors can result in more reliable operation. In this design, a 4-bit counter is maintained in each missing pulse detector. Whenever a pulse is present, this counter increments by 1, reaching a maximum value of 1111 (15). Whenever a pulse is absent, this counter decrements, with a minimum value of 0000 (0). The most significant bit (MSB) of the counter is used to indicate the missing pulse condition, as it requires several missing pulses to cause the counter to decrement to 0111. This effectively prevents a few missing pulses from being recognized as a broken-beam event. Because the optical beams use invisible IR radiation, it is difficult to align the IR LEDs and the photodiodes, or even to tell if the LEDs are illuminated. For a visual indication of proper beam alignment, each beam has two status indicators, displaying BEAM GOOD and BEAM BAD status. When the LED and photodiode for a given beam are properly aligned, the BEAM GOOD indicator will illuminate, and the BEAM BAD indicator will remain dark. In the case of total misalignment, or if the LED and photodiode are separated beyond their maximum range, the BEAM BAD LED will illuminate. In the case of a marginal signal, both LEDs will illuminate, with the relative degree of illumination providing an indication of alignment and signal strength. The overall operation of the instrument is managed by the state controller logic. This circuitry implements the state machine shown in Figure 6 and provides for four operating states: RESET, ARMED, RUNNING, and DONE.
When the state controller is in the RESET state, the counter is reset and disabled. Additionally, the display is completely blanked. The RESET state can be entered at any time by closing the reset input switch. Closing the arm switch, however, will move the controller from the RESET state into the ARM state. In the ARM state, the controller enables the display so it reads 0.000 and waits for beam A to be interrupted. When this event occurs, the controller moves into the RUNNING state where the counter is enabled and begins counting elapsed milliseconds. The controller also waits for beam B to be interrupted. When this occurs, it moves into the DONE state.
To make the instrument state even more obvious, and because they look cool, I added several indicator LEDs to show state (see Photo 1). The red LED indicates the device is ARMED, green indicates RUNNING, and yellow indicates that the measurement cycle is finished. In the RESET state no LEDs are activated. The ABEL code listings for the two cPLDs are available in as Web Listing 1 and Web Listing 2.
Summary
IspPAC, E2CMOS, MACH, and PCC-Designer are registered trademarks of, and ispLEVER is trademarked by, Lattice Semiconductor Corp.
SIDEBARS:
Ed Ramsden, a member of the Sensors Editorial Advisory Board, is Senior Applications Engineer, Mixed Signal Products, Lattice Semiconductor Corp., 5555 NE Moore Ct., Hillsboro, OR 97124-8347; 503-268-8648, fax 503-268-8693, ed.ramsden@latticesemi.com.
|
|
|
|
|