6
September 9, 2010 | EDN 47 readerS SOLVe deSIGN PrOBLeMS EditEd By Martin rowE  and Fran GranvillE design ideas You sometimes need to measure load currents as large as 5A in the presence of a common-mode voltage as high as 500V. T o do so, you can us e Ana- log Devices’ (www.analog.com) AD8212 high-voltage current-shunt monitor to measure the voltage across a shunt resis- tor. You can use this circuit in high-cur- rent solenoid or motor-control applica- tions.  Figure 1 shows the circuit, which uses an external resistor and a PNP tran- sistor to convert the AD8212’s output current into a ground-referenced output voltage proportional to the IC’s differen- tial input voltage. The PNP transistor handles most of the supply voltage, ex- tending the common-mode-voltage range to several hundred volts. An external resistor, R BIAS , safely lim- its the circuit voltage to a small frac- tion of the supply voltage. The internal bias circuit and 5V regulator provide an output voltage that’s stable over the op- erating temperature range, yet it mini- mizes the required number of external components. Base-current compensa- tion lets you use a low-cost PNP pass transistor, recycling its base current, I B , and mirroring it back into the sig- nal path to maintain system precision. The common-emitter breakdown volt- age of this PNP transistor becomes the operating common-mode range of the circuit. The internal regulator sets the voltage on COM to 5V below the power-supply voltage, so the supply voltage for the measurement circuit is also 5V . Choose a value for the bias resistor, R BIAS , to allow enough current to flow to turn on and continue the operation of the regulator. Current monitor compensates for errors Chau Tran and Paul Mullins, Analog Devices, Wilmington, MA + 8 1 HEAVY LOAD BIAS R SHUNT 1k  V P  V + 1k CURRENT MIRROR  ALPHA COM I OUT 6 5 3 2 I BIAS R BIAS I C I B  V OUT R L  AD8212 SENSE  A 1 Figure 1 An external PNP transistor lets you operate the circuit at high voltages. DIs I sid 48 Buck regulator handles light loads 51 Sense multiple pushbuttons using only two wires 52 Tricolor LED emits light of any color or hue wh e u esg pbems sus? Pubsh hem hee ecee $150! Se u desg ies eesg es@ccm.cm.

25620-Sense_multiple_pushbuttons_using_only_two_wires_PDF

Embed Size (px)

Citation preview

8/7/2019 25620-Sense_multiple_pushbuttons_using_only_two_wires_PDF

http://slidepdf.com/reader/full/25620-sensemultiplepushbuttonsusingonlytwowirespdf 1/6

September 9, 2010 | EDN 47

readerS SOLVe deSIGN PrOBLeMS

EditEd By Martin rowE and Fran GranvillE

designideas

↘You sometimes need to measureload currents as large as 5A in the

presence of a common-mode voltage ashigh as 500V. To do so, you can use Ana-log Devices’ (www.analog.com) AD8212high-voltage current-shunt monitor tomeasure the voltage across a shunt resis-tor. You can use this circuit in high-cur-rent solenoid or motor-control applica-tions. Figure 1 shows the circuit, whichuses an external resistor and a PNP tran-sistor to convert the AD8212’s outputcurrent into a ground-referenced outputvoltage proportional to the IC’s differen-tial input voltage. The PNP transistorhandles most of the supply voltage, ex-tending the common-mode-voltagerange to several hundred volts.

An external resistor, RBIAS

, safely lim-its the circuit voltage to a small frac-tion of the supply voltage. The internalbias circuit and 5V regulator provide anoutput voltage that’s stable over the op-erating temperature range, yet it mini-mizes the required number of externalcomponents. Base-current compensa-tion lets you use a low-cost PNP passtransistor, recycling its base current,I

B, and mirroring it back into the sig-

nal path to maintain system precision.The common-emitter breakdown volt-age of this PNP transistor becomes theoperating common-mode range of thecircuit.

The internal regulator sets the voltageon COM to 5V below the power-supply

voltage, so the supply voltage for themeasurement circuit is also 5V. Choose avalue for the bias resistor, R

BIAS, to allow

enough current to flow to turn on andcontinue the operation of the regulator.

Current monitor compensatesfor errorsChau Tran and Paul Mullins, Analog Devices, Wilmington, MA

+

8

1

HEAVY

LOAD

BIAS

RSHUNT

1k VP

 V+

1k

CURRENT MIRROR

 ALPHA

COM

IOUT

6

5

3

2

