0% found this document useful (0 votes)
240 views77 pages

I. Company Profile: HCL: Overview

Embedded systems are designed to perform one or a few dedicated functions often with real-time computing constraints. A general-purpose computer is designed to be flexible and to meet a wide range of end-user needs. The key characteristic is however being dedicated to handle a particular task, which may require very powerful processors.

Uploaded by

Rohit Kumar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
240 views77 pages

I. Company Profile: HCL: Overview

Embedded systems are designed to perform one or a few dedicated functions often with real-time computing constraints. A general-purpose computer is designed to be flexible and to meet a wide range of end-user needs. The key characteristic is however being dedicated to handle a particular task, which may require very powerful processors.

Uploaded by

Rohit Kumar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 77

I.

COMPANY PROFILE
HCL: Overview

• Hindustan Computers Ltd., one of the India’s largest electronics, computing and information
Technology Company. Founded in 1976 by Mr. Shiv Nadar, Ajai Chawdhary and four other
colleagues

• Based in Noida, it’s a $ 5 billion company with over 60,000 employees and is working in 26
countries

VISION
A global corporation enriching lives and enabling business transformation for our customers, with leadership
in chosen technologies and markets. Be the first choice for employees and partners, with commitment to
sustainability.

MANAGEMENT OBJECTIVES
To fuel initiative and foster activity by allowing individuals freedom ofaction and innovation in attaining
defined objectives.

STRENTHS OF HCL
1. Industry Experience of 32 years
2. True Corporate Exposure
3. Contemporary Knowledge and World class experience

IMPORTANCE OF MANAGEMENT TRAINING


• To improve knowledge and efficiency for the job

• Provide useful tools to improve the leadership and management ability.

• Understand the roles and responsibilities as a manager.

1
II. JOB ASSIGNED

Introduction: - Designing of various projects based on embedded systems.

III. MODULAR DESCRIPTION OF THE JOB: -

1. Programming in embedded C.
2. I have done programming of controller of 8051 family.
3. I also made some projects.

2
IV. Detail Description of individual module

IV.1 CHAPTER-1

INTRODUCTION

INTRODUCTION TO THE DEPARTMENT

An embedded system is a computer system designed to perform one or a few dedicated functions
often with real-time computing constraints. It is embedded as part of a complete device often including
hardware and mechanical parts. By contrast, a general-purpose computer, such as a personal computer (PC),
is designed to be flexible and to meet a wide range of end-user needs. Embedded systems control many
devices in common use today.

Embedded systems are controlled by one or more main processing cores that is typically either a
microcontroller or a digital signal processor (DSP). The key characteristic is however being dedicated to
handle a particular task, which may require very powerful processors. Since the embedded system is
dedicated to specific tasks, design engineers can optimize it reducing the size and cost of the product and
increasing the reliability and performance.

CHARACTERISTICS

1. Embedded systems are designed to do some specific task, rather than be a general-purpose computer
for multiple tasks. Some also have real-time performance constraints that must be met, for reasons
such as safety and usability; others may have low or no performance requirements, allowing the
system hardware to be simplified to reduce costs.
2. Embedded systems are not always standalone devices. Many embedded systems consist of small,
computerized parts within a larger device that serves a more general purpose.
3. The program instructions written for embedded systems are referred to as firmware, and are stored in
read-only memory or Flash memory chips. They run with limited computer hardware resources: little
memory, small or non-existent keyboard and/or screen.

3
Peripherals

Embedded Systems talk with the outside world via peripherals such as:

• Serial Communication Interfaces (SCI): RS-232, RS-422, RS-485 etc.


• Synchronous Serial Communication Interface: I2C, SPI, SSC and ESSI (Enhanced Synchronous
Serial Interface).
• Universal Serial Bus (USB).
• Multi Media Cards (SD Cards, Compact Flash etc).
• Networks: Ethernet, Controller Area Network, LAN Works, etc.
• Timers: PLL(s), Capture/Compare and Time Processing Units.
• Discrete IO: like as General Purpose Input/Output (GPIO).
• Analog to Digital/Digital to Analog (ADC/DAC).
• Debugging: JTAG, ISP, ICSP, BDM Port, BITP DP9 port.

4
IV.2 CHAPTER-2

SOFTWARE USED
The Keil 8051 Development Tools are designed to solve the complex problems facing embedded software
developers.
• When starting a new project, simply select the microcontroller you use from the Device Database
and the µVision IDE sets all compiler, assembler, linker, and memory options for you.
• Numerous example programs are included to help you get started with the most popular embedded
8051 devices.
• The Keil µVision Debugger accurately simulates on-chip peripherals (I²C, CAN, UART, SPI,
Interrupts, I/O Ports, A/D Converter, D/A Converter, and PWM Modules) of your 8051 device.
Simulation helps you understand hardware configurations and avoids time wasted on setup
problems. Additionally, with simulation, you can write and test applications before target hardware
is available.

VARIOUS STEPS TO USE THE KEIL COMPILER:

• Open keil from the start menu.


• Select a new project from the project menu.
• Make a new folder in any drive.
• Name the project as abc and then click save.
• Right click on target, then options for the target, then choose the device, set the crystal frequency,
click on the create hex file option to create hex file at the output.
• Then create a new file from the file menu and save it with the same name of project using extension
.c or .asm.
• Right clicks on the source group, then click on add files option to add the files and then click on
close.

5
HOW TO DEBUG THE PROGRAM:

• After writing the code, click on file menu and select save.
• Click on project menu and rebuild all target files.
• In build window, it should report as ‘0 Error(s), 0 Warning(s)’.
• Click on debug menu and select start/stop debug session.
• Click on peripherals, select I/O ports like as port 1.
• A new window will pop up, which represents the port and pins.

• Now to execute the program stepwise click on F10 key.


• To exit out click on debug menu and select start/stop debug session.

6
IV.3 CHAPTER-3. STUDY OF VARIOUS MODULES

IV.3 .1 INTERFACING OF LEDs WITH THE MICROCONTROLLER

The LED is based on the semiconductor diode. When a diode is forward biased (switched
on), electrons are able to recombine with holes within the device, releasing energy in the form of photons.
This effect is called electroluminescence and the color of the light (corresponding to the energy of the
photon) is determined by the energy gap of the semiconductor. LEDs present many advantages over
incandescent light sources including lower energy consumption, longer lifetime, improved robustness,
smaller size, faster switching, and greater durability and reliability.

IV.3.1.1CIRCUIT DIAGRAM:

IV.3.1.2 STEPS TO DESIGN THE HARDWARE:

IV.3.1.2.1 COMPONENT REQUIRED:

• LEDs (8).
• 470 resistor (1).
• Switches (3).
• Connecting wires.
7
• Zero PCB.

IV.3.1.2.2 STEPS:

• Take 8 LEDs, solder them on PCB and connect their positive terminal to the +5 V supply through
470 resistor.
• Connect their negative terminal to the 8 pins of microcontroller (say port 1).
• Write code for different patters of LEDs using KEIL software and burn the HEX file of these codes
in microcontroller.

IV.3.1.3 PROGRAM: To shift the 8 LEDs one by one on right hand side.

#include<reg51.h>

#include<intrins.h>

void ms_delay(unsigned char a)

{unsigned char i,j;

for(i=0;i<a;i++)

{for(j=0;j<223;j++)

{_nop_( );}

}}

void s_delay(unsigned char a)

{unsigned char i;

unsigned int j;

for(i=0;i<a;i++)

{for(j=0;j<1000;j++)

{ms_delay(1);

}}}

void main( )

