You are on page 1of 50

SIET, ECE (2009-2013)

CHAPTER-1 INTRODUCTION
1.1ELECTRONICS
Electronics is the branch of science and technology which makes use of the controlled motion of electrons through different media and vacuum. The ability to control electron flow is usually applied to information handling or device control. Electronics is distinct from electrical science and technology, which deals with the generation, distribution, control and application of electrical power. This distinction started around 1906 with the invention by Lee De Forest of the triode, which made electrical amplification possible with a non-mechanical device. Until 1950 this field was called "radio technology" because its principal application was the design and theory of radio transmitters, receivers and vacuum tubes. Most electronic devices today use semiconductor components to perform electron control. The study of semiconductor devices and related technology is considered a branch of physics, whereas the design and construction of electronic circuits to solve practical problems come under electronics engineering. This article focuses on engineering aspects of electronics ELECTRONIC COMPONENTS An electronic component is any physical entity in an electronic system used to affect the electrons or their associated fields in a desired manner consistent with the intended function of the electronic system. Components are generally intended to be connected together, usually by being soldered to a printed circuit board (PCB), to create an electronic circuit with a particular function (for example an amplifier, radio receiver, or oscillator). Components may be packaged singly or in more complex groups as integrated circuits. Some common electronic components are capacitors, resistors, diodes, transistors, etc. Components are often categorized as active (e.g. transistors and thyristors) or passive (e.g. resistors and capacitors). The main components used in electronics are of two types: ACTIVE PASSIVE ACTIVE COMPONENTS
1

SIET, ECE (2009-2013)

The components which produce the energy in the form of current or voltage are called as active components or we can say that the component which can perform a specific function like amplifying the signal, rectify the signal they are called active component. For ex: transistors, diode PASSIVE COMPONENTS The components which store the energy in the form of current or voltage are called as passive components or we can say that the component which cant perform any function itself but when these components are connected in any circuit with active component then it gives a performance. For ex: resistor, capacitor, and inductor.

Figure1.1 Active & Passive components NEED OF PASSIVE COMPONENTS They help in amplification of active components TYPES OF PASSIVE COMPONENTS 1. Vacuum tubes 2. Semiconductor devices

1.2 INTRODUCTION TO MICROCONTROLLER

SIET, ECE (2009-2013)

A micro controller is a programmable logic and integrated circuit which can be programmed to do a number of tasks. It is possible to control just about anything with the program written by the user. A microcontroller (sometimes abbreviated C, uC or MCU) is a small computer on a single integrated circuit containing a processor core, memory, and programmable input/output peripherals. Neither program memory in the form of NOR flash or OTP ROM is also often included on chip, as well as a typically small amount of RAM. Microcontrollers are designed for embedded applications, in contrast to the microprocessors used in personal computers or other general purpose applications. Microcontrollers are used in automatically controlled products and devices, such as automobile engine control systems, implantable medical devices, remote controls, office machines, appliances, power tools, toys and other embedded systems. By reducing the size and cost compared to a design that uses a separate microprocessor, memory, and input/output devices, microcontrollers make it economical to digitally control even more devices and processes. Mixed signal microcontrollers are common, integrating analog components needed to control non-digital electronic systems .Some microcontrollers may use four-bit words and operate at clock rate frequencies as low as 4 kHz, for low power consumption (mill watts or microwatts). They will generally have the ability to retain functionality while waiting for an event such as a button press or other interrupt; power consumption while sleeping (CPU clock and most peripherals off) may be just nanowatts, making many of them well suited for long lasting battery applications. Other microcontrollers may serve performance-critical roles, where they may need to act more like a digital signal processor (DSP), with higher clock speeds and power consumption. Novices in electronics usually think that the microcontroller is the same as the microprocessor. That's not true. They differ from each other in many ways. The first and most important difference in favor of the microcontroller is its functionality. In order for the microprocessor to be used, other components, first of all memory, must be added to it. Even though it is considered a powerful computing machine, it is not capable of establishing direct communication with the peripherals. Instead, specialized circuits must be used for this purpose. This is how it was in the beginning and remains the same today. We can find microcontrollers in all kinds of electronic devices these days. Any device that measures, stores, controls, calculates, or displays information must have a microcontroller chip inside. The largest single use for microcontrollers is in automobile industry (microcontrollers
3

SIET, ECE (2009-2013)

widely used for controlling engines and power controls in automobiles). You can also find microcontrollers inside keyboards, mouse, modems, printers, and other peripherals. In test equipments, microcontrollers make it easy to add features such as the ability to store measurements, to create and store user routines, and to display messages and waveforms. Consumer products that use microcontrollers include digital camcorders, optical players, LCD/LED display units, etc. And these are just a few examples

1.3 MICROCONTROLLER STRUCTURE


A microcontroller basically contains one or more following components:

Central processing unit(CPU) Random Access Memory)(RAM) Read Only Memory(ROM) Input/output ports Timers and Counters Interrupt Controls Analog to digital converters Digital analog converters Serial interfacing ports Oscillatory circuits

SIET, ECE (2009-2013)

Figure: 1.2 Structure of Microcontroller

1.4 A LITTLE HISTORY


In its January 1975 issue, Popular Electronics magazine featured an article describing the Altair 8800 computer, which was the first microcomputer that hobbyists could build and program themselves. The basic Altair included no keyboard, video display, disk drives, or other elements we now think of as essential elements of a personal computer. Its 8080 microprocessor was programmed by flipping toggle switches on the front panel. Standard RAM was 256 bytes and a kit version cost $397 ($498 assembled). A breakthrough in the Altairs usability occurred when a small company called Microsoft offered a version of the BASIC programming language for it. Of course, the computer world has changed a lot since the introduction of the Altair. Microsoft has become an enormous software publisher, and a typical personal computer now includes a keyboard, video display, disk drives, and Megabytes of RAM. Whats more, theres no longer any need to build a personal computer from scratch, since mass production has drastically lowered the price of assembled systems. At most,
5

