Download - LED project abstact
-
7/30/2019 LED project abstact
1/6www.edn.com Septemb er 4 , 2003 | ed n 89
ideasdesign
Edited by Bill Travis
You can connect seven-segmentLCDs using only a two-wire inter-face (Figure 1). The two-wire inter-
face may be at the field-effect, direct-drive LCD or at a serial interface (such asI2C) that uses an eight-pin microcon-troller.The design in Figure 1 uses an At-
mel (www.atmel.com) ATtiny12 micro-controller, IC1. V
CCcan range from 2.7 to
5.5V. Each digit receives drive from an 8-bit 74HC164 shift register, which pro-vides seven outputs for each of the seg-ments and one output for a decimal pointor a colon.The data input to the shift reg-ister drives the LCDs common terminal.Software for the eight-pin microcon-troller generates the required symmetri-cal ac square wave between the segmentsand the common terminal (Listing 1,which you can find at the Web version of
this Design Idea at www.edn.com). Thisgeneration entails shifting the seven-seg-ment data and decimal points to the ap-propriate outputs and setting the shift-register-input/LCD-common-terminalto low at a less-than 1-msec rate. A delay
of 16 msec followed by shifting the samedata complemented, as well as the com-plement of the LCD common terminalwith another 16-msec delay, provides thesecond half of the required ac waveform.Because field-effect LCDs takes tens ofmilliseconds to respond, the rapid data-
shifting and display-common changingdoes not affect the displayed image. Youcan use the two 16-msec delays per cyclefor application processing.
Directly driving the segments allowsthe display of not only the numbers zeroto nine, but also any combination of seg-ments and decimal points. You can usethe eight-pin ATtiny12 with a built-in, 1-MHz clock oscillator to produce the de-scribed two-wire signal and to provide atwo-wire I2C application interface. Thededicated use of the microcontroller for
display control and its I2
C interface freesthe application hardware and softwarefrom timing and resource restrictions.The implemented I2C interface operatesat 0 to 40 kbps and is bit-synchronous.One data protocol allows for the input of
a two-byte binary integer, which convertsto decimal for display. A third byte in theprotocol indicates any decimal points orcolons. This data format allows the easi-est interface from binary measurement orcalculation. A second protocol acceptsfour bytes that directly control the seg-
ments and decimal points, allowing thedisplay of a variety of characters andsymbols possible on a seven-segment dis-play. You can download the source codeand hex object file for the ATtiny12 fromthe Web version of this Design Idea atwww.edn.com. The code provides atwo-wire I2C interface for a four-digitLumex (www.lumex.com) LCD-S401C-52TR display.
37 36 345 6 7 35 8
3 4 115 6 10 12 13
A BCLK
CLR
QAQB QC QD QE QFQG QH
9821
VCC
VCC
VCC
32 31 299 10 11 30 12
3 4 115 6 10 12 13
A BCLK
CLR
QAQB QC QD QE QFQG QH
9821
VCC
IC6LCD40
27 26 2413 14 15 25 16
3 4 115 6 10 12 13
A BCLK
CLR
QAQB QCQD QEQF QGQH
9821
VCC
23 22 2017 18 19 21 28
3 4 115 6 10 12 13
A BCLK
CLR
QAQB QC QD QE QFQG QH
1G 1F 1E 1D 1C1B 1A 1DP 2G 2F 2E 2D 2C2B2A 2DP 3G 3F 3E 3D 3C3B 3A 3DP 4G 4F 4E 4D 4C4B 4ACOL
CM2
CM1
9821
VCC
IC574HC164
IC474HC164
IC374HC164
IC274HC164
401
1234
8765
ATTINY12
SCK
RSTPB3PB4GND
VCCPB2PB1PB0
IC1
BACKLIGHT CONTROL
R110k
C10.1 F
DSD
SRDASRCL
TOINTO
F igure 1
Seven-segment LCD uses two-wire interfaceHans Krobath, EEC, Nesconset, NY
A minuscule 8-bit microcontroller
lets you use a two-wire interface todrive a seven-segment LCD.
Seven-segment LCD uses
two-wire interface ..........................................89
Open-collector output provides
fail-safe operation..........................................90
Low-battery indicator uses fleapower ......90
Indicator has electronic lens ....................92
Thermal switches provide
circuit disconnect............................................98
Buck-boost regulator suits
battery operation ........................................100
Publish your Design Idea in EDN. See theWhat s Up sect ion a t www.edn .com.
-
7/30/2019 LED project abstact
2/690 edn | Septemb er 4 , 2003 www.edn.com
ideasdesign
It is common practice to use digitalopen-collector outputs for controlunits in industrial applications. Using
these outputs,you can switch loads, suchas relays, lamps, solenoids, and heaters.One possible problem inherent to thistype of output stage is a short circuitfrom the output to the supply voltage (of-ten, 24V). This condition can destroy theoutput transistor if it lacks protection.The simplest approach to solving thisproblem is to use a fuse.This method has
a disadvantage, however: You have to re-place the fuse after it blows. APTC (resettable) fuse is often tooslow to protect the transistor under theshort-circuit condition. Another possi-bility is to use a current source as theswitching element. This approach is safeand simple, but it produces heat duringthe error condition. If the power ratingand the cooling of the transistor are in-adequate, the transistor fails because ofthermal overload. The circuit in Figure1 shows another simple approach to the
fail-safe protection of such switching de-vices.
The principal function of the circuit isto switch off the transistor if the voltageon the collector is higher than a prede-termined value.Under normal switchingconditions, transistor Q
1should saturate
when it turns on with a voltage lowerthan 0.2V between the collector of Q
1and
ground. If a short circuit exists on theoutput J
1or if the impedance of the load
is lower than specified,the voltage on thecollector of Q
1rises because too little
base-current feed comes from the controllogic (via R
4) to saturate Q
1. If the collec-
tor voltage of Q1 reaches the switchingvoltage on the base of Q
2, Q
2turns on,
and Q1
switches off. You can adjust thisswitching point with the R
1-R
2voltage di-
vider.Now,the voltage on the collector ofQ
1rises to 24V, and the output stays in
the switched-off condition. To reset thecircuit, you must switch the steering out-put from the control logic to low. Now,
the Schottky diode,D1, is forward-biased
and thus discharges C1
and switches offQ
2. If the steering output from the con-
trol logic again switches to the high state,Q
2stays in the switched-off condition
during the charging of C1. If the output
of Q1 is not overloaded, Q1 saturatesagain and stays switched on.If the outputhas a short circuit to the supply or it isoverloaded, then Q
1switches on only
during the charging of C1; after this time,
Q2
switches off Q1. The maximum load
current depends on the value of R4, the
output voltage from the control logic,and the current gain of Q
1.
FROM CONTROL LOGIC
OR MICROCONTROLLER
2
3 IC11
R41.2k
D1BAT85
C147 F
R12.2k
R210k
R3100
Q2BC548
J1 OUTPUT
2
1
24V
D21N4004
Q1BD139
F igure 1
Open-collector output provides fail-safe operationSusanne Nell, Breitenfurt, Austria
This circuit provides fail-safe protection of an open-collector output stage.
It is always desirable to use a low-battery indicator that consumes as lit-tle power as possible. For a 9V, 450-
mAhr alkaline battery, a 50-A low-battery indicator can by itself run the bat-tery down in a little more than a year.Bat-tery-powered devices that need to runcontinuously for a long time require bat-tery indicators that consume minimalpower. The circuit in Figure 1, designed
for a 9V battery, uses extra-low power.When the battery is at full charge (9V),
the circuit draws 1.4-A current. At theindication-threshold voltage, 6.5V, thecircuit draws 1 A. Assume that the av-erage operating current is 1.2 A. Thecircuit uses 42 mAhr in a four-year peri-od, less than 10% of the batterys ratedenergy. A red LED, D
2, flashes periodical-
ly when the battery voltage drops below6.5V. IC
1, an LTC1540, is a nanopower
comparator with a built-in 1.18V refer-
ence. A battery-voltage divider compris-ing R
1and R
2, and a positive-feedback
network,R3, feed the positive input of the
comparator. The positive feedback gen-erates hysteresis in the comparator. Thenegative input of the comparator receivesbias from the reference voltage, throughthe R
4-C
1delay circuit.
During normal operation, the voltageat the positive input is approximately1.62V when the battery is at 9V. The out-put of the comparator is at a high state,
such that no current flows through D1and D
2. When the battery voltage drops
Low-battery indicator uses fleapowerYongping Xia, Navcom Technology, Redondo Beach, CA
-
7/30/2019 LED project abstact
3/692 edn | Septemb er 4 , 2003 www.edn.com
ideasdesign
below 6.5V, the voltage at the positive in-put drops below the reference voltage atthe negative input. The output of IC
1
switches from high to low, thereby light-
ing the LED, D2. The switchingchanges the voltage at the positiveinput to 0.58V and causes C
1to discharge
through D1
and R6. Because the value of
R6
is much smaller than that of R4, the
voltage at the negative input dropsquickly, according to the time constantthat C
1and R
6set. Once the voltage at the
negative input falls below 0.58V, thecomparator switches back to a high state.This change sets the voltage at the posi-tive input to 1.18V, turns off the LED,and reverse-biases D
1, so the reference
charges C1 through R4. When the volt-age at the negative input again reaches1.18V, the cycle repeats. The LEDs on-time is a function of C
1and R
6, and the
off-time is a function of C1
and R4. With
the values in Figure 1, the on- and off-
times are 20 msec and 10 sec, respective-ly,at 6.5V threshold voltage.At this point,the LEDs on-state current is (6.5V
1.8V)/2.2 k2.1 mA.The average LEDcurrent is (20 msec2.1 mA)/10 sec4.2A.
R22.2M
R410M
IC1LTC1540
C10.33 F
R120M
R320M
R620k
R52.2k
D2LED
D11N4148
9V
V+3
4
8
5
6
HYST
REF
7
2 1
GND
_
+
F igure 1
This fleapower low-battery indicator draws just 1.2-A operating current.
The method for implementing an ex-tended-scale meter described in anearlier Design Idea had a conceptual
error:The meter impedance must changecontinuously, not discretely as expressed(Reference 1). You could achieve the de-sired result by using a digital poten-tiometer controlled by an input voltagevia an appropriate interface. But this ap-proach is probably too sophisticated. Fig-ure 1 shows an alternative approach thatneeds only a small and inexpensive mi-crocontroller. The method exploits the
fact that a dc meter measuresthe average value of a PWM sig-nal: I
AVGI
PEAK(T
PULSEWIDTH)/(T
PERIOD).
Therefore,you can control the currentthrough the meter by changing the pulsewidth of the PWM signal. The PWM-generating software determines the lawthat governs the change in current in themeter. In the process of creating this soft-ware, you can choose expansion of anypart of the scale (Figure 2).
The transfer function, a, represents alinear meter response; b denotes expan-
sion of the beginning of the scale; c indi-cates expansion of the middle of the scale;
and d denotes theexpansion of the upperend of the scale. The curves with highslopes in the graph of Figure 2 corre-spond to expanded scales. You can createthe scale patterns by choosing the thresh-old voltages (breakpoints) and slopes.The circuit resembles an electronic lensattached to the meter, which magnifiesany chosen part of the scale. The ADC in
the microcontroller of Figure 1 trans-forms the measured input voltage into its
8-bit hex equivalent. The microcontrollerprogram (Listing 1 at the Web version ofthis Design Idea at www.edn.com) readsthe hex value and finds a correspondingpulse width from a table in its memory.Finally, the routine generates the PWMsignal with the given pulse width. Figure3 shows the software flow chart for theprocess.
As an example of the method, calculatethe scale expansion of a 100-A dc me-
IOIPPW
PERIOD
OSC
PB7ADC
6
PWM
A
RVPD4
2
VIN
C
R
3
5 MC68HRC908JK1
PERIOD
PW
IQ
IP
TIME
19
F igure 1
Indicator has electronic lensAbel Raynus, Armatron International Inc, Melrose, MA
An inexpensive microcontroller allows you to expand any portion of the scale of a linear meter.
-
7/30/2019 LED project abstact
4/696 edn | Septemb er 4 , 2003 www.edn.com
ideasdesign
ter with a measured-voltage range of 0 to5V. You need to magnify the portion ofthe input from 2 to 3V, from 20 to 70%,leaving 10% at the beginning and 20% at
the end of the scale (Figure 2, character-istic c). Table 1 shows the steps of the cal-culations, which you execute as follows:
1. Choose a number (N) and the val-ues of the measured input voltages, V
IN.
These parameters depend on the desiredaccuracy of the meter scale. As an exam-ple, assume voltages with increments of0.5V for the low slope (Figure 2) and0.1V for the high slope (Table 1, column2). Therefore, N19.
2. Calculate the 8-bit ADCsdigital output, N
IN, for the se-
lected input voltages (column 3): NIN(256/5)VIN51.2V
IN.
3. Transform NIN
from decimal tohexadecimal format (column 4). The er-rors arising from the 8-bit quantizationare insignificant for an analog indicator.
4. Choose the PWM period, T. Thisvalue depends on the rapidity of the in-put-voltage change and should be rela-tively short to prevent needle chatter. As-sume T10 msec for easy Table 1calculations.
5. Calculate the number of timer cycles
for the PWM period.The accuracy of any
microcontrollers time intervals is a func-tion of the accuracy of its oscillator fre-quency, which for the MC68HRC908K1depends on the external RC circuit. Thedata sheet for the IC recommends a tol-erance of 1% or less for these componentsto obtain a clock tolerance of 10% or bet-ter. But it is difficult to find a 10-pF1%capacitor, so this design uses a less ex-pensive 5% capacitor and measures theoscillation frequency. According to the
microcontroller manual,the timing com-
ponents R20 k and C10 pF shouldyield a frequency of approximately 4.5MHz. The measured frequency is 5.75MHz. With the timer/counter prescalerset at 64, the timer-clock period is 44.5sec. Hence, you can calculate the num-ber of timer cycles for any time interval asN
t(t in milliseconds)/(44.5103)
22.5(t in milliseconds). Thus,for T10msec, N
10225 or N
HEX$E1.
6. Determine the duty cycle () of the
PWM signal for each chosen input volt-age, V
IN, as well as the scale-expansion
pattern (column 5);(IV/I
MAX)100%.
You could either read the current value di-rectly from the diagram in Figure 2 (char-acteristic c) or calculate it for three linearparts of the scale with the following equa-tion: I
VI
TiS
i(V
INV
Ti), where I
Vis the
current for the given input voltage VIN
, ITi
is the current for the threshold voltage VTi
(i{1,2,3}),and Siis the slope of each lin-
ear portion of the scale in Figure 2 (char-acteristic c).The expressions for the three
piecewise-linear segments are as follows:
7. Determine the pulse width of thePWM signal: PWT (column 6).
8. Calculate the number of timer cy-cles, N
OUT, for this pulse width by using
50
10
0 100
40 6050
VOLTS
b
20 8030 70
100
90
80
70
60
50
40
30
20
10
0
CURRENT
(A)
VIN
0 1 2 3 4 5
bc
a
d
10 90
0 100
40 60
VOLTS
c
2030 70
10 90
0100
40 6050
VOLTS
a
A
A
A
A
20 8030
1
0
4
5
2 3
70
90
10 90
0 100
40 6050
VOLTS
d
0123
4
01
2
3
1
0
23
45
45
20 8030 70
80
5F igure 2
By selecting slopes and breakpoints, you can expand the bottom (b), the middle (c), or the top (d)
portions of a linear meters response.
RESET
MAIN
START
YES
YES
YES
INITIALIZATION
CLEAR X-REGISTER
CONVERT VIN TO
HEX FORMAT BY ADC
COMPARE VIN WITH VXFROM THE C MEMORY
COMPARE VIN WITH
THE NEXT VX
DOES ITMATCH?
ARE ALL VXCHECKED?
VINV0?
SET PWX
FROM MEMORY
GENERATE PWMSIGNAL
STOP GENERATINGPWM
F igure 3This flow chart shows the steps in the scale-expansion process.
V I S A VT T0 010
251 1 1= = = =; ; / .
V V I A
S A V
T T2 10
80 10
3 270
2 2
2
= =
=
=
; ;
/ .
V V IT 33 = ; TT A
S A V
3
3
80
100 80
5 310
=
=
=
;
/ .
-
7/30/2019 LED project abstact
5/6
Asingle temperature sensor canprovide an interrupt to a micro-controller when the measured tem-
perature goes out of range. You needmultiple temperature sensors when youhave to monitor more than one hotspot. A microcontroller implements theproper protective action when one ofthe temperature monitors detects anovertemperature condition. It is some-times easier and more cost-effective tosimply disconnect the offending circuitfrom the power supply without involv-
ing a microcontroller. A simple ther-mal-protection circuit (Figure 1) in-cludes two temperature switches, IC
1
and IC2, with active-high outputs. Tem-
perature thresholds for these switchesdepend on resistors R
1and R
2, and the
switch outputs connect to the inputs ofa dual-input OR gate, IC
3. OR gates
with more than two inputs are availableif you need more than two tem-perature switches. When excessivetemperature drives either input high,the OR gates output switches high,
causing an SCR (silicon-controlled rec-tifier) to crowbar the power supply and
blow the fuse. You must take precau-tions to ensure that the SCR does nottrigger on a false gate pulse. Power-sup-ply transients can cause a false high sig-nal at the output of the OR gate and
cause the SCR to turn on. Once trig-gered, the SCR cannot turn off, and thefuse blows. A small RC filter, R
3and C
3,
suppresses any gate transients thatwould otherwise turn on the SCR.
Thermal switches provide circuit disconnectMark Cherry, Maxim Integrated Products, Sunnyvale, CA
98 edn | Septemb er 4 , 2003 www.edn.com
ideasdesign
the equation for Nt
and transform thenumber into hexadecimal format(columns 7 and 8).
9. Enter NIN
and NOUT
Listing 1.
You can use any microcontroller witha PWM function and built-in ADC. Theone in Figure 1 has a 12-channel, 8-bitADC and the capability to generate aPWM signal.This microcontroller has 15I/O pins, which are necessary for execut-ing other functions. If your applicationneeds only to effect the meter-scale ex-pansion, then the eight-pin 68HC908-QT2 is probably a better choice. This mi-crocontroller has a built-in oscillator andcosts less than $1.You can download List-ing 1 from the Web version of this Design
Idea at www.edn.com.
Reference
1. Raynus,Abel, Expanded-scale indi-cator revisited, EDN, Aug 8, 2002, pg112.T
TABLE 1EXAMPLE OF MIDSCALE EXPANSION1 2 3 4 5 6 7 8
VIN
NIN
Pulse width NOUT
x (V) NIN
(hexadecimal) (%) (msec) NOUT
(hexadecimal)
0 0.04 2 $2 0 0 0 $01 0.5 25.6 $1A 2.5 0.25 5.6 $6
2 1 51.2 $33 5 0.5 11.2 $0b
3 1.5 76.8 $4D 7.5 0.75 16.87 $11
4 2 102.4 $66 10 1 22.5 $16
5 2.1 107.5 $6C 17 1.7 38.25 $26
6 2.2 112.6 $71 24 2.4 54 $36
7 2.3 117.8 $76 31 3.1 69.75 $46
8 2.4 122.9 $7B 38 3.8 85.5 $55
9 2.5 128 $80 45 4.5 101.25 $65
10 2.6 133.1 $85 52 5.2 117 $75
11 2.7 138.2 $8A 59 5.9 132.75 $85
12 2.8 143.3 $8F 66 6.6 148.5 $95
13 2.9 148.5 $94 73 7.3 164.25 $A4
14 3 153.6 $9A 80 8 180 $B415 3.5 179.2 $B3 85 8.5 191.25 $BF
16 4 204.8 $CD 90 9 202.5 $CB
17 4.5 230.4 $E6 95 9.5 213.75 $D6
18 5 250.9 $FB 99 9.9 222.75 $DF
VCC OUTSET
OUT
SET
GNDHYST
IC1MAX6510
IC374HC32
C10.1 F
C20.1 F
C30.033 F
R1
13.7k
R310k
D1EC103A
1
24
5
3
3
6
VCC OUTSET
OUT
SET
GNDHYST
IC2MAX6510
R213.7k
1
24
56
TO CIRCUIT
5V
POWER
SUPPLY
F igure 1
This thermal-protection circuit includes a crowbar device, D1, driven by thermal switches IC
1and IC
2.
-
7/30/2019 LED project abstact
6/6