0% found this document useful (0 votes)
75 views

Constructing A Matrix Keypad

A 4x4 matrix keypad is interfaced with a microcontroller. It has 4 rows and 4 columns, with a key at each intersection. To scan the keypad, each row is made low while reading the columns. If a key is pressed in that row, the corresponding column will be low, identifying the pressed key. An IR LED-phototransistor pair is used to detect the presence of people by transmitting and receiving infrared light. An MQ-5 gas sensor detects LPG gas leaks, with its output going high when gas levels reach 1000ppm. It is used with a circuit providing audio-visual alerts of any detected gas leak.

Uploaded by

Geo Babu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views

Constructing A Matrix Keypad

A 4x4 matrix keypad is interfaced with a microcontroller. It has 4 rows and 4 columns, with a key at each intersection. To scan the keypad, each row is made low while reading the columns. If a key is pressed in that row, the corresponding column will be low, identifying the pressed key. An IR LED-phototransistor pair is used to detect the presence of people by transmitting and receiving infrared light. An MQ-5 gas sensor detects LPG gas leaks, with its output going high when gas levels reach 1000ppm. It is used with a circuit providing audio-visual alerts of any detected gas leak.

Uploaded by

Geo Babu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 13

3.

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.

Scanning a Matrix Keypad


There are many methods depending on connecting the keypad with the controller, but the
basic logic is same. We make the columns as i/p and we drive the rows making them o/p, this
whole procedure of reading the keyboard is called scanning. In order to detect which key is
pressed from the matrix, we make row lines low one by one and read the columns. Lets say we
first make Row1 low, and then read the columns. If any of the key in row1 is pressed will make
the corresponding column as low i.e. if second key is pressed in Row1, then column2 will give
low. So we come to know that key 2 of Row1 is pressed. This is how scanning is done.
So to scan the keypad completely, we need to make rows low one by one and read the
columns. If any of the buttons is pressed in a row, it will take the corresponding column to a low
state which tells us that a key is pressed in that row. If button 1 of a row is pressed then Column
1 will become low, if button 2 then column2 and so on...

3.6 Stepper Motor


Stepper motors consist of a permanent magnet rotating shaft, called the rotor, and
electromagnets on the stationary portion that surrounds the motor, called the stator. Figure 1
illustrates one complete rotation of a stepper motor. At position 1, we can see that the rotor is
beginning at the upper electromagnet, which is currently active (has voltage applied to it). To
move the rotor clockwise (CW), the upper electromagnet is deactivated and the right
electromagnet is activated, causing the rotor to move 90 degrees CW, aligning itself with the
active magnet. This process is repeated in the same manner at the south and west electromagnets
until we once again reach the starting position.

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.

3.7 Alcohol Sensor


Alcohol gas is supplied in pressurized steel cylinders. As this gas is heavier than air,
when it leaks from a cylinder it flows along floor and tends to settle in low spots such as a
basement. This can cause fire or suffocation if not dealt with. Here is a circuit that detects the

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.

MQ-5 Gas Sensor


They are used in gas leakage detecting equipments in family and industry, are suitable for
detecting of LPG, natural gas , town gas, avoid the noise of alcohol and cooking fumes and
cigarette smoke.

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.

IR Transmitter Receiver Pair


The IR LED phototransistor pair is used for detect the presence of the
people entering the premises.

An IR LED, also known as IR transmitter, is a special purpose LED that transmits


infrared rays in the range of 760 nm wavelength. Such LEDs are usually made of gallium
arsenide or aluminium gallium arsenide. They, along with IR receivers, are commonly used as
sensors.
The appearance is same as a common LED. Since the human eye cannot see the infrared
radiations, it is not possible for a person to identify whether the IR LED is working or not, unlike
a common LED. To overcome this problem, the camera on a cellphone can be used. The camera
can show us the IR rays being emanated from the IR LED in a circuit.

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.

Homojunction planar phototransistor structure

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.

Heterojunction mesa-structure phototransistor

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.

Phototransistor circuit configurations


The phototransistor can be used in a variety of different circuit configurations. Like more
conventional transistors, the phototransistor can be used in common emitter and common

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.

Common emitter phototransistor circuit


The common emitter phototransistor circuit configuration is possibly the most widely used, like
its more conventional straight transistor circuit. The collector is taken to the supply voltage via a
collector load resistor, and the output is taken from the collector connection on the
phototransistor. The circuit generates an output that moves from a high voltage state to a low
voltage state when light is detected.
The circuit actually acts as an amplifier. The current generated by the light affects the base
region. This is amplified by the current gain of the transistor in the normal way.

Common emitter phototransistor circuit

Common collector phototransistor circuit


The common collector, or emitter follower phototransistor circuit configuration has effectively
the same topology as the normal common emitter transistor circuit - the emitter is taken to
ground via a load resistor, and the output for the circuit being taken from the emitter connection
of the device.
The circuit generates an output that moves from the low state to a high state when light is
detected.

Common collector / emitter follower phototransistor circuit

Phototransistor circuit operation


The phototransistor circuits can be used on one of two basic modes of operation. They are called
active or linear mode and a switch mode.
Operation in the "linear" or active mode provides a response that is very broadly proportional to
the light stimulus. In reality the phototransistor does not give a particularly linear output to the
input stimulus and it is for this reason that this mode of operation is more correctly termed the
active mode.
The operation of the phototransistor circuit in the switch mode is more widely used in view of
the non-linear response of the phototransistor to light. When there is little or no light, virtually no
current will flow in the transistor, and it can be said to be in the "off" state. However as the level
of light increases, current starts to flow. Eventually a point is reached where the phototransistor
becomes saturated and the level of current cannot increase. In this situation the phototransistor is
said to be saturated. The switch mode, therefore has two levels: - "on" and "off" as in a digital or
logic system. This type of phototransistor mode is useful for detecting objects, sending data or
reading encoders, etc.
With most circuits not using the base connection (even if it is available), the only way to change
the mode of operation of the circuit is to change the value of the load resistor. This is set by
estimating the maximum current anticipated from the light levels encountered.
Using this assumption, the following equations can be used:
Active mode:

VCC

>

RL

Ic

Switch mode:

VCC

<

RL

Ic

Where
RL = load resistor (i.e. Rc or Re in the diagrams above).

IC = maximum anticipated current.


VCC = supply voltage.

Use of base connection in phototransistor circuits


On some phototransistors, the base connection is available. Access to the base connection allows
the phototransistor circuit conditions to be set more appropriately for some applications.

Phototransistor circuit with base resistor

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.

You might also like