SIET, ECE (2009-2013)

building a personal computer now involves only installing assembled boards and other major components in an enclosure.

A personal computer like Apples Macintosh or IBMs PC is a general-purpose machine, since you can use it for many applicationsword processing, spreadsheets, computer-aided design, and morejust by loading the appropriate software from disk into memory. Interfaces to personal computers are for the most part standard ones like those to video displays, keyboards, and printers.

But along with cheap, powerful, and versatile personal computers has developed a new interest in small, customized computers for specific uses. Each of these small computers is dedicated to one task, or a set of closely related tasks. Adding computer power to a device can enable it to do more, or do it faster, better, or more cheaply. For example, automobile engine controllers have helped to reduce harmful exhaust emissions. And microcontrollers inside computer modems have made it easy to add features and abilities beyond the basic computer-to-phoneline interface.

In addition to their use in mass-produced products like these, its also become feasible to design computer power into one-of-a-kind projects, such as an environmental controller for a scientific study or an intelligent test fixture that ensures that a product meets its specifications before its shipped to a customer.

At the core of many of these specialized computers is a microcontroller. The computers program is typically stored permanently in semiconductor memory such as ROM or EPROM. The interfaces between the microcontroller and the outside world vary with the application, and may include a small display, a keypad or switches, sensors, relays, motors, and so on.

These small, special-purpose computers are sometimes called single-board computers , or SBCs. The term can be misleading, however, since the computer doesnt have to be on a single circuit board, and many types of computer systems, such as laptop and notebook computers, are now manufactured on a single board.

SIET, ECE (2009-2013)

1.5 ALL THE MICROCONTROLLER IS CAPABLE OF


Microcontrollers are very popular nowadays. Just pay attention to the example below and you will understand the reasons for their great success. It won't take up much of your time, just a couple of minutes. Around ten years ago, the process of designing an electronic device controlling an elevator in a multistory building was extremely difficult, even for a team of experts. Have you ever thought of what requirements an ordinary elevator has to meet? How to deal with situation when two or more people call the same elevator at the same time? Which call has the priority? How to handle the security questions? Loss of electricity? Operation failure? Misuse? After solving these basic questions, a tough process of designing an appropriate electronics using a large number of special-purpose chips comes next. Depending on the device complexity, such process can take weeks, even months. Then it's time to make a printed circuit board and assemble device. A huge device! It is another long-lasting and trying work. Finally, when your device is finished and tested many times, the crucial moment comes. The moment when you take a deep breath and switch the power supply on. The party is over at this point as electronic devices almost never start to operate immediately. Get ready for many sleepless nights, corrections, improvements... and don't forget, we are still talking about running an ordinary elevator. When your device finally works perfectly and everybody is satisfied and you get paid for the work you have done, other constructing companies will become interested in your work. Of course, if you are lucky, another day will bring you a locking offer from a new investor. A new building has four stories more. You know what it is all about? You think you can control destiny? You are going to make a universal device which can be used in buildings of 4 to 40 stories, a masterpiece of electronics? Even if you manage to make such an electronic jewel, your investor will wait in front of your door asking for a camera in the elevator. Or for relaxing music in case of elevator failure. Or for a two-door elevator. Anyway, Murphy's law is inexorable and you will certainly not be able to make advantage of all the effort you have made. Unfortunately, everything said so far is true. This is what 'handling electronics' really means. No, no, wait, let us correct ourselves, this is how it was until the first microcontrollers were designed - small, powerful and cheap devices. Since the moment their programming stopped being a science, everything went in another direction...

SIET, ECE (2009-2013)

Electronics capable of controlling a small submarine, a crane or an elevator are now built into one single chip. Microcontrollers offer a wide range of applications, but only a few of them are normally used. It's up to you to decide what you want from the microcontroller and dump a program accordingly containing appropriate instructions into it. Prior to turning the device on, its operation should be tested by simulation. If everything works fine, build the microcontroller into your device. If you ever need to change, improve or upgrade the program, just does it. Until when? Until you feel satisfied. That's all.

1.6 TYPES OF MICROCONTROLLER


As of 2008 there are several dozen microcontroller architectures and vendors including:

Parallax Propeller Free scale 68HC11 (8-bit) Intel 8051 Silicon Laboratories Pipelined 8051 Microcontrollers ARM processors (from many vendors) using ARM7 or Cortex-M3 cores are generally microcontrollers

STMicroelectronics STM8 (8-bit), ST10 (16-bit) and STM32 (32-bit) Atmel AVR (8-bit), AVR32 (32-bit), and AT91SAM (32-bit) Freescale ColdFire (32-bit) and S08 (8-bit) Hitachi H8, Hitachi SuperH (32-bit) Hyperstone E1/E2 (32-bit, First full integration of RISC and DSP on one processor core [1996] [1])

Infineon Microcontroller: 8, 16, 32 Bit microcontrollers for automotive and industrial applications

MIPS (32-bit PIC32) NEC V850 (32-bit)

SIET, ECE (2009-2013)

NXP Semiconductors LPC700 (8-bit)

LPC1000, LPC2000, LPC3000, LPC4000 (32-bit), LPC900,

PIC (8-bit PIC16, PIC18, 16-bit dsPIC33 / PIC24) PowerPC ISE PSoC (Programmable System-on-Chip) Rabbit 2000 (8-bit) Texas Instruments Microcontrollers: TI MSP430 16-bit Microcontrollers, C2000 (32bit), and Stellaris (32-bit)