IBIASRBIAS

IC

IB

 VOUT

RL

 AD8212

SENSE

 A1

Figure 1 An external PNP transistor lets you operate the circuit at high voltages.

DIs Isid

48 Buck regulator handleslight loads

51 Sense multiple pushbuttonsusing only two wires

52 Tricolor LED emits lightof any color or hue

▶wh e u esg pbems sus? Pubsh hemhee ecee $150! Seu desg ies [email protected].

8/7/2019 25620-Sense_multiple_pushbuttons_using_only_two_wires_PDF

http://slidepdf.com/reader/full/25620-sensemultiplepushbuttonsusingonlytwowirespdf 2/6

48 EDN | September 9, 2010

dsignidas

For high-voltage operation, set IBIAS

at200

μA to 1 mA. The low end ensures

the turn-on of the bias circuit; the highend is limited, depending on the deviceyou use.

With a 500V battery and an RBIAS

valueof 1000 kΩ, for example, I

BIAS=(V

+–5V)/

RBIAS

=495V/1000 kΩ=495 μA.The circuit creates a voltage on the

output current approximately equal tothe voltage on COM plus two times theV

BE(base-to-emitter voltage), or V

+–

5V+2VBE

. The external PNP transistorwithstands two times the base-to-emit-ter voltage of more than 495V, and allthe internal transistors withstand volt-ages of less than 5V, well below theirbreakdown capability.

Current loss through the base of thePNP transistor reduces the output cur-rent of the AD8212 to form the collec-tor current, I

C. This reduction leads to

an error in the output voltage. You canuse a FET in place of the PNP transis-

tor, eliminating the base-current errorbut increasing the cost. This circuit usesbase-current compensation, allowing useof a low-cost PNP transistor and main-taining circuit accuracy. In this case,current-mirror transistors, the AD8212’sinternal resistors, and amplifier A

1com-

bine to recycle the base current. Figure 2 shows a plot of output-cur-

rent error versus load current with andwithout the base-current-compensationcircuit. Using the compensation circuitreduces the total error from 1 to 0.4%.You should choose the gain of the loadresistor, R

L, to match the input volt-

age range of an ADC. With a 500-mVmaximum differential-input voltage, themaximum output current would be 500μA. With a load resistance of 10 kΩ,the ADC would see a maximum outputvoltage of 5V.EDN

1.2

1

0.8

LOAD CURRENT (A)

OUTPUT-

CURRENT

ERROR (%)

0 1 5

1.4

0.6

0.4

0.2

0

−0.2

−0.4

−0.6

−0.8

−1.2

−1

−1.4

WITH COMPENSATION

WITHOUT COMPENSATION

2 3 4

Figure 2 Internal base-current compensation reduces error.

↘Buck regulators operating inCCM (continuous-conduction

mode) have straightforward operation,allowing for easy calculation of outputvoltage and system design. However,lightly loaded buck regulators operatein DCM (discontinuous-conductionmode), and their operation is morecomplicated. The duty cycle changesfrom a ratio of the output voltage andthe input voltage. A regulator that re-duces a 12V input to 6V has a 50% dutycycle. When the regulator is too lightlyloaded to keep some current continu-ously flowing in the inductor, it enters

DCM. The duty cycle changes to acomplex function of inductor value,input voltage, switching frequency, andoutput current, greatly slowing the con-trol-loop response.

Many buck-controller ICs use a float-ing-gate driver (  Figure 1). You use aseparate supply reference voltage, V

REF,

for high efficiency. During start-up, itpowers the NFET gate driver to a diodedrop below the reference voltage. Suf-ficient voltage is available to drive the

Buck regulator handles light loadsJustin Larson and Frank Kolanko, On Semiconductor, East Greenwich, RI

(6V–D1 )

 VIC=0V

D2 COUT

SOURCE

0V

GATE

Q1

CBOOST

L1 VOUT

0V

 VIN

BOOST

D1

 VREF

6V

BUCK CONTROLLER

Figure 1 Many buck-controller ICs use a floating-gate driver.

8/7/2019 25620-Sense_multiple_pushbuttons_using_only_two_wires_PDF

http://slidepdf.com/reader/full/25620-sensemultiplepushbuttonsusingonlytwowirespdf 3/6

50 EDN | September 9, 2010

dsignidas

gate of the FET because the initial con-ditions dictate 0V on the output and onthe source of FET Q

1.

During CCM, current always flowsthrough the inductor. Q

1or D

