Upload
chandushar1604
View
220
Download
0
Embed Size (px)
Citation preview
7/30/2019 6726481
1/6
April 22, 2010 | EDN 71
readerS SOLVe deSIGN PrOBLeMS
EditEd By Martin rowEand Fran GranvillE
desgndeas
The circuit in this Design Ideaprovides a way to convey mixed
analog and digital inputs into a micro-controller using one input pin. The out-put of the circuit connects to a micro-controllers ADC-input pin. The circuitcomprises a single variable resistor anda number of SPST (single-pole/single-throw) switches (Figure 1). The push-buttons allow the user to select modes,states, or options, and the analog inputprovides a method of conveying an ad-justable parameter. The implementa-tion requires you to analyze a parallelresistor circuit and a voltage divider.
If you carefully select the resistor val-ues, the circuit provides a discernibleanalog input as well as a number of dis-crete pushbutton-input states.
Selecting the resistor values is a
multistep process, and a spreadsheet,which you can download at www.edn.com/100422dia, aids in performing thecalculations. Say, for example, that youwant 5-kV potentiometer R
ADJto pro-
duce a 0 to 100% value into the micro-controller. Typically, you would mapthe sampled value of 0 to 255 into a0 to 100 value to represent a percent-age. However, by selecting the valuesof bias resistor R
BIAS, you arrive at a di-
rect analog input centered on the 0 to255 range of the ADCfor example,78 to 178.
To compute the appropriate high-
and low-side bias-resistor values, thefollowing equations solve this circuitas a simple voltage divider:
Substituting and solving for RBIAS
and given that the maximum voltage
reports a value of 255, the maximumlow voltage reports a value of 78, themaximum high voltage value reportedis 178, and R
ADJhas a value of 5 kV
yield the following equation:
The computed value of RBIAS
is3875V. Using a standard value of 3.3kV, the potentiometers input rang-es from 73 to 182. This range yields alarger dynamic range than you need but
allows for a guard range between thepotentiometers values and the push-buttons values. Because the positionof R
ADJaffects the overall resistance
the circuit sees when you press eitherswitch, the microcontroller must inter-pret a range of values for each switch.To determine the switch resistance,R
SW, for either S
1or S
2, you use a paral-
lel-resistor network at both extremes ofthe potentiometers position.
When you press S1and R
ADJis at the
maximum position, the effective resis-
tance of the bottom leg of the divideris RSW
in parallel with the series combi-nation of R
ADJand R
BIAS. At the mini-
mum position, the effective resistanceis R
SWin parallel with R
BIAS:
Read multiple switches anda potentiometer settingwith one microcontroller input pin
Figure 1 This circuit allows onemicrocontroller pin to read multipleswitches and a potentiometervalue.
i
RBIASRSW
RSW RBIAS
RADJ
V
S2
S1
MICROCONTROLLER
ADC
DIs Isid
72 Three-transistor modulator-amplifier circuit works with swept-control frequencies
76 Tables ease microcontrollerprogramming
76 Monitor alarm and indicator
display multiple deviationboundaries
ETo see all of EDNs DesignIdeas, visit www.edn.com/designideas.
Ke F, Pe, il
VR
R RLOWBIAS
ADJ BIAS2=
+
VMAX;
=
+
+
VR R
R RVHIGH
BIAS ADJ
ADJ BIASMAX.2
=RV
BIASLOOW ADJ
MAX LOW
R
V V
=
2
ADJ HIGH MAX
MAX HIGH
R V V
V V
=
23875
( )V.
REFFMAX = +
+ +
R R R
R R R
SW ADJ BIAS
SW ADJ BIAS
( );
REFFMIN =RSW
+
R
R RBIAS
SW BIAS
.
7/30/2019 6726481
2/6
72 EDN | April 22, 2010
desgndeas
You determine the value when youpress S
1by evaluating the voltage di-
vider that RBIAS
and RRFFMAX
form:
Observe that when RADJ
is at its max-imum value and you press S
1, it must
produce a value less than the smallestvalue R
ADJproduces by itself to unique-
ly determine that you have pressed theswitch. So the maximum effective re-sistance, R
EFFMAX, must produce a value
less than the maximum low voltage, asthe following equation shows:
Substituting and solving this equationfor the switch resistance yields:
Using the spreadsheet to computethe switch resistance yields 1558V,and you can choose a nominal 1.5-kV resistor. This selection causes S
1to
produce a range of 28 to 71 when you
press it, depending on the potentiom-eters position. Likewise, choosing thesame value for S
2produces a range of
184 to 227. These ranges are bands ofvalues that you can use to determinewhich switch you pressed regardlessof the potentiometers position. Al-though selecting symmetrical resistor
values is not necessary, it minimizesthe number of calculations you needto perform and simplifies the design.Furthermore, selecting smaller seriesswitch resistors opens the guard rangebetween them and the potentiometer,which may be desirable if the result-ing values are too close together. Themicrocontroller uses a small subrou-tine, Listing 1, which you can down-load at www.edn.com/100422dia, todetermine both switch positions and
the potentiometers setting.The limitation of this technique isthat you cannot press more than onepushbutton at any time. In addition,the microcontroller can read the po-tentiometers position only when youare not pressing any other pushbut-tons. This example shows how to use
two pushbuttons, but the number ofpushbuttons can vary. Input rangesare available for as many as 10 push-buttons and one potentiometer, all ofwhich share the same input pin (Fig-ure 2). Although the computed rang-es do not overlap and are unique, itis doubtful that your ADC hardwarecan reliably distinguish these bandsunder all circumstances. Choosingsmaller resistor values keeps thesebands farther apart, creating a larger
guard range.Using this technique with fourpushbuttons and one potentiometeris well within reason. Experimentingwith the spreadsheet helps make quickwork of determining just the right se-ries-resistor values for each switch andits output range.EDN
Figure 2 The circuit can have 10 pushbuttons and one potentiometer.
=
+
VR
R RVS MAX
EFFMAX
EFFMAX BIASMAX1 ..
.RR
R REFFMAX
BIAS
BIAS ADJ
2
5 Green, red/green,red/green, red/green
5 Green, green, green/red,green/red
4 Green, red, green/red
3 Green, green, green, red
2 Green, green, red
1 Green
21 Red
22 Red, red, green
23 Red, red, red, green24 Red, green, red/green
25 Red, red, red/green,red/green
,,<