Toshiba TLCS-870 (8-bit/16-bit)

And many others, some of which are used in very narrow range of applications or are more like applications processors than microcontrollers. The microcontroller market is extremely fragmented, with numerous vendors, technologies, and markets. Note that many vendors sell (or have sold) multiple architectures.

1.7 EMBEDDED DESIGN


A microcontroller can be considered a self-contained system with a processor, memory and peripherals and can be used as an embedded system. The majority of microcontrollers in use today are embedded in other machinery, such as automobiles, telephones, appliances, and peripherals for computer systems. These are called embedded systems. While some embedded systems are very sophisticated, many have minimal requirements for memory and program length, with no operating system, and low software complexity. Typical input and output devices include switches, relays, solenoids, LEDs, small or custom LCD displays, radio frequency devices, and sensors for data such as temperature, humidity, light level etc. Embedded systems usually have no keyboard, screen, disks, printers, or other recognizable I/O devices of a personal computer, and may lack human interaction devices of any kind.

1.8 FUNCTIONS OF MICROCONTROLLER:


Ability to execute a stored set of instructions to carry out user defined task. Ability to access external memory chips to read & write data from/to memory.
9

SIET, ECE (2009-2013)

Ability to interface with the I/O devices.

Basic components of a Microcontroller are A CPU to execute programmed code Memory, both RAM and ROM Internal timers and input/output system, in form of i/o pins

Some Microcontrollers have some extra features like- UART for serial communication, Internal EEPROM and PWM modules for analogue output. Microcontrollers are the main heart of any embedded system. They run the hardware according to the program burnt them.

1.9 MICROCONTROLLER ARCHITECTURES:


There are two types of basic architectures:

VON-NEUMANN ARCHITECTURE- It has only one bus which is used for both data transfers and instruction fetches, and therefore data transfers and instruction fetches must be scheduled - they cannot be performed at the same time. HARWARD ARCHITECTURE- It has physically separate signals and storage for code and data memory. It is possible to access program memory and data memory simultaneously. Microcontroller architectures vary widely. Some designs include general-purpose

microprocessor cores, with one or more ROM, RAM, or I/O functions integrated onto the package. Other designs are purpose built for control applications. A micro-controller instruction set usually has many instructions intended for bit-wise operations to make control programs more compact. For example, a general purpose processor might require several instructions to test a bit in a register and branch if the bit is set, where a micro-controller could have a single instruction to provide that commonly-required function. Microcontrollers typically do not have a math coprocessor, so floating point arithmetic is performed by software. Since the emergence of microcontrollers, many different memory technologies have been used. Almost all microcontrollers have at least two different kinds of memory, a non-volatile memory for storing firmware and a read-write memory for temporary data.
10

SIET, ECE (2009-2013)

Figure: 1.3 Architecture of microcontroller

1.10 PROGRAMMING ENVIRONMENT


Microcontrollers were originally programmed only in assembly language, but various highlevel programming languages are now also in common use to target microcontrollers. These languages are either designed specially for the purpose, or versions of general purpose languages such as the C programming language. Compilers for general purpose languages will typically have some restrictions as well as enhancements to better support the unique characteristics of microcontrollers. Some microcontrollers have environments to aid developing certain types of applications. Microcontroller vendors often make tools freely available to make it easier to adopt their hardware. Many microcontrollers are so quirky that they effectively require their own non-standard dialects of C, such as SDCC for the 8051, which prevent using standard tools (such as code libraries or static analysis tools) even for code unrelated to hardware features. Interpreters are often used to hide such low level quirks. Interpreter firmware is also available for some microcontrollers. For example, BASIC on the early microcontrollers Intel 8052 BASIC and FORTH on the Zilog Z8 as well as some modern devices. Typically these interpreters support interactive programming.
11

SIET, ECE (2009-2013)

Simulators are available for some microcontrollers, such as in Microchip's MPLAB environment and the Revolution Education PICAXE range. These allow a developer to analyze what the behavior of the microcontroller and their program should be if they were using the actual part. A simulator will show the internal processor state and also that of the outputs, as well as allowing input signals to be generated. While on the one hand most simulators will be limited from being unable to simulate much other hardware in a system, they can exercise conditions that may otherwise be hard to reproduce at will in the physical implementation, and can be the quickest way to debug and analyze problems. Recent microcontrollers are often integrated with on-chip debug circuitry that when accessed by an in-circuit emulator via JTAG, allow debugging of the firmware with a debugger.

1.11 USES OF MICROCONTROLLER: Reduce chip count. Many applications do not require as much computing power. Less space. Reduced power consumption. Less weight. Reduced design cost.

1.12 ADVANTAGES OF MICROCONTROLLER


The main advantages of microcontrollers are given: a) Microcontrollers act as a microcomputer without any digital parts. b) As the higher integration inside microcontroller reduce cost and size of the system. c) Usage of microcontroller is simple, easy for troubleshoot and system maintaining. d) Most of the pins are programmable by the user for performing different functions. e) Easily interface additional RAM, ROM,I/O ports.

12

SIET, ECE (2009-2013)

f) Low time required for performing operations.

1.13 DISADVANTAGES OF MICROCONTROLLER


The main disadvantages of microcontrollers are given: a) Microcontrollers have got more complex architecture than that of microprocessors. b) Only perform limited number of executions simultaneously. c) Mostly used in micro-equipments. d) Cannot interface high power devices directly.

1.14 APPLICATIONS OF MICROCONTROLLER


Microcontrollers are widely used in modern electronics equipments. Some basic applications of microcontroller is given below. a) b) c) d) e) Used in biomedical instruments. Widely used in communication systems. Used as peripheral controller in PC. Used in robotics. Used in automobile fields.

CHAPTER-2
13

