Embebded Training

38
        4  Department of Electronic & Communication Engineering  This is to certify that Nikhil Agrawal, student of fourth year in Electronics and Communication Branch has successfully completed his Industrial training on Embedded System Design Using 8-Bit Microcontroller & PCB Designing” at PLC Institute of Electronics, New Delhi, during the 2009 – 2010 session. I hereby approve his training work and report. Mr.Jitendra Mishra Dr. L.D. BALANI  Prof. Sameena Zaafar Lecture of Electronics & Director PCST-Bhopal . H.O.D. of Electronics & Communication Department. Communication Department. Training Incharge.  CERTIFICATE

Transcript of Embebded Training

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 1/38        4

 

Department of Electronic & Communication

Engineering

 This is to certify that Nikhil Agrawal, student of fourth

year in Electronics and Communication Branch has

successfully completed his Industrial training on

“Embedded System Design Using 8-Bit

Microcontroller & PCB Designing”  at PLC Institute of 

Electronics, New Delhi, during the 2009 – 2010 session.

I hereby approve his training work and report.

Mr.Jitendra Mishra Dr. L.D. BALANI Prof. Sameena Zaafar

Lecture of Electronics & Director PCST-Bhopal .H.O.D. of Electronics & Communication

Department.Communication Department.Training Incharge.

 

CERTIFICATE

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 2/38        4

DECLARATION

hereby declare that the work that is being presented in the Major

training report entitled  Embedded System Design Using 8-Bit

Microcontroller in partial fulfillment of the requirement for the award

of degree of Bachelor of Engineering in Electronics & Communication

Engineering is an authentic record of our work carried out under the

guidance of PLC Institute of Electronics . The training has been carried

out at PLC Institute of Electronics, New Delhi.

I

The matter embodied in the report has not been submitted for the

award of any other degree or diploma.

  Nikhil

Agrawal.

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 3/38        4

 

ACKNOWLEDGEMENT

We express our deep senses of gratitude to our respected and

learned guide Mr. B.P Arun, for their valuable help and guidance. We

are thankful to them for the encouragement they have given us in

completing the training.

I am also grateful to respected Mr. Subrato Howlader

Training Officer, for permitting us to utilize all the necessary

facilities of the organization.

I am also graceful to the college and Dept. of Electronics and

Communication for their valuable guidance and permission for taking

this training.

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 4/38        4

Lastly, we would like to express our deep appreciation towards

our batch mates for providing us the moral support and

encouragement.

Introduction-

An embedded system is a computer system designed to perform oneor a few dedicated functions, often with real-time computing constraints. Itis embedded as part of a complete device often including hardware andmechanical parts. In contrast, a general-purpose computer, such as apersonal computer, is designed to be flexible and to meet a wide range of an end-user's needs. Embedded systems control many of the commondevices in use today.

Embedded systems are controlled by a main processing core that istypically either a microcontroller or a digital signal processor (DSP).

Since the embedded system is dedicated to specific tasks, designengineers can optimize it reducing the size and cost of the product andincreasing the reliability and performance. Some embedded systems are

mass-produced, benefiting from economies of scale.

Physically, embedded systems range from portable devices such asdigital watches and MP3 players, to large stationary installations like traffic lights, factory controllers, or the systems controlling nuclear power plants.Complexity varies from low, with a single microcontroller chip, to very highwith multiple units, peripherals and networks mounted inside a large chassis or enclosure.

In general, "embedded system" is not an exactly defined term, as manysystems have some element of programmability. For example, handheld 

computers share some elements with embedded systems such as the

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 5/38        4

operating systems and microprocessors which power them, but are not trulyembedded systems, because they allow different applications to be loadedand peripherals to be connected.

Variety of Embedded System- Embedded systems span all aspects of modern life and there are many examples of their use.

 Telecommunications systems employ numerous embedded systemsfrom telephone switches for the network to mobile phones at the end-user.Computer networking uses dedicated routers and network bridges to routedata.

Consumer electronics include personal digital assistants (PDAs), mp3 players, mobile phones, videogame consoles, digital cameras, DVD players, GPS receivers, and printers. Many household appliances, suchas microwave ovens, washing machines and dishwashers, are includingembedded systems to provide flexibility, efficiency and features.Advanced HVAC systems use networked thermostats to more accurately

and efficiently control temperature that can change by time of dayand season. Home automation uses wired- and wireless-networking that canbe used to control lights, climate, security, audio/visual, surveillance, etc.,all of which use embedded devices for sensing and controlling.

  Transportation systems from flight to automobiles increasingly useembedded systems. New airplanes contain advanced avionics suchas inertial guidance systems and GPS receivers that also have considerablesafety requirements. Various electric motors — brushless DC motors, induction motors and DC motors — are usingelectric/electronic motor controllers. Automobiles, electric vehicles,and hybrid vehicles are increasingly using embedded systems to maximizeefficiency and reduce pollution. Other automotive safety systemsinclude anti-lock braking system (ABS), Electronic Stability Control (ESC/ESP), traction control (TCS) and automatic four-wheel drive.

Medical equipment is continuing to advance with more embeddedsystems for vital signs monitoring, electronic stethoscopes for amplifyingsounds, and various medical imaging (PET, SPECT, CT, MRI) for non-invasiveinternal inspections.

Characteristics-1 Embedded systems are designed to do some specifictask, rather than be a general-purpose computer for multiple tasks. Some

also have real-time performance constraints that must be met, for reasonssuch as safety and usability; others may have low or no performancerequirements, allowing the system hardware to be simplified to reducecosts.

2. Embedded systems are not always standalone devices. Many embeddedsystems consist of small, computerized parts within a larger device thatserves a more general purpose. For example, the Gibson Robot Guitar features an embedded system for tuning the strings, but the overallpurpose of the Robot Guitar is, of course, to play music.[5] Similarly, anembedded system in an automobile provides a specific function as a

subsystem of the car itself.

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 6/38        4

3. The program instructions written for embedded systems are referred toas firmware, and are stored in read-only memory or Flash memory chips. They run with limited computer hardware resources: little memory, small ornon-existent keyboard and/or screen.

Processors in Embedded Systems-

Embedded processors can be broken into two broad categories:ordinary microprocessors (μP) and microcontrollers (μC), which have manymore peripherals on chip, reducing cost and size. Contrasting to thepersonal computer and server markets, a fairly large number of basic CPU architectures are used; there are Von Neumann as well as various degreesof Harvard architectures, RISC as well as non-RISC and VLIW; word lengthsvary from 4-bit to 64-bits and beyond (mainly in DSP processors) althoughthe most typical remain 8/16-bit. Most architectures come in a large numberof different variants and shapes, many of which are also manufactured by

several different companies.

A long but still not exhaustive list of common architecturesare: 65816, 65C02, 68HC08, 68HC11, 68k, 8051, ARM, AVR, AVR32, Blackfin, C167, Coldfire, COP8, CortusAPS3, eZ8, eZ80, FRV, H8, HT48, M16C,M32C,MIPS, MSP430, PIC, PowerPC, R8C, SHARC, ST6, SuperH, TLCS-47, TLCS-870, TLCS-900, Tricore, V850, x86, XE8000, Z80, AsAP etc

