Constructing A Matrix Keypad
Constructing A Matrix Keypad
5 Matrix Keypad
Keypads are a part of HMI or Human Machine Interface and play really important role in
a small embedded system where human interaction or human input is needed. Matrix keypads
are well known for their simple architecture and ease of interfacing with any microcontroller. In
this project we used the interfacing of a 4x4 matrix keypad with microcontroller.
Constructing a Matrix Keypad
Construction of a keypad is really simple. As per the outline shown in the figure below
we have four rows and four columns. In between each overlapping row and column line there is
a key. We have to do is connect the rows and columns to a port of microcontroller and program
the controller to read the input.
Figure 1
In the above, its used a motor with a resolution of 90 degrees or demonstration purposes.
In reality, this would not be a very practical motor for most applications. The average stepper
motor's resolution -- the amount of degrees rotated per pulse -- is much higher than this. For
example, a motor with a resolution of 5 degrees would move its rotor 5 degrees per step, thereby
requiring 72 pulses (steps) to complete a full 360 degree rotation.
It can double the resolution of some motors by a process known as "half-stepping".
Instead of switching the next electromagnet in the rotation on one at a time, with half stepping
you turn on both electromagnets, causing an equal attraction between, thereby doubling the
resolution. As you can see in Figure 2, in the first position only the upper electromagnet is active,
and the rotor is drawn completely to it. In position 2, both the top and right electromagnets are
active, causing the rotor to position itself between the two active poles. Finally, in position 3, the
top magnet is deactivated and the rotor is drawn all the way right. This process can then be
repeated for the entire rotation.
Figure 2
There are several types of stepper motors. 4-wire stepper motors contain only two
electromagnets; however the operation is more complicated than those with three or four
magnets, because the driving circuit must be able to reverse the current after each step. For our
purposes, we will be using a 6-wire motor.
Unlike our example motors which rotated 90 degrees per step, real-world motors employ a series
of mini-poles on the stator and rotor to increase resolution. Although this may seem to add more
complexity to the process of driving the motors, the operation is identical to the simple 90 degree
motor we used in our example. An example of a multipole motor can be seen in Figure 3. In
position 1, the north pole of the rotor's permanent magnet is aligned with the south pole of the
stator's electromagnet. Note that multiple positions are aligned at once. In position 2, the upper
electromagnet is deactivated and the next one to its immediate left is activated, causing the rotor
to rotate a precise amount of degrees. In this example, after eight steps the sequence repeats.
Figure 3
The specific stepper motor we are using for our experiments (ST-02: 5VDC, 5 degrees per step)
has 6 wires coming out of the casing. If we follow Figure 5, the electrical equivalent of the
stepper motor, we can see that 3 wires go to each half of the coils, and that the coil windings are
connected in pairs. This is true for all four-phase stepper motors.
Figure 5
However, if you do not have an equivalent diagram for the motor you want to use, you can make
a resistance chart to decipher the mystery connections. There is a 13 ohm resistance between the
center-tap wire and each end lead, and 26 ohms between the two end leads. Wires originating
from separate coils are not connected, and therefore would not read on the ohm meter.
leakage of LPG gas and alerts the user through audio-visual indications. The MQ-5 gas sensor
module is used in this circuit. Its output goes high when the gas level reaches or exceeds certain
point. A preset in the module is used to set the threshold. As per its datasheet, it has high
sensitivity to propane, butane, isobutene, LPG and natural gas. The sensor can also be used to
detect combustible gases, especially methane. W h e n e v e r there is LPG concentration of 1000
ppm (parts per million) in the area, the OUT pin of the sensor module goes high.
Structure and configuration of MQ-5 gas sensor is shown as Fig. 1 (Configuration A or B),
sensor composed by micro AL2O3 ceramic tube, Tin Dioxide (SnO2) sensitive layer, measuring
electrode and heater are fixed into a crust made by plastic and stainless steel net. The heater
provides necessary work conditions for work of sensitive components. The enveloped MQ-5
have 6 pin ,4 of them are used to fetch signals, and other 2 are used for providing heating current.
Electric parameter measurement circuit is shown as Fig.2E. Sensitivity characteristic curve.
Fig.3 is shows the typical sensitivity characteristics of the MQ-5 for several gases. in their:
Temp: 20 Humidity: 65%O2 concentration 21% RL=20k Ro: sensor resistance at
1000ppm of H2 in the clean air. Rs:sensor resistance at various concentrations of gases.
Fig.4 is shows the typical dependence of the MQ-5 on temperature and humidity.
Ro: sensor resistance at 1000ppm of H2 in air at 33%RH and 20 degree.
Rs: sensor resistance at different temperature and humidity.
SENSITVITY ADJUSTMENT
Resistance value of MQ-5 is difference to various kinds and various concentration gases.
So, When using this components, sensitivity adjustment is very necessary. we recommend that
you calibrate the detector for 1000ppm H2 or LPG concentration in air and use value of Load
resistance ( RL) about 20 K(10K to 47K). When accurately measuring, the proper alarm
point for the gas detector should be determined after considering the temperature and humidity
influence.
Phototransistor
The phototransistor is a semiconductor light sensor formed from a basic transistor with a
transparent cover that provides much better sensitivity than a photodiode . There is a wide
selection of photosensitive devices that are available to the electronic designer. Whilst photodiodes fulfil many requirements, phototransistors or photo transistors are also available, and are
more suitable in some applications. Providing high levels of gain, and standard devices are low
cost, these phototransistors can be used in many applications.
The idea of the photo transistor has been known for many years. William Shockley first proposed
the idea in 1951, not long after the ordinary transistor had been discovered. It was then only two
years before the photo transistor was demonstrated. Since then phototransistors have been used
in a variety of applications, and their development has continued ever since.
Phototransistor structure
Although ordinary transistors exhibit the photosensitive effects if they are exposed to light, the
structure of the phototransistor is specifically optimised for photo applications. The photo
transistor has much larger base and collector areas than would be used for a normal transistor.
These devices were generally made using diffusion or ion implantation.
Early photo transistors used germanium or silicon throughout the device giving a homo-junction
structure. The more modern phototransistors use type III-V materials such as gallium arsenide
and the like. Heterostructures that use different materials either side of the p-n junction are also
popular because they provide a high conversion efficiency. These are generally fabricated using
epitaxial growth of materials that have matching lattice structures. These photo transistors
generally use a mesa structure. Sometimes a Schottky (metal semiconductor) junction can be
used for the collector within a phototransistor, although this practice is less common these days
because other structures offer better levels of performance.
In order to ensure the optimum conversion and hence sensitivity, the emitter contact is often
offset within the phototransistor structure. This ensures that the maximum amount of light
reaches the active region within the phototransistor.
Phototransistor operation
Photo transistors are operated in their active regime, although the base connection is left open
circuit or disconnected because it is not required. The base of the photo transistor would only be
used to bias the transistor so that additional collector current was flowing and this would mask
any current flowing as a result of the photo-action. For operation the bias conditions are quite
simple. The collector of an n-p-n transistor is made positive with respect to the emitter or
negative for a p-n-p transistor.
The light enters the base region of the phototransistor where it causes hole electron pairs to be
generated. This mainly occurs in the reverse biased base-collector junction. The hole-electron
pairs move under the influence of the electric field and provide the base current, causing
electrons to be injected into the emitter.
Phototransistor characteristics
As already mentioned the photo transistor has a high level of gain resulting from the transistor
action. For homo-structures, i.e. ones using the same material throughout the device, this may be
of the order of about 50 up to a few hundred. However for the hetero-structure devices, the levels
of gain may rise to ten thousand. Despite their high level of gain the hetero-structure devices are
not widely used because they are considerably more costly to manufacture. A further advantage
of all phototransistors when compared to the avalanche photodiode, another device that offers
gain, is that the phototransistor has a much lower level of noise.
One of the main disadvantages of the phototransistor is the fact that it does not have a
particularly good high frequency response. This arises from the large capacitance associated with
the base-collector junction. This junction is designed to be relatively large to enable it to pick up
sufficient quantities of light. For a typical homo-structure device the bandwidth may be limited
to about 250 kHz. Hetero-junction devices have a much higher limit and some can be operated at
frequencies as high as 1 GHz.
The characteristics of the photo-transistor under different light intensities. They are very similar
to the characteristics of a conventional bipolar transistor, but with the different levels of base
current replaced by the different levels of light intensity.
There is a small amount of current that flows in the photo transistor even when no light is
present. This is called the dark current, and represents the small number of carriers that are
injected into the emitter. Like the photo-generated carriers this is also subject to the amplification
by the transistor action.
Phototransistor symbol
The phototransistor symbol for use in electronic circuit diagrams is very straightforward. It is
formed from the basic transistor symbol with arrows point in to it to indicate that it is light
sensitive.
The phototransistor symbol often has two arrows pointing towards it, but other phototransistor
symbols show a jagged arrow. Both versions of the phototransistor symbol are acceptable and
understood.
Phototransistor symbol
The circuit symbol also has the convention arrow and directions on the emitter connection. It
points inwards on a PNP phototransistor circuit symbol and outwards on an NPN phototransistor
symbol.
It can be seen that the phototransistor symbol shown does not give a base connection. Often the
base is left disconnected as the light is used to enable the current flow through the
phototransistor. In some instances the base may be biased to set the required operating point. In
this case the base will be shown in the normal way on the phototransistor symbol.
collector circuits. Common base circuits are not normally used because the base connection is
often left floating.
The choice of common emitter or common collector phototransistor circuit configuration
depends upon the requirements for the circuit. The two phototransistor circuit configurations
have slightly different operating characteristics and these may determine the circuit used.
VCC
>
RL
Ic
Switch mode:
VCC
<
RL
Ic
Where
RL = load resistor (i.e. Rc or Re in the diagrams above).
High values of base resistor Rb prevent low levels of light from raising the current levels in the
collector emitter circuit and in this way ensuring a more reliable digital output. All other aspects
of the circuit function remain the same.