SIET, ECE (2009-2013)

INTRODUCTION TO 8051

2.1 INTRODUCTION
8051 is a small piece of semiconductor integrated circuits. The package type of these integrated circuits is DIP package. DIP stand for Dual Inline Package for semiconductor IC. This package is very easy to be soldered onto the strip board. However using a DIP socket is much easier so that this chip can be plugged and removed from the development board. This is very popular. Apart from that it is also very easy to be assembled. Additional components that you need to make this IC work are just a 5V power supply adapter, a 20MHz crystal oscillator and 2 units of 22pF capacitors.

Figure: 2.1 8051

2.2 HISTORY

14

SIET, ECE (2009-2013)

The original 8051 was built to be used with General Instruments' new 16-bit CPU, the CP1600. While generally a good CPU, the CP1600 had poor I/O performance, and the 8-bit 8051 was developed to improve performance of the overall system by offloading I/O tasks from the CPU. The 8051 used simple microcode stored in ROM to perform its tasks, and although the term was not used at the time, it shares some common features with RISC designs. In 1985, General Instruments spun off their microelectronics division and the new ownership cancelled almost everything which by this time was mostly out-of-date. The 8051, however, was upgraded with internal EPROM to produce a programmable channel controller and today 8051 are available with various on-board peripherals and program memory from 256 words to 64k words and more (a "word" is one assembly language instruction, varying from 12, 14 or 16 bits depending on the specific family).8051are registered trademarks of Microchip Technology.

Figure: 2.2 various microcontrollers

2.3 FEATURES OF 8051


RISC ARCHITESTURES Only 35 instructions to learn All single-cycle instructions except branches Operating frequency 0-20 MHz
15

SIET, ECE (2009-2013)

Precision internal oscillator Factory calibrated Software selectable frequency range of 8MHz to 31KHz Power supply voltage 2.0-5.5V Consumption: 220uA (2.0V, 4MHz), 11uA (2.0 V, 32 KHz) 50nA (stand-by mode) Power-Saving Sleep Mode Brown-out Reset (BOR) with software control option 35 input/output pins High current source/sink for direct LED drive Software and individually programmable pull-up resistor Interrupt-on-Change pin 8K ROM memory in FLASH technology Chip can be reprogrammed up to 100.000 times In-Circuit Serial Programming Option Chip can be programmed even embedded in the target device 256 bytes EEPROM memory Data can be written more than 1.000.000 times 368 bytes RAM memory A/D converter: 14-channels 10-bit resolution 3 independent timers/counters Watch-dog timer Analogue comparator module with Two analogue comparators Fixed voltage reference (0.6V) Programmable on-chip voltage reference PWM output steering control
16

SIET, ECE (2009-2013)

Enhanced USART module Supports RS-485, RS-232 and LIN2.0 Auto-Baud Detect Master Synchronous Serial Port (MSSP) Supports SPI and I2C mod

2.4 PERFORMANCE
The 8051 instruction set is suited to implementation of fast lookup tables in the program space. Such lookups take one instruction and two instruction cycles. Many functions can be modeled in this way. Optimization is facilitated by the relatively large program space of the 8051 (e.g. 4096 x 14-bit words) and by the design of the instruction set, which allows for embedded constants. For example, a branch instruction's target may be indexed by W, and execute a "RETLW" which does as it is named - return with literal in W. Execution time can be accurately estimated by multiplying the number of instructions by two cycles; this simplifies design of real-time code. Similarly, interrupt latency is constant at three instruction cycles. External interrupts have to be synchronized with the four clock instruction cycle; otherwise there can be a one instruction cycle jitter. Internal interrupts are already synchronized. The constant interrupt latency allows 8051 to achieve interrupt driven low jitter timing sequences. An example of this is a video sync pulse generator. This is no longer true in the newest PIC models, because they have a synchronous interrupt latency of three or four cycles.

2.5 MEMORY DESCRIPTION OF 8051


This microcontroller has three types of memory- ROM, RAM and EEPROM. All of them will be separately discussed since each has specific functions, features and organization.

ROM MEMORY ROM memory is used to permanently save the program being executed. This is why it is often called program memory. The 8051 has 8Kb of ROM (in total of 8192 locations). Since this ROM is made with FLASH technology, its contents can be changed by providing a special programming voltage (13V).Anyway, there is no need to explain it in detail because it is

17

SIET, ECE (2009-2013)

automatically performed by means of a special program on the PC and a simple electronic device called the Programmer.

EEPROM MEMORY Similar to program memory, the contents of EEPROM is permanently saved, even the power goes off. However, unlike ROM, the contents of the EEPROM can be changed during operation of the microcontroller. That is why this memory (256 locations) is a perfect one for permanently saving results created and used during the operation.

RAM MEMORY This is the third and the most complex part of microcontroller memory. In this case, it consists of two parts: general-purpose registers and special-function registers (SFR). Even though both groups of registers are cleared when power goes off and even though they are manufactured in the same way and act in the similar way, their functions do not have many things in common.

GENERAL-PURPOSE REGISTERS General-Purpose registers are used for storing temporary data and results created during operation. For example, if the program performs a counting (for example, counting products on the assembly line), it is necessary to have a register which stands for what we in everyday life call sum. Since the microcontroller is not creative at all, it is necessary to specify the address of some general purpose register and assign it a new function. A simple program to increment the value of this register by 1, after each product passes through a sensor, should be created. Therefore, the microcontroller can execute that program because it now knows what and where the sum which must be incremented is. Similarly to this simple example, each program variable must be reassigned some of general-purpose register.

SFR REGISTERS Special-Function registers are also RAM memory locations, but unlike general-purpose registers, their purpose is predetermined during manufacturing process and cannot be changed.
18