2sup-

plies this current during the flyback

event that Q1’s turn-off causes ( Figure

2). The flyback event creates a voltageat the source of Q

1, and the drop across

D2

limits this voltage, making it a nega-tive voltage with respect to ground. Suf-ficient voltage is available to drive Q

because the CBOOST

capacitor boosts the

gate voltage. This boost provides a high

voltage to the boost pin and the resul-tant negative voltage on the Q

1source.

The system enters DCM when theload drops to the point at which the av-erage current demand is less than one-half the current ripple. Diode D

2pre-

vents reverse current in the inductor.Depending on the chip you use, theoutput may overshoot due to the slowerresponse time of the control loop. Theregulator may also miss pulses and gen-erally operate unpredictably. After Q

turns off, CBOOST

starts to bleed downthrough the boost pin and D

1( Figure

3). The extended off time of Q1in DCM

starts to discharge the CBOOST

capacitor.At approximately 3V across C

BOOST, Q

does not turn on until the output capaci-

tor, COUT, discharges adequately to pro-vide a lower voltage on the source of Q

1

than that of the boost pin through D1.

This behavior is unacceptable in a volt-age regulator.

High temperatures create a situationwith higher leakage currents. You don’tknow the temperature coefficient of the current into the boost pin, so youshould also check operation at low tem-perature. Evaluate the system to deter-mine the lowest capacitor value, usingthis result in your worst-case evaluation

simulations. You can thus ensure thatthe design will operate in DCM by in-creasing the value of C

BOOST. You could

also increase the reference voltage towhich D

1connects. You may want to

consider replacing D1

with a low-leak-age Schottky diode. If none of these ap-proaches results in reliable operation,you can switch to an IC that uses a gatedriver referenced to ground or modifyyour design to use a synchronous-buckarchitecture.EDN

 VREF

6V

D2 COUT

SOURCE

GATE

Q1

CBOOST

L1 VOUT

8V

 VIN

BOOST

D1

BUCK CONTROLLER

(0VD2)+VCBOOST

(0VD2 )

Figure 2 During CCM, current always flows through the inductor. Q1

or D2

suppliesthis current during the flyback event that Q1’s turn-off causes.

8V+VCBOOST

COUT

SOURCE

GATE

CBOOST

L1

 VOUT

8V8V 0V

BOOST

D1

BUCK CONTROLLER

D2

Q1

 VIN

 VREF

6V

Figure 3 The CBOOST capacitor discharges when the regulator goes into DCM.

yOu dON’t kNOw

the teMPerature

cOeffIcIeNt Of thecurreNt INtO the

BOOSt PIN, SO yOu

ShOuLd aLSO check

OPeratION at LOw

teMPeature.

8/7/2019 25620-Sense_multiple_pushbuttons_using_only_two_wires_PDF

http://slidepdf.com/reader/full/25620-sensemultiplepushbuttonsusingonlytwowirespdf 4/6

September 9, 2010 | EDN 51

↘Keyboards and numeric keypads

often provide the user interfacefor electronic equipment, but many ap-plications require only a few pushbut-tons. For those applications, you canmonitor multiple pushbuttons over asingle pair of wires ( Figure 1).

The multichannel 1-Wire address-able switch, IC

1, provides PIO (input/

output ports) P0 through P7, which inthis application serve as inputs. The1-MΩ R

PDresistors connect these ports

to ground to ensure a defined logic-zerostate. Diode/capacitor combination D

1/

C1

forms a local power supply that stealsenergy from the 1-Wire communicationline. Pressing a pushbutton connectsthe corresponding port to the local sup-ply voltage, which is equivalent to logicone. This change of state sets the port’sactivity latch (Reference 1).

As a 1-Wire slave device, IC1

doesn’t

initiate communications. Instead, themaster device—typically, a microcon-troller—polls the 1-Wire line. To mini-mize overhead, IC

1supports conditional

search, a 1-Wire network function. Be-fore using that function, however, youmust configure IC

1according to the

needs of the application. That con-figuration includes channel selection,which defines the qualifying input ports;channel-polarity selection, which speci-fies the polarity of the qualifying ports;choosing a pin or an activity latch forthe port; and specifying whether the de-vice will respond to activity at a singleport, an OR, or at all ports, an AND.

Consider, for example, that IC1

shallrespond to a conditional search if it de-tects activity at any of the eight ports.This search requires a channel-selection

mask of 11111111b for address 008Bh.The numeral one indicates that IC

