2.13 design ideas.pdf

(1730 KB) Pobierz
design ideas
readerS SOLVe deSIGN PrOBLeMS
Auto pulse generator senses
and responds to a probed load
Raju Baddi, Tata Institute of Fundamental Research, Pune, India
DIs Inside
52 Read 10 or more switches
using only two I/O pins of a
microcontroller
57 Successfully choose
complementary bipolar transistors
58 Synchronized regulator
produces coherent noise
To see and comment on
all of EDN ’s Design Ideas, visit
www.edn.com/designideas.
This automatic pulse generator
arrangement of probes shown. A regu-
lar arrangement of independent probes
also may be used. The circuit has been
tested with a 5V supply, as well.
Two versions are shown: Figure 1
uses an NE555 timer IC as a mono-
stable and is the easiest to get working.
Figure 2 eliminates the NE555 for a
reduced parts count but could be affect-
ed by variations in the parameters and
different manufacturers of the CD4069
CMOS hex inverter used in place of
the NE555.
Transistors Q 1 and Q 2 are switches
that connect the +ve and −ve probes
to the 3.6V supply and ground when
( figures 1 and 2 ) is a test gadget
that senses a probed contact to a pair of
terminals under test and automatically
issues a momentary power pulse to
them once proper contact is made.
These terminals could be the input of
a logic gate, an LED on a circuit board,
a transformer or relay coil, etc. The
need for such a pulse often arises in the
day-to-day engineering work of experi-
menting and testing.
The gadget is powered with a small
3.6V rechargeable NiCd battery. You
can easily construct it in a glue-stick
tube ( Figure 3 ) with the special
turned on by the CD4069 and the
NE555. R 3 and R 4 bias gate G 1 ’s input
just below the switching threshold to
hold its output high, which holds the
output of gate G 2 low. The time con-
stant formed by C 1 provides a certain
PULSE-ISSUE
INDICATOR
3.6V
+
48
10k
BC559
R
220
Q 1
G 6
3
7,6
CD4069
PROBES CONNECTED
TO A LARGE INDUCTANCE,
SAY 20 mH
NE555
R 1
100k
C
G 4
22k
21
CD4069
BC549
R 3
12M
Q 3
G 3
R 2
270
D 1
D 1
R 5
1M
CD4069
CD4069
100k
G 1
G 2
D 2
1N4007
C 3
0.1 F
CD4069
G 5
CD4069
C 2
0.1 F
R 4
10M
R 6
100k
C 1
0.1 F
10k
BC549
Q 2
Figure 1 The NE555 version is easy to get working but has an increased parts count.
[ www.edn.com ]
50 EDN | February 2013
1124191664.401.png 1124191664.412.png 1124191664.423.png 1124191664.434.png 1124191664.001.png 1124191664.011.png 1124191664.022.png 1124191664.033.png 1124191664.044.png 1124191664.055.png 1124191664.066.png 1124191664.077.png 1124191664.088.png 1124191664.099.png 1124191664.109.png 1124191664.120.png 1124191664.131.png 1124191664.142.png 1124191664.153.png 1124191664.164.png 1124191664.175.png 1124191664.186.png 1124191664.197.png 1124191664.208.png 1124191664.218.png 1124191664.229.png 1124191664.240.png 1124191664.251.png 1124191664.262.png 1124191664.273.png 1124191664.284.png 1124191664.295.png 1124191664.306.png 1124191664.317.png 1124191664.328.png 1124191664.339.png 1124191664.350.png 1124191664.360.png 1124191664.371.png 1124191664.382.png 1124191664.387.png 1124191664.388.png 1124191664.389.png 1124191664.390.png 1124191664.391.png 1124191664.392.png 1124191664.393.png 1124191664.394.png 1124191664.395.png 1124191664.396.png 1124191664.397.png 1124191664.398.png 1124191664.399.png 1124191664.400.png 1124191664.402.png 1124191664.403.png 1124191664.404.png 1124191664.405.png 1124191664.406.png 1124191664.407.png 1124191664.408.png 1124191664.409.png 1124191664.410.png 1124191664.411.png 1124191664.413.png 1124191664.414.png 1124191664.415.png 1124191664.416.png 1124191664.417.png 1124191664.418.png 1124191664.419.png 1124191664.420.png 1124191664.421.png 1124191664.422.png 1124191664.424.png 1124191664.425.png 1124191664.426.png 1124191664.427.png 1124191664.428.png 1124191664.429.png 1124191664.430.png 1124191664.431.png 1124191664.432.png 1124191664.433.png 1124191664.435.png 1124191664.436.png 1124191664.437.png 1124191664.438.png 1124191664.439.png 1124191664.440.png 1124191664.441.png 1124191664.442.png 1124191664.443.png 1124191664.444.png 1124191664.002.png
 