SIET, ECE (2009-2013)

Since their bits are physically connected to particular circuits on the chip (A/D converter, serial communication module, etc.), any change of their contents directly affects the operation of the microcontroller or some of its circuits. For example, by changing the TRISA register, the function of each port .A pin can be changed in a way it acts as input or output. Another feature of these memory locations is that they have their names (registers and their bits), which considerably facilitates program writing. Since high-level programming language can use the list of all registers with their exact addresses, it is enough to specify the registers name in order to read or change its contents.

Figure: 2.3 SFR Registers

RAM MEMORY BANKS The data memory is partitioned into four banks. Prior to accessing some register during program writing (in order to read or change its contents), it is necessary to select the bank which contains that register. In order to facilitate operation, the most commonly used SFRs have the same address in all banks which enables them to be easily accessed. This is the third and the most complex part of microcontroller memory. In this case, it consists of two parts: general-purpose registers and special-function registers (SFR). Even though both groups of registers are cleared when power goes off and even though they are manufactured in the same way and act in the similar way, their functions do not have many things in common.
19

SIET, ECE (2009-2013)

STACK A part of the RAM used for the stack consists of eight 13-bit registers. Before the microcontroller starts to execute a subroutine (CALL instruction) or when an interrupt occurs, the address of first next instruction being currently executed is pushed onto the stack, i.e. onto one of its registers. In that way, upon subroutine or interrupt execution, the microcontroller knows from where to continue regular program execution. This address is cleared upon return to the main program because there is no need to save it any longer, and one location of the stack is automatically available for further use. It is important to understand that data is always circularly pushed onto the stack. It means that after the stack has been pushed eight times, the ninth push overwrites the value that was stored with the first push. The tenth push overwrites the second push and so on .In addition, the programmer cannot access these registers for write or read and there is no Status bit to indicate stack overflow or stack underflow conditions. For that reason, one should take special care of it during program writing.

CENTRAL PROCESSING UNIT CPU is manufactured with in RISC technology an important factor when deciding which microprocessor to use. RISC Reduced Instruction Set Computer gives two great advantages:

The CPU can recognize only 35 simple instructions (In order to program some other microcontrollers it is necessary to know more than 200 instructions by heart).

The execution time is the same for all instructions except two and lasts 4 clock cycles (oscillator frequency is stabilized by a quartz crystal). The Jump and Branch instructions execution time is 2 clock cycles. It means that if the microcontrollers operating speed is 20MHz, execution time of each instruction will be 200nS, i.e. the program will be executed at the speed of 5 million instructions per second!

20

SIET, ECE (2009-2013)

Figure: 2.4 CPU Memories

2.6 ADVANTAGES OF 8051


The 8051 architectures have these advantages: Small instruction set to learn RISC architecture Built in oscillator with selectable speeds Easy entry level, in circuit programming plus in circuit debugging PIC Kit units available from Microchip.com for less than $50 Inexpensive microcontrollers Wide range of interfaces including I2C, SPI, USB, USART, A/D, programmable Comparators, PWM, LIN, CAN, PSP, and Ethernet. This IC can be reprogrammed and erased up to 10,000 times.

Therefore it is very good for new product development phase.

2.7 LIMITATIONS
The 8051 architectures have these limitations:

One accumulator. Register-bank switching is required to access the entire RAM of many devices

21

SIET, ECE (2009-2013)

Operations and registers are not orthogonal; some instructions can address RAM and/or immediate constants, while others can only use the accumulator.

22

SIET, ECE (2009-2013)

Figure 2.5 Pin Diagram of 8051

CHAPTER 3
23

SIET, ECE (2009-2013)

PRINTED CIRCUIT BOARD & SOLDERING

3.1 PRINTED CIRCUIT BOARD


A printed circuit board, or PCB, is used to mechanically support and electrically connect electronic components using conductive pathways, tracks or signal traces etched from copper sheets laminated onto a non-conductive substrate. It is also referred to as printed wiring board (PWB) or etched wiring board. Printed circuit boards are used in virtually all but the simplest commercially produced electronic devices. A PCB populated with electronic components is called a printed circuit assembly (PCA), printed circuit board assembly or PCB Assembly (PCBA). In informal use the term "PCB" is used both for bare and assembled boards, the context clarifying the meaning. Alternatives to PCBs include wire wrap and point-to-point construction. PCBs must initially be designed and laid out, but become cheaper, faster to make, and potentially more reliable for high-volume production since production and soldering of PCBs can be automated. Much of the electronics industry's PCB design, assembly, and quality control needs are set by standards published by the IPC organization.

Figure 3.1 PCB

3.2 CONVERSION OF CCB INTO PCB


STEP 1: Take a copper clad board.
24

SIET, ECE (2009-2013)

STEP2: Draw a layout of the circuit. STEP3: Trace the mirror image of layout on CCB. STEP4: Piant the layout on CCB. STEP5: Now remove the copper through the etching process. STEP6: After etching remove the paint. STEP7: Now start testing the copper tracks. STEP8: PCB is prepared & components can be mounted.

Figure3.2 Finished PCB

3.3 PCB LAYOUT


The PCB layout is a mirrored positive one - black on white. Mirrored as viewed from the silkscreen top side. The PCB layout is printed 1:1 on paper by means of a laser printer or copier machine. The laser printer or copier toner will not run out when it gets wet or oily. The ink of an inkjet paper print does run out and inkjet printers are therefore useless with the described method.

25

SIET, ECE (2009-2013)

3.4 PCB ETCHING


