You are on page 1of 68


In this project we show that how we control the movement of the robotic arm with the help of the GSM control signal

CONCEPT: In this project we use smart logic and control system of embedded system by using microcontroller. In this project we use ic 89c51 as a main processor.. microcontroller sense the signal and drive the motor of the robotic vehicle. .

In this project first of all we attach one mobile phone with the circuit, First of all phone is automatic on and wait for the signal.. In this project we use dtmf decoding technology. Signal from the mobile phone is decoded by the dtmf decoder ic. So our Ist circuit in this project ic 8870. IC 8870 is a bcd to dtmf decoder. So our first part of the circuit is our dtmf decoder. This part is very much necessary, without using this part is not possible to interact with the mobile phone or dtmf based any phone. Whenever we press any switch from the transmitter phone then transmitter transmit some signal as per the switch press. So on every press switch there is a different signal

Frequency 697 770 852

1209 1 4 7

1336 2 5 8

1477 3 6 9

1633 A B C


Output of the dtmf decoder is bcd. Next circuit is how to convert bcd signal into decimal signal. In this project we use ic 74154 as a bcd to decimal decoder circuit. IC 74154 converts the bcd signal into decimal signal . Output of the 74154 is active low. Output of the 74154 is connected to the 89c2051 microcontroller. Ic 89c2051 microcontroller basically drive the motor for forward and reverse movement. Output of the microcontroller is connected to the optocoupler circuit. Here in this project we use ic pc 817 as a optocoupler to interface the microcontroller to small slow speed dc gear motor. One gear motor drive the vehicle and second gear motor change the front wheel of vehicle..

Power supply circuit. In this project we use 9 volt battery to drive the vehicle. One 9 volt battery for the microcontroller circuit. Second 9 volt battery drive the motor driver circuit . Here in the project we one 5 volt regulator circuit. Output of the 9 volt dc is converted into 5 volt dc by using 7805 regulator circuit. Ic 7805

regulator converts the 9 volt dc into 5 volt dc with the help of the 5 volt regulator 7805.

In this project we use 5 motors to control the movement of the robotic arm. Out of this 5 motors we use two motor/s for the forward and reverse movement and three motors for the arm movement. All these motors are connected with the microcontroller and motor driver circuit. In the motor driver circuit we interface the micrcontroller with the H bridge circuit and optocoupler circuit. H bridge is a combination of four transistor. Out of these four transistor , two transistors are NPN transistor and two transistors are PNP transistor.. We use slow speed gear motor in this project. Working voltage of these motors are 9 volt to 12 volt dc. We use two power source in this project. One for the motors and second for the controller circuit.

For controlling a dc motor we use H bridge circuit. IN this project we use four transistor circuit to control the

movement of dc motor for forward and reverse movement.

Collector of both the transistor is connected to the positive supply 9 volt. This 9 volt supply is for the DC motor. If we use 12 volt motor then we use 12 volt dc supply here. Emitter of both the transistor is connected to the DC motor. Emitter of the PNP transistor is connected to the emitter of NPN transistor. Collector of both the PNP transistor is connected to the ground potential. Base point of both

transistor is join together. On this point we give a voltage.

if we give a positive voltage to the base of left junction and negative voltage to the right junction then motor moves to one direction. Because due to positive on base NPN is on and due to negative on base PNP is on. If left side NPN is on and right side PNP is on then motor moves to the one direction. If the voltage is reverse on the base point then motors moves to the reverse direction.

motor move to the reverse direction because base voltage is change . Now left NPN and right PNP is on and motor moves to the reverse direction. Now when we attach the H bridge to the logical output of the microcontroller. So to interface the micro-controller with this H bridge we must connect a OPTO-COUPLER with the controller.

Opto-Coupler is a special optically isolated device to interface the input with output using light. Opto-Coupler provide a electrical isolation between the input and output circuit . Opto-coupler provide a isolation between the two power supply. Microcontroller power supply is 5 volt dc and motor supply is vary from 9volt to 12 volt dc. With the help of the microcontroller we provide a optical isolation between two power supply

In opto-coupler there is one input and one output and there is no connection between input and output. On input point there is one infra red l.e.d. cathode point of the l.e.d is connected to the resistor R1 and further connected to the microcontroller ports. In this project we use five dc motor, so we use five H bridge circuit with the ten opto-coupler circuit. Main object of this project is control the arm from any part of the world with the help of any mobile phone. It is actually possible to control the robot from any part of the world with the help of mobile phone or land line

phone. For this purpose we attach one mobile phone with the project. Now we dial this specific number from any phone. On the receiving end phone is automatic on after few bells with the help of enhancement setting. After auto answer option receiver phone is ready to receive a command from transmitter phone. With the help of the transmitter phone we press dtmf codes. Receiving phone receive the code signal and decode the signal and immediate respond with the circuit and control the movement of the vehicle as per the command given. Assume that if we press a digit 1 from the transmitter and when code no 1 is receive on the receiver phone then this number is decoded by the DTMF decoder. This DTMF decoder is further connected to the control circuit.