design ideas
3.6V
MONOSTABLE
PULSE-
ISSUE
INDICATOR
D 4
1N4148
R
220
10k
Q 1
3
G 4
R 1
100k
G 5
PROBES CONNECTED
TO A LARGE INDUCTANCE,
SAY 20 mH
BC559
CD4069
CD4069
G 6
C
CD4069
R F
1M
47k
R 3
12M
D 1
Q 3
BC549
CD4069
G 3
R 2
270
D 2
1N4007
C 3
0.1 F
R 5
1M
D 3
1N4148
100k
G 1
G 2
CD4069
R 4
10M
CD4069
C 1
0.1 F
C 2
0.1 F
R 6
1M
10k
Q 2
T~0.7 TO 1.1 RC
BC549
Figure 2 You can eliminate the NE555, but variations in the G 4 input switching threshold can affect the pulse duration.
amount of noise immunity
and determines the minimum
time for which the test circuit
should be connected between
the probes. The 100-kΩ resis-
tor in series with the input of
G 1 limits the input current in
case the probe is accidentally
connected to an active circuit.
R 1 connects to the junc-
tion of R 3 and R 4 through a
reverse-biased diode, D 1 . It
normally has no effect as long
as the probes are not connect-
ed through a load, because the
series string of R 1 , D 1 , R 2 , and
D 2 is a high-resistance circuit
compared with the 12 MΩ of
R 3 . As soon as you connect a
passive test circuit such as a
resistor/inductor/LED, how-
ever, D 1 and R 2 are paralleled
by it. Thus, the branch in par-
allel with R 3 has a lower resis-
tance and the G 1 input voltage
increases such that it is now
recognized as logic 1, driving
G 1 ’s output low.
R 5 and C 2 form a debounce-
and-delay network to ensure
that the probes are firmly con-
nected to the circuit under
test before the power pulse is
issued. When the output of G 1
goes low, capacitor C 2 begins to
discharge through R 5 . The logic
input voltage of G 2 changes
within a time on the order of
R 5 C 2 .
In Figure 1 , the rising out-
put of G 2 immediately triggers
the NE555 monostable through
G 3 and the differentiator formed
by C 3 and R 6 . Once C 3 has fin-
ished charging through R 6 , G 3 ’s
input returns to ground and its
output returns high to allow
the NE555 to complete its tim-
ing cycle with a duration that
its R and C values determine. 1
The timed logic 1 output of the
NE555 turns on Q 3 to light the
“pulse issued” LED, and through
G 4 , G 5 , and G 6 turns on Q 1 and
Q 2 to present the power pulse to
the circuit under test.
Only one pulse is gener-
ated per contact; removing the
probes and then reconnecting
them will issue a new pulse. If
the circuit under test is induc-
tive and greater than 20 mH at
TIP WIDENED
USING A SHARP
TOOL FOR INSERTING
COMPONENT LEAD
CONNECTING WIRE
GEL-PEN
REFILL TIPS
SPRING (ALSO ACTS
AS CONNECTING WIRE)
GEL-PEN
REFILL PIPE
BETTER TO BEND
A BIT INWARDS
GLUE-STICK CAP
SCREWS
CIRCUIT
BOARD
ON
SWITCH
MOUNTED
ON TUBE
OFF
15 TO 20G
GLUE-STICK
TUBE
3.6V
NiCd
BATTERY
RESISTOR-DIODE
COMBINATION TO
LIMIT THE CURRENT
POWER SOCKET
FOR CHARGING
Figure 3 You can build the automatic pulse generator in a
used glue-stick tube.
[ www.edn.com ]
February 2013 | EDN 51
1124191664.003.png 1124191664.004.png 1124191664.005.png 1124191664.006.png 1124191664.007.png 1124191664.008.png 1124191664.009.png 1124191664.010.png 1124191664.012.png 1124191664.013.png 1124191664.014.png 1124191664.015.png 1124191664.016.png 1124191664.017.png 1124191664.018.png 1124191664.019.png 1124191664.020.png 1124191664.021.png 1124191664.023.png 1124191664.024.png 1124191664.025.png 1124191664.026.png 1124191664.027.png 1124191664.028.png 1124191664.029.png 1124191664.030.png 1124191664.031.png 1124191664.032.png 1124191664.034.png 1124191664.035.png 1124191664.036.png 1124191664.037.png 1124191664.038.png 1124191664.039.png 1124191664.040.png 1124191664.041.png 1124191664.042.png 1124191664.043.png 1124191664.045.png 1124191664.046.png 1124191664.047.png 1124191664.048.png 1124191664.049.png 1124191664.050.png 1124191664.051.png 1124191664.052.png 1124191664.053.png 1124191664.054.png 1124191664.056.png 1124191664.057.png 1124191664.058.png 1124191664.059.png 1124191664.060.png 1124191664.061.png 1124191664.062.png 1124191664.063.png 1124191664.064.png 1124191664.065.png 1124191664.067.png 1124191664.068.png 1124191664.069.png 1124191664.070.png 1124191664.071.png 1124191664.072.png 1124191664.073.png 1124191664.074.png 1124191664.075.png 1124191664.076.png 1124191664.078.png 1124191664.079.png 1124191664.080.png 1124191664.081.png 1124191664.082.png 1124191664.083.png 1124191664.084.png 1124191664.085.png 1124191664.086.png 1124191664.087.png 1124191664.089.png 1124191664.090.png 1124191664.091.png 1124191664.092.png 1124191664.093.png 1124191664.094.png 1124191664.095.png 1124191664.096.png 1124191664.097.png 1124191664.098.png 1124191664.100.png 1124191664.101.png 1124191664.102.png 1124191664.103.png 1124191664.104.png 1124191664.105.png
 