In general life number of tasks can be performed by using a 8- bitmicrocontroller, for example the filling machine we see at fuel station, carsecurity system is another best example of the embedded system design.

8-Bit Microcontroller-

A microcontroller (also microcontroller unit, MCU or µC) is a smallcomputer on a single integrated circuit consisting of a relatively simple CPUcombined with support functions such as a crystal oscillator, timers,watchdog timer, serial and analog I/O etc. Programmed memory in the formof NOR flash or OTP ROM is also often included on chip, as well as a typicallysmall amount of RAM. Microcontrollers are designed for small or dedicatedapplications. Thus, in contrast to the microprocessors used in personal computers and other high-performance or general purpose applications,

simplicity is emphasized. Some microcontrollers may operate at clock rate frequencies as low as 4 kHz, as this is adequate for many typicalapplications, enabling low power consumption (mill watts or microwatts). They will generally have the ability to retain functionality while waiting foran event such as a button press or other interrupt; power consumptionwhile sleeping (CPU clock and most peripherals off) may be just nano watts,making many of them well suited for long lasting battery applications. 8051is one of the famous architecture of 8-Bit Microcontroller.

8051 Description-

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 7/38        4

Brief History-In 1981, Intel Cooperation introduced an 8-bitmicrocontroller called the 8051.this microcontroller had 128 byte of Ram,4K byte of on chip Rom, two timer, one serial port, and four ports (each 8-bits wide) all on a single chip. At the it is also referred to as a ”system onchip”. The 8051 is 8-bit processor, meaning that CPU can work on only 8bits of data at a time. Data greater than 8- bit has to be broken into 8-bitspieces to be produced by the CPU

 The 8051 became widely popular after Intel allowed other manufactures tomake and market any flavor of the 8051 they please with the condition thatthey remain code compatible with the 8051. This led to many versions of the 8051 with different speed, ROM, and amount of the on chip ROM. Itshould be noticed that, although new versions are different in speed,memory but all are compatible with the original 8051 as war as theinstruction are concerned.

8051 is a CISC type of microcontroller. The CISC stands for complex

instruction set computer. It means that the set of instructions in 8051 canbe developed by using the different combination of logics. There are about150 types of mode of addressing possible in CISC processors. This makeseasily to design the compiler for the compilation of code developed inhigher language into assembly language.

  There microcontroller introduce after 8051 are introduced in tablegiven below.

Feature 8051 8052 8031

ROM (on-chip

program space inbyte)

4K 8K 0K  

RAM (bytes) 128 256 128

 Timers 2 3 2

I/O Pins 32 32 32

Serial Port 1 1 1

Interrupt Source 6 8 6

8051- Architecture-

Block Diagram-

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 8/38        4

8051 Microcontroller Memory-

  Types of Memory- as three very general types of memory. To effectively

program the 8051 it is necessary to have a basic understanding of thesememory types. The memory types are illustrated in the following graphic.

 They are: On-Chip Memory, External Code Memory, and External RAM.

On-Chip Memory refers to any memory (Code, RAM, or other) thatphysically exists on the microcontroller itself. On-chip memory can beof several types, but we'll get into that shortly.

External Code Memory is code (or program) memory that residesoff-chip. This is often in the form of an external EPROM.

External RAM is RAM memory that resides off-chip. This is often inthe form of standard static RAM or flash RAM.

Code Memory-Code memory is the memory that holds the actual 8051program that is to be run. This memory is limited to 64K and comes in manyshapes and sizes: Code memory may be found on-chip, either burned into

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 9/38        4

the microcontroller as ROM or EPROM. Code may also be stored completelyoff-chip in an external ROM or, more commonly, an external EPROM. FlashRAM is also another popular method of storing a program. Variouscombinations of these memory types may also be used--that is to say, it ispossible to have 4K of code memory on-chip and 64k of code memory off-chip in an EPROM.

When the program is stored on-chip the 64K maximum is often reduced to4k, 8k, or 16k. This varies depending on the version of the chip that is beingused. Each version offers specific capabilities and one of the distinguishingfactors from chip to chip is how much ROM/EPROM space the chip has.

However, code memory is most commonly implemented as off-chip EPROM. This is especially true in low-cost development systems and in systemsdeveloped by students.

External RAM- As an obvious opposite of Internal RAM, the 8051 also

supports what is called External RAM.

As the name suggests, External RAM is any random access memory which isfound off-chip. Since the memory is off-chip it is not as flexible in terms of accessing, and is also slower. For example, to increment an Internal RAMlocation by 1 requires only 1 instruction and 1 instruction cycle. Toincrement a 1-byte value stored in External RAM requires 4 instructions and7 instruction cycles. In this case, external memory is 7 times slower!

On-Chip Memory- As mentioned at the beginning of this chapter, the 8051includes a certain amount of on-chip memory. On-chip memory is really one

of two types: Internal RAM and Special Function Register (SFR) memory. Thelayout of the 8051's internal memory is presented in the following memorymap:

As is illustrated in this map, the 8051 has a bank of 128 bytes of InternalRAM. This Internal RAM is found on-chip on the 8051 so it is the fastest RAMavailable, and it is also the most flexible in terms of reading, writing, andmodifying its contents. Internal RAM is volatile, so when the 8051 is resetthis memory is cleared.

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 10/38        4

 The 128 bytes of internal ram is subdivided as shown on the memory map. The first 8 bytes (00h - 07h) are "register bank 0". By manipulating certainSFRs, a program may choose to use register banks 1, 2, or 3. Thesealternative register banks are located in internal RAM in addresses 08hthrough 1Fh. We'll discuss "register banks" more in a later chapter. For nowit is sufficient to know that they "live" and are part of internal RAM.

Bit Memory also lives and is part of internal RAM. We'll talk more about bitmemory very shortly, but for now just keep in mind that bit memory actuallyresides in internal RAM, from addresses 20h through 2Fh.

 The 80 bytes remaining of Internal RAM, from addresses 30h through 7Fh,may be used by user variables that need to be accessed frequently or athigh-speed. This area is also utilized by the microcontroller as a storagearea for the operating stack. This fact severely limits the 8051s stack since,as illustrated in the memory map, the area reserved for the stack is only 80bytes--and usually it is less since this 80 bytes has to be shared between

the stack and user variables.

