Professional Documents
Culture Documents
• If the data read is all 1s, no key in that row is activated and the process is
moved to the next row. It grounds the next row, reads the columns, and
checks for any zero. This process continues until the row is identified. After
identification of the row in which the key has been pressed, the next task is
to find out which column the pressed key belongs to.
Interfacing of 4x4 matrix keyboard
7 segment display
• A seven segment display is the most basic electronic display
device that can display digits from 0-9. The most common
configuration has an array of eight LEDs arranged in a special
pattern to display these digits. They are laid out as a squared-
off figure „8‟. Every LED is assigned a name from „a‟ to „h‟
and is identified by its name. Seven LEDs „a‟ to „g‟ are used to
display the numerals while eighth LED „h‟ is used to display
the dot/decimal.
7 segment display
• LEDs are often grouped to form seven-segment display. The below Fig.
shows the front of a seven segment display. It contains seven LEDs (A, B,
C, D, E, F and G) shaped in a figure of 8. Each LED is called a segment. If
a particular LED is forward biased, that LED or segment will light and
produces a bar of light. By forward biasing various combinations of seven
LEDs, it is possible to display any number from 0 to 9. For example, if
LEDs A, B, C, D and G are lit (by forward biasing them), the display will
show the number 3. Similarly, if LEDs C, D, E, F, A and G are lit, the
display will show the number 6. To get the number 0, all segments except
G are lit.
• The Below Fig. shows the schematic diagram of seven-segment display.
External series resistors are included to limit currents to safe levels. Note
that the anodes of all seven LEDs are connected to a common positive
voltage source of +5 V. This arrangement is known as common-anode
type. In order to light a particular LED, say A, we ground the point A in
Fig. It forward biases the LED A which will be lit.
Common Anode Display
The Common Anode (CA) – In the common anode display, all the
anode connections of the LED segments are joined together to logic
“1”. The individual segments are illuminated by applying a ground,
logic “0” or “LOW” signal via a suitable current limiting resistor to the
Cathode of the particular segment (a-g)
The Common Cathode (CC) – In the common cathode display,
all the cathode connections of the LED segments are joined
together to logic “0” or ground. The individual segments are
illuminated by application of a “HIGH”, or logic “1” signal via a
current limiting resistor to forward bias the individual Anode
terminals (a-g).
ADC interfacing
• Analogue to Digital Converter, or ADC, is a data converter
which allows digital circuits to interface with the real world by
encoding an analogue signal into a binary code.
• Main Types of ADC Converters
There are really five major types of ADCs in use today:
• Successive Approximation (SAR) ADC
• Delta-sigma (ΔΣ) ADC
• Dual Slope ADC
• Pipelined ADC
• Flash ADC
Features : ADC0808/ADC0809 :
• Easy Interface to All Microprocessors
• Operates with 5 VDC
• No Zero or Full-Scale Adjust Required
• 8-Channel Multiplexer with Address Logic
• 0V to VCC Input Range
• Outputs meet TTL Voltage Level Specifications
• ADC0808 Equivalent to MM74C949
• ADC0809 Equivalent to MM74C949-1
• 28-pin molded chip carrier package
Types of ADC
1. Flash Type ADC
• Also called the parallel A/D converter, this circuit is the simplest to understand.
It is formed of a series of comparators, each one comparing the input signal to
a unique reference voltage. The comparator outputs connect to the inputs of a
priority encoder circuit, which then produces a binary output.
• A flash ADC (also known as a direct-conversion ADC) is a
type of analog-to-digital converter that uses a linear voltage
ladder with a comparator at each "rung" of the ladder to
compare the input voltage to successive reference voltages.
• Often these reference ladders are constructed of many
resistors; however, modern implementations show that
capacitive voltage division is also possible.
• The output of these comparators is generally fed into a digital
encoder, which converts the inputs into a binary value.
2. Successive Approximation Type ADC
It consists of a successive approximation register (SAR), DAC and comparator.
The output of SAR is given to n-bit DAC. The equivalent analog output voltage
of DAC, VD is applied to the non-inverting input of the comparator. The second
input to the comparator is the unknown analog input voltage VA. The output of
the comparator is used to activate the successive approximation logic of SAR.
When the start command is applied, the SAR sets the MSB to logic 1 and other
bits are made logic 0, so that the trial code becomes 1000.
Advantages:
• 1 Conversion time is very small.
• 2 Conversion time is constant and independent of the
amplitude of the analog input signal VA.
Disadvantages:
• 1 Circuit is complex.
• 2 The conversion time is more compared to flash type ADC.
Interfacing of ADC to 8051
DAC
• Microcontroller are used in wide variety of applications like
for measuring and control of physical quantity like
temperature, pressure, speed, distance, etc.
• In these systems microcontroller generates output which is in
digital form but the controlling system requires analog signal
as they don't accept digital data thus making it necessary to
use DAC which converts digital data into equivalent
analog voltage.
• In the figure shown, we use 8-bit DAC 0808. This IC converts
digital data into equivalent analog Current. Hence we require
an I to V converter to convert this current into equivalent
voltage.
• According to theory of DAC Equivalent analog output is
given as:
Interfacing Diagram
• Types of Digital to Analog Converter (DAC)
• There are basically four types of Digital to Analog
Converter circuits namely:
• Binary Weighted Resistor D/A Converter Circuit
• Binary ladder or R–2R ladder D/A Converter
Circuit
• Segmented DAC
• Delta-Sigma DAC
• Advantages of Digital to Analog Converter
(DAC)
• The advantages of Digital to Analog Converter
are:
• Weighted Resistor Circuit is the fastest
converting circuit compared to other
methods.
• High resolution and accuracy can be achieved.
• DAC’s are simple to implement.
Disadvantages of Digital to Analog Converter (DAC)
The disadvantages of DAC are:
• Voltage levels must be exactly the same for all
inputs in Weighted Resistors DAC. E.g. 4-bit
Converter requires 4 resistors.
• Binary weighted Resistor circuit that require Op-
Amps are expensive.
• Power dissipation of Binary weighted Resistors
Circuit is very high.
• In R-2R Ladder converters, Delay is caused as the
circuit needs switching based on the inputs.
• Gain Error, Offset Error, Non-linearity is commonly
caused by Resistors used in the circuit.
Draw an interacting diagram of DAC with 8051 and write an embedded C
program for generation of Triangular having frequency of 50Hz.
#include<reg51.h> }
void delay(unsigned int); }
void main(void) }
{
unsigned int x;
For(;;) void delay(unsigned int time)
{ {
for(x=0;x<250;x++) unsigned int i,j;
{ for(i=0;i<time;i++)
P1=x; for(j=0;j<1275;j++);
delay(100); }
}
for(x=250;x>0;x–)
{
P1=x;
delay(100);
Stepper motor
• The Stepper motor is a brushless DC motor that divides the full rotation
angle of 360° into a number of equal steps.
• The motor is rotated by applying a certain sequence of control signals. The
speed of rotation can be changed by changing the rate at which the control
signals are applied.
• Various stepper motors with different step angles and torque ratings are
available in the market.
• A microcontroller can be used to apply different control signals to the
motor to make it rotate according to the need of the application.
• For more information about Stepper Motor and how to use it, refer to the
topic Stepper Motor in the sensors and modules section.
Interfacing of 8051 with stepper motor
Write an embedded C program to rotate the stepper motor in
clockwise direction continuously with highest delay generated
using timer 0 mode1 .
#include< reg51.h>
void delay(void); P2 = 0x03;
Void main() delay();
{ P2 = 0x01;
while( 1) delay();
{ }
for(i=0; i<12; i++) }
{ void delay(void)
P2 = 0x09; {
delay(); TMOD=0x01;
P2 = 0x08; TL0=0x00;
delay(); TH0=0x00;
P2 = 0x0C; TR0=1;
delay(); While(TF0==0);
P2 = 0x04; TR0=0;
delay(); TF0=0;
P2 = 0x06; }
delay();
P2 = 0x02;
delay();
Relay
• A relay is an electronically operated switch that is remotely
activated by an electromagnet which pulls a set of contacts to
either make or break a circuit.
• Electrical relays are commonly used for switching signals,
radio frequencies, high current circuits when using a lower
current circuit, and loads such as resistive, motor, lamp,
inductive, and capacitive applications.
• This is helpful when an in-line switch or existing circuit does
not have the capacity to handle the required current.
Interfacing Relay with 8051 microcontroller
#include<reg51.h> }
sbit relay_pin = P2^0; while(1);
void Delay_ms(int); }
void main() void Delay_ms(int k)
{ {
do int j;
{ int i;
relay_pin = 0; //Relay ON for(i=0;i<k;i++)
Delay_ms(1000); for(j=0;j<100;j++)
relay_pin = 1; //Relay OFF }
Delay_ms(1000);
Buzzer
• An audio signaling device like a beeper or buzzer may be
electromechanical or piezoelectric or mechanical type.
• The main function of this is to convert the signal from audio to
sound. Generally, it is powered through DC voltage and used
in timers, alarm devices, printers, alarms, computers, etc.
• Based on the various designs, it can generate different sounds
like alarm, music, bell & siren.
Interfacing Buzzer with 8051 microcontroller
#include "REG51.h" for(i=0;i<4500;i++); // Delay
#define buz P1 buz=0x00; // OFF Buzzer
sbit SW=P3^0; for(i=0;i<4500;i++); // Delay
long int i; }
void main() }
{ }
while(1) }
{
if (SW==0)
{ for(i=0;i<=9000;i++);
if(SW==0)
{
while(SW==0);
buz=0x01; // ON Buzzer
Optoisolators
• optocoupler is also called optoisolator, photocoupler and
optical isolator. It is used to provide isolation between two
electrical circuits.
• It is a electrical component which is used to transmit input
signal by using light energy signals. It provides electrical
coupling between input and output through light waves.
• Its main purpose is to avoid changing in voltages at output
side to appearing at input side. Higher voltage fluctuations
may damage input side electrical components.
Interfacing Optoisolator with 8051 microcontroller
#include<reg51.h> void Delay_ms(int k)
sbit opto= P2^0; {
void Delay_ms(int); int j;
void main() int i;
{ for(i=0;i<k;i++)
While(1) for(j=0;j<100;j++)
{ }
opto = 0; //ON Delay_ms(1000);
opto = 1; //OFF
Delay_ms(1000);
}
while(1);
}
Data Acquisition System
• A data acquisition system is a system that comprises sensors,
measurement devices, and a computer. A data acquisition system
is used for processing acquired data, which involves collecting the
information required to understand electrical or physical
phenomena.
Types of Data Acquisition Systems
Data acquisition systems can be classified into the following two types.
• Analog Data Acquisition Systems
• Digital Data Acquisition Systems