design ideas
the end of the pulse, the inductive back
EMF will flash LED D 1 if the probes are
still connected.
In Figure 2 , the NE555 has been
replaced by a monostable comprising
G 3 and G 4 , D 4 , and R F . R 6 has been
changed to 1 MΩ, and diode D 3 has
been added to the input of G 3 . Resistor
R holds G 4 ’s input high, which in the
quiescent state causes G 4 ’s output to
hold G 3 ’s input low. A rising edge from
G 2 causes a low to couple through the
initially discharged capacitor, C, to G 4 ,
whose rising output is fed back to G 3 as
positive feedback and holds G 3 ’s input
high even if the probes are removed. If
this happens, D 3 becomes reverse biased
and prevents G 2 ’s falling edge from
affecting the monostable operation.
Capacitor C then slowly charges
through resistor R until G 4 ’s input rises
above its switching threshold, and the
positive-feedback process reverses. The
pulse duration depends on the R×C
time constant, and is about 0.7 to 1.1
RC, depending on the G 4 threshold
voltage, which can vary between 0.33
and 0.67 of the supply voltage. The
author suggests 1 MΩ for R and 40 nF
for C, but R could be made variable,
as well. D 4 ensures that C discharges
rapidly as G 3 ’s output returns high.
In either case of Figure 1 or Figure
2 , the momentary high output of the
monostable turns Q 3 on to flash the
pulse-issued indicator LED. It also turns
on both Q 1 and Q 2 to power the probes.
D 2 serves to isolate the −ve probe from
the primary input of the circuit at G 1 to
avoid immediate self-suppression. EDN
RefeRence
1 NE555 data sheet, Figure 11,
Texas Instruments, June 2010,
http://bit.ly/127p7kq.
such as the Maxim DS2408 8-channel
addressable switch.
The first method has several disad-
vantages: The MCU has to have an
ADC function, debounce wait times
reduce the polling rate, and an error
results if the switch is opened during the
ADC sampling time. The second method
also has the drawback of comparatively
low speed; it uses 1-wire communica-
Read 10 or more switches using
only two I/O pins of a microcontroller
Aruna Prabath Rubasinghe, University of Moratuwa, Moratuwa, Sri Lanka
There are several ways to read
an analog MCU pin to read multiple
switches by assigning a unique voltage
to each switch through a resistor net-
work, or you can use a one-wire device,
multiple switch inputs using a
reduced number of microcontroller-unit
(MCU) pins. For example, you can use
S 0
S 1
S 2
CLOCK
PULSE
14
13
3
2
4
7
10
1
5
6
9
Q9 11
S 3
Q0
Q1
CLK
E
S 4
Q2
Q3
Q4
Q5
Q6
Q7
Q8
INTERRUPT
S 5
IC 1
4017
S 6
S 7
S 8
15
CO 12
RESET
MR
S 9
R 1
4.7k
Figure 1 You can easily expand this circuit to many more than 10 switches, yet still use only two MCU I/O pins, by cascading
multiple CD4017 counters through their carry-outs to the following enables.
[ www.edn.com ]
52 EDN | February 2013
1124191664.106.png 1124191664.107.png 1124191664.108.png 1124191664.110.png 1124191664.111.png 1124191664.112.png 1124191664.113.png 1124191664.114.png 1124191664.115.png 1124191664.116.png 1124191664.117.png 1124191664.118.png 1124191664.119.png 1124191664.121.png 1124191664.122.png 1124191664.123.png 1124191664.124.png 1124191664.125.png 1124191664.126.png 1124191664.127.png 1124191664.128.png 1124191664.129.png 1124191664.130.png 1124191664.132.png 1124191664.133.png 1124191664.134.png 1124191664.135.png 1124191664.136.png 1124191664.137.png 1124191664.138.png 1124191664.139.png 1124191664.140.png 1124191664.141.png 1124191664.143.png 1124191664.144.png 1124191664.145.png 1124191664.146.png 1124191664.147.png 1124191664.148.png 1124191664.149.png 1124191664.150.png 1124191664.151.png 1124191664.152.png 1124191664.154.png 1124191664.155.png 1124191664.156.png 1124191664.157.png 1124191664.158.png 1124191664.159.png 1124191664.160.png 1124191664.161.png 1124191664.162.png 1124191664.163.png 1124191664.165.png 1124191664.166.png 1124191664.167.png 1124191664.168.png 1124191664.169.png 1124191664.170.png 1124191664.171.png 1124191664.172.png 1124191664.173.png 1124191664.174.png 1124191664.176.png 1124191664.177.png 1124191664.178.png 1124191664.179.png 1124191664.180.png 1124191664.181.png 1124191664.182.png 1124191664.183.png 1124191664.184.png 1124191664.185.png 1124191664.187.png 1124191664.188.png 1124191664.189.png 1124191664.190.png 1124191664.191.png 1124191664.192.png 1124191664.193.png 1124191664.194.png 1124191664.195.png 1124191664.196.png 1124191664.198.png 1124191664.199.png 1124191664.200.png 1124191664.201.png 1124191664.202.png 1124191664.203.png 1124191664.204.png 1124191664.205.png 1124191664.206.png 1124191664.207.png 1124191664.209.png 1124191664.210.png 1124191664.211.png 1124191664.212.png 1124191664.213.png 1124191664.214.png 1124191664.215.png
 