1has

selected a port. This search also requires achannel-polarity selection of 11111111bfor address 008Ch, where the numeralone indicates a high level, and a control/

status register setting of 00000001b for ad-dress 008Dh, which selects the port’s ac-tivity latch as a source and specifies ORas the conditional search term—that is,activity at any port.

After power-up, the configurationdata must be loaded into IC

1using the

write-conditional-search-register com-mand. Next, the channel-access-writecommand, with FFh as a PIO output-data byte, defines the ports as inputs.Subsequently, the issue of a reset-activi-ty-latches command completes the con-figuration. IC

1is now ready to handle

pushbutton activity.After you configure IC

1, the applica-

tion software enters an endless loop, inwhich a conditional-search commandfollows a 1-Wire reset. With no push-button activity, IC

1does not respond, as

Sense multiple pushbuttonsusing only two wiresBernhard Linke, Maxim Integrated Products Inc, Dallas, TX

8/7/2019 25620-Sense_multiple_pushbuttons_using_only_two_wires_PDF

http://slidepdf.com/reader/full/25620-sensemultiplepushbuttonsusingonlytwowirespdf 5/6

52 EDN | September 9, 2010

dsignidas

a logic one indicates, for the 2 bits im-mediately after the conditional-search-command code. In that case, the mi-crocontroller cancels the conditionalsearch and starts over.

If IC1

responds to the conditionalsearch, the first 2 bits will be one andzero, representing the least-significant

bit of the device’s family code, 29h,in its true and inverted forms. In thatcase, the microcontroller should com-plete the conditional-search flow, whichcomprises a 192-bit sequence. Next, themicrocontroller reads from IC

1by is-

suing a read-PIO-registers commandusing 008Ah, the address of the PIO-activity-latch-state register. The micro-controller then issues a 1-Wire reset, a

resume command, and a resume-and-re-set-activity-latches command. It then re-turns to the endless loop, polling for thenext pushbutton event.

If IC1

responds and no other 1-Wireslave is connected, the microcontrollercould cancel the conditional search afterreading the first 2 bits, issue a 1-Wire

reset, issue a skip-ROM command, andthen read the PIO-activity-latch-stateregister. Next, it must issue a 1-Wirereset, a skip-ROM command, and a re-set-activity-latches command before re-turning to the endless loop.

The code read from the PIO-activi-ty-latch-state register tells which but-ton was pressed. If you press S

1, the

data is 00000001b; if you press S2, it is

00000010b; and so forth. At least oneof the 8 bits will be one. If you press sev-eral buttons after the last reset-activity-latches command, several bits are one.The application software must then de-cide whether such a condition is valid.In the simplest case, one-of-eight code,the software considers all codes thathave several bits at one as invalid.

You can expand this concept to morethan eight pushbuttons. Instead of asso-ciating one pushbutton with one port,you can associate additional pushbut-tons with two simultaneously activatedports, representing two-of-eight code( Figure 2). If another pushbutton ac-tivates P

Xor P

Y, the diodes prevent

that activity from propagating to otherports. Again, the application softwaremust check the code it reads from thePIO-activity-latch-state register to de-cide whether it is valid. The theoreti-cal limit of this concept is 255 pushbut-tons, which require combinations of two,three, four, five, six, seven, or eight di-

odes per additional pushbutton. Whenthe cost of diodes for each additionalpushbutton begins to exceed the bene-fits, you will find that adding anotherDS2408 is more cost-effective.EDN

RefeRence

1 “DS2408 1-Wire 8-Channel Address-able Switch,” Maxim Integrated Prod-ucts Inc, www.maxim-ic.com/ds2408.

1-WIRE

      .

      .

      .

D1

1N4148C1

1 µF

S1

GND GND

RSTZ

 VCC

P0

P1

P2.

.

.

IO

P7

S2

S3

S8

IC1

DS2408

RPD

1MRPD

1MRPD

1M

RPD

1M

Figure 1 This circuit connects to a microcontroller and can monitor eight pushbut-tons using only two wires.

P X SN

 VCC

PY

Figure 2 This circuit can monitor 28additional pushbuttons if you use

diodes to connect them to two ports.

↘The human eye can see any coloras a mixture of blue, red, and

green. The circuit in Figure 1 producesall three colors through an Avago(www.avagotech.com) ASMT-YTB0tricolor LED. You can produce a widerange of colors by varying the current

in the blue, red, and green LEDs.The collector outputs of bipolar differ-