Register Banks-  The 8051 uses 8 "R" registers which are used in many of its instructions. These "R" registers are numbered from 0 through 7 (R0, R1,R2, R3, R4, R5, R6, and R7). These registers are generally used to assist inmanipulating values and moving data from one memory location to another.For example, to add the value of R4 to the Accumulator, we would executethe following instruction. However, as the memory map shows, the "R"Register R4 is really part of Internal RAM. Specifically, R4 is address 04h. This can be see in the bright green section of the memory map. Thus theabove instruction accomplishes the same thing as the following operation.

 The concept of register banks adds a great level of flexibility to the 8051,especially when dealing with interrupts (we'll talk about interrupts later).However, always remember that the register banks really reside in the first32 bytes of Internal RAM.

Bit Memory- The 8051, being a communications-oriented microcontroller,gives the user the ability to access a number of bit variables. Thesevariables may be either 1 or 0.

 There are 128 bit variables available to the user, numbered 00h through7Fh. The user may make use of these variables with commands such asSETB and CLR. For example, to set bit number 24 (hex) to 1 you wouldexecute the instruction:

Special Function Register (SFR) Memory- Special Function Registers(SFRs) are areas of memory that control specific functionality of the 8051processor. For example, four SFRs permit access to the 8051s 32input/output lines. Another SFR allows a program to read or write to the8051s serial port. Other SFRs allow the user to set the serial baud rate,control and access timers, and configure the 8051s interrupt system.

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 11/38        4

The Accumulator- If you’ve worked with any other assembly languagesyou will be familiar with the concept of an Accumulator register.

 The Accumulator, as its name suggests, is used as a general register toaccumulate the results of a large number of instructions. It can hold an 8-bit(1-byte) value and is the most versatile register the 8051 has due to theshear number of instructions that make use of the accumulator. More thanhalf of the 8051s 255 instructions manipulate or use the accumulator insome way.

For example, if you want to add the number 10 and 20, the resulting 30 willbe stored in the Accumulator. Once you have a value in the Accumulatoryou may continue processing the value or you may store it in anotherregister or in memory.

The "R" Registers- The "R" registers are a set of eight registers that arenamed R0, R1, etc. up to and including R7.

 These registers are used as auxiliary registers in many operations. Tocontinue with the above example, perhaps you are adding 10 and 20. Theoriginal number 10 may be stored in the Accumulator whereas the value 20may be stored in, say, register R4. To process the addition you wouldexecute the command:

The "B" Register- The "B" register is very similar to the Accumulator in thesense that it may hold an 8-bit (1-byte) value.

 The "B" register is only used by two 8051 instructions: MUL AB and DIV AB.

 Thus, if you want to quickly and easily multiply or divide A by anothernumber, you may store the other number in "B" and make use of these twoinstructions.

Aside from the MUL and DIV instructions, the "B" register is often used asyet another temporary storage register much like a ninth "R" register.

The Data Pointer (DPTR)- The Data Pointer (DPTR) is the 8051s only user-accessible 16-bit (2-byte) register. The Accumulator, "R" registers, and "B"register are all 1-byte values.

DPTR, as the name suggests, is used to point to data. It is used by a numberof commands which allow the 8051 to access external memory. When the8051 accesses external memory it will access external memory at theaddress indicated by DPTR.

While DPTR is most often used to point to data in external memory, manyprogrammers often take advantage of the fact that its the only true 16-bitregister available. It is often used to store 2-byte values which have nothingto do with memory locations.

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 12/38        4

The Program Counter (PC)- The Program Counter (PC) is a 2-byteaddress which tells the 8051 where the next instruction to execute is foundin memory. When the 8051 is initialized PC always starts at 0000h and isincremented each time an instruction is executed. It is important to notethat PC isn’t always incremented by one. Since some instructions require 2or 3 bytes the PC will be incremented by 2 or 3 in these cases.

 The Program Counter is special in that there is no way to directly modify itsvalue. That is to say, you cant do something like PC=2430h. On the otherhand, if you execute LJMP 2430h you’ve effectively accomplished the samething.

The Stack Pointer (SP) - The Stack Pointer, like all registers except DPTRand PC, may hold an 8-bit (1-byte) value. The Stack Pointer is used toindicate where the next value to be removed from the stack should betaken from.

When you push a value onto the stack, the 8051 first increments the valueof SP and then stores the value at the resulting memory location.

When you pop a value off the stack, the 8051 returns the value from thememory location indicated by SP, and then decrements the value of SP.

Pin Diagram of 8051 & Description-

Pin and Ports Description of 8051-

Pins 1-8: Port 1 Each of these pins can be configured as an inputor an output.

Pin 9 : RS A logic one on this pin disables the microcontroller andclears the contents of most registers. In other words, the positivevoltage on this pin resets the microcontroller. By applying logiczero to this pin, the program starts execution from the beginning.

Pins10-17: Port 3 Similar to port 1, each of these pins can serveas general input or output. Besides, all of them have alternativefunctions:

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 13/38        4

Pin 10: RXD Serial asynchronous communication input or Serialsynchronous communication output.

Pin 11: TXD Serial asynchronous communication output or Serialsynchronous communication clock output.

Pin 12: INT0 Interrupt 0 input.

Pin 13: INT1 Interrupt 1 input.

Pin 14: T0 Counter 0 clock input. Pin 15: T1 Counter 1 clock input.

Pin 16: WR Write to external (additional) RAM.

Pin 17: RD Read from external RAM.

Pin 18, 19: X2, X1 Internal oscillator input and output. A quartzcrystal which specifies operating frequency is usually connected tothese pins. Instead of it, miniature ceramics resonators can alsobe used for frequency stability. Later versions of microcontrollersoperate at a frequency of 0 Hz up to over 50 Hz.

Pin 20: GND Ground.

Pin 21-28: Port 2 If there is no intention to use external memorythen these port pins are configured as general inputs/outputs. Incase external memory is used, the higher address byte, i.e.addresses A8-A15 will appear on this port. Even though memorywith capacity of 64Kb is not used, which means that not all eightport bits are used for its addressing, the rest of them are notavailable as inputs/outputs.

Pin 29: PSEN If external ROM is used for storing program then alogic zero (0) appears on it every time the microcontroller reads abyte from memory.

Pin 30: ALE Prior to reading from external memory, themicrocontroller puts the lower address byte (A0-A7) on P0 andactivates the ALE output. After receiving signal from the ALE pin,the external register (usually 74HCT373 or 74HCT375 add-on chip)memorizes the state of P0 and uses it as a memory chip address.Immediately after that, the ALU pin is returned its previous logicstate and P0 is now used as a Data Bus. As seen, port datamultiplexing is performed by means of only one additional (andcheap) integrated circuit. In other words, this port is used for bothdata and address transmission.

Pin 31: EA By applying logic zero to this pin, P2 and P3 are used

for data and address transmission with no regard to whether thereis internal memory or not. It means that even there is a programwritten to the microcontroller, it will not be executed. Instead, theprogram written to external ROM will be executed. By applyinglogic one to the EA pin, the microcontroller will use bothmemories, first internal then external (if exists).

Pin 32-39: Port 0 Similar to P2, if external memory is not used,these pins can be used as general inputs/outputs. Otherwise, P0 isconfigured as address output (A0-A7) when the ALE pin is drivenhigh (1) or as data output (Data Bus) when the ALE pin is drivenlow (0).

Pin 40: VCC +5V power supply.

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 14/38        4

Input/output Ports (I/O Ports)-

All 8051 microcontrollers have 4 I/O ports each comprising 8 bits which canbe configured as inputs or outputs. Accordingly, in total of 32 input/outputpins enabling the microcontroller to be connected to peripheral devices areavailable for use.

Pin configuration, i.e. whether it is to be configured as an input (1) or anoutput (0), depends on its logic state. In order to configure a microcontrollerpin as an input, it is necessary to apply a logic zero (0) to appropriate I/Oport bit. In this case, voltage level on appropriate pin will be 0.

Similarly, in order to configure a microcontroller pin as an input, it isnecessary to apply a logic one (1) to appropriate port. In this case, voltagelevel on appropriate pin will be 5V (as is the case with any TTL input). Thismay seem confusing but don't loose your patience. It all becomes clear afterstudying simple electronic circuits connected to an I/O pin.

Input/output (I/O) pin-Figure above illustrates a simplified schematic of all circuits within the microcontroller connected to one of its pins. It refers toall the pins except those of the P0 port which do not have pull-up resistorsbuilt-in.

Output pin-A logic zero (0) is applied to a bit of the P register. The outputFE transistor is turned on, thus connecting the appropriate pin to ground.

Input pin-A logic one (1) is applied to a bit of the P register. The output FEtransistor is turned off and the appropriate pin remains connected to thepower supply voltage over a pull-up resistor of high resistance.

Port 0 - The P0 port is characterized by two functions. If external memory isused then the lower address byte (addresses A0-A7) is applied on it.Otherwise, all bits of this port are configured as inputs/outputs.

 The other function is expressed when it is configured as an output. Unlike

other ports consisting of pins with built-in pull-up resistor connected by its

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 15/38        4

end to 5 V power supply, pins of this port have this resistor left out. Thisapparently small difference has its consequences. If any pin of this port isconfigured as an input then it acts as if it “floats”. Such an input hasunlimited input resistance and undetermined potential. When the pin isconfigured as an output, it acts as an “open drain”. By applying logic 0 to aport bit, the appropriate pin will be connected to ground (0V). By applyinglogic 1, the external output will keep on “floating”. In order to apply logic 1(5V) on this output pin, it is necessary to built in an external pull-up resistor.

Only in case P0 is used for addressing external memory, the microcontrollerwill provide internal power supply source in order to supply its pins withlogic one. There is no need to add external pull-up resistors.

Port 1 -P1 is a true I/O port, because it doesn't have any alternativefunctions as is the case with P0, but can be configured as general I/O only. It

has a pull-up resistor built-in and is completely compatible with TTL circuits.

Port 2- P2 acts similarly to P0 when external memory is used. Pins of thisport occupy addresses intended for external memory chip. This time it isabout the higher address byte with addresses A8-A15. When no memory isadded, this port can be used as a general input/output port showingfeatures similar to P1.

 Port 3-All port pins can be used as general I/O, but they also have analternative function. In order to use these alternative functions, a logic one

(1) must be applied to appropriate bit of the P3 register. In terms of hardware, this port is similar to P0, with the difference that its pins have apull-up resistor built-in.

 Pin's Current limitations - When configured as outputs (logic zero(0)), single port pins can receive a current of 10mA. If all 8 bits of a port areactive, a total current must be limited to 15mA (port P0: 26mA). If all ports(32 bits) are active, total maximum current must be limited to 71mA. Whenthese pins are configured as inputs (logic 1), built-in pull-up resistorsprovide very weak current, but strong enough to activate up to 4 TTL inputsof LS series.

8051-Microcontroller Programming-

 There are many ways to program a microcontroller, for example we candevelop a program in Assembly language and burn into microcontroller ICby the use of Assembler. Now a day the codes of the program aredeveloped in “c” language. Now this code which is encoded in “c” isconverted into Assembly language and then transferred to microcontroller.

For the training session I have use the microcontroller “P89V51RD2BN”,which is a product of Philips. This microcontroller have the core of 8051

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 16/38        4

micro processor, so any program of 8051 can be developed and tested on it. The specialty of this microcontroller is that it is in circuit programmable. Byit means that we can develop our code in PC and can directly transfer intomicrocontroller by a means of Serial port. It have 2 timers, total of 64K totalROM, and 128K of ROM.

 The IED used for this purpose is KEIL. It is a 8051 developing tool and used

for developing code using “c language”. By the term IDE we understandintegrated development environment, it provides the facility of developing acode, debugging and simulation of the developed code. After the

compilation of the code the keil develops a .hex file at defined destinationand this hex file is actually burned into microcontroller. For burning purposewe use new software known as “Flash Magic”. This software is used todownload the code in microcontroller.

Why use of C?

Compiler produces hex files that we download into the ROM of themicrocontroller. The size of the hex file produced by the compiler is on of the main concern of the microcontroller programming, for two reasons:

1. Microcontrollers have limited on-chip ROM. Is limited to2. The code space for the 64K bytes.

While working on Assembly language, it produces the hex file that is muchsmaller than C, but programming in Assembly Language is tedious and timeconsuming. C programming, on the other hand, is less time consuming and

much easier to write, but the hex file produced is much larger than if weuse Assembly language.

Following advantages of programming in C:

1. It is easier and less time consuming to write in C than Assembly.2. C is easier to modify and update.3. We can use code available in function libraries.4. C code is portable to other microcontroller with little or no

modification.

Data Types in C-  There are some specific C Data types that are mostuseful and widely used for 8051 microcontroller.

1. Unsigned char- it is an 8-bit data type that takes a value in range of 0-255(00-FFH). It also stores the ASCII values of the characters.

2. Signed char- it is also a 8 bit data type that uses the most significant bitD7 to represent the – or + value. As a result, we have only 7 bits formagnitude to the signed number, giving us the value from -128 to +128. Italso stores the ASCII values of all characters.

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 17/38        4

3. Unsigned int- this is 16 bit data type which only takes the integer valueand it ranges from 0 to 65535(0000-FFFFH).

4. Signed int- this is similar to signed char, but the only difference is that ittake sonly the integer value which ranges from -32,768 to +32767.

5. Sbit (single bit)- this sbit is widely used for accessing the single- bitaddressable registers.

  The programming in c will we explained with the example during the

explanation of interfacing of microcontroller with different elements.

Interfacing of Microcontroller-

1. Interfacing with LED-   This comes under the port programming

concept. The output voltage of pin of microcontroller can be upto 5 V.

We directly connect the LED to the pin, but doing so can damage theLED. That’s why we use to connect a resistor in series with it and

microcontroller. The connectional block diagram is shown in the

figure in next page.

First program of the training is to produce the alternate chaser of the

LEDs. It means the LEDs must glow in alternate pattern. The program is as

follow.

2. Interfacing with Switch- Microcontroller can be directly connectedwith switch. Switches are used for execution of particular task of userschoose at a given instate.

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 18/38        4

For example we want to on fan so we just put on the switch, in similarway we can do with microcontroller. For this the port pin by which theswitch is connected is set to 1 (high), and when the switch is pressed thisport get grounded and become zero and this logic can be used to do anytask.

3. Serial port Connection-  This very important interfacing regardingto my industrial training program, since I have programmed themicrocontroller through serial port. The 3.0 (10th pin) and 3.1 (11th pin)of 8051. Used for the serial port communication. This is used for theinterfacing of the microcontroller based board with PC. Themicrocontroller uses the 11.80MHz

fr. for the operation. For the serial port communication we required the ICknown as MAX 232 or 233. Since the microcontroller uses the TTL logic andthe serial port transmission logic is different. That’s for the conversion of logics this IC is used.

4. Interfacing with LCD - This section covers the real-world applicationof the 8051. In this I will explain, how to interface the 8051 to devicessuch as LCD and Seven Segment. Now question arises which is betterone, LCD or seven Segment. The recent development has made theLCD operation better than 7 Segment.

5. Interfacing with Seven Segment- Segment displays are basically7 LED's. It will be much easier to understand if you firstread Interfacing LED's to Microcontroller.

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 19/38        4

Basically there are two types of 7-Seg display's:

Common Cathode where all the segments share the sameCathode.

Common Anode where all Segments share the same Anode.

Here we will be only discussing the Common Anode type. In common Anodein order to turn ON a segment the corresponding pin must be set to 0. Andto turn it OFF it is set to 1.

Figure 1 shows how to interface 7-seg display to a microcontroller. Now wecreate a lookup table containing the seven segment pattern to display thecorresponding hex digits. e.g. consider we have to display '1' from theabove figure we come to know that turning ON segment B & C will show '1'on the 7-seg display so P2.1 & P2.2 should be LOGIC 0 whereas rest of the pins should be LOGIC 1. FIGURE 2 shows the lookup table for CAdisplay.

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 20/38        4

 

We can now interface a single 7-Seg to the microcontroller but forinterfacing multiple 7-seg's we use Scanning Principle where One 7-seg isdisplayed after another but this process is very fast hence the flickeringcannot be seen by human eye. Figure 3shows the circuit for interfacing two7 segment displays.

When interfacing more than one 7-seg display the segment's (A-G) of alldisplays are connected together whereas their ANODE (Cathode in case of CC displays) are switched ON one after another. Consider we have todisplay '31' on the above 7-seg display so we TURN ON the first transistorby setting its corresponding pin to 1 & then give the 7-seg equivalent codefor '3' which is 4fh. Then we TURN OFF the first transistor & TURN ON thesecond & output its corresponding 7-seg equivalent code of '1' i.e. 06h.Thenwe again go back to display '3' this is a never ending loop. 

6. ADC, DAC, & SENSOR INTERFACING- Analog signals are verycommon inputs to embedded systems .Most transducers and sensorssuch as temperature, pressure, velocity, humidity areanalog. Therefore we need to convert these analog signals in to digitalso that 8051 can read it.

ANALOG DIGITAL TO CONVERTER (ADC)-Commonly used ADC device– ADC804.

ABOUT IC

Pin out-

CS – Chip Select , active low.

RD – Read Digital data from ADC, H-L edge triggered.

WR -- Start conversion, L-H pulse edge triggered.

INTR -- end of conversion, Goes low to indicate conversion done.

Data bits -- D0-D7.

CLK IN & CLK R.CLK IN is an input pin connected to an external clock source when anexternal clock is used for timing. However, ADC804 has an internalclock generator.

To use the internal clock generator of the ADC804, the CLK IN and CLK 

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 21/38        4

R pins are connected to a capacitor and a resistor. In that case, theclock frequency is determined by the equation.f=1/1.1RC R=10K and C=150pF f=606Hz the conversion time is 110us.

Input Voltage range-

Default 0-5V. Can be changed by setting different value for Vref /2 pin.Vin =Vin(+) – Vin (-)

Range=0 to 2x Vref /2. For Vin = 2x Vref /2. We get 256 as a digital outputon D0-D7. (Refer Table)

Step Size Smallest change– (2 x Vref /2)/ 256 for ADC804, for eg.for step size 10mv ,digital output on D0-D7 changes by one count forevery 10mv change of the input analog voltage.

Data Out - Dout = V in / Step Size. For input voltage of 2.56 volts (Vref =1.28volts) and step size of 10mv Dout =2560/10 =256 or FF that is full scaleoutput.

Conversion- Time Greater than 110us for ADC804

Resolution-8 bits for ADC804.

INTERFACING ADC804 TO 8051-  Signals to be interfaced (on the

ADC804).D0-D7, RD, WR, INTR, CS Can do both Memory mapping and IO mapping. 

Memory Mapping (timing is critical) - Connect D0-D7 of ADC804 tothe data bus of the8051 system. Connect RD, WR of the ADC804 to the8051 system (ensure polarity).Connect CS of ADC804 to an appropriateaddress decoder output. Connect INTR of ADC804 to an externalinterrupt Pin on the 8051 (INT0 or INT1)

Vref/2(Volts)

Vin(Volts)

Step size(mV)

Open(2.5)

0 to 55/256 =19.53

2.560 to5.12

5.12/256=20

1.280 to2.56

2.56/256 =10

0.5 0 to 1 1/256=3.90

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 22/38

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 23/38        4

PinOut- 

D0-D7 à Connected to the Processor’s IO port.

Vref+, Vref-, Vee Usage- Just write a byte to the IO port and the DAC converts it to ananalog value Some 8051 clones have ADCs and DACs in built.

SENSOR- With the advancement in technology, the new variety of sensors is available. The output of these sensors is already calibratedand after converting into digital form we can directly feed intomicroprocessor for processing.

7. Interface with DC Motor- L293D is a dual H-Bridge motor driver, sowith one IC we can interface two DC motors which can be controlled inboth clockwise and counter clockwise direction and if you have motorwith fix direction of motion then you can make use of all the four I/Osto connect up to four DC motors. L293D has output current of 600mA

and peak output current of 1.2A per channel.

Moreover for protection of circuit from back EMF output diodes are includedwithin the IC. The output supply (VCC2) has a wide range from 4.5V to 36V,which has made L293D a best choice for DC motor driver. A simpleschematic for interfacing a DC motor using L293D is shown below.

As you can see in the circuit, three pins are needed for interfacing aDC motor (A, B, Enable). If you want the o/p to be enabled completely then

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 24/38        4

you can connect Enable to VCC and only 2 pins needed from controller tomake the motor work.

As per the truth mentioned in the image above its fairly simple toprogram the microcontroller. It’s also clear from the truth table of BJT circuitand L293D the programming will be same for both of them, just keeping inmind the allowed combinations of A and B. We will discuss aboutprogramming in C as well as assembly for running motor with the help of amicrocontroller

8. Interface with Stepper Motor- here are actually many ways you caninterface a stepper motor to your controller, out of them the most usedinterfaces are:

1. Interface using L293D - H-Bridge Motor Driver

2. Interface using ULN2003/2004 - Darlington Arrays

We will discuss both connection techniques one by one. The abovementioned methods need 4 controller pins for interface.

Connecting Uni-polar stepper using L293D.-

As you see in the circuit above the four pins "Controller pin 1",2,3 and 4will control the motion and direction of the stepper motor according tothe step sequence programmed in the controller.

Connecting Unipolar stepper using ULN2003/2004.-

As already discussed in case of L293D, Here in this circuit too the fourpins "Controller pin 1",2,3 and 4 will control the motion and direction of 

the stepper motor according to the step sequence sent by the controller.

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 25/38        4

2wire connection for Unipolar Stepper Motor.-

We have seen the generally used 4-wire connection method forinterfacing unipolar stepper motor, but we can simplify the design tomake controller use less pins with the help of 2-wire connection method. The circuit for 2-wire connection is shown below.

PIC Microcontroller-

1.Introduction-PIC is a family of  Harvard architecture microcontrollers made by Microchip Technology, derived fromthe PIC1640  originally developed by General Instrument's MicroelectronicsDivision. The name PIC initially referred to "Peripheral InterfaceController".

PICs are popular with both industrial developers and hobbyists alike due totheir low cost, wide availability, large user base, extensive collection of application notes, availability of low cost or free development tools, and

serial programming (and re-programming with flash memory) capability.

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 26/38        4

Microchip announced on February 2008 the shipment of its six billionth PICprocessor. 

2. Core Architecture- The PIC architecture is distinctively minimalist. It is

characterized by the following features:

Separate code and data spaces (Harvard architecture).

A small number of fixed length instructions. Most instructions are single cycle execution (4 clock cycles), with

single delay cycles upon branches and skips.

A single accumulator (W), the use of which (as source operand) isimplied (i.e. is not encoded in the opcode).

All RAM locations function as registers as both source and/ordestination of math and other functions.

A hardware stack for storing return addresses.

A fairly small amount of addressable data space (typically 256bytes), extended through banking.

Data space mapped CPU, port, and peripheral registers.

  The program counter is also mapped into the data space andwritable (this is used to implement indirect jumps).

3. Data space (RAM)-PICs have a set of registers that function as generalpurpose RAM. Special purpose control registers for on-chip hardwareresources are also mapped into the data space. The addressability of memory varies depending on device series, and all PIC devices have somebanking mechanism to extend the addressing to additional memory. Laterseries of devices feature move instructions which can cover the whole

addressable space, independent of the selected bank. In earlier devices(i.e., the baseline and mid-range cores), any register move had to beachieved via the accumulator.

4. Code space-All PICs feature Harvard architecture, so the code space andthe data space are separate. PIC code space is generally implementedas EPROM, ROM, or flash ROM.

In general, external code memory is not directly addressable due to the lackof an external memory interface. The exceptions are PIC17 and select highpin count PIC18 devices.

5. Word size- The word size of PICs can be a source of confusion. AllPICs handle (and address) data in 8-bit chunks, so they should be called 8-bit microcontrollers. However, the unit of addressability of the code space isnot generally the same as the data space. For example, PICs in the baselineand mid-range families have program memory addressable in the sameword size as the instruction width, ie. 12 or 14 bits respectively. In contrast,in the PIC18 series, the program memory is addressed in 8-bit increments(bytes), which differs from the instruction width of 16 bits.

In order to be clear, the program memory capacity is usually stated innumber of (single word) instructions, rather than in bytes.

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 27/38        4

6. Stacks-PICs have a hardware call stack , which is used to save returnaddresses. The hardware stack is not software accessible on earlier devices,but this changed with the 18 series devices.

Hardware support for a general purpose parameter stack was lacking inearly series, but this greatly improved in the 18 series, making the 18 seriesarchitecture more friendly to high level language compilers.

7. Instruction set-A PIC's instructions vary from about 35 instructions forthe low-end PICs to over 80 instructions for the high-end PICs. Theinstruction set includes instructions to perform a variety of operations onregisters directly, the accumulator and a literal constant or theaccumulator and a register, as well as for conditional execution, andprogram branching.

PIC Programming-

During the training module we have use the PIC16F876. It is a productof microchip cooperation. KIEL is used for programming the 8051, like insame way microC is a IDE for the code development of PIC microcontroller.

MicroC- mikroC is a powerful, feature rich development tool for PIC micros.It is designed to provide the programmer with the easiest possible solutionfor developing applications for embedded systems, without compromisingperformance or control.

 

mikroC IDE

PIC and C fit together well: PIC is the most popular 8-bit chip in the world,used in a wide variety of applications, and C, prized for its efficiency, is thenatural choice for developing embedded systems. mikroC provides asuccessful match featuring highly advanced IDE, ANSI compliant compiler,broad set of hardware libraries, comprehensive documentation, and plentyof ready-to-run examples.

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 28/38        4

Features- mikroC allows you to quickly develop and deploycomplex applications:

• Write your C source code using the built-in Code Editor (Code andParameter Assistants, Syntax Highlighting, Auto Correct, Code Templates, and more…)

• Use the included mikroC libraries to dramatically speed up thedevelopment: data acquisition, memory, displays, conversions,communications… Practically all P12, P16, and P18 chips aresupported.

• Monitor your program structure, variables, and functions in the CodeExplorer.

• Generate commented, human-readable assembly, and standard HEXcompatible with all programmers.

• Inspect program flow and debug executable logic with the integratedDebugger.

• Get detailed reports and graphs: RAM and ROM map, code statistics,

assembly listing, calling tree, and more…• We have provided plenty of examples for you to expand, develop, and

use as building bricks in your projects. Copy them entirely if you deemfit – that’s why we included them with the compiler.

PCB Designing-

1. Introduction- We have designed our circuit, perhaps even bread

boarded a working prototype, and now it's time to turn it into a nice Printed

Circuit Board (PCB) design. For some designers, the PCB design will be anatural and easy extension of the design process. But for many others the

process of designing and laying out a PCB can be a  very daunting task.

 There are even very experienced circuit designers who know very little

about PCB design,  and as such leave it up to the "expert" specialist PCB

designers. Many companies even have their own  dedicated PCB design

departments. This is not surprising, considering that it often takes a great

deal of   knowledge and talent to position hundreds of components and

thousands of tracks into an intricate (some say artistic) design that meets a

whole host of physical and electrical requirements. Proper PCB design is

very often an integral part of a design. In many designs (high speed digital,

low level analog and RF to name a few) the PCB layout may make or break

the operation and electrical performance of the design. It must be

remembered that PCB traces have resistance, inductance, and capacitance,

 just like your circuit does.  This article is presented to hopefully take some of 

the mystery out of PCB design. It gives some advice and  “rules of thumb”

on how to design and lay out your PCBs in a professional manner. It is,

however, quite difficult to try and “teach” PCB design. There are many basic

rules and good practices to follow, but apart from that PCB  design is a

highly creative and individual process. It is like trying to teach someone how

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 29/38        4

to paint a picture.  Everyone will have their own unique style, while some

people may have no creative flair at all! Indeed, many PCB designers like to

think of PCB layouts as works of art, to be admired for their beauty and

elegance. “If it looks good, it’ll work good.” is an old catch phrase.

2. Standards- There are industry standards for almost every aspect of PCB

design. These standards are controlled by the former Institute forInterconnecting and Packaging Electronic Circuits, who are now knownsimply as the IPC (www.ipc.org). There is an IPC standard for every aspectof PCB design, manufacture, testing, and anything else that you could everneed.Local countries also have their own various standards for many aspects of PCB design and manufacture, but by and large the IPC standards are theaccepted industry standard around the world. Printed Circuit Boards are alsoknown (some would say, more correctly known) as Printed Wiring Boards, orsimply Printed Boards. But we will settle on the more common term PCB for

this article.

3. The Schematic- Before we even begin to lay out our PCB, you MUSThave a complete and accurate schematic diagram. Many people jumpstraight into the PCB design with nothing more than the circuit in their head,or the schematic drawn on loose post-it notes with no pin numbers and noorder. This just isn’t good enough, if you don’t have an accurate schematicthen your PCB will most likely end up a mess, and take you twice as long asit should.

4. Working To Grids-  The second major rule of PCB design, and the one

most often missed by beginners, is to lay out our board on a fixed grid. Thisis called a “snap grid”, as our cursor, components and tracks will “snap”into fixed grid positions. Not just any size grid minds, but a fairly coarseone. 100 thou is a standard placement grid for very basic through holework, with 50 thou being a standard for general tracking work, like runningtracks between through hole pads. For even finer work we may use a 25thou snap grid or even lower. Many designers will argue over the merits of a20 thou grid vs. a 25 thou grid for instance. In practice, 25 thou is oftenmore useful as it allows you to go exactly half way between 50 thou spacedpads.

5. Working From The Top- PCB design is always done looking from thetop of our board, looking through the various layers as if they weretransparent. This is how all the PCB packages work. The only time we willlook at our board from the bottom is for manufacturing or checkingpurposes. This “through the board” method means that we will have to getused to reading text on the bottom layers as a mirror image, get used to it.

6. Tracks-  There is no recommended standard for track sizes. What sizetrack we use will depend upon (in order of Importance) the electricalrequirements of the design, the routing space and clearance we have

available, and we own personal preference. Every design will have a

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 30/38        4

different set of electrical requirements which can vary between tracks onthe board. All but basic non-critical designs will require a mixture of tracksizes. As a general rule though, the bigger the track width, the better.Bigger tracks have lower DC resistance, lower inductance, can be easier andcheaper for the manufacturer to etch, and are easier to inspect and rework.

7. Vias- Vias connect the tracks from one side of our board to another, byway of a hole in our board. On all but cheap homemade and low endcommercial prototypes, vias are made with electrically plated holes, calledPlated through Holes (PTH). Plated through holes allow electrical connectionbetween different layers on your board.

8. Polygons- Polygons are available on many PCB packages. A polygonautomatically fills in (or “floods”) a desired area with copper, which “flows”around other pads and tracks. They are very useful for laying down groundplanes. Make sure you place polygons after you have placed all of yourtacks and pads.

An example of a “Solid Polygon Fill” (Left), and a “Hatched Polygon Fill”(Right).

9. Clearances-Electrical clearances are an important requirement for allboards. Too tight a clearance between tracks and pads  may lead to“hairline” shorts and other etching problems during the manufacturingprocess. These can be very hard to fault find once your board is assembled.Once again, don’t “push the limits” of your manufacturer unless you have

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 31/38        4

to, stay above their recommended minimum spacing if at all possible.   Atleast 15 thou is a good clearance limit for basic through hole designs, with10 thou or 8 thou being used for more dense surface mount layouts. If yougo below this, it’s a good idea to consult with your PCB manufacturer first.For 240V mains on PCB’s there are various legal requirements, and you’llneed to consult the relevant standards if you are doing this sort of work. Asa rule of thumb, an absolute minimum of 8mm (315 thou) spacing should beallowed between 240V tracks and isolated signal tracks. Good designpractice would dictate that you would have  much larger clearances thanthis anyway.

For non-mains voltages, the IPC standard has a set of tables thatdefine the clearance required for various voltages. A simplified table isshown here. The clearance will vary depending on whether the tracks are onan internal layers or the external surface. They also vary with theoperational height of the board above sea level, due to the thinning of theatmosphere at high altitudes. Conformal coating also improves these figuresfor a given clearance, and this is often used on military spec PCBs.

10. Basic Routing- Now it’s time for some basic routing rules. Routing isalso known as “tracking”. Routing is the process of laying down tracks toconnect components on your board. An electrical connection between twoor more pads is known as a “net”.

Keep nets as short as possible. The longer your total track length, thegreater it’s resistance, Capacitance and Inductance. All of which canbe undesirable factors.

 Tracks should only have angles of 45 degrees. Avoid the use of rightangles, and under no circumstances use an angle greater than 90degrees. This is important to give a professional and neat appearanceto your board. PCB packages will have a mode to enforce 45 degreemovements, make use of it. There should never be a need to turn itoff. Contrary to popular belief, sharp right angle corners on tracksdon’t produce measurable EMI or other problems. The reasons toavoid right angles are much simpler - it just doesn’t look good, and itmay have some manufacturing implications.

Forget nice rounded track corners, they are harder and slower toplace and have no real advantage. Stick to 45 degree increments.Rounded track bends belong to the pre-CAD taped artwork era.

“Snake” your tracks around the board, don’t just go “point to point”.

Point to point tracking may look more efficient to a beginner at first,but there are a few reasons you shouldn’t use it. The first is that it’sugly, always an important factor in PCB design! The second is that it isnot very space efficient when you want to run more tracks on otherlayers.

Enable your Electrical grid, which is sometimes referred to as a “snapto center” or “snap to nearest” option. Let the software find thecenters of pads and ends of tracks automatically for you. This is greatfor when you have pads and tracks which aren’t lined up to yourcurrent snap grid. If you don’t have these options enabled then youmay have to keep reducing your snap grid until you find one that fits.

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 32/38        4

Far more trouble than it’s worth. There is almost never a reason tohave these options disabled.

Always take your track to the center of the pad, don’t make your trackand pad “just touch”. There are few reasons for this. The first is thatit’s sloppy and unprofessional. The second is that your program maynot think that the track is making electrical connection to the pad.

Proper use of a snap grid and electrical grid will avoid problems here. Use a single track, not multiple tracks tacked together end to end. Itmay make no difference to the look of your final board, but it can be apain for future editing. Often you’ll have to extend a track a bit. In thiscase it’s best to delete the old one and place a new one. It may take afew extra seconds, but it’s worth it. People looking at your finishedboard may not know, but YOU’LL know! It’s the little touches like thisthat set good PCB designers apart.

Make sure your tracks go right through the exact center of pads andcomponents, and not off to one side. Use of the correct snap grid willensure that you get this right every time. If your track doesn’t go

through the exact center then you are using the wrong snap grid. Whydo you need to do this? It makes your board neater and moresymmetrical, and it gives you the most clearance.

Only take one track between 100 thou pads unless absolutelynecessary. Only on large and very dense designs should you considertwo tracks between pads. Three tracks between pads is not unheardof, but we are talking seriously fine tolerances here.

For high currents, use multiple vias when going between layers. Thiswill reduce your track impedance and improve the reliability. This is ageneral rule whenever you need to decrease the impedance of your

track or power plane. Don’t “drag” tracks to angles other than 45 degrees

“Neck down” between pads where possible. Eg, a 10 thou trackthrough two 60 thou pads gives a generous 15 thou clearancebetween track and pad.

If your power and ground tracks are deemed to be critical, then laythem down first. Also, make your power tracks as BIG as possible.

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 33/38        4

An example of GOOD power routing (Left) and BAD power routing

(Right).

An example of GOOD routing (Left) and BAD routing (Right).

11. Finishing Touches- Once we have finished all our routing, our boardisn’t done quite yet. There are a few last minute checks and  finishingtouches you should do.

If we have thin tracks (<25 thou) then it’s nice to add a “chamfer” toany “T” junctions, thus eliminating any 90 degree angles. This makesthe track more physically robust, and prevents any potentialmanufacturing etching problems. But most importantly, it looks nice.

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 34/38        4

Check that we have any required mounting holes on the board. Keepmounting holes well clear of any components or tracks. Allow roomfor any washers and screws.

Minimize the number of hole sizes. Extra hole sizes cost you money,as the manufacturer will charge you based on not only the number of holes in your boards, but the number of different hole sizes you have.

It takes time for the very high speed drill to spin down, change drillbits, and then spin up again. Check with your manufacturer for thesecosts, but you can’t go wrong by minimizing the number of hole sizes.

Double check for correct hole sizes on all your components. Nothing ismore annoying than getting your perfectly laid out board back fromthe manufacturer, only to find that a component won’t fit in theholes! This is a very common problem, don’t get caught out.

Ensure that all our vias are identical, with the same pad and holesizes. Remember our pad to hole ratio. Errors here can cause“breakouts” in our via pad, where the hole, if shifted slightly can beoutside of your pad. With plated through holes this is not always fatal,

but without a complete annular ring around your hole, your via will bemechanically unreliable.

Check that there is adequate physical distance between all ourcomponents. Watch out for components with exposed metal that canmake electrical contact with other components, or exposed tracksand pads.

Change our display to “draft” mode, which will display all your tracksand pads as outlines. This will allow us to see your board “warts andall”, and will show up any tracks that are tacked on or not ending onpad centers.

If we wish, add “teardrops” to all your pads and vias. A teardrop is anice “smoothing out” of the junction between the track and the pad,not surprisingly, shaped like a teardrop. This gives a more robust andreliable track to pad interface, better than the almost right anglebetween a standard track and pad. Don’t add teardrops manuallythough, it’s a waste of time. But if your program supports automaticteardrop placement, feel free to use it.

12. Single Sided Design- Single sided design can greatly reduce the costof our board. If we can fit our design on a single sided board then it ispreferable to do so. Look inside many of today’s consumer items like TV’s

and DVD players, and we will almost certainly find some single sidedboards. They are still used because they are so cheap to manufacture.

Single sided design however requires some unique techniques which arearen’t required once we go to doubled sided and multi-layer design. It iscertainly more challenging than a double sided layout. In fact, a single sidedboard design will be regarded inversely proportional to the number of  jumper links used. No jumper links earns the admiration of many peers!

It is all about a balance between board size and the number of jumperlinks required. Almost every single sided board will require some jumperlinks, so it is important to minimize these.

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 35/38        4

Component placement is even more critical on a single sided board, sothis is no time to make all our components nice and neatly aligned. Arrangeyour components so that they give the shortest and most efficient trackingpossible. It is like playing a game Chess, if we don’t think many movesahead then we will get our self in a corner pretty quickly. Having just onetrack running from one side of your board to the other can ruin your wholelayout, as it makes routing any other perpendicular tracks impossible.

Many people will route their board as though it is a double sided board,but only with straight tracks on the top layer. Then when the board is to bemanufactured, the top layer tracks are replaced with jumper links. This canbe a rather inefficient way to approach single sided design, and is notrecommended. We must be frugal in our placement, and don’t be afraid torip everything up and try again if you see a better way to route something.With experience, we will be able to tell before we even start, if a design if worth trying to route on a single sided board.

13. Rats Nest-

A Typical “Rats Nest” Display.

Our job of component placement will be made infinitely easier byhaving a “rats nest” display enabled. If there is one reason for going to thetrouble of drawing up an accurate schematic and importing a netlist, this issurely it. For large designs, a rats nest display is essential.

A rats nest display is one where the program will draw a straight line(not a track) between the pads of components which are connected on theschematic. In effect, it shows the connectivity of your circuit before we startlaying out tracks. At the start of your board layout, with all your componentsplaced down randomly, this will appear as a huge and complicated randommaze of lines. Hence the name rats nest.

 The rats nest may look very daunting at first, but when we move each

component the lines will automatically move with them. In this way we can

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 36/38        4

see instantly which components are connected to which, without having torefer back to the schematic and constantly cross reference componentdesignators. Once we have used this feature once, you won’t want to livewithout it. Even when doing simple designs with a few dozen components,we will miss this functionality.

With the rats nest display enabled, it will be almost possible to lay outall of our components optimally in no time, without having to lay down onesingle track. The rats nest display will effectively show us what our trackswill connect to. The rats nest lines should disappear when we route yourtracks between components, so our design will get less and less“complicated looking” as we go along. When all the rats nest linesdisappear, our board is fully routed.

14. PCB Designing Tools- There are many tools available in maket for thedesigning of PCB. For example, PCB Express, Orcade, Dip Trace, and manymore. During the training module we have trained on Dip Trace software. Itis good and much easier to work when you are beginner.

First we develop a schematic diagramed of the circuit in schematiceditor.

Schematic Editor- After developing the schematic diagram we useto convert it into the PCB. For this we go to the “File” in menu bar andselect “Convert to PCB”. Now a new window appears known as PCBEditor.

Schematic Editor Window

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 37/38        4

PCB Editor- As soon the new window opens you can see that Ratsnet will

PCB Editor Window.

be appear in front of us. Now the new task of placing the components andto arrange the component in systematically arranged manner, in order toget good PCB. The picture in next page will show how it appears.

Now after completion of placement, tracking and routing the PCB appearsas.

8/8/2019 Embebded Training

http://slidepdf.com/reader/full/embebded-training 38/38

FINAL PCB LAYOUT.