The developed PCB is etched with a 220 g/l solution of ammonium peroxydisulf ate (NH4)2S2O8 a.k.a. ammonium persulfate, 220 gram added to 1 liter of water and mix it until everything is dissolved. Theoretically it should be possible to etch slightly more than 60 grams of copper with 1 liter etching solution. Assume an 50% efficiency, about 30 grams of copper. With a thickness of 35 m copper on your PCB this covers a copper area of about 1000 cm 2. Unfortunately the efficiency of the etching solution degrades, dissolved ammonium peroxydisulfate decomposes slowly. You better make just enough etching solution you need to etch. For an etching tray of about 20 x 25 cm a minimum practical amount is 200-250 ml solution. So you dissolve about 44 grams ammonium peroxydisulfate into 200 ml or 55 grams into 250 ml water. Etching at ambient temperature might take over an hour, it is better to heat up the etching solvent to about 35-45 degrees Celcius. The etching solution heating up could be done in a magnetron, this takes about 40 to 60 seconds in a 850W magnetron depending on the initial temperature of the etching solution (hint: first try this with just water to determine the timer setting of the magnetron). The etching - rocking the etching tray - takes about 15-30 minutes at this temperature. If you have a heated, air-bubble circulated etching fluid tank available, this is probably the fastest way to etch. At higher temperatures the etching performance decreases. The etching process is an exothermic reaction, it generates heat. Take care, cool your etching tray when necessary! You should minimize the amount of copper to etch by creating copper area in your PCB layout as much as possible. When starting the etching process and little to etch it is difficult to keep the etching solution at 35-45 degrees Celcius. It helps to fill for example the kitchen sink with warm water and rock the etching tray in the filled kitchen sink. When the ammonium peroxydisulfate is dissolved it is a clear liquid. After an etching procedure it gradually becomes blue and deeper blue - the chemical reaction creates dissolved copper sulfate CuSO4. Compared to other etching chemicals like hydrated iron (III) chloride FeCl3.6H2O a.k.a. ferric chloride or the combination of hydrochloric acid HCL and hydrogen peroxide H2O2, using ammonium peroxydisulfate is a clean and safe method. Did you ever spilled dissolved iron chloride on your clothes or your assumed stainless steel kitchen sink? Do you really want to keep concentrated hydrochloric acid and hydrogen peroxide at home? So,
26

SIET, ECE (2009-2013)

without doubt ammonium peroxydisulfate is the best choice for etching at home. However, copper sulfate is a poisonous substance and should be treated as chemical waste.

Figure 3.3 PCB Etching

3.5 SOLDERING
Soldering is a process in which two or more metal items are joined together by melting and flowing a filler metal (solder) into the joint, the filler metal having a lower melting point than the work piece. Soldering differs from welding in that soldering does not involve melting the work pieces. In brazing, the filler metal melts at a higher temperature, but the work piece metal does not melt. Formerly nearly all solders contained lead, but environmental concerns have increasingly dictated use of lead-free alloys for electronics and plumbing purposes.

Figure 3.4 Soldering

3.5.1 SOLDERS
27

SIET, ECE (2009-2013)

Soldering filler materials are available in many different alloys for differing applications. In electronics assembly, the eutectic alloy of 63% tin and 37% lead (or 60/40, which is almost identical in melting point) has been the alloy of choice. Other alloys are used for plumbing, mechanical assembly, and other applications. Some examples of soft-solder are tin-lead for general purposes, tin-zinc for joining aluminium, lead-silver for strength at higher than room temperature, cadmium-silver for strength at high temperatures, zinc-aluminium for aluminium and corrosion resistance, and tin-silver and tin-bismuth for electronics. A eutectic formulation has advantages when applied to soldering: the liquidus and solidus temperatures are the same, so there is no plastic phase, and it has the lowest possible melting point. Having the lowest possible melting point minimizes heat stress on electronic components during soldering. And, having no plastic phase allows for quicker wetting as the solder heats up, and quicker setup as the solder cools. A non-eutectic formulation must remain still as the temperature drops through the liquidus and solidus temperatures. Any movement during the plastic phase may result in cracks, resulting in an unreliable joint. 3.5.2 FLUX The purpose of flux is to facilitate the soldering process. The obstacle to a successful solder joint is an impurity at the site of the union, e.g. dirt, oils or oxidation. The impurities can be removed by mechanical cleaning or by chemical means, but the elevated temperatures required to melt the filler metal (the solder) encourages the work piece (and the solder) to re-oxidize. This effect is accelerated as the soldering temperatures increase and can completely prevent the solder from joining to the work piece. One of the earliest forms of flux was charcoal, which acts as a reducing agent and helps prevent oxidation during the soldering process. Some fluxes go beyond the simple prevention of oxidation and also provide some form of chemical cleaning (corrosion).

3.5.3 PROCESSES
28

SIET, ECE (2009-2013)

There are three forms of soldering, each requiring progressively higher temperatures and producing an increasingly stronger joint strength:

Soft soldering, which originally used a tin-lead alloy as the filler metal, silver soldering, which uses an alloy containing silver, Brazing which uses a brass alloy for the filler.

CHAPTER 4 ANGLE & DIRECTION CONTROL OF STEPPER MOTOR


29

SIET, ECE (2009-2013)

(MINOR PROJECT)
4.1LIST OF COMPONENTS USED
Various components used in this project are as follows: Resistors Capacitors Diodes Motor Driver Voltage Regulator 8051 Microcontroller 16*2 LCD Transformer Stepper motor

4.1.1 RESISTORS Resistance is a passive component. It is defined as opposition to flow of current and is defined by OHMS law, which states that current in circuit, is directly proportional to electromagnetic force and inversely to resistance. it is measured in ohms. Material shows a great variability in there resistively & in fact it is one of the most widely used physical quantities. Material such as silver & copper have very low resistance, steal & nickel offer such a high resistance that it can be considered to be virtually infinite & in fact they are regarding as insulator. To match various requirement of there many applications, resistor vary wide in size& composition. Although in general ,resistor are cylindrical in shape with a lead at either ends, there physical size ranges from larger than a pin head to over all the dimension of several cm material used in there construction vary.