ential stages form the current sources. Aclassic symmetrical differential stage withtwo equal bipolar transistors is a back-bone of almost all bipolar analog ICs. Inthis case, however, the differential stage

is asymmetrical, with a 2-to-1 collector-current distribution instead of the com-mon 1-to-1 ratio at 0V base-voltage dif-ference. The circuit produces the 2-to-1current ratio by paralleling a third equaltransistor, Q

3, to Q

1. The common col-

lector of the paralleled transistor pairconnects to the common emitter of theQ

4/Q

5differential stage. Thus, the base

differential voltages equal 0V at both thestages, and collector currents I

R, I

G, and

IB

are almost equal.

Tricolor LED emits lightof any color or hueMarián Štofka, Slovak University of Technology, Bratislava, Slovakia

8/7/2019 25620-Sense_multiple_pushbuttons_using_only_two_wires_PDF

http://slidepdf.com/reader/full/25620-sensemultiplepushbuttonsusingonlytwowirespdf 6/6

September 9, 2010 | EDN 53

+

+

120 RBA

2.2k

2.2k

RBB

2.2k

2.2k

15k P1

15k

P2

15k

15k

100 nF

OPTICAL OUTPUT(R,G,B MIX)

RED

 ASMT-YTB0

9V

IB

IC1

IGIR

GREEN BLUE

5.6k

82 nF ADR1581 VOLTAGE

REFERENCE

 ADR158182 nF

 VB

 V+

 V−

 V A

IO

≈IO–IB

0% BLUE

100% BLUE ADA4091-2

0% RED

0% GREEN VREF1.25 V

Q3

Q4

IC2

2.5VQ5

Q1 Q2

Q6

IC3A

IC3B

Figure 1 Potentiometers P1

and P2

let you control the color of emitted light.

The differential stages let you vary IR,

IG, and I

Bover a range of 0 to I

O, where

IR+I

G+I

B≈I

O=4.43 mA. This value is ap-

proximate because IR+I

G+I

Bis lower by

a relative value of 3/b, where b is a cur-rent gain of the bipolar transistors. Therelative error is less than 1%. TransistorQ

6equalizes Q

2’s collector voltage with

those of the Q1

and Q3

collectors. Thisapproach preserves the matching of the

base-emitter voltages of Q1, Q2, and Q3.The base currents of bipolar transistorsin this case can reach to as much as 100μA. For this reason, you route the colorand hue control voltages, V

Aand V

B,

which you derive from resistive potenti-ometers P

1and P

2, to the bases of Q

2and

Q5

through voltage-follower-connectedop amps IC

3Aand IC

3B, two halves of 

an Analog Devices’ (www.analog.com)ADA4091-2. The ADA4091-2 has lowpower consumption and input offset

voltage of less than 500 μV with a typi-cal value of 80 μV.

The ADA4091-2 has a maximuminput bias current of 65 nA, whichcauses a negligible voltage drop on re-sistors R

BAand R

BB. This voltage drop

is less than 130 μV. You can achieveeven more accuracy by inserting resis-tors of the same value as R

BAbetween

the respective inverting inputs and out-

puts of both the A and the B followers.This step brings reduction of input-bias-current-caused errors to one-sixth worstcase—down to 1/600.

Potentiometer P1

controls the blueLED’s intensity. At the upper-end posi-tion, when the LED is 100% blue, tran-sistors Q

2and Q

3are off, which turns off 

Q4

and Q5. Thus I

Oflows solely through

Q2

and Q6. The red and green LEDs are

therefore off. When P1’s wiper is at 0V,

output current flows exclusively through

paralleled Q1

and Q3

and distributes it-self to Q

4and Q

5, depending on the po-

sition of the wiper of potentiometer P2.

With P2’s wiper at its upper end, the cir-

cuit emits 100% green light. At 0V, theemitted light is fully red. An intermedi-ate position of the wiper yields a mixtureof red and green. By moving P

1’s wiper

from the ground position, the circuitproduces a mixture of red, green, and

blue.Transistors Q

1, Q

2, and Q

3should

tightly match. You need a difference inbase-emitter voltages of less than 1.5 mV.The same requirement holds true for theQ

4/Q

5pair. Matching requirements are

less stringent for Q6. You should use a

bipolar NPN matched-transistor pair forQ

1through Q

6, or at least Q

1through Q

5,

whereas Q6

is a single transistor. Eventu-ally, you can use three matched-transis-tor pairs.EDN