design ideas
5V
S 0
S 1
R 3
15k
R 2
10k
S 2
V 1
14
13
CLOCK/RESET
PULSE
3
2
4
7
10
1
5
6
9
Q9 11
S 3
CLK
Q0
Q1
E
S 4
Q2
Q3
Q4
Q5
Q6
Q7
Q8
V 2
INTERRUPT
S 5
R 4
1k
IC 1
4017
S 6
Q 1
S 7
2N2222
S 8
15
CO 12
MR
S 9
R 1
4.7k
LOGIC HIGH HIGH IMPEDANCE=CLOCK PULSE
LOGIC LOW HIGH IMPEDANCE=RESET PULSE
HIGH IMPEDANCE=IDLE
Figure 2 You can add three resistors and a transistor to implement the occasional synchronizing reset without using a third I/O pin.
START
START_TIMER( );
n=0;
EXTERNAL
INTERRUPT
TIMER
INTERRUPT
USER FUNCTIONS
INFINITE LOOP
DISABLE EXTERNAL
INTERRUPTS( );
BUTTON_FUNCTION(n);
YES
n=0;
n=9?
NO
n=n+1;
10-µSEC_COUNTER_PULSE( );
ENABLE EXTERNAL INTERRUPTS( );
Figure 3 This flowchart displays the process for reading an all-pushbutton system. Only one button at a time should be pressed.
[ www.edn.com ]
54 EDN | February 2013
1124191664.216.png 1124191664.217.png 1124191664.219.png 1124191664.220.png 1124191664.221.png 1124191664.222.png 1124191664.223.png 1124191664.224.png 1124191664.225.png 1124191664.226.png 1124191664.227.png 1124191664.228.png 1124191664.230.png 1124191664.231.png 1124191664.232.png 1124191664.233.png 1124191664.234.png 1124191664.235.png 1124191664.236.png 1124191664.237.png 1124191664.238.png 1124191664.239.png 1124191664.241.png 1124191664.242.png 1124191664.243.png 1124191664.244.png 1124191664.245.png 1124191664.246.png 1124191664.247.png 1124191664.248.png 1124191664.249.png 1124191664.250.png 1124191664.252.png 1124191664.253.png 1124191664.254.png 1124191664.255.png 1124191664.256.png 1124191664.257.png 1124191664.258.png 1124191664.259.png 1124191664.260.png 1124191664.261.png 1124191664.263.png 1124191664.264.png 1124191664.265.png 1124191664.266.png 1124191664.267.png 1124191664.268.png 1124191664.269.png 1124191664.270.png 1124191664.271.png 1124191664.272.png 1124191664.274.png 1124191664.275.png 1124191664.276.png 1124191664.277.png 1124191664.278.png 1124191664.279.png 1124191664.280.png 1124191664.281.png 1124191664.282.png 1124191664.283.png 1124191664.285.png 1124191664.286.png 1124191664.287.png 1124191664.288.png 1124191664.289.png 1124191664.290.png 1124191664.291.png 1124191664.292.png 1124191664.293.png 1124191664.294.png 1124191664.296.png 1124191664.297.png 1124191664.298.png 1124191664.299.png 1124191664.300.png 1124191664.301.png 1124191664.302.png 1124191664.303.png 1124191664.304.png 1124191664.305.png 1124191664.307.png 1124191664.308.png 1124191664.309.png 1124191664.310.png 1124191664.311.png 1124191664.312.png 1124191664.313.png 1124191664.314.png 1124191664.315.png 1124191664.316.png 1124191664.318.png 1124191664.319.png 1124191664.320.png 1124191664.321.png 1124191664.322.png 1124191664.323.png 1124191664.324.png 1124191664.325.png 1124191664.326.png 1124191664.327.png 1124191664.329.png 1124191664.330.png 1124191664.331.png 1124191664.332.png 1124191664.333.png 1124191664.334.png 1124191664.335.png 1124191664.336.png 1124191664.337.png 1124191664.338.png 1124191664.340.png 1124191664.341.png 1124191664.342.png 1124191664.343.png 1124191664.344.png 1124191664.345.png 1124191664.346.png 1124191664.347.png 1124191664.348.png 1124191664.349.png 1124191664.351.png 1124191664.352.png 1124191664.353.png
 