30

SIET, ECE (2009-2013)

4.1Resistors Resistors are two types: Fixed resistors. Variable resistors

FIXED RESISTORS The most common fixed resistor is the composition type. The resistance element is made of graphite, or some other form of carbon, and alloy materials. These resistors generally have resistance values that range from 0.1 to 22 ohm Another kind of fixed resistor is the wire wound type. The resistance element is usually made of nickel-chromium wire wound on a ceramic rod. These resistors generally have resistance values that range from 1 to 100 k ohm. VARIABLE RESISTORS Variable resistors are used to adjust the amount of resistance in a circuit. A variable resistor consists of a sliding contact arm that makes contact with a stationary resistance element. As the sliding arm moves across the element, its point of contact on the element changes, effectively changing the length of the element. The rating of a variable resistor is its resistance at its highest setting. RESISTIVITY & CONTINUITY The electrical resistance of a wire would be expected to be greater for a longer wire, less for a wire of larger cross sectional area, and would be expected to depend upon the material out of which the wire is made. Experimentally, the dependence upon these properties is a straightforward one for a wide range of conditions, and the resistance of a wire can be expressed as

31

SIET, ECE (2009-2013)

The factor in the resistance which takes into account the nature of the material is the resistivity . Although it is temperature dependent, it can be used at a given temperature to calculate the resistance of a wire of given geometry. The inverse of resistively is called conductivity. There are contexts where the use of conductivity is more convenient. 4.1.2 CAPACITORS The capacitors function is to store electricity, or electrical energy.

The capacitor also functions as a filter, passing alternating current (AC), and blocking direct current (DC). This symbol is used to indicate a capacitor in a circuit diagram.

ELECTROLYTIC CAPACITORS

Figure 4.2Electrolytic Capacitors

Aluminum is

used for the electrodes

by using a thin

oxidization

membrane.

Large values of capacitance can be obtained in comparison with the size of the capacitor, because the dielectric used is very thin. TANTALUM CAPACITORS Tantalum Capacitors are electrolytic capacitors that is use a material called tantalum for the electrodes. Large values of capacitance similar to aluminum electrolytic capacitors can be obtained. Also, tantalum capacitors are superior to aluminum electrolytic capacitors in temperature and frequency characteristics.
32

SIET, ECE (2009-2013)

Figure 4.3Tantulum Capacitors When tantalum powder is baked in order to solidify it, a crack forms inside. An electric charge can be stored on this crack. CERAMIC CAPACITORS Ceramic capacitors are constructed with materials such as titanium acid barium used as the dielectric. Internally, these capacitors are not constructed as a coil, so they can be used in high frequency applications.

Figure 4.4 Ceramic Capacitors

4.1.3 DIODES Diodes are components that allow current to flow in only one direction. They have a positive side (leg) and a negative side. When the voltage on the positive leg is higher than on the negative leg then current flows through the diode (the resistance is very low). When the voltage is lower on the positive leg than on the negative leg then the current does not flow (the resistance is very high). The negative leg of a diode is the one with the line closest to it. It is called the cathode. The 33ositive end is called the anode.

33

SIET, ECE (2009-2013)

Figure4.5 Diodes 4.1.4 MOTOR DRIVER The L293 is a quadruple high-current half-H driver designed to provide bidirectional drive currents of up to 1 A at voltages from 4.5 V to 36 V. It is designed to drive inductive loads such as relays, solenoids, dc and bipolar stepping motors, as well as other high-current/high-voltage loads in positive-supply applications. 4.1.5 VOLTAGE REGULATOR A dc voltage regulator requires many components such as zener diode, transistors, resistors & potentiometer etc. all these components were provided in a single integrated circuit chip a722.it is a monolithic voltage regulator developed by fair child semiconductor ltd. In 1868. An improved IC was then developed as 7805 by fair child semiconductor & LM309 by national semiconductor. These IC are three terminal fixed voltage regulator. This required an unregulated supply between input and common terminal. It has internal protection against overload to give a fixed output voltage at +5v.

The three terminal voltage regulator is a single I.C. does not require many external components, has in built circuit for overload protection, saves spaces and cost.

34

SIET, ECE (2009-2013)

Figure 4.6Voltage Regulator

4.1.6 8051 MICROCONTROL Microcontroller is a general purpose device. It has a CPU, memory, serial, parallel ports, interrupts, counters, timers, ROM, RAM all are embedded together on a single chip. An embedded system uses a microcontroller to do one and only one task. A printer is an example of embedded system since processor inside it can perform only one task getting the data in printing it contrast to it with the personal computer. A computer can be used for any numbers of applications such as word processor, video game playing etc. Computer can perform muti task as it has RAM memory and operating system that loads the application software in to RAM and gets the CPU run it.

Figure 4.7 Block Diagram

4.1.7 LCD (LIQUID CRYSTAL DISPLAY) It is very important to keep a track of the working of almost all the automated and semiautomated devices, be it a washing machine, an autonomous robot or anything else. This is achieved by displaying their status on a small display module. LCD (Liquid Crystal Display) screen is such a display module and a 16x2 LCD module is very commonly used. These modules are replacing seven segments and other multi segment LEDs for these purposes. The reasons being: LCDs are economical, easily programmable, have no limitation of displaying special & even custom characters (unlike in seven segments), animations and so on.

35

SIET, ECE (2009-2013)

