16 Design Ideas
16 Design Ideas
16 Design Ideas
ideas
anuals for microprocessor-based 3.3V devices often include inFigure 1 VCORE structions for entering a S1 secret mode in which you can test or reset the device. These instructions typiTO C 4 3.3V VCC3 cally ask you to depress and hold one or two switches for a minimum time interS2 6 val. You can adopt several measures to 5 VCC 3.3V 1M IC1 avoid accidentally triggering the test TO C MAX6360 5 WDI mode: Depress two keys, hold both 1 1k RST TO C keys simultaneously and continuously 3 through the minimum interval, and 2 MR GND make the interval two to five seconds long. You can implement such designs with a handful of resistors, capacitors, and diodes and a comparator or two. Such circuitry may remain useless or lack You can activate IC1 only by depressing S1 and S2 simultaneously for at least 2.9 sec. customer appreciation, but it raises cost and complexity while lowering system re- ure 1 monitors two voltages, provides a WDI, which remains floating because the liability. A better alternative is to imple- power-on reset, and includes a watchdog 1-M resistor limits the current to less ment the function with minimal addi- timer. If you dont need the watchdog than 5 A. The transistor turns on and function elsewhere in the system, it can forces WDI to the active-high level only tional components (Figure 1). Microprocessor-based devices usually help to implement the switch-delay cir- when you depress S1 as well. If you deinclude a voltage supervisor that moni- cuitry. Fortunately, the watchdog timer press the switches in reverse order, WDI tors the VCC level and, in some cases, the self-resets when the WDI (watchdog in- switches high only when you close S2. You core voltage. When either voltage drops put) Pin 5 is floating, an indication that must close both switches to activate the below its threshold, the supervisor issues the circuit is disabled. Thus, you can im- watchdog timer. After the timer activates, a reset to the microprocessor. IC1 in Fig- plement the switch-delay circuitry by en- IC1 imposes a 2.9-sec delay before assertabling and disabling the watchdog timer. ing a reset (Pin 1). If you release either Simply provide an interface between or both switches during this 2.9-sec periWDI and the switches that enable the test od, the timer resets. Thus, for the miniWatchdog timer allows mode. The nominal time-out period for mal cost of an npn transistor and three entry to test mode..........................................87 IC1s watchdog timer is 2.9 sec. resistors, the supervisor IC can monitor Transistors offer thermal protection WDI must float when both switches two voltages, provide a power-on-reset for controller....................................................88 are open and when you depress only one. signal, and implement a dual-switch deWhen you depress both, WDI must as- lay function. To monitor one voltage, you Variable load tests voltage sources ..........90 sume either the active-high or the active- can replace IC1 with a MAX823. Linear supply uses switchlow state as specified in the data sheet. mode regulation ............................................90 Note that WDI can remain floating while Sonarlike method detects sinking 5 A. The npn transistor isolates fluid level ..........................................................94 WDI from the switches pulldown resis- Is this the best Design Idea in this tors. When S2 closes, current flows issue? Vote at www.ednmag.com/edn through the base of the transistor to mag/vote.asp.
July 19, 2001 | edn 87
www.ednmag.com
design
ideas
www.ednmag.com
design
ideas
R1 150
Q1 BD135 5V
D5 5.6V
R6 + 1k
C2 1 F/ 10V 0V
pates appreciable power when the mains voltage is high. Figure 2 shows that Q1 must handle nearly 0.75W at nominal input voltage and output current. A TO-92 small-signal transistor, such as a BC337, is adequate for 300 mA, but a medium-power device, such as a BD135, is a better choice. To cut costs, this design uses no heat
This simple plug-in power supply is effective but has no current limiting. www.ednmag.com
design
ideas
2 sink. Inasmuch as the circuitry is inside a nonventilated plug-in plastic 1.75 Figure 2 case, the junction temperature of 1.5 the BD135 attains temperatures greater AT 230V INPUT WITH SWITCH-MODE CURRENT LIMITING than 100 C. 1.25 AT 230V INPUT WITH LINEAR CURRENT LIMITING POWER Assuming that you need current lim(W) 1 iting, if you use a linear current-limiting 0.75 circuit, Q1 needs to dissipate nearly 2.5W in the case of a short-circuited output. 0.5 The probable result is the melting of the 0.25 plastic case and the failure of Q1. To avoid CURRENT-LIMITING SWITCH MODE ZONE that disaster, you can use switch-mode 0 current limiting. Figure 3 shows the cir0 25 50 75 100 125 150 175 200 225 250 275 300 325 350 IOUT (mA) cuit of Figure 1 with some additional components, and Figure 2 shows the benefits of the limiting. Q1 and Q2 act as Without switch-mode current limiting, the circuit of Figure 1 can crash and burn. one emitter follower, but with lower base current. A small-signal Schottky diode, FUSE LINK 1N4001 BAT85, which receives its bias from R3 TRANSFORMER and R2, provides an approximate 0.25V W2 100 F/ + reference voltage for comparator IC1As 25V AC IN noninverting input. The inverting input W1 reads the voltage drop created by the output current across R3. As long as the outQ2 1N4001 1N4001 1k BD136 2.2k put current remains less than 300 mA, the output of the comparator is in 10k Figure 3 1N4001 1N4001 a high-impedance state (openQ1 L1 BC337 collector), and the circuit works like a lin300 H + 2200 F/ 5V ear regulator. R2 R1 16V If the output current reaches 300 mA, + 1k 1k 10 F/ 1k D1 10V the comparators output switches low 1N5818 8 2 5.6V and thus turns off Q1 and Q2. The current 1 0V IC1B LM393 1k through L1 decreases exponentially and 3 IC1A 5 + + R3 LM393 4 D2 7 flows through Schottky diode D1. As the 0.82 BAT85 6 emitter of Q1 is then at approximately 0.5V, the bias current in D2 decreases. The voltage drop across D2 drops by ap- The addition of a few components protects Figure 1s circuit against overcurrent conditions. proximately 10%. As a consequence, the output current decreases until it reaches 270 mA. Then, the comparator switches 5.5 back to a high-impedance state, 5 LINEAR ZONE Figure 4 turning on Q1 and Q2 and again 4.5 biasing D2 with R1 and R2. The current 4 in L1 increases exponentially until it 3.5 again reaches 300 mA. L1 is a 300- H in3 VOUT ductor using a powdered-iron core. Fig2.5 (V) ure 4 illustrates the current-limiting acCURRENT-LIMITING 2 SWITCH-MODE ZONE tion of the switch-mode circuitry.
1.5 1 0.5
0 0 25 50 75 100 125 150 175 200 225 250 275 300 325 350 IOUT (mA)
Is this the best Design Idea in this issue? Vote at www.ednmag.com/edn mag/vote.asp.
Switch-mode current limiting restricts current in Figure 3s circuit to about 320 mA. www.ednmag.com
design
ideas
igure 1 illustrates a simple, costeffective method of measurPOWER FOR RECEIVER PIEZOELECTRIC TRANSMITTER Figure 1 AMPLIFIER FUNNEL TUBE ing the height of fluid in a PIEZOELECTRIC ULTRASONIC TRANSMITTED WAVE column by using ultrasonic waves. Two RECEIVER COAX CABLE piezoelectric transducers generate and listen to the ultrasonic acoustical wave. SCREWADJUSTABLE First, the transmitter piezo element reCHIRP FITTING ceives stimulation from a square wave 8 COP8 that lasts three or four cycles. This techC LM111 OUTPUT COMPARATOR DATA nique produces the most efficient transECHO PULSE L fer of electrical energy to acoustical enECHO 8 ergy. The acoustical wave produced at the EXTERNAL OFFSET REFLECTED WAVE transmitter funnels down into the waveh WAVEGUIDE TUBE guide tube. The wave then concentrates FLUID at the tip of the funnel tube and dispersVESSEL es into the waveguide tube. Part of the wave, or crosstalk, travels up toward the A fluid-level measurement system uses ultrasonic sonar principles. receiver. The other part travels down toward the fluid. The receiver detects and ignores the crosstalk component of the wave. Part of the crosstalk wave is absorbed in the reflection from the receiver, and the remaining energy propagates down toward the fluid. The receiver then listens to the wave that echoes off the surface of the fluid. The first of these waves that strikes the receiver is the component that has propagated toward the fluid. This component is the primary echo. The crosstalk wave arrives shortly thereafter with a reduction in amplitude; this wave constitutes the secondary echo. The COP8 C measures the time it takes to propagate a wave from an arbitrary point on the surface of the Figure 2 fluid to the receiver. You can choose any arbitrary point; the C can offset, or compensate for, the point with To make a measurement, the receiver must ignore the crosstalk wave and concentrate on the the aid of external data. The mechanical primary echo. system in Figure 1 has two major advantages. The first advantage is a cost savings in using two separate piezo elements. Piezo elements for only receivers and only transmitters are less expensive in the ensemble than a piezo element designed for both. The other advantage is the crude mechanical diode that the funnel tube forms. A high-intensity wave propagates from the tunnel, but the receiver recaptures only a small fraction of Figure 3 it. Figure 2 shows a typical waveshape using Panasonic (www.panasonic. com) EFRTSB40KS and EFRRSB40KS piezo elements. Upon application of the Some adjustments in the system produce a more distinct primary echo.
www.ednmag.com
design
ideas
chirp wave, the receiver immeTRANSMITTER POD diately detects the crosstalk 2 J3 wave. After an interval, P3 Figure 4 PIEZO the receiver detects the primary echo, followed closely 1 by the secondary echo. 4 3 2 Reducing the amplitude of the crosstalk wave is convenRECEIVER POD ient (Figure 2) This reduction 5V allows shorter waveguide 500k tubes, increasing the versatility 10 F 7 of the design. One simple way 2 V+ IC2 of reducing crosstalk is to adCLC425 6 3 J1 just the receivers distance from OUT + P1 + 2 X1 the funnel tip, thus moving the V receiver to an antinode. An4 PIEZO other possible adjustment is to 1 2 4 3 1k 1k 10 F reduce the length of the chirp. 5V JP1 JP2 Figure 3 shows the acoustical POWER CABLE 5V 1 1 waves after making the cited 2 2 adjustments. In the circuit of 3 3 Figure 4, the COP8, IC1, puls5V es I/O port G5 at the piezo el5V ements resonant frequency of JP4 JP3 approximately 40.3 kHz. This 5V 1 1 signal switches Q1 and ener2 2 3 3 gizes the series-LC tank circuit, R1 7 5V which has the same resonant 1k 10 3 J2 frequency as the piezo element. IC3 P2 9 2.2k 2.2k LM111W 100 pF This tank circuit boosts the 2.5k 2 + 0.001 F 6 5 voltage across the piezo ele1 0.001 F R2 ment from 5 to 25V p-p. The 2 4 3 1 F 5V 1k receiver then detects and dis5V cards the crosstalk wave. After L1 CLOSE TO L1 a short interval, the crosstalk 47 H M2N7000 Q 1 220 F vanishes, and the COP8 begins 1 F listening to the output of the comparator and begins count5k 0.1 F 0.1 F 0.1 F ing program cycles and, thus, J4 P4 time. 0.05 F 5V When the echo reaches the piezo receiver X1, IC2 amplifies 5V 4 3 2 the echo 1000 times. The am4 plified signal then routes to the 1 5 VCC G6/5 CLK LO/CMPOUT LM111 comparator, IC3. The 6 16 STROBE G5 L1/CMPIN first echo component to reach 7 15 L2/CMPIN+ DATA G3/TIO 8 the amplitude of the threshold L3 IC1 9 set by R1 and R2 trips IC3 to a 10 MHz 3 L4 COP823CJ/SO CLK 10 logic one, and the COP8 stops L5 Y2 11 10 pF counting. Figure 5 illustrates L6 2 12 G7/CKO this process. The COP8 starts L7/MODOUT 14 listening at the rising edge of RST 10 pF RESET GND the trace labeled COP8 Timed 13 Interval, just after the crosstalk becomes silent. When the BASEBOARD echos amplitude crosses the comparators trip voltage, the The ultrasonic fluid-level measurement system uses standard, readily available components.
www.ednmag.com
design
ideas
comparators output switches high, and the COP8 stops timing. Armed with this timing data, converting the figures to a distance is trivial. One constraint is that the leading edge of the echo must occur after the disappearance of the crosstalk. This constraint demands an offset distance or an origin that meets the constraint. Assuming the constraint is satisfied, the distance is d VAIR(t/2). The velocity of sound in air at room temperaFigure 5 ture is 345m/sec, or 0.345 mm/ sec. Solving for distance, d 0.172t mm, with t in microsec- The COP8 doesnt start listening until its timed interval arrives after the disappearance of the crosstalk wave. onds. If you apply this distance to the waveform in Figure 5, the distance from internal pullup, and then an interrupt oc- When the decimal-digit register reaches the origin to the fluids surface is 0.172 curs on a negative edge. At some prede- nine, the next decimal register incremm/ sec (6750 sec 4750 sec)- termined time, the crosstalk is finished, ments, and so on. This operation pro344 mm, or 13.54 in. The COP8 C and the timer starts and counts down un- duces three registers with a decimalcontrols the fluid-level detector. Its first til the interrupt occurs. When the nega- equivalent number. function in producing the waveform is to tive edge arrives on the port pin, the reThe COP8 can then send the data to chirp the piezo transmitter. The C sults of the timer transfer to the upper the display panel. You set the flags in the uses its 16-bit programmable timer to and lower R1B. It remains on the port pin control register for microwire/plus seriperform this step. The timers clock speed to convert the number in the R1B regis- al I/O. This setting configures ports G4 is the same as that of an instruction cy- ters. Because the timer counts down, you and G5 as data out and clock, respectivecle, which is one-tenth of the oscillator need to subtract the number from the ly. You configure ports G0 and G1 as outspeed (10 MHz). You set the appropriate starting point to determine the actual put enable and strobe, respectively. You timer control for PWM. This process time. The difference in fluid level deter- then use a look-up table to send the corproduces a square wave of 40 kHz with mines whether you need a prescaler. Be- rect data to the display driver. The data 50% duty cycle. This figure represents the cause the speed of the timer is 1 sec, any loads into the serial-I/O register. The resonant frequency of the piezo elements value greater than 1 msec shows up as an busy flag in the PSW register initiates the (Figure 5). You should minimize the over-range condition on the display. This data transfer. The transfer continues at crosstalk because it is unusable for the example with a 2-ft change in fluid level clock speed until all 8 bits complete the measurement. The system should gener- uses a prescaler with a factor of four, transfer. The process occurs for all three ate only three or four pulses to perform meaning that the resolution decreases by digits, starting with the least significant this step. More pulses create longer a factor of four. digit. You can download the assembly crosstalk and problems if the piezo reOnce you determine the prescaler, you code for the COP8 from EDNs Web site, ceiver receives the crosstalk and primary need to convert the data in the two 8-bit www.ednmag.com. Click on Search echo at the same time. The timer in the registers to a three-digit decimal equiva- Databases, then enter the software cenC starts and then experiences a short lent for the three seven-segment LED dis- ter to download the file for Design Idea delay. During this delay, port G3 gener- plays. The conversion process is similar #2718. You can find additional informaates the square wave. The short delay lim- to counting. You set up three 8-bit regis- tion about the COP8 at www.national. its the amount of pulses to the piezo ters and increment them each time the com/cop8. transmitter. two 8-bit registers decrement. Consider While the waveform from the trans- the lower 8 bits of the hexadecimal nummitter propagates down the tube, a de- ber. Each time the lower 8-bit register lay ensures that the COP8 does not trig- reaches zero, the upper register decreger during the crosstalk. The Cs timer ments, and the lower bit begins at 0xFFh characteristic then goes into input-cap- again. This process repeats until the ture mode. Because the LM111 has a hexadecimal registers equal zero. Each Is this the best Design Idea in this common-emitter transistor output, the time a hexadecimal number decrements, issue? Vote at www.ednmag.com/edn programming of port G2 uses the weak a decimal-digit register increments. mag/vote.asp.
www.ednmag.com