In this project we provide a DTMF control logic to control the robotic arm for all the direction Ist circuit is ic 8870. IC 8870 is a bcd to dtmf decoder. So our first part of the circuit is our dtmf decoder. This part is very much necessary, without using this part is not possible to interact with the mobile phone or dtmf based any phone. Whenever we press any switch from the transmitter phone then transmitter transmit some signal as per the switch press. So on every press switch there is a different signal

These signals are knows as DTMF signal. DTMF means dual tone multi frequency

Frequency 697 770 852 941

1209 1 4 7 *

1336 2 5 8 0

1477 3 6 9 #

1633 A B C D

DTMF is available in the form of sound signal. At the receiver end with the help of mobile phone and handsfree kit we decode the sound signal from mobile phone. For decoding the signal we cut the speaker of handsfree and connect the speaker wires to the dtmf decoder circuit .DTMF decoder circuit receive this signal on pin no 2 and 3 via resistor and capacitor circuit. One crystal is connected across the pin no 7 and 8 for demodulating the signal. IC 8870/9170 is capable to decode the signal. Pin no 18 of the ic is connected to the positive supply. Pin no 5,6,9 is connected to the ground pin. Output signal is available on the pin no 11,12,13,14 in the binary output. One pulse is also available on the pin no 15 for visual indication. Output of DTMF decoder is further connected to the ic 74154 ic.

Our next circuit is how to convert bcd signal into decimal signal. In this section we use ic 74154 as a bcd to decimal decoder circuit. IC 74154 converts the bcd signal into decimal signal .IC 74154 is 24 pin ic and main function of this ic is de-multiplexer. There is total 16 outputs are available from this ic. We get a low output signal from the ic. enable pins of this ic is also active on low signal. On pin no 18 and 19 we connect a one transistor circuit. Collector of the transistor is connected to the pin no 18 and 19 and base point of the transistor is connected to the pin no 15 of the dtmf decoder ic. Output of the 74154 is connected to the 89S51 micro-controller. IC 89S51 micro-controller basically control the arm for all the direction. With the help of this controller we control the movement of all motors.