{ int i,j;

while(1)

{P1=0xff;
8
j=P1;

for(i=0;i<=7;i++)

{j=j>>1;

if(i>0)

{j=(0x80) | j;

s_delay(1);

P1=j; } } }

IV.3.2 INTERFACING OF SWITCHES WITH THE MICROCONTROLLER

• Take 2 pin three switches and connect their one pin to the GND.
• Now connect the other pin of switches to three pins of microcontroller (say P3.0, P3.1, P3.2).
• Now burn the code for the three patterns of LEDs using switches.

IV.3.2.1 PROGRAM: Write a code that performs following operations.

• P3.0 = right shift operation.


• P3.1 = left shift operation.
• P3.2 = even/odd LEDs

#include<reg51.h>

#include<intrins.h>

void ms_delay(unsigned char a)

{ unsigned char i,j;

for(i=0;i<a;i++)

{for(j=0;j<223;j++)

{_nop_( );} } }

void s_delay(unsigned char a)

9
{unsigned char i;

unsigned int j;

for(i=0;i<a;i++)

{for(j=0;j<1000;j++)

{ms_delay(1);} } }

void main( )

{ int i,j;

if(P30==0)

{while(1)

{P1=0xff;

j=P1;

for(i=0;i<=7;i++)

{j=j>>1;

if(i>0)

{j=(0x80) | j;}

s_delay(1);

P1=j;}

}}

else if(P31==0)

{int i,j;

while(1)

{P1=0xff;

j=P1;

for(i=0;i<=7;i++)

{j=j<<1;
10
if(i>0)

{j=(0x01)| j; }

s_delay(1);

P1=j;}

else if(P32==0)

{while(1)

{P1=0x55;

s_delay(1);

P1=0xAA;

s_delay(1);

11
IV.3.3 INTERFACING OF SEVEN SEGMENT DISPLAY WITH THE MICROCONTROLLER

• Single seven segment display.


• Double seven segment display.

A seven-segment display (abbreviation: "7-seg(ment) display"), less commonly known as a seven-


segment indicator, is a form of electronic display device for displaying decimal numerals that is an
alternative to the more complex dot-matrix displays. Seven-segment displays are widely used in digital
clocks, electronic meters, and other electronic devices for displaying numerical information.

In addition to the ten numerals, seven segment displays can be used to show letters of the latin,
cyrillic and greek alphabets including punctuation, but only few representations are unambiguous and
intuitive at the same time: uppercase A, B, C, E, F, G, H, I, J, L, O, P, S, U, Y, Z, and lowercase a, b, c, d, g,
h, i, n, o, q, r, t, u.

IV.3.3.1 TYPES OF SEVEN SEGMENT:

• Common anode.
• Common cathode.

Seven segment displays can be divided into 2 types of connection. One is called common anode of
which all the anodes of the LEDs are connected together, leaving the cathodes open for connection. The
other one is called common cathode of which all the cathodes of the LEDs are connected together, leaving
the anodes open for connection.

12
IV.3.3.2 SINGLE SEVEN SEGMENT:

IV.3.3.2.1 CIRCUIT DIAGRAM:

13
14
IV.3.3.2.2 STEPS TO DESIGN THE HARDWARE:

IV.3.3.2.2.1 COMPONENT REQUIRED:

• Seven segment display (2).


• 1K resistor (2).
• BC 557 transistor (2).
• Switches (3).
• Connecting wires.
• Zero PCB.
• 20 pin IC Base.

IV.3.3.2.2.2 STEPS:

• Solder IC base on the zero PCB and then insert seven segment displays in it.
• Now connect the seven segment display to the controller port 2 by taking (a) as LSB segment and (h)
as MSB segment.
• Connect the pins according to the figure shown above.

How to make a code for a digit:

Digit H G f e d c b a Hex
code
0 1 1 0 0 0 0 0 0 0xC0
1 1 1 1 1 1 0 0 1 0xF9

IV.3.3.2.3 PROGRAM: To display 0 to 9 digits on seven segment display.

#include<reg51.h>

#include<intrins.h>

void ms_delay(unsigned char a)

{ unsigned char i,j;

for(i=0;i<a;i++)

15
{for(j=0;j<223;j++)

{_nop_( );} } }

void s_delay(unsigned char a)

{unsigned char i;

unsigned int j;

for(i=0;i<a;i++)

{for(j=0;j<1000;j++)

{ms_delay(1);} } }

void main( )

{ int a[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x98}, int i;

while(1)

{ P1=0xff;

for(i=0;i<=9;i++)

{s_delay(1);

P1=a[i]; } } }

16
IV.3.3.3DOUBLE SEVEN SEGMENT:

IV.3.3.3.1 CIRCUIT DIAGRAM:

17
IV.3.3.3.2 STEPS:

• Solder IC base on the zero PCB and then insert two seven segment displays in it.
• Now connect the two seven segment displays parallely and then connect them to controller’s port 2
by taking (a) as LSB segment and (h) as MSB segment.
• Connect the common Vcc pins of two displays to collector of two BC 557 transistors.
• Connect both the emitters to +Vcc.
• Connect the base of two transistors to the port pins P0.0 and P0.1 through 1K resistor as shown in
circuit diagram.
• Write the code using KEIL software and burn HEX file in the controller.

HOW IT IS POSSIBLE TO DISPLAY 2 DIGITS USING 1 PORT ONLY:

• Switch ON 1 transistor at a time and send data to port pins.


• Switch OFF the first transistor and switch ON the other transistor, send data to port pins.
• Repeat this task for at least 50 times to display the 2 digits.
• This switching is so fast that it appears that both displays are displaying digits continuously.

IV.3.3.3.3 PROGRAM: Write a code that performs following operations.

• P3.0 = one by one increment.


• P3.1 = one by one decrement.
• P3.2 = auto-increment up to 99.

#include<reg51.h>

#include<intrins.h>

void ms_delay(unsigned char a)

{ unsigned char i,j;

for(i=0;i<a;i++)

{for(j=0;j<223;j++)

{ _nop_( );}

18
}

void s_delay(unsigned char a)

{unsigned char i;

unsigned int j;

for(i=0;i<a;i++)

{for(j=0;j<1000;j++)

{ms_delay(1);

int y[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x98};

int i,x,a,b;

void display(int p);

void main( )

{ label: if((P30==0)&&(x<99))

{ x++;

display(x);

goto label;}

else if((P31==0)&&(x>0))

{ x--;

display(x);

goto label;}

19
else if(P32==0)

{ while(x<99)

{display(x);

x++; }

goto label;}

else if((P30==1)&&(P31==1)&&(P32==1))

{display(x);

goto label;

void display(int p)

{ a=p/10;

b=p%10;

for(i=0;i<=50;i++)

{P01=1;

P00=0;

P2=y[a];

ms_delay(5);

P01=0;

P00=1;

P2=y[b];

ms_delay(5); }

20
IV.3.4 INTERFACING OF DC MOTOR WITH THE MICROCONTROLLER

This section begins with an overview of the basic operation of DC motors. Then we describe how to
interface a DC motor to the 8051. Finally, we use C language programs to demonstrate the concept of pulse
width modulation (PWM) and show how to control the speed and direction of a DC motor.

DC MOTOR:

A direct current (DC) motor is another widely used device that translates electrical pulses into mechanical
movement. In the DC motor we have only + and - leads. Connecting them to a DC voltage source moves the
motor in one direction. By reversing the polarity, the DC motor will move in the opposite direction. One can
easily experiment with the DC motor. For example, small fans used in many motherboards to cool the CPU
are run by DC motors. By connecting their leads to the + and - voltage source, the DC motor moves. While a
stepper motor moves in steps of 1 to 15 degrees, the DC motor moves continuously. In a stepper motor, if
we know the starting position we can easily count the number of steps the motor has moved and calculate
the final position of the motor. This is not possible in a DC motor. The maximum speed of a DC motor is
indicated in rpm and is given in the data sheet. The DC motor has two rpms: no-load and loaded. The
manufacturer's data sheet gives the no-load rpm. The no-load rpm can be from a few thousand to tens of
thousands. The rpm is reduced when moving a load and it decreases as the load is increased. For example, a
drill turning a screw has a much lower rpm speed than when it is in the no-load situation. DC motors also
have voltage and current ratings. The nominal voltage is the voltage for that motor under normal conditions,
and can be from 1 to 150V, depending on the motor. As we increase the voltage, the rpm goes up. The
current rating is the current consumption when the nominal voltage is applied with no load, and can be from
25mA to a few amps. As the load increases, the rpm is decreased, unless the current or voltage provided to
the motor is increased, which in turn increases the torque. With a fixed voltage, as the load increases, the
current (power) consumption of a DC motor is increased. If we overload the motor it will stall, and that can
damage the motor due to the heat generated by high current consumption.

IV.3.4.1 Unidirection Control:


Figure shows the DC motor rotation for clockwise (CW) and counterclockwise (CCW) rotations.

21
IV.3.4.2 Bidirectional control:

With the help of relays or some specially designed chips we can change the direction of the DC motor
rotation. Following figures show the basic concepts of H-Bridge control of DC motors.

H-Bridge Motor Configuration:

Figure shows the connection of an H-Bridge using simple switches. All the switches are open, which does
not allow the motor to turn.

IV.3.4.2.1 H-Bridge Motor Clockwise Configuration:

Figure shows the switch configuration for turning the motor in one direction. When switches 1 and 4 are
closed, current is allowed to pass through the motor.

22
IV.3.4.2.2 H-Bridge Motor Counterclockwise Configuration:

Figure shows the switch configuration for turning the motor in the opposite direction from the configuration
of above figure. When switches 2 and 3 are closed, current is allowed to pass through the motor

23
IV.3.4.3 Pulse width modulation (PWM):

The speed of the motor depends on three factors: (a) load, (b) voltage, and (c) current. For a given fixed load
we can maintain a steady speed by using a method called pulse width modulation (PWM). By changing
(modulating) the width of the pulse applied to the DC motor we can increase or decrease the amount of
power provided to the motor, thereby increasing or decreasing the motor speed. Notice that, although the
voltage has fixed amplitude, it has a variable duty cycle. That means the wider the pulse, the higher the
speed. PWM is so widely used in DC motor control that some microcontrollers come with the PWM
circuitry embedded in the chip. In such microcontrollers all we have to do is load the proper registers with
the values of the high and low portions of the desired pulse, and the rest is taken care by the microcontroller.
This allows the microcontroller to do other things. For microcontrollers without PWM circuitry, we must
create the various duty cycle pulses using software, which prevents the microcontroller from doing other
things. The ability to control the speed of the DC motor using PWM is one reason that DC motors are
preferable over AC motors. AC motor speed is dictated by the AC frequency of the voltage applied to the
motor and the frequency is generally fixed. As a result, we cannot control the speed of the AC motor when
the load is increased.

Pulse Width Modulation Comparison:

24
IV.3.4.4 CIRCUIT DIAGRAM:

25
IV.3.4.5 STEPS TO DESIGN THE HARDWARE:

IV.3.4.5.1 COMPONENT REQUIRED:

• 4n35 Optocoupler (6).


• 470 resistor (6).
• 1K resistor (6).
• BC 369 transistors (6).
• IN4007 diodes (6).
• 12 V relay (1).
• 6 pin IC Base (6).
• Connecting wires.
• 12 V DC motor (1).
• Zero PCB (3).
• Switches (2).

How to drive the motor unidirectional?

IV.3.4.5.2 STEPS:

• Solder IC Base on the Zero PCB.


• Then connect first pin of 4n35 to +5V supply through 470 resistor.
• Connect second pin to controller P0.2.
• Connect base pin of BC369 to pin 5 through a 1K resistor.
• Connect 4 pin and collector of transistor to ground.
• Connect a diode and 12V supply to emitter as shown in the circuit diagram.
• Connect motor across the emitter and 12V supply.

26
IV.3.4.6 PROGRAM: Write a code that performs following operations.

• P3.0 = switch ON the motor.


• P3.1 = switch OFF the motor.

#include<reg51.h>

#include<intrins.h>

void main( )

{ if((P30==1)&&(P31==1))

{goto label2;}

label1: if(P30==0)

{while(1)

{P02=0;

if((P31==0)&&(P30==1))

{goto label2;} } }

label2: {while(1)

{P02=1;

if((P30==0)&&(P31==1))

{goto label1;} } } }

IV.3.4.7 PROGRAM: Write a code that performs following operations.

• P3.0 = rotate motor at slow speed.


• P3.1 = rotate motor at medium speed.
• P3.2 = rotate motor at high speed.

#include<reg51.h>

#include<intrins.h>

void mic_delay(unsigned char a)

{ unsigned char i;

for(i=0;i<a;i++)

27
{_nop_( );}

void medspeed( );

void highspeed( );

void lowspeed( );

void main( )

{if((P30==1)&&(P31==1)&&(P32==1))

{while(1)

{P02=1;

if((P30==1)||(P31==1)||(P32==1))

{goto label;}

label: if(P30==0)

{while(1)

{lowspeed( );

if((P30==1)&&((P31==0)||(P32==0)))

{goto label;}

else if(P31==0)

{while(1)

{medspeed( );
28
if((P31==1)&&((P30==0)||(P32==0)))

{goto label; }

else if(P32==0)

{while(1)

{highspeed( );

if((P32==1)&&((P30==0)||(P31==0)))

{goto label;}

}}

void lowspeed( )

{P02=0;

mic_delay(25);

P02=1;

mic_delay(75);}

void medspeed( )

{P02=0;

mic_delay(50);

P02=1;

mic_delay(50);}

void highspeed( )

{P02=0;}
29
IV.3.5 RELAY:

A relay is an electrically operated switch. Current flowing through the coil of the relay creates a
magnetic field which attracts a lever and changes the switch contacts. The coil current can be on or off so
relays have two switch positions and most have double throw (changeover) switch contacts as shown in the
diagram.

Relays allow one circuit to switch a second circuit which can be completely separate from the first.
For example a low voltage battery circuit can use a relay to switch a 230V AC mains circuit. There is no
electrical connection inside the relay between the two circuits; the link is magnetic and mechanical.

Most relays are designed for PCB mounting but you can solder wires directly to the pins providing you take
care to avoid melting the plastic case of the relay. The supplier's catalogue should show you the relay's
connections. The coil will be obvious and it may be connected either way round. Relay coils produce brief
high voltage 'spikes' when they are switched off and this can destroy transistors and ICs in the circuit. To
prevent damage you must connect a protection diode across the relay coil.

30
IV.3.5.1 CIRCUIT DIAGRAM:

31
IV.3.5.2 STEPS TO DESIGN THE HARDWARE:

• Solder IC Base on the Zero PCB.


• Then connect first pin of 4n35 to +5V supply through 470 resistor.
• Connect second pin to controller P0.2.
• Connect base pin of BC369 to pin 5 through a 1K resistor.
• Connect 4 pin and collector of transistor to ground.
• Connect a diode and 12V supply to emitter as shown in the circuit diagram.
• Connect first pin of relay to 12V supply and second pin to emitter terminal.
• Connect common terminal to 12V supply.
• Connect one end of the motor to NO (normally open) and other end to the ground.

IV.3.5.3 PROGRAM: Write a code that performs following operations.

• P3.0 = switch ON the motor.


• P3.1 = switch OFF the motor.

#include<reg51.h>

#include<intrins.h>

void main( )

{ if((P30==1)&&(P31==1))

{goto label2;}

label1: if(P30==0)

{while(1)

{P02=0;

if((P31==0)&&(P30==1))

{goto label2;} } }

label2: {while(1)

{P02=1;

if((P30==0)&&(P31==1))

{goto label1;

}
32
}

33
IV.3.6 INTERFACING OF DC MOTOR AND H-BRIDGE CIRCUIT WITH THE
MICROCONTROLLER

IV.3.6.1 CIRCUIT DIAGRAM:

34
IV.3.6.2 PROGRAM: Write a code that performs following operations.

• P3.0 = rotate clockwise direction.


• P3.1 = rotate anti-clockwise direction.
• P3.2 = switch OFF the motor.

#include<reg51.h>

#include<intrins.h>

void main( )

{label:

if(P30==0)

{while(1)

{P03=P04=1;

P02=P05=0;

if((P31==0)||(P32==0))

{goto label;} } }

else if(P31==0)

{while(1)

{P02=P05=1;

P03=P04=0;

if((P32==0)||(P30==0))

{goto label; }

else if(P32==0)

{while(1)

{ P02=P03=P04=P05=1;
35
if((P30==0)||(P31==0))

{goto label; }

36
IV.3.7-Liquid Crystal Display

IV.3.7.1 LCD Display


Liquid crystal displays (LCD) are widely used in recent years as compares to LEDs. This is due to the
declining prices of LCD, the ability to display numbers, characters and graphics, incorporation of a
refreshing controller into the LCD, their by relieving the CPU of the task of refreshing the LCD and also the
ease of programming for characters and graphics. HD 44780 based LCDs are most commonly used.
The LCD discuss in this section has the most common connector used for the Hitatchi 44780 based LCD is
14 pins in a row and modes of operation and how to program and interface with microcontroller is describes
in this section.

16 Gnd
16 15
15 Vcc
14 D7
14 13
13 D6
12 D5
12 11
11 D4
10 D3
10 9
9 D2
8 D1
8 7
7 D0
3

6 E
6 5
5 R/W
4 RS
4 3 2
3 Contrast
2 Vcc
2 1
1 Gnd
1

Fig 3.21 LCD Pin Description Diagram

VCC, VSS, VEE


The voltage VCC and VSS provided by +5V and ground respectively while VEE is used for controlling LCD
contrast. Variable voltage between Ground and Vcc is used to specify the contrast (or "darkness") of the
characters on the LCD screen.
RS (register select)
There are two important registers inside the LCD. The RS pin is used for their selection as follows. If RS=0,
the instruction command code register is selected, then allowing to user to send a command such as clear
display, cursor at home etc.. If RS=1, the data register is selected, allowing the user to send data to be
displayed on the LCD.
R/W (read/write)
The R/W (read/write) input allowing the user to write information from it. R/W=1, when it read and R/W=0,
when it writing.
EN (enable)
37
The enable pin is used by the LCD to latch information presented to its data pins. When data is supplied to
data pins, a high power, a high-to-low pulse must be applied to this pin in order to for the LCD to latch in
the data presented at the data pins.
D0-D7 (data lines)
The 8-bit data pins, D0-D7, are used to send information to the LCD or read the contents of the LCD’s
internal registers. To displays the letters and numbers, we send ASCII codes for the letters A-Z, a-z, and
numbers 0-9 to these pins while making RS =1. There are also command codes that can be sent to clear the
display or force the cursor to the home position or blink the cursor.
We also use RS =0 to check the busy flag bit to see if the LCD is ready to receive the information. The busy
flag is D7 and can be read when R/W =1 and RS =0, as follows: if R/W =1 and RS =0, when D7 =1(busy
flag =1), the LCD is busy taking care of internal operations and will not accept any information. When D7
=0, the LCD is ready to receive new information.

IV.3.7.2 LCD INTERFACING WITH 8051 MICROCONTROLLER

Frequently, an 8051 program must interact with the outside world using input and output devices that
communicate directly with a human being. One of the most common devices attached to an 8051 is an LCD
display. Some of the most common LCDs connected to the 8051 are 16x2 and 20x2 displays. This means 16
characters per line by 2 lines and 20 characters per line by 2 lines, respectively.
Fortunately, a very popular standard exists which allows us to communicate with the vast majority of LCDs
regardless of their manufacturer. The standard is referred to as HD44780U, which refers to the controller
chip which receives data from an external source (in this case, the 8051) and communicates directly with the
LCD. The 44780 standard requires 3 control lines as well as either 4 or 8 I/O lines for the data bus. The user
may select whether the LCD is to operate with a 4-bit data bus or an 8-bit data bus. If a 4-bit data bus is used
the LCD will require a total of 7 data lines (3 control lines plus the 4 lines for the data bus). If an 8-bit data
bus is used the LCD will require a total of 11 data lines (3 control lines plus the 8 lines for the databus).
The three control lines are referred to as EN, RS, and RW.
The EN line is called "Enable." This control line is used to tell the LCD that you are sending it data. To send
data to the LCD, your program should make sure this line is low (0) and then set the other two control lines
and/or put data on the data bus. When the other lines are completely ready, bring EN high (1) and wait for
the minimum amount of time required by the LCD datasheet (this varies from LCD to LCD), and end by
bringing it low (0) again. The RS line is the "Register Select" line. When RS is low (0), the data is to
betreated as a command or special instruction (such as clear screen, position cursor, etc.). When RS is high
38
(1), the data being sent is text data which sould be displayed on the screen. For example, to display the letter
"T" on the screen you would set RS high. The RW line is the "Read/Write" control line. When RW is low
(0), the information on the data bus is being written to the LCD. When RW is high (1), the program is
effectively querying (or reading) the LCD. Only one instruction ("Get LCD status") is a read command. All
others are write commands--so RW will almost always be low.
Finally, the data bus consists of 4 or 8 lines (depending on the mode of operation selected by the user). In
the case of an 8-bit data bus, the lines are referred to as DB0, DB1, DB2, DB3, DB4, DB5, DB6, and DB7.
As we've mentioned, the LCD requires either 8 or 11 I/O lines to communicate with.
For the sake of this tutorial, we are going to use an 8-bit data bus--so we'll be using 11 of the 8051's I/O pins
to interface with the LCD. Let's draw a sample psuedo-schematic of how the LCD will be connected to the
8051.

As you can see, we've established a 1-to-1 relation between a pin on the 8051 and a line on the 44780 LCD.
Thus as we write our assembly program to access the LCD, we are going to equate constants to the 8051
ports so that we can refer to the lines by their 44780 name as opposed to P0.1, P0.2, etc. Let's go ahead and
write our initial equates:

DB0 EQU P1.0

DB1 EQU P1.1

DB2 EQU P1.2

DB3 EQU P1.3

DB4 EQU P1.4

DB5 EQU P1.5

DB6 EQU P1.6

DB7 EQU P1.7

39
EN EQU P3.7

RS EQU P3.6

RW EQU P3.5

IV.3.7.3 LCD pin description

Pin Symbol I/O Description


1 VSS - Ground
2 VCC - +5V power supply
3 VEE - Power supply to control contrast
4 RS I RS=0 to select command register, RS=1 to select data
register.
6 E I/O Enable
7 PB0 I/O The 8 bit data bus
8 PB1 I/O The 8 bit data bus
9 DB2 I/O The 8 bit data bus
10 DB3 I/O The 8 bit data bus
11 DB4 I/O The 8 bit data bus
12 DB5 I/O The 8 bit data bus
13 DB6 I/O The 8 bit data bus
14 DB7 I/O The 8 bit data bus

IV.3.7.4 PROGRAMME

#include<reg51.h>

#include<intrins.h>

#define data P1

#define RS P33

#define RW P34

40
#define E P35

void ms_delay(unsigned char a)

unsigned char i,j;

for(i=0;i<a;i++)

for(j=0;j<224;j++)

_nop_();

void cmd()

data=ACC;

RS=0;

RW=0;

E=1;

41
ms_delay(10);

E=0;

void display()

data=ACC;

RS=1;

RW=0;

E=1;

ms_delay(10);

E=0;

void lcd_init()

ACC=0x38;

cmd();

ACC=0x80;

cmd();

42
ACC=0x06;

cmd();

ACC=0x0c;

cmd();

ACC=0x01;

cmd();

void main()

lcd_init();

ACC='c';

display();

ACC='h';

display();

ACC='a';

display();

ACC='l';

display();

43
ACC='_';

display();

ACC='g';

display();

ACC='y';

display();

ACC='a';

display();

44
IV.3.8 ANALOG TO DIGITAL CONVERTER 0808

IV.3.8.1 GENERAL DESCRIPTION

The ADC0808, ADC0809 data acquisition component is amonolithic CMOS device With an 8-bit analog-to-
digital converter,8-channel multiplexer and microprocessor compatiblecontrol logic. The 8-bit A/D
converter uses successive approximationas the conversion technique. The converter featuresa high
impedance chopper stabilized comparator, a256R voltage divider with analog switch tree and a
successiveapproximation register. The 8-channel multiplexer candirectly access any of 8-single-ended
analog signals.The device eliminates the need for external zero andfull-scale adjustments. Easy interfacing
to microprocessorsis provided by the latched and decoded multiplexer addressinputs and latched TTL TRI-
STATE® outputs.The design of the ADC0808, ADC0809 has been optimizedby incorporating the most
desirable aspects of several A/Dconversion techniques. The ADC0808, ADC0809 offers highspeed, high
accuracy, minimal temperature dependence, excellentlong-term accuracy and repeatability, and
consumesminimal power. These features make this device ideallysuited to applications from process and
machine control toconsumer and automotive applications.

IV.3.8.2 CIRCUIT DIAGRAM


J3
VCC
J1
1
2
3
4
5
6
7
8

100K
6 C3
5 .01 R1
4
3
2 R2 C1 33pf
1 47K
U2
CON6 1 28
C2 .01 2 IN3 IN2 27
J4
3 IN4 IN1 26
1 IN5 IN0
8

4 J2
2 5 IN6 25
DIS

CV
VCC

THR

IN7 A0 24 1
VCC 6 A1 23 2
U4 7 START A2 3
LM555 8 EOC 22
9 D3 ADC0808 ALE 21
GND

10 OE D7 20
TR

CLK D6
Q

19
11 D5 18 J10
VCC 12 VCC D4 17
1

13 REF+ D0 16 1
14 GND REF- 15 2
D1 D2 3
4
5
6
7
J8
8
1 9
2 10
3
4

45
IV.3.8.2.1 FEATURES

1.Easy interface to all microprocessors

2. Operates ratiometrically or with 5 VDC or analog span

adjusted voltage reference

3. No zero or full-scale adjust required

4.8-channel multiplexer with address logic

5. 0V to 5V input range with single 5V power supply

6. Outputs meet TTL voltage level specifications

7. Standard hermetic or molded 28-pin DIP package

8. 28-pin molded chip carrier package

9. ADC0808 equivalent to MM74C949

IV.3.8.3 PROGRAM

#include<reg51.h>

#include<intrins.h>

#define data P1

#define adc P2

sbit st=P3^4;

sbit RS=P3^5;

sbit RW=P3^6;

sbit E=P3^7;

void ms_delay(unsigned char a)


{

unsigned char i,j;


46
for(i=0;i<a;i++)

for(j=0;j<224;j++)

_nop_();

void cmd(unsigned char x)

data=x;

RS=0;

RW=0;

E=1;

ms_delay(10);

E=0;

void display(unsigned char x)

data=x;

RS=1;

RW=0;

47
E=1;

ms_delay(10);

E=0;

void lcd_init()

cmd(0x38);

cmd(0x38);

cmd(0x80);

cmd(0x06);

cmd(0x0c);

cmd(0x01);

unsigned char cnvrt(void)

st=0;

ms_delay(5);

st=1;

ms_delay(10);

st=0;

ms_delay(5);

ms_delay(20);

48
return (adc);

void print(unsigned char y)

unsigned char D1,D2,D3;

cmd(0x80);

D1=y%10;

y=y/10;

D2=y%10;

D3=y/10;

display(D3+48);

ms_delay(10);

display(D2+48);

ms_delay(10);

display(D1+48);

ms_delay(10);

void main()

unsigned char x;

lcd_init();

while(1)

49
x=cnvrt();

print(2*x);

50
IV.3.9 INTERFACING OF STEPPER MOTOR WITH 8051

IV.3.9.1 STEPPER MOTOR

Motion Control, in electronic terms, means to accurately control the movement of an object based on either
speed, distance, load, inertia or a combination of all these factors. There are numerous types of motion
control systems, including; Stepper Motor, Linear Step Motor, DC Brush, Brushless, Servo, Brushless
Servo and more.
A stepper motor is an electromechanical device which converts electrical pulses into discrete mechanical
movements. Stepper motor is a form of ac. motor .The shaft or spindle of a stepper motor rotates in discrete
step increments when electrical command pulses are applied to it in the proper sequence. The motors
rotation has several direct relationships to these applied input pulses. The sequence of the applied pulses is
directly related to the direction of motor shafts rotation. The speed of the motor shafts rotation is directly
related to the frequency of the input pulses and the length of rotation is directly related to the number of
input pulses applied [39].
For every input pulse, the motor shaft turns through a specified number of degrees, called a step. Its working
principle is one step rotation for one input pulse. The range of step size may vary from 0.72 degree to 90
degree. In position control application, if the number of input pulses sent to the motor is known, the actual
position of the driven job can be obtained.
A stepper motor differs from a conventional motor (CM) as under:

a. Input to SM is in the form of electric pulses whereas input to a CM is invariably from a constant
voltage source.
b. A CM has a free running shaft whereas shaft of SM moves through angular steps.
c. In control system applications, no feedback loop is required when SM is used but a feedback loop is
required when CM is used.
d. A SM is a digital electromechanical device whereas a CM is an analog electromechanical device
[40].

Open Loop Operation:-

One of the most significant advantages of a stepper motor is its ability to be accurately controlled in an open
loop system. Open loop control means no feedback information about position is needed. This type of
control eliminates the need for expensive sensing and feedback devices such as optical encoders. Control
position is known simply by keeping track of the input step pulses [39].

51
Every stepper motor has a permanent magnet rotor (shaft) surrounded by a stator. The most common stepper
motor has four stator windings that are paired with a center-tapped common. This type of stepper motor is
commonly referred to as a four- phase stepper motor. The center tap allows a change of current direction in
each of two coils when a winding is grounded, thereby resulting in a polarity change of the stator. Notice
that while a conventional motor shaft runs freely, the stepper motor shaft moves in a fixed repeatable
increment which allows one to move it to a precise position. This repeatable

Rotor Alignment fixed movement is possible as a result of basic magnetic theory where poles of the Same
polarity repel and opposite poles attract. The direction of the rotation is dictated by the stator poles. The
stator poles are determined by the current sent through the wire coils. As the direction of the current is
changed, the polarity is also changed causing the reverse motion of the rotor. The stepper motor used here
has a total of 5 leads: 4 leads representing the four stator windings and 1 common for the center tapped
leads. As the sequence of power is applied to each stator winding, the rotor will rotate. There are several
widely used sequences where each has a different degree of precision. Table shows the normal 4-step
sequence. For clockwise go for step 1 to 4 & for counter clockwise go for step 4 to 1.

Winding A 1
2
3
Winding B
4
5
6

Winding C Winding D

52
Stator Windings Configuration

Winding A Winding B Winding C Winding D


0 1 1 1
1 1 1
1 0 1
1 1 0

Input Sequence to the Windings

Since the stepper motor is not an ordinary motor and has four separate coils which have to be energised one by
one in a stepwise fashion . We term them as coil A,B,C and D . At a particular instant the coil a should get
supply and then after some delay the coil B should get a supply and then coil C and then coil D and so on the
cycle continues. The more the delay is introduced between the energisation of the coils the lesser is the speed
of the stepper motor and vice versa . For such a complex requirement of alternate supplies to the coil of
stepper motor we need a special unit which will perform this operation . Here we are using a PC to perform
this function . How we perform it is explained below: At the printer port we have 25 pins and out of these 25
pins pin number 2 to 9 are the output pins which can be used to control any hardware circuit .The pin number
10,12,13 and 15 are input pins which can be used get any input signal from an external hardware.The pin
numbers 18to 25 are the ground pins . Since the stepper motor has five wires ; four out of them
corresponding to four coils and one is ground reference , we will be using four output pins(2,3,4, and 5) of the
printer port and any pin out of 18 to 25 for the stepper motor. What we have done is that we connected each
of the output pin of the printer port to the pin number 1 of a different I.C. (817) known as the optocoupler. It
is a four pin I.C. .Its pin number 2 is connected to the ground reference form the printer port. Internally at pin
number 1 of the optocoupler the p- portion of an LED is connected and its n- side is connected to the pin
number 2 . Now when we want to provide supply to the coil A of the stepper motor , we activate the pin
number 2 of the printer port . This will make the LED inside the optocoupler(connected to pin number 2) to
glow and its light falls on the base of a phototransistor which is also mounted inside the optocoupler with its
emitter at pin number 3 and the collectorat its pin number 4 . The falling of light ensures that the base of the
phototransistor
starts conducting and the emitter and the collector are virtually short circuited . We have connected +9 V
supply to the emitter of the phototransisitor which is now being forwarded to the collector . But the output
current of the phototransistor is very low to energise the coil of the stepper motor . So we feed the output of
the stepper motor to a current amplyfying transistor (369) at its base and its emitter is connected to positive
supply . Now the current output will be sufficient to energise the coil . This output is now fed to the coil A
of the stepper motor . Now after a certain delay we activate the pin number 3 of the printer port . This will
53
make the LED inside the optocoupler , to which pin number 3 is connected , to glow and accordingly the
amplified output will fed to coil B for its energisation .This process continues for all the four coils and after
that we can say that the motor has taken a step . If we continue this cycle the motor keeps on rotating.
As we know that the stepper motor comprises of four coils A,B,C, and D . These coils must be given the
supply in the form of steps i.e. firstly coil a should get the supply , then after a delay coil B gets a supply ,
then coil C and then coil D.The more delay you introduce between the passing on of supply from one coil to
another the speed of the motor will be that much slow.Now at the printer port of the computer we have 25
pins and out of them pin number 2 to 9 are output pins which can supply an input to an external hardware ,
which in yours case is a stepper motor . As we need to pass on stepwise input only to four coils we will be
using just pin numbers 2,3,4 and 5 of the printer port .The method of using the output pins of the printer port
is as follows:
If you write a statement:
Outportb(0x378,1);

When this statement will be executed it will send the binary equivalent of the value written after the comma
(i.e. 1) in the form of a byte i.e. 00000001 at the output pins of the printer port.The parameter 0X378 is the
address of the output pins of the printer port and the value in send to these pins starting from pin number 2
.i.e. when this statement will be executed pim number 1 will output a high signal and rest all output pins
willprovide a low signal.Similarly if your statement is:

Outportb(0X378,4);
The execution of this statement will send its binary equivalent i,e, 00000100 at the output pins . It means
that pin number 4 will be getting a signal and will output this to the external circuit and rest all pins will be
low.Thus we connected coils A,B,C,D to the pins 2,3,4,5 and pass supply to them in a stepwise fashion i.e.
we execute the following set tf statements:
Outportb(0x378,1);
Delay(100);
Outportb(0x378,2);
Delay(100);
Outportb(0x378,4);
Delay(100);
Outportb(0x378,8);
Delay(100);

This cycle keeps on continuing. But these output pinsa are not connected directly to the stepper motor. We
always need to isolate any hardware operating from the Computer. So we connect these each of the output
54
pins to an optocoupler IC . Its pin number 1 is connected to the output pins from the PC and pin number 2 is
connected to the ground reference form the PC i.e. any of the pin numbers 18 to 25.When the Pc activates
any output pin the pin number 1 of that particular optocoupler get a +5 V supply. Inside the IC at pin number
we have the p- side of an LED and its n-side is connected at pin number 2. Its pin 3 and 6 are not connected .
Across its pin numbers 4 & 5 a phototransistor is mounted internally whose base is photosensitive. Now
when the output pin of the printer port becomes high ,the corresponding LED
glows and the phototransistor’s base gets activated becauese the light is made to fall on its base. The emitter
of the phototransistor is at pin number 4 of the IC which is connected to negative supply.The activation of
the base pase\ses on the –ve supply from the emitter to the collector which is at the pin number 5 .So now
we get a low signal .This signal is then inverted using hex inverter 4049.But its output is not sufficient to
drive the stepper motor .Hence we need to use a darlington pair assenbly of two transistors(BC 547) in
which the emitter of first drives the base of the second transistor .Their output is now provided to the stepper
motor. Accordingly 4 darlington pairs are required for 4 coils which will operate in a stepwise manner to
pass supply to the coils of stepper motor in a stepwise manner.

STEP ANGLE AND STEPS PER REVOLUTION


Movement associated with a single step, depends on the internal construction of the motor, in particular the
number of teeth on the stator and the rotor. The step angle is the minimum degree of rotation associated with
a single step.
Step per revolution is the total number of steps needed to rotate one complete rotation or 360 degrees (e.g.,
180 steps * 2 degree = 360) [31].
Since the stepper motor is not ordinary motor and has four separate coils, which have to be energized one
by one in a stepwise fashion. We term them as coil A, B, C and D. At a particular instant the coil A should
get supply and then after some delay the coil B should get a supply and then coil C and then coil D and so on
the cycle continues. The more the delay is introduced between the energizing of the coils the lesser is the
speed of the stepper motor and vice versa.
For such a complex requirement of alternate supplies to the coil of stepper motor we need a special unit that
will perform this operation. Here we are using a PC to perform this function.

55
IV.3.9.2 PROGRAM

#define p3 P32
#define p4 P33

void main()
{
unsigned char i;
while(1)
{
for(i=0;i<8;i++)
{
p1=0;
p4=p2=p3=1;
ms_delay(250);

p2=0;
p4=p1=p3=1;
ms_delay(250);

p3=0;
p4=p2=p1=1;
ms_delay(250);

p4=0;
p1=p2=p3=1;
ms_delay(250);
}
p1=p2=p3=p4=1;
secdelay(1);

for(i=0;i<8;i++)
{
p4=0;
p1=p2=p3=1;
ms_delay(250);
56
p3=0;
p4=p1=p2=1;
ms_delay(250);

p2=0;
p4=p3=p1=1;
ms_delay(250);

p1=0;
p4=p2=p3=1;
ms_delay(250);
}
}

57
IV.3.10 SERIAL COMMUNICATION

IV.3.10.1 Data Communication Concepts


Within a microcomputer data is transferred in parallel, because that is the fastest way to do it. For
transferring data over long distances, however, parallel data transmission requires too many wires.
Therefore, data to be sent long distances is usually converted from parallel form to serial form so that it can
be sent on a single wire or pair of wires. Serial data received from a distant source is converted to parallel
form so that it can be easily transferred on the microcomputer buses.
Serial Interface
Basic concepts concerning the serial communication can be classified into categories below:
• Interfacing requirements
• Transmission format
• Error check in data communication
• Standards in serial I/O

Ii/Interfacing Requirements
The serial interface requirement is very much similar to parallel interface requirement. Computer
identifies the peripheral through port address and enable if using the read and write signals. The primary
difference between the parallel I/O and serial I/O is the number of lines used for data transfer. Parallel I/O
requires the entire bus while the serial I/O requires only one or pair of data lines for communication.
i. Transmission Format
Transmission format for communication is concerned with the issues such as synchronization,
direction of data flow, speed, errors and medium of transmission. Serial data can be sent synchronously or
asynchronously.
ii. Synchronous Data Transmission
For synchronous data transmission data is sent in blocks at a constant rate. The start and end of the
block are identified with specific bytes or bit patterns.

iii. Asynchronous Data Transmission


For asynchronous transmission each data character has a bit which identifies its start and 1 or 2 bits,
which identifies its end. Since each character is individually identified, characters can be sent at any time
(asynchronously), in the same way that a person types on a keyboard.
The asynchronous format is character oriented. Each character carries the information of the start and
stop bits. When no data is being transferred ,a receiver stage high at the logic 1 called mark; logic 0 is called
space. The transmission of data begins with one start bit (low) followed by a character and one or two stop

58
bits (high). This is known as framing. The asynchronous format is generally used in low speed transmission
(less than 20k bits/sec) in serial I/O one bit is sent out at a time. Therefore how long the bit stays on or off is
determined by the speed at which bits are transmitted. The receiver should be set up to receive the bits at the
same rate of transmission; otherwise the receiver may not be able to differentiate between the two
consecutive 0s and 1s.
The rate at which the bits are transmitted (bits/sec) is called baud. Each equipment has its own baud
requirements. The figure shown below shows how the ASCII character A (41) will be transmitted with the
1200 baud with the framing information of one start and one stop bit. The bit time (delay between any two
successive bits) is 0.83ms; this is determined by the baud as follows.

Mark
Start Bit
Transmission Data Stop Bit

Asynchronous Data Format

IV. Error Check In Data Communication


During transmission, various types of errors can occur. These errors need to be checked, therefore,
additional information for error checking is sent during transmission the receiver can check the received data
against the error check information, and if the error is detected, the receiver can request there retransmission
of that data segment. Three methods generally used for this purpose are parity check, checksum and
redundancy check.

59
V. Standard in Serial I/O
The serial I/O technique is commonly used to interface terminals, printers etc. a standard is normally
defined by a professional organization (such as IEEE). A standard may include such items as assignment of
pin positions for signals, voltage levels, speed of data transfer, length of cable and mechanical
specifications. When data are transmitted as voltage, the commonly used standard is known as RS232C. it is
defined as reference to data terminal equipment (DTE) and data communication equipment (DCE). The rate
of transmission is RS232C is restricted to a maximum of 20k baud and a distance of 50 feet.

Serial Port Description

The electrical speifications of the serial port are contained in the EIA { Electronics industry Association}
RS232 standard

It states many parameters such as

1. A “Space” {logic 0} will between +3 and +25 Volts.


2. A “Mark” {logic 1} will between -3 and -25 Volts.
3. The region between +3 and -3 volts is undefined.
4. An open circuit voltage should never exceed 25 volts.{In Reference to GND}
5. A short circuit current should not exceed 500 ma.The driver should be able to handle this without
damage.

These connectors come in two forms: A male and a female connector. There are the D-Type 9 pin
connector and D-Type pin connector both of which are male on the back of the PC.The female
connector has holes that allow the pins on the male end to be inserted into the connector.

DB-9

This is a female DB-9 connector:

60
The female DB-9 connector is typically used as the "plug" that goes into a typical PC. If you see one of
these on the back of your computer, it is likely not to be used for serial communication, but rather for things
like early VGA or CGA monitors (not SVGA) or for some special control/joystick equipment.

And this is a male DB-9 connector:

This is the connector that you are more likely to see for serial communications on a "generic" PC. Often you
will see two of them side by side (for COM1 and COM2). Special equipment that you might communicate
with would have either connector, or even one of the DB-25 connectors listed below.

DB-25

This is a female DB-25 connector:

This is what you normally find on the end of a traditional parallel printer cable on a PC. This connector type
is also used frequently for equipment that conforms to RS-232 serial data communication as well, so don't
always assume if you see one of these connectors that it is always parallel. When the original RS-232
specification was written, this was originally the kind of connector that was intended, but because many of
the pins were seldom if ever used, it was switched to the DB-9 connectors on more recent equipment like the
original IBM-PC (yes, that is comparatively recent equipment for this standard).

This is a male DB-25 connector:

61
Male DB-25 connectors are usually used on a PC for parallel data communication, which is beyond the
scope of this series of articles. However, you should still be aware that this connector is also used for serial
communications on many different types of equipment. In fact, if you have a random piece of equipment
that you are trying to see how it works, you can presume that it is a piece of serial equipment. Hacking
random connectors is also beyond the scope of this document, but it can be an interesting hobby by itself.

3.11.2 Pin connections for 9 pin connectors

9 Pin Connector on a DTE device (PC connection)

Male RS232
DB9

Pin Number Direction of signal:

1 Carrier Detect (CD) (from DCE) Incoming signal from a modem

2 Received Data (RD) Incoming Data from a DCE

3 Transmitted Data (TD) Outgoing Data to a DCE

4 Data Terminal Ready (DTR) Outgoing handshaking signal

5 Signal Ground Common reference voltage

6 Data Set Ready (DSR) Incoming handshaking signal

7 Request To Send (RTS) Outgoing flow control signal

8 Clear To Send (CTS) Incoming flow control signal

9 Ring Indicator (RI) (from DCE) Incoming signal from a modem

25 Pin Connector on a DTE device (PC connection)

Male RS232
DB25

Pin Number Direction of signal:

1 Protective Ground

2 Transmitted Data (TD) Outgoing Data (from a DTE to a DCE)

62
3 Received Data (RD) Incoming Data (from a DCE to a DTE)

4 Request To Send (RTS) Outgoing flow control signal controlled by DTE

5 Clear To Send (CTS) Incoming flow control signal controlled by DCE

6 Data Set Ready (DSR) Incoming handshaking signal controlled by DCE

7 Signal Ground Common reference voltage

8 Carrier Detect (CD) Incoming signal from a modem

20 Data Terminal Ready (DTR) Outgoing handshaking signal controlled by DTE

22 Ring Indicator (RI) Incoming signal from a modem

Serial pinouts[D 25 and D9 Connectors]

9-pin 25-pin pin definition

1 8 DCD (Data Carrier Detect)

2 3 RX (Receive Data)

3 2 TX (Transmit Data)

4 20 DTR (Data Terminal Ready)

5 7 GND (Signal Ground)

6 6 DSR (Data Set Ready)

7 4 RTS (Request To Send)

8 5 CTS (Clear To Send))

9 22 RI (Ring Indicator)

The TD (transmit data) wire is the one through which data from a DTE device is transmitted to a DCE
device. This name can be deceiving, because this wire is used by a DCE device to receive its data. The TD
line is kept in a mark condition by the DTE device when it is idle. The RD (receive data) wire is the one on
which data is received by a DTE device, and the DCE device keeps this line in a mark condition when idle.

RTS stands for Request To Send. This line and the CTS line are used when "hardware flow control" is
enabled in both the DTE and DCE devices. The DTE device puts this line in a mark condition to tell the
remote device that it is ready and able to receive data. If the DTE device is not able to receive data (typically
because its receive buffer is almost full), it will put this line in the space condition as a signal to the DCE to
stop sending data. When the DTE device is ready to receive more data (i.e. after data has been removed from
its receive buffer), it will place this line back in the mark condition. The complement of the RTS wire is
CTS, which stands for Clear To Send. The DCE device puts this line in a mark condition to tell the DTE
device that it is ready to receive the data. Likewise, if the DCE device is unable to receive data, it will place
this line in the space condition. Together, these two lines make up what is called RTS/CTS or "hardware"
flow control. The Software Wedge supports this type of flow control, as well as Xon/XOff or "software"
flow control. Software flow control uses special control characters transmitted from one device to another to
tell the other device to stop or start sending data. With software flow control the RTS and CTS lines are not
63
used.

DTR stands for Data Terminal Ready. Its intended function is very similar to the RTS line. DSR (Data Set
Ready) is the companion to DTR in the same way that CTS is to RTS. Some serial devices use DTR and
DSR as signals to simply confirm that a device is connected and is turned on. The Software Wedge sets
DTR to the mark state when the serial port is opened and leaves it in that state until the port is closed. The
DTR and DSR lines were originally designed to provide an alternate method of hardware handshaking. It
would be pointless to use both RTS/CTS and DTR/DSR for flow control signals at the same time. Because
of this, DTR and DSR are rarely used for flow control.

CD stands for Carrier Detect. Carrier Detect is used by a modem to signal that it has a made a connection
with another modem, or has detected a carrier tone.

The last remaining line is RI or Ring Indicator. A modem toggles the state of this line when an incoming call
rings your phone.

The Carrier Detect (CD) and the Ring Indicator (RI) lines are only available in connections to a modem.
Because most modems transmit status information to a PC when either a carrier signal is detected (i.e. when
a connection is made to another modem) or when the line is ringingthese two lines are rarely used

Port Addresses and IRQ’s in the PC are as given below

Name Addresses IRQ

COM 1 3F8 4

COM 2 2F8 3

COM 3 3E8 4

COM 4 2E8 3

RS-232 communication is asychronous.That is a clock signal is not sent with the data. Each word is
synchronized using it,s start bit, and an internal clock on each side, keeps tabs on the timing.

IV.3.10.3 MAX 232 (communication interface)


This chip is used when interfacing micro controller with PC to check the Baud rate and changes the
voltage level because micro controller is TTL compatible whereas PC is CMOS compatible. The MAX 232
IC contains the necessary drivers{two} and receivers {two}, to adapt the RS- 232 signal voltage levels to
TTL logic.It became popular,because it just needs one voltage{+5V} and generates the necessary RS-232
voltage levels{approx -10V AND +10V} internally.This greatly simplified the design of circuitry.And this
made the IC so popular.MAX232 is just a driver/receiver.It does not generate the necessary RS-232
sequence of marks and spaces with the right timing,it does not decode RS-232 signal, it does not provide a
serial /parallel conversion.All it does is to convert signal voltage levels.

64
General Description
The MAX220–MAX249 family of line drivers/receivers is intended for all EIA/TIA-232E and
V.28/V.24 communications interfaces, particularly applications where ±12V is not available. These parts are
especially useful in battery-powered systems, since their low-power shutdown mode reduces power
dissipation to less than 5µW.

Applications

• Portable Computers
• Low-Power Modems
• Interface Translation
• Battery-Powered RS-232 Systems
• Multidrop RS-232 Networks

Features
1. Superior to bipolar
2. Low-power receive mode in shutdown
3. Meet all EIA/TIA-232E and v.28 specifications.
4. 3-state driver and receiver output.
The MAX220–MAX249 contain four sections: dual charge-pump DC-DC voltage converters, RS-
232 drivers, RS-232 receivers, and receiver and transmitter enable control inputs.

65
IV.3.10.4 CIRCUIT DIAGRAM

Dual Charge-Pump Voltage Converter

The MAX220–MAX249 have two internal charge-pumps that convert +5V to ±10V (unloaded) for
RS-232 driver operation. The first converter uses capacitor C1 to double the +5V input to +10V on C3 at the
V+ output. The second converter uses capacitor C2 to invert +10V to -10V on C4 at the V- output. A small
amount of power may be drawn from the +10V (V+) and -10V (V-) outputs to power external circuitry
except on the MAX225 and MAX245–MAX247, where these pins are not available. V+ and V- are not
regulated, so the output voltage drops with increasing load current. Do not load V+ and V- to a point that
violates the minimum ±5V EIA/TIA-232E driver output voltage when sourcing current from V+ and V- to
external circuitry. When using the shutdown feature in the MAX222, MAX225, MAX230, MAX235,
MAX236, MAX240, MAX241, and MAX245–MAX249, avoid using V+ and V to power external circuitry.
When these parts are shut down, V- falls to 0V, and V+ falls to +5V. For applications where a +10V
66
external supply is applied to the V+ pin (instead of using the internal charge pump to generate +10V), the
C1 capacitor must not be installed and the SHDN pin must be tied to VCC. This is because V+ is internally
connected to VCC in shutdown mode.

RS-232 Drivers

The typical driver output voltage swing is ±8V when loaded with a nominal 5k RS-232 receiver
and VCC = +5V. Output swing is guaranteed to meet the EIA/TIA- 232E and V.28 specification, which
calls for ±5V minimum driver output levels under worst-case conditions. These include a minimum 3k
load, VCC = +4.5V, and maximum operating temperature. Unloaded driver output voltage ranges from (V+
-1.3V) to (V- +0.5V). Input thresholds are both TTL and CMOS compatible. The inputs of unused drivers
can be left unconnected since 400k input pull-up resistors to VCC are built in (except for the MAX220).
The pull-up resistors force the outputs of unused drivers low because all drivers invert. The internal input
pull-up resistors typically source 12µA, except in shutdown mode where the pull-ups are disabled. Driver
outputs turn off and enter a high-impedance state—where leakage current is typically microamperes
(maximum 25µA)—when in shutdown mode, or when in three-state mode, device power is removed.
Outputs can be driven to ±15V. The power supply current typically drops to 8µA in shutdown mode.
The MAX220 does not have pull-up resistors to force the outputs of the unused drivers low. Connect
unused inputs to GND or VCC. The MAX239 has a receiver three-state control line, and the MAX223,
MAX225, MAX235, MAX236, MAX240, and MAX241 have both a receiver three-state control line and a
low-power shutdown control. The receiver TTL/CMOS outputs are in a high-impedance, three-state mode
whenever the three-state enable line is high (for the MAX225/MAX235/MAX236/MAX239– MAX241),
and are also high-impedance whenever the shutdown control line is high. When in low-power shutdown
mode, the driver outputs are turned off and their leakage current is less than 1µA with the driver output
pulled to ground. The driver output leakage remains less than 1µA, even if the transmitter output is back
driven between 0V and (VCC + 6V). Below -0.5V, the transmitter is diode clamped to ground with 1k
series impedance. The transmitter is also zener clamped to approximately VCC + 6V, with a series
impedance of 1k . The driver output slew rate is limited to less than 30V/µs as required by the EIA/TIA-
232E and V.28 specifications. Typical slew rates are 24V/µs unloaded and 10V/µs loaded with 3 and
2500pF.

RS-232 Receivers

EIA/TIA-232E and V.28 specifications define a voltage level greater than 3V as logic 0, so all
receivers invert. Input thresholds are set at 0.8V and 2.4V, so receivers respond to TTL level inputs as well
as EIA/TIA-232E and V.28 levels. The receiver inputs withstand an input over voltage up to ±25V and

67
provide input terminating resistors with nominal 5k values. The receivers implement Type 1 interpretation
of the fault conditions of V.28 and EIA/TIA-232E. The receiver input hysteresis is typically 0.5V with a
guaranteed minimum of 0.2V. This produces clear output transitions with slow-moving input signals, even
with moderate amounts of noise and ringing. The receiver propagation delay is typically 600ns and is
independent of input swing direction.

IV.3.10.5 PROGRAM
#include<reg51.h>
#include<intrins.h>
void main()
{unsigned char a[13]={"GOOD MORNING\0"};
unsigned char x;
TMOD=0x20;
TH1=0xfa;
SCON=0x50;
TR1=1;

for(x=0;x<=11;x++)
{SBUF=a[x];
here:if(TI==0)
{goto here;}
TI=0;
}

68
V. Practical Application

• Consumer Electronics
• Industrial Automation
• Medical Electronics
• Computer Networking
• Telecommunication
• Wireless Technologies
• Instrumentation
• Security

69
VI. Conclusion

Overall my six month training was a great practical experience in the field of embedded technology.
I have done all the peripheral of 8051 controller ex. UART, ADC, I/O Ports etc..Now I know how to use
microcontroller in the industries.

70
VII. DATA SHEETS

PNP Silicon AF Transistor BC 369

Maximum Ratings
Type Marking Ordering Code Pin Configuration Package

BC 369 – C62702-C748 TO-92

Parameter Symbol Values Unit

Collector-emitter voltage VCE0 20 V


Peak collector current ICM 2
Base current IB 100 mA
Collector current IC 1 A
Junction temperature Tj 150 °C
Total power dissipation, TC = 90 °C2) Ptot 0.8 (1) W
Storage temperature range Tstg – 65 … + 150
Collector-base voltage VCB0 25
Thermal Resistance

Junction - ambient2) Rth JA 156 K/W


Emitter-base voltage VEB0 5
Peak base current IBM 200
Junction - case3) Rth JC 75

71
LIQUID CRYSTAL DISPLAY
SPECFICATIONS FOR LIQUID CRYSTAL DISPLAY MODULE
MODEL NO: DV-16100-S2FBLY
DATA VISION 99/08/30 4 / 20
Item Characteristic
Number of Characters 16 1
Dot dimensions(mm) 0.55 0.75
Dot spacing (mm) 0.08
Character Size (mm) 3.07 6.56
Module dimensions (Horizontal
Vertical Thickness, mm)
80.0 36.0 14.5max.
Viewing area (Horizontal Vertical, mm)
65.0 14.0
Active area (Horizontal Vertical,mm)

ABSOLUTE MAXIMUM RATING

Electrical Characteristics (Without LED backlight)

72
73
OPTOCOUPLER

COMPATIBLE WITH STANDARD TTL INTEGRATED CIRCUITS


_ Gallium-Arsenide-Diode Infrared Source
Optically Coupled to a Silicon npn
Phototransistor
_ High Direct-Current Transfer Ratio
_ High-Voltage Electrical Isolation
1.5-kV, 2.5-kV, or 3.55-kV Rating
_ High-Speed Switching
tr = 7 ms, tf = 7 ms Typical
_ Typical Applications Include Remote
Terminal Isolation, SCR and Triac Triggers,
Mechanical Relays and Pulse Transformers
_ Safety Regulatory Approval
UL/CUL, File No. E65085
absolute maximum ratings at 25°C free-air temperature (unless otherwise noted)†
Input-to-output peak voltage (8-ms half sine wave): 4N35 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.55
kV
4N36 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.5 kV
4N37 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.5 kV
Input-to-output root-mean-square voltage (8-ms half sine wave): 4N35 . . . . . . . . . . . . . . . . . . . . . . . . . 2.5
kV
4N36 . . . . . . . . . . . . . . . . . . . . . . . . 1.75 kV
4N37 . . . . . . . . . . . . . . . . . . . . . . . . 1.05 kV
Collector-base voltage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. 70 V
Collector-emitter voltage (see Note 1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
30 V
Emitter-base voltage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
..7V
Input-diode reverse voltage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
.6V
Input-diode forward current: Continuous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
mA
Peak (1 ms, 300 pps) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
74
3A
Phototransistor continuous collector current . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
mA
Continuous total power dissipation at (or below) 25°C free-air temperature:
Infrared-emitting diode (see Note 2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 mW
Phototransistor (see Note 3) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300 mW
Continuous power dissipation at (or below) 25°C lead temperature:
Infrared-emitting diode (see Note 4) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 mW
Phototransistor (see Note 5) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500 mW
Operating temperature range, TA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . –55°C to
100°C
Storage temperature range, Tstg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . –55°C to
150°C
Lead temperature 1,6 mm (1/16 inch) from case for 10 seconds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260°C
† Stresses beyond those listed under “absolute maximum ratings” may cause permanent damage to the
device. These are stress ratings only, and
functional operation of the device at these conditions is not implied. Exposure to absolute-maximum-rated
conditions for extended periods may
affect device reliability.
NOTES: 1. This value applies when the base-emitter diode is open-circulated.
2. Derate linearly to 100°C free-air temperature at the rate of 1.33 mW/°C.
3. Derate linearly to 100°C free-air temperature at the rate of 4 mW/°C.
4. Derate linearly to 100°C lead temperature at the rate of 1.33 mW/°C. Lead temperature is measured on the
collector lead
0.8 mm (1/32 inch) from the case.
5. Derate linearly to 100°C lead temperature at the rate of 6.7 mW/°C.
PRODUCTION DATA information is current as of publication date. Copyright W 1998, Texas Instruments
Incorporated
Products conform to specifications per the terms of Texas Instruments
standard warranty. Production processing does not necessarily include
testing of all parameters.

75
TEMPERATURE SENSOR

The LM35 series are precision integrated-circuit temperature sensors, whose output voltage is linearly
proportional to the Celsius (Centigrade) temperature. The LM35 thus has an advantage over linear
temperature sensors calibrated in ° Kelvin, as the user is not required to subtract a large constant voltage
from its output to obtain convenient Centigrade scaling. The LM35 does not require any external calibration
or trimming to provide typical accuracies of ±1⁄4°C at room temperature and ±3⁄4°C over a full −55 to
+150°C temperature range. Low cost is assured by trimming and calibration at the wafer level. The LM35’s
low output impedance, linear output, and precise inherent calibration make interfacing to readout or control
circuitry especially easy. It can be used with single power supplies, or with plus and minus supplies. As it
draws only 60 A from its supply, it has very low self-heating, less than 0.1°C in still air. The LM35 is rated
to operate over a −55° to +150°C temperature range, while the LM35C is rated for a −40° to +110°C range
(−10° with improved accuracy). The LM35 series is available packaged in hermetic TO-46 transistor
packages, while the LM35C, LM35CA, and LM35D are also available in the plastic TO-92 transistor
package. The LM35D is also available in an 8-lead surface mount small outline package and a plastic TO-
220 package. Features
• Calibrated directly in ° Celsius (Centigrade)
• Linear + 10.0 mV/°C scale factor
• 0.5°C accuracy guaranteeable (at +25°C)
• Rated for full −55° to +150°C range
• Suitable for remote applications
• Low cost due to wafer-level trimming
• Operates from 4 to 30 volts
• Less than 60 A current drain
• Low self-heating, 0.08°C in still air
• Nonlinearity only ±1⁄4°C typical
• Low impedance output, 0.1 W for 1 mA load

76
VIII. Bibliography

Electronics for you

http://www.atmel.com

http://www.electronics4u.com

http://www.alldatasheet.com

IX. References
BOOK: - Let Us C by “Yashavant P. Kanetkar”
Embedded System by “Mohmmad Ali Mazidi”

Datasheets: - AT89C51 by “Atmel”


BC369 by “Fairchild”

77

You might also like