design ideas
tion, which requires continuous polling;
and each poll generates an 8-bit data
sequence relevant to switch positions.
This Design Idea describes a method
for reading multiple pushbuttons or
open/closed switches using only two
digital I/O pins and a timer interrupt of
the MCU ( Figure 1 ). Optionally, a third
I/O pin can be assigned to periodically
reset the CD4017 (a cascadable decoded
1-of-10 Johnson counter) for reliable
operation should an EMI or ESD event
occur that could falsely clock the coun-
ter, or you can use the circuit shown in
Figure 2 and retain the two-pin feature.
The diodes isolate the counter outputs
in the event that two or more switches
are closed at the same time. You can
increase the number of switches con-
nected by cascading multiple CD4017
ICs using a carry-out signal (pin 12) and
a clock signal (pin 14).
Reliable operation fol-
lowing the initial power-up
reset depends on the CD4017
counter’s remaining synchro-
nized with the MCU counter.
This synchronization can be
upset by an ESD or EMI event
such as a nearby cell phone, so
it would be wise to include in
the firmware a periodic hard-
ware reset to the CD4017 to
keep the counts synchronized.
Figure 2 shows how you can
do this without having to use
a third MCU pin.
For this function, you use
the MCU’s ability to keep
its I/O pin in three different
states: high, low, and, by tem-
porarily changing the pin to
an input, high impedance.
In the logic-high state,
transistor Q 1 turns on through
R 4 , making the voltage on V 1
logic high and the voltage on
V 2 below the logic-low level.
This sets the clock pin to a
logic high while keeping the
reset pin at a logic low.
In the logic-low state,
transistor Q 1 turns off, mak-
ing the voltage on V 1 logic
low and the voltage on V 2
above the logic-high level.
This sets the reset pin to logic
high while keeping the clock in the
logic-low state.
In the idle high-impedance state,
transistor Q 1 is turned on through R 3
and R 4 , making the voltage on V 1 and
V 2 below the logic-low level. This sets
both the clock and reset pins of the
CD4017 to a logic-low state.
To send a clock edge, therefore,
change the state in the following man-
ner: high impedance > logic high >
high impedance. Likewise, to reset the
CD4017, change the state as follows:
high impedance > logic low > high
impedance.
The flowchart in Figure 3 is for an
all-pushbutton system and functions
as follows: At the start, the MCU sets
a counter variable to 0 and starts an
interrupt-enabled timer, which is set to
overflow and interrupt at 1-msec inter-
vals. In the timer-interrupt routine, sev-
eral tasks are carried out: External inter-
rupts are disabled; the counter variable
is incremented by 1; a 10-μsec clock
pulse is sent to the CD4017; and the
external interrupt is enabled.
a thIrd I/O PIN caN
Be aSSIGNed tO PerI-
OdIcaLLy reSet the
cd4017 durING aN
eMI Or eSd eVeNt.
As the MCU clocks the CD4017
every 1 msec and increments the coun-
ter variable by 1 if its value is less than
9, the CD4017 output corresponding
to the counter-variable value goes to
logic high from logic low; that is, if
the counter-variable value is 2, then
the decoded 2 output of the
CD4017 (pin 4) is at logic
high while all other outputs
are at logic low. At this time,
if the user pressed pushbut-
ton S 2 , it would send a logic-
high signal to the external
interrupt pin of the MCU.
Pressing any other button
does not generate external
interrupts, because all other
outputs of the CD4017 are in
the logic-low state.
When the MCU receives
the external interrupt, it gets
the current counter-variable
value (which is 2) from its
memory, identifies the pressed
button as S 2 , and thus carries
out the functions relevant to
S 2 . When the counter vari-
able reaches 9, it is set to 0
through the software, as the
CD4017 also resets automati-
cally at the 10th pulse.
Note that only one button
at a time should be pressed; if
two consecutive buttons are
pressed together, there may
not be enough dropout time
between successive counter
states for the interrupt edge to
register. You can resolve this
issue by using the flowchart
shown in Figure 4 . EDN
START
START_TIMER( );
n=0;
TIMER
INTERRUPT
USER FUNCTIONS
INFINITE LOOP
YES
n=0;
n=9?
NO
n=n+1;
NO
10-µSEC_COUNTER_PULSE( );
INPUT_HIGH?
YES
BUTTON_FUNCTION(n);
Figure 4 When non-momentary toggle switches are used,
you can decode multiple combinations of switch closures by
checking the state of the interrupt input.
[ www.edn.com ]
56 EDN | February 2013
1124191664.354.png 1124191664.355.png 1124191664.356.png 1124191664.357.png 1124191664.358.png 1124191664.359.png 1124191664.361.png 1124191664.362.png 1124191664.363.png 1124191664.364.png 1124191664.365.png 1124191664.366.png 1124191664.367.png 1124191664.368.png 1124191664.369.png 1124191664.370.png 1124191664.372.png 1124191664.373.png 1124191664.374.png 1124191664.375.png 1124191664.376.png 1124191664.377.png 1124191664.378.png 1124191664.379.png 1124191664.380.png 1124191664.381.png 1124191664.383.png 1124191664.384.png 1124191664.385.png 1124191664.386.png
 
Zgłoś jeśli naruszono regulamin