Documente Academic
Documente Profesional
Documente Cultură
by
2
LIST OF FIGURES
3
ABSTRACT
Technology Involved
Hardware Used:
8-bit microcontroller (AT89S52),
Darlington pair,
Relays SPDT,
Software Used:
Keil Compiler
4
CONTENTS
List of Figures 3
Abstract 4
Contents 5
CHAPTER 1: INTRODUCTION
1.1. Hardware used 7
1.2. Brief overview of peripherals attached 7
1.3. Description 7
1.4 Features 8
5
3.2.2. Uses of Relays
15
3.3. AT89S52 Microcontroller 16
3.4.1. Description 20
3.4.2. Available types
20
3.4.3. Features 20
3.4.4. Block Diagram 20
CHAPTER 4: TESTING
4.1. Hardware Testing 22
4.1.1. Without IC 22
4.1.2. With IC 22
4.2. Software Testing 23
4.2.1. Relay Testing 23
4.2.2. Remote Testing 24
CHAPTER 5: SNAPSHOTS
5.1. Block Diagram 29
5.2. Circuit Diagram 30
5.2.1 Circuit Diagram of Controller 30
5.2.2 Circuit Diagram of Darlington Pair 31
5.2.3 Circuit Diagram of TSOP 31
5.3 Snapshots
5.3.1. Project at ON state 32
5.3.2. When Relay 1 is ON 33
5.3.3. When Relay 2 is ON 34
5.3.4. When Relay 3 is ON 35
5.3.5. When Relay 4 is ON 36
5.3.6. When all relays are OFF 37
5.3.7. Remote used 37
CHAPTER 7: REFERNECES 39
6
Chapter-1
Introduction to Project
7
It is basically an embedded system based project and in this project I am controlling an
electronic device from remote location i.e. infrared. This idea is having a lot of
applications in daily life. It uses both the software as well as hardware part. The main
purpose of this project is to run equipment through the remote location without use of
wires i.e. through wireless media. User can switch on/off his home appliances by remote
as per user requirement and user is far apart from the device.
1.4 Features:
8
CHAPTER 2
LITERATURE: A REVIEW
2.1.1 Components
Components in an Embedded System are as:-
• Hardware
• Input & Output
• Software
9
• LCD
• Motors
• Serial data
2.1.5 Characteristics
Characteristics of Embedded System are:-
• Perform a single set of functions.
• It works in a time constraint environment.
• Most of the embedded system avoids mechanical moving parts because of friction
& due to friction losses are their & hence probability of accuracy decreases.
• Embedded systems have low cost due to mars production.
10
• Consumer electronics, e.g., cameras, camcorders,
• Consumer products, e.g., washers, microwave ovens, ...
• Automobiles (anti-lock braking, engine control...)
• Industrial process controllers & avionics/defense
• Computer/Communication products, e.g. printers, FAX Machine
• Emerging multimedia applications e.g. cell phones, personal digital assistants…
2.1.8 Difference between Embedded System & General Computing
Platform
• An embedded system will have very few resources compared to general purpose
computing systems like a desktop computer.
• The memory capacity and processing power in an embedded system is limited
where as it is more challenging to develop an application in embedded system due
to its constricted environment as compared to developing the same for a desktop
system.
2.2 Micro-Controller
11
2.2.1.2 8 – Bit Microcontrollers
• Represent a transition zone between dedicated, high-volume, 4-bit micro-
controllers and the high performance 16 bit microcontroller
• 8 – Bit word size adequate for many computing tasks and control or monitoring
applications.
• Application: simple appliance control, high-speed machine control, data
collection
2.2.1.3 16 – Bit Microcontrollers
• Provide faster response and more sophisticated calculations
• Applications: control of servomechanism like robot arm
12
RAM(bytes) 128 128 256
Timers 2 2 3
I/O Pins 32 32 32
Serial Port 1 1 1
Interrupt Sources 6 6 8
13
CHAPTER 3
TECHNOLOGY INVOLVED
In some application the amount of input current available to switch on a transistor is very
low. This may mean that a single transistor may not be able to pass sufficient current
required by the load. As stated earlier this equals the input current x the gain of the
transistor (hFE). If it is not be possible to increase the input current then we need to
increase the gain of the transistor. This can be achieved by using a Darlington Pair.
A Darlington Pair acts as one transistor but with a current gain that equals:
Total current gain (hFE total) = current gain of transistor 1 (hFE t1) x current gain of
transistor 2 (hFE t2)
So for example if you had two transistors with a current gain (hFE) = 100:
(hFE total) = 100 x 100
(hFE total) = 10,000
You can see that this gives a vastly increased current gain when compared to a single
transistor. Therefore this will allow a very low input current to switch a much bigger load
current.
14
It is also worth noting that the voltage drop across collector and emitter pins of the
Darlington Pair when the turn on will be around 0.9V Therefore if the supply voltage is
5V (as above) the voltage across the load will be will be around 4.1V (5V – 0.9V)
3.2 RELAYS
3.2.1 SPDT Relays:
(Single Pole Double Throw Relay) an electromagnetic switch, consist of a coil (terminals
85 & 86), 1 common terminal (30), 1 normally closed terminal (87a), and one normally
open terminal (87) (Figure 1).
When the coil of an SPDT relay (Figure 1) is at rest (not energized), the common
terminal (30) and the normally closed terminal (87a) have continuity. When the coil is
energized, the common terminal (30) and the normally open terminal (87) have
continuity.
The diagram below center (Figure 2) shows an SPDT relay at rest, with the coil not
energized. The diagram below right (Figure 3) shows the relay with the coil energized.
As you can see, the coil is an electromagnet that causes the arm that is always connected
to the common (30) to pivot when energized whereby contact is broken from the
normally closed terminal (87a) and made with the normally open terminal (87).
When energizing the coil of a relay, polarity of the coil does not matter unless there is a
diode across the coil. If a diode is not present, you may attach positive voltage to either
terminal of the coil and negative voltage to the other, otherwise you must connect
positive to the side of the coil that the cathode side (side with stripe) of the diode is
connected and negative to side of the coil that the anode side of the diode is connected.
15
Fig 3.2.1: Pin Diagram of SPDT Relays
Anytime you want to switch a device which draws more current than is provided by an
output of a switch or component you'll need to use a relay. The coil of an SPDT or an
SPST relay that we most commonly use draws very little current (less than 200
milliamps) and the amount of current that you can pass through a relay's common,
normally closed, and normally open contacts will handle up to 30 or 40 amps.
This allows you to switch devices such as headlights, parking lights, horns, etc., with low
amperage outputs such as those found on keyless entry and alarm systems, and other
components. In some cases you may need to switch multiple things at the same time
using one output. A single output connected to multiple relays will allow you to open
continuity and/or close continuity simultaneously on multiple wires.
VCC
Supply voltage.
GND
Ground
Port 0
Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each pin can sink
eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high
impedance inputs. Port 0 can also be configured to be the multiplexed low order
Address/data bus during accesses to external Program and data memory in this mode, P0
has internal Pull ups. Port 0 also receives the code bytes during Flash programming and
outputs the code bytes during program verification. External pull-ups are required during
program verification.
Port 1
Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 1 output buffers
can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled high
by the internal pull-ups and can be used as inputs. As inputs, Port 1 pins that are
16
externally being pulled low will source current (IIL) because of the internal pull-ups. In
addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external count input
(P1.0/T2) and the Timer/counter 2 trigger input (P1.1/T2EX), respectively, as shown in
the following table. Port 1 also receives the low-order address bytes during Flash
programming and verification.
Port 2
Port 2 is an 8-bit bidirectional I/O port with internal pull ups. The Port 2 output buffers
can sink/source four TTL inputs. When 1s are written to Port 2 pins, they are pulled high
by the internal pull-ups and can be used as inputs. As inputs, Port 2 pins that are
externally being pulled low will source Current (IIL) because of the internal pull-ups Port
2 emits the high-order address byte during fetches from external program memory and
during accesses to external data memory that use 16-bit addresses (MOVX @ DPTR). In
this application, Port 2 uses strong internal pull-ups when emitting 1s. During accesses to
external data memory that uses 8-bit addresses (MOVX @ RI); Port 2 emits the contents
of the P2 Special Function Register. Port 2 also receives the high-order address bits and
some control signals during Flash programming and verification.
Port 3
Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 3 output buffers
can sink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled high
by the internal pull-ups and can be used as inputs. As inputs, Port 3 pins that are
externally being pulled low will source current (IIL) because of the pull-ups. Port 3 also
serves the functions of various special features of the AT89S52, as shown in the
following table. Port 3 also receives some control signals for Flash programming and
verification
17
• P3.5 T1 (timer 1 external input)
• P3.6 WR (external data memory write strobe)
• P3.7 RD (external data memory read strobe)
RST
Reset input. A high on this pin for two machine cycles while the oscillator is running
resets the device. This pin drives High for 96 oscillator periods after the Watchdog times
out. The DISRTO bit in SFR AUXR (address 8EH) can be used to disable this feature. In
the default state of bit DISRTO, the RESET HIGH out feature is enabled.
ALE/PROG
Address Latch Enable (ALE) is an output pulse for latching the low byte of the address
during accesses to external memory. This pin is also the program pulse input (PROG)
during Flash programming. In normal operation, ALE is emitted at a constant rate of 1/6
the oscillator frequency and may be used for external timing or clocking purposes. Note,
however, that one ALE pulse is skipped during each access to external data memory. If
desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit
set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is
weakly pulled high. Setting the ALE-disable bit has no Effect if the microcontroller is in
external execution mode.
PSEN
Program Store Enable (PSEN) is the read strobe to external program memory. When the
AT89S52 is executing code from external program memory, PSEN is activated twice
each machine cycle, except that two PSEN activations are skipped during each access to
external data memory.
EA/VPP
External Access Enable EA must be strapped to GND in order to enable the device to
fetch code from external program memory locations starting at 0000H up to FFFFH.
Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset.
EA should be strapped to VCC for internal program executions. This pin also receives the
12-volt programming enable voltage (VPP) during Flash Programming.
XTAL1
Input to the inverting oscillator amplifier and input to the internal clock operating circuit.
XTAL2
Output from the inverting oscillator amplifier.
18
3.3.2 PIN DIAGRAM
19
Fig 3.3.1: Pin Diagram of AT89S52
3.4 TSOP
3.4.1. Description
20
The TSOP17.. – series are miniaturized receivers for infrared remote control systems.
PIN diode and preamplifier are assembled on lead frame, the epoxy package is designed
as IR filter. The demodulated output signal can directly be decoded by a microprocessor.
TSOP17.. is the standard IR remote control receiver series, supporting all major
transmission codes.
Type fo Type fo
TSOP1730 30 kHz TSOP1733 33 kHz
TSOP1736 36 kHz TSOP1737 36.7kHz
TSOP1738 38 kHz TSOP1740 40 kHz
TSOP1756 56 kHz
3.4.3 Features
21
Fig 3.4.2: IR Receiver Module
22
CHAPTER-4
TESTING
4.1 HARDWARE TESTING
4.1.1 WITHOUT IC
Power off testing: in this testing module I have checked continuity to all the peripherals
mounted on the PCB i.e. if there is any loose connection or breakage in between
connections then it must be repaired.
Continuity in between:
• Controller & L293D
• Controller & HT12D
• Controller and LCD
• Controller with Buzzer
• All the components connected to IC’s
• Keys must be short on pressing
• When key pressed then it short with encoder pin
• Signal goes from encoder to decoder also non distorted
• Output of decoder in BCD form supplied to LED’s so, that connection also tight
Power on testing: in this module all the frequencies, voltages, ground, +ve, -ve points
checked i.e. is all the requirements are fulfilled or not i.e. voltages & frequencies supplied
or generated by supply is right or not. In this:
Vcc=5v
Gnd=0v
Reset=0v initial & 5v pressed
4.1.2 WITH IC
With IC testing, power on testing type, in which IC also mounted on its base & supply
connected to main. In this some parameters are observed which are mentioned as below:
Vcc=5v
Gnd=0v
Reset= low-high-low
Crystal Oscillator: in this there are 2 parameters as below Voltage & Frequency.
Voltage at 18 & 19 pin <=2v
Frequency=11.0592MHz
23
4.2 SOFTWARE TESTING
This is that testing module in which the hardware components are tested by running
software on them to check only the connections and hardware. The different hardware
tested in this module is given as with their software’s:
RELAY TESTING
#include <reg51.h>
sbit relay1=P2^3;
sbit relay2=P2^2;
sbit relay3=P2^1;
sbit relay4=P2^0;
sbit ir=P3^2;
//-------------------------
void delay_us(unsigned int);
//-----------------------------
//---------------------
void main()
{
relay1=0;
relay2=0;
relay3=0;
relay4=0;
while(1)
{
relay1=~relay1;
delay_us(50000);
}
}
void delay_us(unsigned int us)
{
TMOD=0x01;
us=65535-us;
TH0=us/255;
TL0=us%255;
TR0=1;
while(TF0==0);
TF0=0;
TR0=0;
}
24
4.2.2. Remote Testing
We are using an IR Remote. To decode the IR signal we use CRO connected with TSOP
and testing phenomenon is as follows:
LO
L1
M0
M1
R1
R0
25
U0
U1
D0
D1
P0
P1
T10
26
T11
T20
T21
T30
T31
27
In this remote, it is using Biphase-S line coding.
So for decoding of same line coding we have to check the middle of each half pulse if
both are same than consider as “1” logic other wise “0” logic.
Half pulse is 857us.
Middle of each half pulses is 857/2=428uS.
It means we have to check the first signal at 428-430uS duration.
Than every 857uS
28
Middle 01 x x 10 10 10 10 11 00 10 11 00 11 01
Upper 01 x x 10 10 10 10 11 00 10 10 10 10 11
Lower 01 x x 10 10 10 10 11 00 10 10 10 11 01
Right 01 x x 10 10 10 10 10 11 00 10 10 10 11
Left 01 x x 10 10 10 10 10 11 00 10 10 11 01
Power 01 x x 10 10 10 10 10 10 11 01 00 10 11
T0 01 x x 10 10 10 10 10 10 11 01 00 11 01
T1 01 x x 10 10 10 10 11 01 01 00 10 10 11
T2 01 x x 10 10 10 10 11 01 01 00 11 01 01
29
CHAPTER-5
SNAPSHOTS
POWER SENSOR
REGULATOR
A
T
8
9
S
5 RELAY 3
RELAY 1
2
RELAY 2
30
5.2 CIRCUIT DIAGRAM OF THE PROJECT
31
5.2.2 Circuit Diagram of Darlington Pair
5.3 SNAPSHOTS
32
5.3.1 Project at ON State
33
5.3.3 When Relay 2 is ON
34
5.3.4 When Relay 3 is ON
35
5.3.5 When Relay 4 is ON
36
5.3.6 When Relays are OFF
37
5.3.7 Remote Used
CHAPTER-6
38
As stated above that I have made a project on remote control this controls home
appliances. This project has many applications in today life as mentioned below:
There is another 3 steps which are applicable over this project they are as mentioned as
below:
CHAPTER-7
REFERENCE
39
To complete this project successfully I need to refer with many websites and books some
of them are as mentioned below:
Web links:
• http://www.google.com/
• http://www.alldatasheet.com/
• http://www.alldatasheet.com/view.jsp?Searchword=at89s52
• http://pdf1.alldatasheet.com/datasheet-pdf/view/82390/ATMEL/AT89S52.html
• http://www.the12volt.com/relays/relays.asp
• http://www.google.co.in/images?
hl=en&resnum=0&q=darlington+pair&um=1&ie=UTF-
8&source=univ&ei=Ui4GTNqWE46wrAfb39jDDA&sa=X&oi=image_result_gro
up&ct=title&resnum=4&ved=0CDAQsAQwAw
• http://www.kitronik.co.uk/pdf/darlingtonpair.pdf
• http://en.wikipedia.org/wiki/Darlington_transistor
• http://www.alldatasheet.com/view.jsp?Searchword=TSOP1738
• http://pdf1.alldatasheet.com/datasheet-
pdf/view/127448/VISHAY/TSOP1738KA1.html
• http://www.google.co.in/search?
hl=en&q=ir+receiver+tsop1738&btnG=Search&aq=3&aqi=g-e2g3g-
s1g4&aql=&oq=ir+receiver+&gs_rfai=
• http://www.physicsforums.com/showthread.php?t=230079
• http://pdf1.alldatasheet.com/datasheet-pdf/view/257587/WINGS/7805A.html
• http://www.alldatasheet.com/datasheet-pdf/pdf/257587/WINGS/7805A.html
APPENDIX -I
CODING OF THE PROJECT
40
//=========================================================
#include <reg51.h>
//---------------------
#define left_key 0x1B535500UL
#define right_key 0x1D535500UL
#define upper_key 0x1D54D500UL
#define lower_key 0x1B54D500UL
#define middle_key 0x1B34D500UL
#define power_key 0x1D2D5500UL
#define t1_key 0x1B2D5500UL
#define t2_key 0x1D4AD500UL
#define t3_key 0x1ACAD500UL
//-----------------------------
//#define ircheck RA0
sbit relay1=P2^3;
sbit relay2=P2^2;
sbit relay3=P2^1;
sbit relay4=P2^0;
sbit ir=P3^2;
//---------------------------
void inti(void);
void delay_us(unsigned int);
void ir_sence(void);
void remote_ok(void);
void remote_inc(void);
void remote_dec(void);
void remote_left(void);
void remote_right(void);
void remoteelse(void);
//---------------------------
unsigned long data_ir=0;
unsigned char relay1_status=0;
unsigned char relay2_status=0;
unsigned char relay3_status=0;
unsigned char relay4_status=0;
//-------------------------
void main()
{
inti();
while(1)
{
while(ir);
ir_sence();
}
}
41
//-----------------------initialisation---------------
void inti(void)
{ //make i/o lines accordingly,
relay1=0;
relay2=0;
relay3=0;
relay4=0;
}
//-------------------------------------------------------
void remote_inc()
{
if(relay1_status==0)
{ relay1=1; relay1_status=1;}
else
{ relay1=0; relay1_status=0;}
}
//-----------------------------------------------
void remote_dec()
{
if(relay2_status==0)
{ relay2=1; relay2_status=1;}
else
{ relay2=0; relay2_status=0;}
}
//----------------------------------------------
void remote_left()
{
if(relay3_status==0)
{ relay3=1; relay3_status=1;}
else
{ relay3=0; relay3_status=0;}
}
//-----------------------------------------------
void remote_right()
{
if(relay4_status==0)
{ relay4=1; relay4_status=1;}
else
{ relay4=0; relay4_status=0;}
}
//-----------------------------------------------
void remote_ok()
{
relay1=0;
relay2=0;
relay3=0;
42
relay4=0;
}
//------------------------------------------------
void remoteelse()
{
delay_us(50000);
delay_us(50000);
delay_us(50000);
}
//-----------------------------------
void delay_us(unsigned int us)
{
TMOD=0x01;
us=65535-us;
TH0=us/256;
TL0=us%256;
TR0=1;
while(!TF0);
TF0=0;
TR0=0;
}
////---------------------------------------------------
//void isr(void) interrupt
void ir_sence(void)
{
// if(INTF==1)
// {
// GIE=0;// intruppt diable
//INTE=0;
data_ir=0;
delay_us(400); //data1
// ircheck=1;
if(ir) data_ir|=0x01;
else data_ir|=0;
delay_us(10);
// ircheck=0;
delay_us(700);//data2
// ircheck=1;
if(ir) data_ir|=0x02;
else data_ir|=0;
delay_us(10);
// ircheck=0;
delay_us(700);//data3
// ircheck=1;
43
if(ir) data_ir|=0x04;
else data_ir|=0;
delay_us(10);
// ircheck=0;
delay_us(700);//data4
// ircheck=1;
if(ir) data_ir|=0x08;
else data_ir|=0;
delay_us(10);
// ircheck=0;
delay_us(700);//data5
// ircheck=1;
if(ir) data_ir|=0x010;
else data_ir|=0;
delay_us(10);
// ircheck=0;
delay_us(700);//data6
// ircheck=1;
if(ir) data_ir|=0x020;
else data_ir|=0;
delay_us(10);
// ircheck=0;
delay_us(700);//data7
// ircheck=1;
if(ir) data_ir|=0x040;
else data_ir|=0;
delay_us(10);
// ircheck=0;
delay_us(700);//data8
// ircheck=1;
if(ir) data_ir|=0x080;
else data_ir|=0;
delay_us(10);
// ircheck=0;
delay_us(700);//data9
// ircheck=1;
if(ir) data_ir|=0x0100;
else data_ir|=0;
delay_us(10);
// ircheck=0;
44
delay_us(700);//data10
// ircheck=1;
if(ir) data_ir|=0x0200;
else data_ir|=0;
delay_us(10);
// ircheck=0;
delay_us(700);//data11
// ircheck=1;
if(ir) data_ir|=0x0400;
else data_ir|=0;
delay_us(10);
// ircheck=0;
delay_us(700);//data12
// ircheck=1;
if(ir) data_ir|=0x0800;
else data_ir|=0;
delay_us(10);
// ircheck=0;
delay_us(700);//data13
// ircheck=1;
if(ir) data_ir|=0x01000;
else data_ir|=0;
delay_us(10);
// ircheck=0;
delay_us(700);//data14
// ircheck=1;
if(ir) data_ir|=0x02000;
else data_ir|=0;
delay_us(10);
// ircheck=0;
delay_us(700);//data15
// ircheck=1;
if(ir) data_ir|=0x04000;
else data_ir|=0;
delay_us(10);
// ircheck=0;
delay_us(700);//data16
// ircheck=1;
if(ir) data_ir|=0x08000;
45
else data_ir|=0;
delay_us(10);
// ircheck=0;
delay_us(700);//data17
// ircheck=1;
if(ir) data_ir|=0x010000;
else data_ir|=0;
delay_us(10);
// ircheck=0;
delay_us(700);//data18
// ircheck=1;
if(ir) data_ir|=0x020000;
else data_ir|=0;
delay_us(10);
// ircheck=0;
delay_us(700);//data19
// ircheck=1;
if(ir) data_ir|=0x040000;
else data_ir|=0;
delay_us(10);
// ircheck=0;
delay_us(700);//data20
// ircheck=1;
if(ir) data_ir|=0x080000;
else data_ir|=0;
delay_us(10);
// ircheck=0;
delay_us(700);//data21
// ircheck=1;
if(ir) data_ir|=0x0100000;
else data_ir|=0;
delay_us(10);
// ircheck=0;
delay_us(700);//data22
// ircheck=1;
if(ir) data_ir|=0x0200000;
else data_ir|=0;
delay_us(10);
// ircheck=0;
46
delay_us(700);//data23
// ircheck=1;
if(ir) data_ir|=0x0400000;
else data_ir|=0;
delay_us(10);
// ircheck=0;
delay_us(700);//data24
// ircheck=1;
if(ir) data_ir|=0x0800000;
else data_ir|=0;
delay_us(10);
// ircheck=0;
delay_us(700);//data25
// ircheck=1;
if(ir) data_ir|=0x01000000;
else data_ir|=0;
delay_us(10);
// ircheck=0;
delay_us(700);//data26
// ircheck=1;
if(ir) data_ir|=0x02000000;
else data_ir|=0;
delay_us(10);
// ircheck=0;
delay_us(700);//data27
// ircheck=1;
if(ir) data_ir|=0x04000000;
else data_ir|=0;
delay_us(10);
// ircheck=0;
delay_us(710);//data28
// ircheck=1;
if(ir) data_ir|=0x08000000;
else data_ir|=0;
delay_us(10);
// ircheck=0;
delay_us(750);//data29
// ircheck=1;
if(ir) data_ir|=0x10000000;
else data_ir|=0;
47
delay_us(10);
// ircheck=0;
delay_us(50000);
delay_us(50000);
delay_us(50000);
delay_us(50000);
// INTF=0;
// GIE=1;
data_ir=0;
//}
}
48