Professional Documents
Culture Documents
This Design Idea describes a single commonly available parts. This torch has 52 Connect a 43 matrix
white-LED torch, which can be proven to be highly durable; the proto- keyboard to a microcontroller
housed in an empty glue-stick tube and type model constructed by the author using two I/O pins
has a long rechargeable-battery life. The has been in service for nearly five years
circuit is constructed with just a few and is still in good working condition. 55 Bender senses shocks
1N4007
WLED
2.2
4.3 CM
Figure 3 The white-LED torch can be assembled inside an empty glue-stick tube.
through the LED and, simultaneously, Figure 2 shows how the circuits dictated by how quickly and deeply Q3
the 10-F capacitor is charged. This components can be assembled onto the goes into saturation.
phase lasts for a time period determined two sides of a circular general-purpose Photographs of the working circuit
by the RC values in the astable circuit. board. Figure 3 shows how the torch can be seen in the online version of this
Once the RC time constant passes, the could be assembled inside the glue-stick Design Idea at www.edn.com/4412618.
process repeats: Q1 turns on, Q2 turns off, tube. Once the torch is assembled and An online appendix contains the quan-
and the other transistors switch as previ- powered up, adjust the 100-k poten- titative aspects of the circuit.EDN
ously described. The current through ter- tiometer in the astable circuit for maxi-
minals 1 and 2 of the coil again increases, mum brightness. Note that, if needed, Reference
storing energy from the battery in the an additional transistor can be used in 1 LT1932 constant-current DC/DC
inductor. During this phase, the 10-F parallel with Q3 to boost the energy LED driver in ThinSOT, Linear Tech-
capacitor powers the LED. stored in the L1-2 inductor. The need is nology, http://bit.ly/17YVEdw.
analog building-block ICs in 4-mm 2
This sawtooth-oscillator circuit, nal components, a low supply current, TDFN packages (the TS12011 and the
drawing less than 3.2 A and and the ability to maintain a constant
working at under 1V, is a useful building amplitude and frequency despite the
block that fits the bill for extremely variable battery voltage. Unlike the The appeal of this
low-power consumption and operation classic op-amp astable multivibrator, circuit includes
to low supply voltages. It could be used this design features comparator thresh-
as the basis for a PWM control loop, a olds that are set by precision reference its small size and
timer, or a VCO, or as a capacitance- voltages rather than the output swing of low external-
to-frequency converter. Its a nifty cir- the op amp in combination with resis-
cuit for two reasons: It uses an open- tor feedback.
component count.
drain comparator output to make an A ratiometric fixed-frequency
accurate switched current source, and design of this type usually results in a TS12012), each containing an op amp,
it uses a latch function to make a simple variable-amplitude sawtooth waveform, a comparator, and a reference. By lean-
comparator into a window comparator, which is undesirable in PWM control ing on their characteristics, the design
while needing no extra components. loops because it can affect the loop can be kept terrifically tiny and simple.
The appeal of this circuit is found gain. As a side benefit, the up/down Heres how the circuit works: A
in the combination of the tiny size, ramps can be independently controlled summing integrator feeding a window
the ridiculously low number of exter- by scaling R1 and R2. comparator generates the sawtooth
disadvantages.
Matrix keyboards are common number of the MCUs I/O pins to con- Since most of the time I/O expand-
as an input device in microcon- nect the keyboard. For example, to ers require a special communication
troller-based projects. A conventional connect a 43 keyboard requires seven protocol (I2C or SPI, for example) to
way of connecting a matrix keyboard digital I/O pins. This becomes a prob- read and write data, the MCU should
to a microcontroller is to use multiple lem when the project is based on a have built-in communication mod-
I/O pins of the MCU. The MCU then low-pin-count MCU or when the ules, or the user has to implement the
uses a scanning algorithm to identify MCU being used does not have enough relevant communication-protocol soft-
which keys are pressed. A drawback of free I/O pins. ware wisely, which adds significantly
this method is that it requires a large Two solutions for this issue are to the overhead of the MCU. On the
D2
1N4148
D1 D3 D5
1N4148 1N4148 1N4148
D4
1N4148
R1 D6 INTERRUPT
D7 1 2 3
1k 1N4148
14 3 A 1 2 3
CLOCK CLK Q0 R4
13 2 D8
E Q1 1k
4 B 4 5 6
Q2 R5 R7
7 D9 47k
Q3 1k
10 C 7 8 9
Q4
1 R6
Q5 D10
IC1 5 1k
R3 0 #
4017 Q6 6
D
10k Q7
9
Q8
11
Q9
15 MR 12
CO
14 CLK 3
Q0
13 2
E Q1
4
Q2
7
Q3
10
Q4
1
IC2 Q5 5
4017 Q6 6 NOTE: DIODES D7, D8, D9, AND D10 ARE EACH A 1N4148.
Q7
9
Q8
11
Q9
15 MR 12
CO
Figure 1 This circuit for a 43 keyboard shows a more efficient architecture using two CD4017 Johnson counters with only two
I/O pins.
COUNT=1;
TIMER(0);
EXTERNAL TMER
DISABLE TIMER INTERRUPT INTERRUPT USER FUNCTIONS INTERRUPT DISABLE TIMER INTERRUPT
DISABLE EXTERNAL INTERRUPT INFINITE_LOOP() DISABLE EXTERNAL INTERRUPT
YES
COUNT=12 COUNT=0;
BUTTON_FUNCTION(COUNT);
NO
COUNT++
ENABLE TIMER INTERRUPT CLOCK();
ENABLE EXTERNAL INTERRUPT ENABLE TIMER INTERRUPT
ENABLE EXTERNAL INTERRUPT
Figure 2 The clock count kept in the MCU increments as it generates clock pulses in intervals; this count is equal to the switch number
focused at the moment.
other hand, assigning a unique voltage The example described here shows column of the respective button are
to each key using a resistor network how to implement this method to read at the logic-high level. If either row or
becomes troublesome as the number of a 43 matrix keyboard. One CD4017 column of the button is logic zero, an
keys becomes high, which will lead to is used to control the keyboard rows, interrupt will not occur.
tight voltage margins. Then, as resistor while the other is used to control the When an interrupt occurs, the
values tend to change with tempera- columns. MCU reads the count value at the
ture, the use of tight voltage margins The MCU generates a clock signal moment; that value is equal to the
can cause incorrect readings. Even and feeds it to the counter IC con- button just pressed.
switch bouncing can play a major role trolling the columns. Initially, the The clock count kept in the MCU
in producing incorrect voltages with 0th output of the column counter increments as it generates clock pulses
this method. Another major drawback and row counter is at logic high, and in intervals; this count is equal to the
of this method is that it requires the the columnEDNDI5310
counter Fig 2.eps DIANE
increments as it switch number on the keypad that
presence in the MCU of an analog receives clock pulses. At the fourth could generate an interrupt if pressed.
input pin. clock pulse, the column counter resets The flow chart in Figure 2 illustrates
The Design Idea described here and simultaneously increments by one this scenario.
addresses all of the above problems the counter controlling the rows. As Note that even though this
in an efficient manner and has sev- the column controller resets, the row example shows a 43 keyboard, you
eral advantages: It requires only two controller increments and the row can also read a 1010 keyboard
I/O pins regardless of the number of controller resets with the fifth clock by using the remaining outputs of
switches connected; it does not require pulse from the column controller. As both 4017 counters. Furthermore,
a special communication protocol; and clock pulses generate, a count variable you can cascade additional 4017
it does not require an analog pin. The on the MCU should be incremented ICs to expand the keyboard size as
idea is based on two CD4017 Johnson and should reset to one upon the fifth necessary. EDN
counters, which are both common and clock pulse to the row controller. The
inexpensive. output of the keyboard is ORed and Reference
Figure 1 shows the circuit for a 43 connected to an external interrupt pin 1 Rubasinghe, Aruna, Read 10 or
keyboard. R1, R4, R5, and R6 are used of the MCU. more switches using only two I/O pins
for current limiting; R7, D4, D5, and D6 An interrupt occurs only if a button of a microcontroller, EDN, Feb 28,
form an OR gate. pressed when both the row and the 2013, www.edn.com/4408027.
to avoid damaging the piezoelectric
With the aid of a simple mount- der one edge of the bender to a mount- elements bond to the brass disc.
ing system and some soldered-on ing bolt. Opposite the mounting bolt, Figure 2 shows a simple alarm cir-
weights, a piezoelectric bender can solder a weight to increase the benders cuit. Giving the bender a good smack
detect mechanical shocks. The bender sensitivity. A small hook affixed to the will develop several volts across R 1,
comprises a piezoelectric-ceramic ele- mounting substrate limits motion so the 10-M resistor. The dual-timer
ment bonded to a thin brass disc. Such that the brittle piezoelectric element IC, IC 1, will then pulse the output
assemblies form the heart of many tele- will not crack. alarm for one minute at a 1-Hz rate.
phone annunciators and wrist-watch For three-axis sensitivity, solder one The alarm has its own driver circuit
or panel-mounted alarms. edge to a mounting bolt as before. At and sounds a piercing 90-dB tone when
Depending on the mounting the other edge, solder a flat-head bolt energized.
scheme, the bender can sense shocks that points away from the mounting The bender and alarm are both
in one axis (Figure 1a) or three axes substrate. Use a pair of jam nuts to available from Projects Unlimited,
(Figure 1b). For one-axis sensing, sol- increase the assemblys polar moment Dayton, OH.EDN
Figure 1 Solidly mounting one end of a piezoelectric bender and affixing a weight to the opposite edge transforms the bender
into a shock sensor. Here, a is sensitive to vertical-axis shocks only; b senses shocks in all three axes.
Figure 2 The circuit sounds a 1-sec alarm whenever you give the bender a good smack.