Figure 4.8 LCD 4.1.8 TRANSFORMER A transformer is a static device, which transfer electric power from one circuit to another of same frequency. It can raise or low the voltage in a circuit but with a corresponding increase or decrease in current. The transformer has two windings primary or secondary. The winding, which is to source of supply, is called primary & other from which the power is obtained is called secondary.

36

SIET, ECE (2009-2013)

Figure 4.9Transformer

4.1.9 STEPPER MOTOR A stepper motor is an electromechanical device which converts electrical pulses into discrete mechanical movements. 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.

Figure 4.10 STEPPER MOTOR

4.2 COST ANALYSIS OF COMPONENTS USED

SR NO

COMPONENT

QUANTITY

COST

IC 8051 MC

90

STEPPER MOTOR

90

TRANSFORMER
37

50

SIET, ECE (2009-2013)

VOLTAGE REGULATOR

10

16*2 LCD DISPLAY

140

CRYSTAL OSCILATOR

20

DIODES

24

SWITCHES

40

RESISTORS

18

10

CAPACITORS

10

32

11

PCB

90

4.3 INTERFACING OF LCD WITH 8051

38

SIET, ECE (2009-2013)

39

SIET, ECE (2009-2013)

FIGURE 4.11- CIRCUIT DIAGRAM

4.3.1PROGRAM
40

SIET, ECE (2009-2013)

org 000 main: mov dptr,#line loop1: clr a movc a,@a+dptr call cmd call delay inc dptr mov dptr,#line1 call loop2 mov a,#0c0h call cmd mov dptr,#line11 main1: jnb p1.4,pos90 jnb p1.5,pos180 jnb p1.6,pos270 jnb p1.7,pos360 jnb p1.0,apos90 jnb p1.1,aposi180 jnb p1.2,aposi270 jnb p1.3,aposi360 mov p2,#00h jmp main1 aposi180:jmp apos180 aposi270:jmp apos270
41

SIET, ECE (2009-2013)

aposi360:jmp apos360 pos90: mov a,#80h call cmd mov dptr,#line2 call loop2 mov a,#0c0h call cmd mov dptr,#line3 call loop2 mov r1,#03 l1: call clkwise djnz r1,l1 jmp main

pos180: mov a,#80h call cmd mov dptr,#line2 call loop2 mov dptr,#line4 call loop2 mov r1,#06 l2: call clkwise djnz r1,l2 jmp main
42

SIET, ECE (2009-2013)

pos270: mov a,#80h call cmd mov dptr,#line2 call loop2 mov a,#0c0h call cmd mov dptr,#line5

mov r1,#09 l3: call clkwise djnz r1,l3 jmp main pos360: mov a,#80h call cmd mov dptr,#line2 call loop2 mov dptr,#line6 call loop2 mov r1,#12 l4: call clkwise djnz r1,l4 jmp main

43

SIET, ECE (2009-2013)

apos90:

mov a,#80h call cmd mov dptr,#line2 call loop2 mov a,#0c0h call cmd mov dptr,#line7 call loop2 mov r1,#03

l5:

call aclkwise djnz r1,l5 jmp main

apos180: mov dptr,#line2 call loop2 mov a,#0c0h call cmd mov dptr,#line8 call loop2 mov r1,#06 l6: call aclkwise djnz r1,l6 jmp main

apos270:
44

SIET, ECE (2009-2013)

mov a,#80h call cmd mov dptr,#line2 call loop2 mov a,#0c0h call cmd mov dptr,#line9 call loop2 mov r1,#09 l7: call aclkwise djnz r1,l7 jmp main

apos360: mov a,#80h call cmd mov dptr,#line2 call loop2 mov a,#0c0h call cmd mov dptr,#line10 call loop2 mov r1,#12 l8: call aclkwise djnz r1,l8 jmp main
45

SIET, ECE (2009-2013)

cmd: mov p0,a clr p3.0 clr p3.1 setb p3.2 call delay clr p3.2 ret dis: setb p3.0 clr p3.1 setb p3.2 call delay clr p3.2 ret movc a,@a+dptr call dis call delay CALL DELAY inc dptr jnz loop2 ret clkwise: mov p2,#33h call delay1
46

SIET, ECE (2009-2013)

mov p2,#66h call delay1 mov p2,#0cch call delay1 mov p2,#99h call delay1 ret aclkwise: mov p2,#33h call delay1 mov p2,#99h call delay1 mov p2,#0cch call delay1 mov p2,#66h call delay1 ret delay1: mov r4,#255 j1: mov r3,#255 djnz r3,$ djnz r4,j1 ret delay: mov r0,#255 djnz r0,$
47

SIET, ECE (2009-2013)

ret org 400h line: db 01h,06h,0eh,38h,80h,00h "Welcome ",00h

line1: db line2: db line3: db line4: db line5: db line6: db line7: db line8: db line9: db line10: db line11: db end

"Shaft position ",00h "A clockwise 90' ",00h "A clockwise 180' ",00h "A clockwise 270' ",00h "A clockwise 360' ",00h "clockwise 90' ",00h "clockwise 180' ",00h "clockwise 270' ",00h "clockwise 360' ",00h "Press key ",00h

4.4 MAJOR APPLICATIONS AND FUTURE SCOPE


A stepper motor is a permanent magnet or variable reluctance dc motor that has the following performance characteristics: 1. Rotation in both directions. 2. Precision angular incremental changes. Stepper motors are used in a wide variety of applications in industry, including computer peripherals, business machines, motion control, and robotics, which are included in process control and machine tool applications. Computer Peripheral- Floppy disc, printer

48

SIET, ECE (2009-2013)

Business Machines- Card reader, type writer, banking systems Process Control- Conveyor Machine Tools- Milling machines, drilling machines, laser cutting, sewing, lathes

Figure 4.12 Minor Project

49

SIET, ECE (2009-2013)

50

You might also like