8051 micro controller
The 8051 The 8051 developed and launched in the early 80`s, is one of the most popular micro controller in use today. It has a reasonably large amount of built in ROM and RAM. In addition it has the ability to access external memory. The generic term `8x51` is used to define the device. The value of x defining the kind of ROM, i.e. x=0, indicates none, x=3, indicates mask ROM, x=7, indicates EPROM and x=9 indicates EEPROM or Flash.

Different micro controllers in market.

PIC One of the famous microcontrollers used in the industries. It is based on RISC Architecture which makes the microcontroller process faster than other microcontroller. INTEL These are the first to manufacture microcontrollers. These are not as sophisticated other microcontrollers but still the easiest one to learn. ATMEL Atmels AVR microcontrollers are one of the most powerful in the embedded industry. This is the only microcontroller having 1kb of ram even the entry stage. But it is unfortunate that in India we are unable to find this kind of microcontroller.

Intel 8051 Intel 8051 is CISC architecture which is easy to program in assembly language and also has a good support for High level languages.

The memory of the microcontroller can be extended up to 64k. This microcontroller is one of the easiest microcontrollers to learn. The 8051 microcontroller is in the field for more than 20 years. There are lots of books and study materials are readily available for 8051.

First of all we select and open the assembler and wrote a program code in the file. After wrote a software we assemble the software by using internal assembler of the 8051 editor. If there is no error then assembler assemble the software abd 0 error is show the output window.

now assembler generate a ASM file and HEX file. This hex file is useful for us to program the blank chip. Now we transfer the hex code into the blank chip with the help of serial programmer kit. In the programmer we insert a blank chip 0f 89s51 series . these chips are multi time programmable chip. This programming kit is seperatally available in the market and we transfer the hex code into blank chip with the help of the serial programmer kit

Advanced Robotics

A mechanical device that sometimes resembles a human and is capable of performing a variety of often complex human tasks on command or by being programmed in advance is defined as a ROBOT

A Robot never becomes fulfill until it can take decisions. We cant go for computers for the computation & intelligence. But we can use single chip microcontrollers for controlling. This robot is not going to do any big tasks there will only be predefined tasks. The robots full control is embedded into one chip which is otherwise known as embedded systems designing.

To make a robot we must surely know to at least use a single microcontroller. So let us see about Embedded System thru 8051.

What is Open SYSTEM? An open system is the normal desktop computer where you can use it for any tasks. If you want to process text documents you can install Ms-word if you want to send mail you can use outlook express and counts on.

What is Embedded System ? An embedded system is the system where you can use it for a specific task.

Microcontroller:A microcontroller (often abbreviated MCU) is a single computer chip that executes a user program, normally for the purpose of controlling some device hence the name microcontroller.

A microcontroller is differed from microprocessor in many ways. Basically microprocessors are the devices which can process huge amount of data. A microprocessor cant do anything on it own. Even to light a led a microprocessor needs minimum of a ROM, RAM, Latch, Address decoders, PORT controllers. But for the same application if you take a microcontroller you barely need a crystal and some capacitors.

So from this you can understand how versatile the microcontroller is.

It is always good to know the market scenario before learning any thing. The following will explain the whole scenario of the embedded industry. This will make you to choose the best one for you.

Different microcontrollers in market.


One of the famous microcontrollers used in the

industries. It is based on RISC Architecture which makes the microcontroller process faster than other microcontroller.


These are the first to manufacture

microcontrollers. These are not as sophisticated other microcontrollers but still the easiest one to learn.


Atmels AVR microcontrollers are one of the most

powerful in the embedded industry. This is the only microcontroller

having 1kb of ram even the entry stage. But it is unfortunate that in India we are unable to find this kind of microcontroller.

Intel 8051

Intel 8051 is CISC architecture which is easy to program in assembly language and also has a good support for High level languages.

The memory of the microcontroller can be extended up to 64k.

This microcontroller is one of the easiest microcontrollers to learn.

The 8051 microcontroller is in the field for more than 20 years. There are lots of books and study materials are readily available for 8051.


The best thing done by Intel is to give the designs of the 8051 microcontroller to everyone. So it is not the fact that Intel is the only manufacture for the 8051 there more than 20 manufactures, with each of

minimum 20 models. Literally there are hundreds of models of 8051 microcontroller available in market to choose. Some of the major manufactures of 8051 are




Philips The Philipss 8051 derivatives has more number of features than in any microcontroller. The costs of the Philips microcontrollers are higher than the Atmels which makes us to choose Atmel more often than Philips

Dallas Dallas has made many revolutions in the semiconductor market. Dallass 8051 derivative is the fastest one in the market. It works 3 times as fast as a 8051 can process. But we are unable to get more in India.

Atmel These people were the one to master the flash devices. They are the cheapest microcontroller available in the market. Atmels even introduced a 20pin variant of 8051 named 2051. The Atmels 8051 derivatives can be got in India less than 70 rupees. There are lots of cheap programmers available in India for Atmel. So it is always good for students to stick with 8051 when you learn a new microcontroller. Architecture

Architecture is must to learn because before learning new machine it is necessary to learn the capabilities of the machine. This is some thing like before learning about the car you cannot become a good driver. The architecture of the 8051 is given below.

The 8051 doesnt have any special feature than other microcontroller. The only feature is that it is easy to learn. Architecture makes us to know about the hardware features of the microcontroller. The features of the 8051 are

4K Bytes of Flash Memory 128 x 8-Bit Internal RAM Fully Static Operation: 1 MHz to 24 MHz 32 Programmable I/O Lines Two 16-Bit Timer/Counters Six Interrupt Sources (5 Vectored) Programmable Serial Channel Low Power Idle and Power Down Modes

The 8051 has a 8-Bit CPU that means it is able to process 8 bit of data at a time. 8051 has 235 instructions. Some of the important registers and their functions are

Name ACCUMULATOR B Program Status Word (PSW) Stack Pointer (SP) Program Counter (PC) Data Pointer (DPTR)

Function All logical & arithmetical operations Mainly used in Multiplication & Division Keeps current status of ALU Points the Stack Location of the next instruction Points the Location of the Data

Every microprocessor & microcontroller uses clock signals. The clock signals are used to synchronize CPU with other peripherals in the CPU. Clock signals are very much important for a time critical jobs. If the oscillator used is not of good quality we will be surely loosing lots of data in serial communication.

Tools for Development.

For developing embedded application we are having two options.


C Compiler


Using assembler can reduce them memory used abundantly. You can have a good control over the code. When you use assembly language you are directly programming the microcontroller. The process time can be easily calculated. Atmel itself gives a free assembler called asm51.

But making a application in assembly language will take many man hours. Porting is not at all possible in assembly language. Even to port the code into another derivative we need to tweak a lot. Debugging is really tough. A simple applications code may range from 400 to 500 lines. It is really tough to map the mistake and rectify it.

C Compiler

This is an universal language and so every one know C. The application can be rapidly developed in C Compiler. The code can be ported into other microcontroller just like that. Debugging is really easy in C.

On the other hand when we use C we dont have the control over the code. The printf is a single statement which takes around 1.2 Kb of code memory. The 8051 it self has only 4Kb of memory. The C Compilers are memory hungry. Even the best compilers fix bugs after its release. The compilers use the ram just like that. The cost of the compiler is very high.

We can still use C Compiler because we can make the applications rapidly. We dont want to learn another new language. We even dont want to learn the whole architecture of the 8051!

The 8051 has only 127 bytes of ram. The enhanced version 8052 even has only 256 bytes of ram. So while programming microcontroller we should take care a lot in the usage of the variables.

A view of the C Compilers available in the market

SDCC Small Device C Compiler open source Compiler started in India.

RIDE yet another famous C Compiler but ram hungry

Hitech Famous in Dev. PIC Micro compilers

Micro C Rather new compiler

Keil Very Nice Compiler

We will be using Keil in our development because it is one of the most used in Embedded Industry. It has a good IDE helps in Rapid Development. Produced Code is smaller than other 8051 Cross compilers. Uses Ram (8051) Very little. Effective debugging with integrated simulator

Let us see some basics of the 8051.

Pin diagram

Power supply:

8051 can handle power supply of 3.5 volts to 7 volts with no problem. Always use a Decoupling Capacitor between the Power supply and the Ground. Decoupling capacitors are used to avoid the spikes. Pin 40 is for VCC and Pin 20 is for Gnd.

Reset Circuitry:

As soon as you give the power supply the 8051 doesnt start. You need to restart for the microcontroller to start. Restarting the microcontroller is nothing but giving a Logic 1 to the reset pin at least for the 2 clock pulses. So it is good to go for a small circuit which can provide the 2 clock pulses as soon as the microcontroller is powered.

This is not a big circuit we are just using a capacitor to charge the microcontroller and again discharging via resistor.


Crystals provide the synchronization of the internal function and to the peripherals. Whenever ever we are using crystals we need to put the capacitor behind it to make it free from noises. It is good to go for a 33pf capacitor.

We can also resonators instead of costly crystal which are low cost and external capacitor can be avoided.

But the frequency of the resonators varies a lot. And it is strictly not advised when used for communications projects.

Using Keil C.

There is nothing much different from the Turbo C we used and Keil C we are going to use. The only difference is that we need to change the header file of the microcontroller we are going to use.


Here in the above code I was using At89c51 so I am including this file for compiling.

After including the file we must declare main function and start writing the code.

#include<AT89x51.h> void main() { int i; while(1){ for (i = 0;i< 9000;i++) P1_1=0; for (i = 0;i< 9000;i++) P1_1=1; } }

These is the code for the blinking of the led.

SFR are the Special Functional Registers. These are used to control the peripherals in the microcontroller these are nothing but addresses in the ram.

Let us see the architecture in detail.





Ports used to communicate with the outside world. It is same like our computer without ports our computer remains useless. If there are no ports in computer then we cant have any devices attached to the computer. Even we cant use Keyboard and monitors.

8051 is having 4 ports & each has 8 I/O Pins. Simplest I/O Port in all microcontroller.

Port0, Port2 can be used for the External addressing. If our code has exceeded the 4kb then we need to use extra rom & ram. For addressing the extra memory chips we need to loose our Port 0 & port 2.

Port3 is one of the important ports; this has the serial port, timers and interrupts pins.

Port 1 is free can be used only as Port!!

How to use a Port?

It is really easy to use the ports of 8051. When you say that you have connected an Led in Port1 pin1 and when you want to light the led just use the code

To check whether a switched pressed or not, you can use the normal if condition statement.

If (P1_1==1) P1_2=1; Else P1_2=0;

Always sink an led rather lighting an led. In the above steps we were lighting the led but it is good to sink. Sinking is nothing instead of giving 5V we will provide the ground for the led.

Try to use negative active switches.

It is been always advised before using a port for input we need to high the port.

Atmels 2051 has a onboard voltage comparator in the port which is much useful for the light following kind of robots.


The 8051 comes equipped with two timers, both of which may be controlled, set, read, and configured individually. The 8051 timers have two general functions: 1) Keeping time and/or calculating the amount of time between events 2) Generating baud rates for the serial port.

How long does a timer take to count?

First, its worth mentioning that when a timer is in interval timer mode (as opposed to event counter mode) and correctly configured, it will increment by 1 every machine cycle. A single machine cycle consists of 12 crystal pulses. Thus a running timer will be incremented:

12,000,000 / 12 = 1,000,000

1,000,000 times per second. Unlike instructions--some of which require 1 machine cycle, others 2, and others 4--the timers are consistent: They will always be incremented once per machine cycle. Thus if a timer has counted from 0 to 50,000 you may calculate:

50,000 / 1,000,000 = .05 .05 seconds have passed. In plain English, about half of a tenth of a second, or one-twentieth of a second.

We can calculate the events with much precisions.

Timer SFRs

The 8051 has two timers which each function essentially the same way. One timer is TIMER0 and the other is TIMER1. The two timers share two SFRs (TMOD and TCON) which control the timers, and each timer also has two SFRs dedicated solely to itself (TH0/TL0 and TH1/TL1).


Description Timer 0 High Byte Timer 0 Low Byte Timer 1 High Byte Timer 1 Low Byte Timer Control Timer Mode

Timer 0 has two SFRs dedicated exclusively to itself: TH0 and TL0. Without making things too complicated to start off with, you may just think of this as the high and low byte of the timer. That is to say, when Timer 0 has a value of 0, both TH0 and TL0 will contain 0. When Timer 0 has the value 1000, TH0 will hold the high byte of the value (3 decimal) and TL0 will contain the low byte of the value (232 decimal). Reviewing low/high byte notation, recall that you must multiply the high byte by 256 and add the low byte to calculate the final value. That is to say:

TH0 * 256 + TL0 = 1000 3 * 256 + 232 = 1000 Timer 1 works the exact same way, but its SFRs are TH1 and TL1.

Since there are only two bytes devoted to the value of each timer it is apparent that the maximum value a timer may have is 65,535. After overflow it becomes 0.


Lets first talk about our first control SFR: TMOD (Timer Mode). The TMOD SFR is used to control the mode of operation of both timers. Each bit of the SFR gives the microcontroller specific information concerning how to run a timer. The high four bits (bits 4 through 7) relate to Timer 1 whereas the low four bits (bits 0 through 3) perform the exact same functions, but for timer 0. The individual bits of TMOD have the following functions: TMOD SFR

Bit Name Explanation of Function 7 GATE1 When this bit is set the timer will only run when INT1 (P3.3) is high. When this bit is clear the timer 6 C/T1

Timer 1

will run regardless of the state of INT1. When this bit is set the timer will count events on T1 1 (P3.5). When this bit is clear the timer will be

5 4 3

incremented every machine cycle. T1M1 Timer mode bit (see below) T1M0 Timer mode bit (see below) GATE0 When this bit is set the timer will only run when INT0 (P3.2) is high. When this bit is clear the timer

1 1 0


will run regardless of the state of INT0. When this bit is set the timer will count events on T0 0 (P3.4). When this bit is clear the timer will be incremented every machine cycle.

1 0

T0M1 T0M0

Timer mode bit (see below) Timer mode bit (see below)

0 0

As you can see in the above chart, four bits (two for each timer) are used to specify a mode of operation. The modes of operation are:

TxM1 0 0 1 1

TxM0 0 1 0 1

Timer Mode 0 1 2 3

Description of Mode 13-bit Timer. 16-bit Timer 8-bit auto-reload Split timer mode

13-bit Time Mode (mode 0)

Timer mode "0" is a 13-bit timer. This is a relic that was kept around in the 8051 to maintain compatibility with its predecessor, the 8048. Generally the 13-bit timer mode is not used in new development.

16-bit Time Mode (mode 1)

Timer mode "1" is a 16-bit timer. This is a very commonly used mode.

TLx is incremented from 0 to 255. When TLx is incremented from 255, it resets to 0 and causes THx to be incremented by 1. Since this is a full 16-bit timer, the timer may contain up to 65536 distinct values. If you set a 16-bit timer to 0, it will overflow back to 0 after 65,536 machine cycles.

8-bit Time Mode (mode 2)

Timer mode "2" is an 8-bit auto-reload mode. What is that, you may ask? Simple. When a timer is in mode 2, THx holds the "reload value" and TLx is the timer itself. Thus, TLx starts counting up. When TLx reaches 255 and is subsequently incremented, instead of resetting to 0 (as in the case of modes 0 and 1), it will be reset to the value stored in THx. This is used in serial port data transferring.

Split Timer Mode (mode 3)

Timer mode "3" is a split-timer mode. When Timer 0 is placed in mode 3, it essentially becomes two separate 8-bit timers. That is to say, Timer 0 is TL0

and Timer 1 is TH0. Both timers count from 0 to 255 and overflow back to 0. All the bits that are related to Timer 1 will now be tied to TH0.

While Timer 0 is in split mode, the real Timer 1 (i.e. TH1 and TL1) can be put into modes 0, 1 or 2 normally--however, you may not start or stop the real timer 1 since the bits that do that are now linked to TH0. The real timer 1, in this case, will be incremented every machine cycle no matter what.


Finally, theres one more SFR that controls the two timers and provides valuable information about them. The TCON SFR has the following structure:


Bit Name Bit

Explanation of Function


7 6


Address 8Fh 8Eh

Timer 1 Overflow. This bit is set by the

microcontroller when Timer 1 overflows. Timer 1 Run. When this bit is set Timer 1 1 is turned on. When this bit is clear Timer 1

5 4


8Dh 8Ch

is off. Timer 0 Overflow. This bit is set by the

microcontroller when Timer 0 overflows. Timer 0 Run. When this bit is set Timer 0 0 is turned on. When this bit is clear Timer 0 is off.

Initializing a Timer

So the Timer is configured how to start it. Just set the bit TR0 in other words.


So this starts Timer 0, for starting Timer 1 we need to go set TR1.


We will be using the timer a lot for detecting the time between the intervals and for capacitor discharge time and etc.


What Events Can Trigger Interrupts?

We can configure the 8051 so that any of the following events will cause an interrupt:

Timer 0 Overflow. Timer 1 Overflow. Reception/Transmission of Serial Character. External Event 0. External Event 1.

Setting Up Interrupts

By default at powerup, all interrupts are disabled. This means that even if, for example, the TF0 bit is set, the 8051 will not execute the interrupt.Your program must specifically tell the 8051 that it wishes to enable interrupts and specifically which interrupts it wishes to enable.

Your program may enable and disable interrupts by modifying the IE SFR (A8h):

Bit 7 6 5 4 3 2 1 0

Name EA ES ET1 EX1 ET0 EX0

Explanation of Function Global Interrupt Enable/Disable Undefined Undefined Enable Serial Interrupt Enable Timer 1 Interrupt Enable External 1 Interrupt Enable Timer 0 Interrupt Enable External 0 Interrupt

Polling Sequence

The 8051 automatically evaluates whether an interrupt should occur after every instruction. When checking for interrupt conditions, it checks them in the following order:

External 0 Interrupt Timer 0 Interrupt External 1 Interrupt Timer 1 Interrupt Serial Interrupt

This means that if a Serial Interrupt occurs at the exact same instant that an External 0 Interrupt occurs, the External 0 Interrupt will be executed first and the Serial Interrupt will be executed once the External 0 Interrupt has completed

Using Interrupts in Keil C

The syntax for the interrupt call is:

void function(void) interrupt 1 using 2 { statements. }

The key is in the "interrupt 1 using 2". Using is the optional which let us not consider now.

The first five interrupt numbers are common to all 8051 types. Interrupt number in Keil C corresponding to Interrupt service function.

#include <reg52.h> #include <stdio.h> no static unsigned long overflow_count = 0;

Interrupt fn

0 External Int 0 Timer/Counter0 void timer0_ISR (void) interrupt 1 1 2 External Int 1 { overflow_count++; /* Increment the overflow count */ 3 Timer/Counter1 } 4 Serial 0 Code for the timer Interrupt. The Function get triggered whenever the timer overflows.
void main (void) { TMOD = (TMOD & 0xF0) | 0x01; ET0 = 1; Interrupts */ TR0 = 1; */ EA = 1; */ /* Set T/C0 Mode */ /* Enable Timer 0 /* Start Timer 0 Running /* Global Interrupt Enable

/*-------------------------------------Do Nothing. Actually, the timer 0 interrupt will occur every 65536 clocks. --------------------------------------*/ while (1)



To make the robots mobile we need to have motors and the control circuitry that could control the motors. There are different kinds of motors available for different application.

1. DC motor 2. Stepper motor 3. Servo motor

DC motors

These are the motors that are commonly found in the toys and the tape recorders. These motors change the direction of rotation by changing the polarity. Most chips can't pass enough current or voltage to spin a motor. Also, motors tend to be electrically noisy (spikes) and can slam power back into the control lines when the motor direction or speed is changed.

Specialized circuits (motor drivers) have been developed to supply motors with power and to isolate the other ICs from electrical problems. These circuits can be designed such that they can be completely separate boards, reusable from project to project.

A very popular circuit for driving DC motors (ordinary or gearhead) is called an H-bridge. It's called that because it looks like the capital letter 'H' on classic schematics. The great ability of an H-bridge circuit is that the motor can be driven forward or backward at any speed, optionally using a completely independent power source.

The H-Bridge Circuit

This circuit known as the H-bridge (named for its topological similarity to the letter "H") is commonly used to drive motors. In this circuit two of four transistors are selectively enabled to control current flow through a motor.

opposite pair of transistors (Transistor One and Transistor Three) is enabled, allowing current to flow through the motor. The other pair is disabled, and can be thought of as out of the circuit. By determining which pair of transistors is enabled, current can be made to flow in either of the two directions through the motor. Because permanentmagnet motors reverse their direction of turn when the current flow is reversed, this circuit allows bidirectional control of the motor.

The H-Bridge with Enable Circuitry

It should be clear that one would never want to enable Transistors One and Two or Transistors Three and Four simultaneously. This would cause current to flow from Power + to Power - through the transistors, and not the motors, at the maximum current-handling capacity of either the power

supply or the transistors. This usually results in failure of the H-Bridge. To prevent the possibility of this failure, enable circuitry as depicted in Figure is typically used. In this circuit, the internal inverters ensure that the vertical pairs of transistors are never enabled simultaneously. The Enable input determines whether or not the whole circuit is operational. If this input is false, then none of the transistors are enabled, and the motor is free to coast to a stop. By turning on the Enable input and controlling the two Direction inputs, the motor can be made to turn in either direction. Note that if both direction inputs are the same state (either true or false) and the circuit is enabled, both terminals will be brought to the same voltage (Power + or Power - , respectively). This operation will actively brake the motor, due to a property of motors known as back emf, in which a motor that is turning generates a voltage counter to its rotation. When both terminals of the motor are brought to the same electrical potential, the back emf causes resistance to the motor's rotation. Stepper motors

Stepper motors are special kind of heavy duty motors having 2 or 4 coils. The motors will be stepping each time when it get the pulse. As there are many coils in the motors we need to energize the coils in a specific sequence for the rotation of the motor. These motors are mostly used in heavy machines. The figure shown below consists of a 4 coil stepper motor and the arrow mark will rotate when the coils are energized in the sequence.

Unlike DC motors stepper motors can be turned accurately for the given degrees.

Servo motors

Servo motors unlike the stepper motor it has to be controlled by the timing signal. This motor has only one coil. It is mostly used in robots for its lightweight and low power consumption. The servo motors can also be accurately rotated by the making the control signal of the servo motor high for a specific time period. Actually the servo motor will be having 3 wires where 2 are for power supply and another one is for the control signal. Driving the servomotors is so simple that you need to make the control signal high for the specific amount of time.

PRINCIPLE OF THE TRANSFORMER:Two coils are wound over a Core such that they are magnetically coupled. The two coils are known as the primary and secondary windings. In a Transformer, an iron core is used. The coupling between the coils is source of making a path for the magnetic flux to link both the coils. A core as in fig.2 is used and the coils are wound on the limbs of the core. Because of high permeability of iron, the flux path for the flux is only in the iron and hence the flux links both windings. Hence there is very little leakage flux. This term leakage flux denotes the part of the flux, which does not link both the coils, i.e., when coupling is not perfect. In the high frequency transformers, ferrite core is used. The transformers may be stepup, step-down, frequency matching, sound output, amplifier driver etc. The basic principles of all the transformers are same.



Resistance is the opposition of a material to the current. It is measured in Ohms ( All conductors represent a certain amount of resistance, since ). no conductor is 100% efficient. To control the electron flow (current) in a predictable manner, we use resistors. Electronic circuits use calibrated lumped resistance to control the flow of current. Broadly speaking, resistor can be divided into two groups viz. fixed & adjustable (variable) resistors. In fixed resistors, the value is fixed & cannot be varied. In variable resistors, the resistance value can be varied by an adjuster knob. It can be divided into (a) Carbon composition (b) Wire wound (c) Special type. The most common type of resistors used in our projects is carbon type. The resistance value is normally indicated by colour bands. Each resistance has four colours, one of the band on either side will be gold or silver, this is called fourth band and indicates the tolerance, others three band will give the value of resistance (see table). For example if a resistor has the following marking on it say red, violet, gold. Comparing these coloured rings with the colour code, its value is 27000 ohms or 27 kilo ohms and its tolerance is 5%. Resistor comes in various sizes (Power rating). The bigger, the size, the more power rating of 1/4 watts. The four colour rings on its body tells us the value of resistor value as given below.



Black--------------------------------------------0 Brown-------------------------------------------1 Red----------------------------------------------2 Orange------------------------------------------3 Yellow------------------------------------------4 Green--------------------------------------------5 Blue----------------------------------------------6 Violet--------------------------------------------7 Grey---------------------------------------------8 White--------------------------------------------9

The first rings give the first digit. The second ring gives the second digit. The third ring indicates the number of zeroes to be placed after the digits. The fourth ring gives tolerance (gold 5%, silver 10%, No colour 20%). In variable resistors, we have the dial type of resistance boxes. There is a knob with a metal pointer. This presses over brass pieces placed along a circle with some space b/w each of them. Resistance coils of different values are connected b/w the gaps. When the knob is rotated, the pointer also moves over the brass pieces. If a gap is

skipped over, its resistance is included in the circuit. If two gaps are skipped over, the resistances of both together are included in the circuit and so on. A dial type of resistance box contains many dials depending upon the range, which it has to cover. If a resistance box has to read upto 10,000 , it will have three dials each having ten gaps i.e. ten resistance coils each of resistance 10. The third dial will have ten resistances each of 100. The dial type of resistance boxes is better because the contact resistance in this case is small & constant.

One can get a constant high-voltage power supply using inexpensive 3-terminal voltage regulators through some simple techniques described below. Depending upon the current requirement, a reasonable load regulation can be achieved. Line regulation in all cases is equal to that of the voltage regulator used. Though high voltage can be obtained with suitable voltage boost circuitry using ICs like LM 723, some advantages of the circuits presented below are: simplicity, low cost, and practically reasonable regulation characteristics. For currents of the order of 1A or less, only one zener and some resistors and capacitors are needed. For higher currents, one pass transistor such as ECP055 is needed.

Before developing the final circuits, let us first understand the 3-terminal type constant voltage regulators. Let us see the schematic in Fig. where 78XX is a 3terminal voltage regulator.

for lowoutput voltage

Schematic obtaining voltage regulated using 3terminal regulators.

Rectified and filtered unregulated voltage is applied at VIN and a constant voltage appears between pins 2 and 2 of the voltage regulator. *The distribution of two currents in the circuit (IBIAS and ILOAD) is as shown. * It is highly recommended to use the two capacitors as shown. Electrically regulator will be at a distance from the rectifier supply. Thus, a tantalum grade capacitor of 5mf and rated voltage is good. Electrolytic capacitor is not suitable for it is poor in response to load transients, which have high frequency components. At the output side a 0.22mf disc ceramic capacitor is useful to eliminate spurious oscillations, which the regulator might break into because of its internal high gain circuitry. These voltage regulators have a typical bias current of 5 mA, which is reasonably constant. By inserting a small resistor Rx between pin 2 and ground, the output voltage in many cases. By this method voltage increment of 5 to 10 per cent is practically feasible. However, if a high-value resistance is used to obtain a higher output voltage, a slight variation in bias current will result in wide variation of the output voltage. Now let us see that what can be done to get a higher but constant output voltage. If to the circuit of Fig. resistor RY and zener Vz are added as shown in Fig., the output voltage is now given by VOUT=VR+VZ + IBIAS RX A constant current flows through RY** because VOUT is constant, and small variations in IBIAS do not change practically the operating point of Vz. This situation is like constant current biasing of zener, which results in a very accurate setting of the zener voltage. ** As long a sVIN>VOUT+2 volts, VOZ is constant from the reasoning of Fig, and thus current through RY is constant.

VOZ=VR + IBIAS Rx Here the pin 2 of the regulator is raised above ground by Vz + IBIAS Rx. Thus, any combination of zener with a proper selection of RY can be used. For example, Let VR=+15 V for 7815 IBIAS=5mA VZ=39V (standard from ECIL) For a standard 400mW zener of ECIL make, IZ MAX=10 mA. Thus, if we let pass 5mA through RY to make a 55-volt supply 55 - 39 RY = ---------------=3.2k3.3k 5 x 10-3 55 - 39 - 15 1 RX = ---------------------= ---------- = 200 ohm IBIAS 5 x 10-3

Schematic for constant high-voltage power supplies It should be noted here that the maximum input voltage allowed for 78XX regulators is 35V between pins 1 and 2. We see that the actual voltage betweens pin 1 and 2 of the regulator in this circuit is VIN - VZ - IBIAS RX It is therefore necessary that VIN be so chosen that voltage between pins 1 and 2 of the IC does not exceed the maximum rating. Also, a high input-output differential voltage VIN-VOUT means more power dissipation

in the series-pass element, the regulator. Thus, with proper selection of the input transformer voltage and capacitor, this should be minimized. For example, if 7805 is used, VR equals + 5V and VZ is 40V, so VOUT=45 volts. For 7805, the maximum input voltage is 35 V and the minimum 7V. Therefore, VIN MAX = 45 + 35 - 5 = 75 VOLTS VIN MIN = 45 + 7 - 5 = 47 VOLTS Thus, from no-load to full-load condition, the unregulated input voltage-including peak ripple-should be within these limits. This gives a margin of 75-47, i.e. 28 volt. Hence, the designer can work out the maximum transformer voltage from the no-load input voltage chosen on the upper side. The capacitor's value can be determined from the full load unregulated voltage chosen. Roughly, per 100mA current, 100mf capacitor gives 1-volt peak-to-peak ripple. Hence, capacitor's value can be determined for the desired current. This circuit will have an excellent load and line regulation. For shotcircuit protection, it is recommended to use a fast-blow fuse of suitable value. Although the regulator has inherent short-circuit protection, the maximum current differs from device to device. Adequate heat sink should be used with the regulator.

Schematic for constant high-voltage power supplies providing currents in excess of one ampere

Now if currents in excess of 1A are needed, the circuit shown in fig. is useful. This circuit is similar to that in Fig. except that a pass transistor ECP055 is added besides a 0.5-ohm or more resistor. This transistor

bypasses the excessive current. By selecting proper Rz the ratio of two currents passing through the regulator and transistor can be altered. This circuit will show load and live regulation within 1% and will function properly for VIN-VOUT as low as 4 volt. For short-circuit protection, a fast blow fuse is recommended as this circuit does not have inherent short-circuit protection. Adequate heat sink is to be used for the pass transistors. For negative voltages, use 79XX series regulators and ECN055 as the pass transistor. Some advantages of the circuits described above are: the lowest cost among comparable performance circuits, ability to work at low input-output differential, and flexibility in design for various applications. So audio enthusiasts, if you are troubled by hum emanating from your power amplifier, try this inexpensive alternative for power supply.