28-08-2014, 12:32 PM
my training is on EMBEDDED SYSTEM ..it consists of 8051 Microprocessors,AVR,PCB designing,PIC,ARM..that is both combination of hardware and softwares..
SIX MONTHS INDUSTRIAL TRAINING TRAINING REPORT UNDERTAKEN AT “C-DAC” IN “ELECTRONICS” ON “EMBEDDED SYSTEM” SUBMITTED IN PARTIAL FULFILLMENT OF THE DEGREE OF BACHELOR OF TECHNOLOGY IN ELECTRONICS & COMMUNICATION Under the Guidance of: Submitted By: Name: Mr.Rohit Moudgil Name:Raminder Sharma Designation: H.O.D College Roll No.:100350415475 Department: ELECTRONICS & COMM. University Roll No.: 100350415475 Gulzar Institute of Engineering & Technology Village: Libra, G.T. Road, Khanna, Punjab Profile of industry. Centre for Development of Advanced Computing (C-DAC), Mohali is a Scientific Society of the Ministry of Communications and Information Technology, Government of India. It was set up in May 1989 as Center for Electronics Design & Technology of India (CEDTI), Mohali. In December 2002, CEDTI Mohali merged with C-DAC with a primary mandate to promote high end R&D. C-DAC Mohali, ISO 9001:2008 certified, is a Research & Development organization engaged in design and deployment of world class IT and electronics solutions. C-DAC Mohali is a dynamic, growing organization Present R&D activities cover projects on Health Informatics including telemedicine, eGovernance, e-Security, BOSS / Linux Server, language technology, Black Box for automobiles, various RFID based security Applications and agri electronics. C-DAC Mohali operates from its own impressive building having a covered area of approximately 4300 sq. mts. The centre is located in the ELTOP (Electronics Town of Punjab) Complex amidst a large number of industries, manufacturing electronic products relating to computers, peripherals, communication equipment and components, offering a great professional challenge to the faculty and staff of the Centre. Two decades ago C-DAC Mohali started as a leading human resource developer and training institute for Information Technology (IT) sector in the northern region. The Centre has earned a brand for quality training programmes. Along with various diploma courses, C-DAC Mohali also offers high-end courses like M.Tech in VLSI as well as ME in Electronic Product Design Technology (EPDT). Short term value added courses designed for knowledge based skill development have also received enormous response. It also offers courses for foreign participants, sponsored by MEA under ITEC/SCAAP programs. ACKNOWLGEMENT I am highly grateful to the authorities of Gulzar group of institutes, Khanna, Ludhiana for providing this opportunity to carry out the project work. I wish to express my sincere and heartfelt gratitude to Er. Kulwinder singh, assistant professor of department of electronic and communication engineering, Gulzar Institute of Engineering & Technology, G.T. Road, Khanna (Ludhiana) for his unfailing inspiration, whole hearted cooperation and painstaking supervision, through discussions, criticism and suggestions given by him during the entire period of work. Without his timely and untiring help, it would have not been possible to present this work in its present form. It is my proud privilege to express regards and sincere thanks to him for his help, inspiration and moral support throughout the dissertation period which went a long way in bringing out this work from conception to completion. I would also like to extend my sincere thanks to Er. Rohit Moudgill (HOD), Er. Ashu jaggi, Er. Sakshi and all staff members of the ELECTRONICS department for the moral support and encouragement they have provided to me during completion of this thesis work. The work would have been incomplete if our workshop faculty would not have helped us in all means during the fabrication work. PREFACE Dear electronic & communication Professional, Welcome to the electrical electronic & communication design productivity and career! electronic & communication is one of the leading designing and documentation widely used in the industry. As per Embedded productivity study, with help you to increase the productivity up to 80%. Our training will make this a reality with your dedication and co operation. In this reference guide, topics are arranged such a way to ensure the learning sequence with practical approach. The first chapter helps you to have a clean idea about how to use the in-built 8051,AVR,PCB and to creats new symbols based on the project requirements. The second chapter explains the circuits building procedures. In the third chapter you will learn to create the power and control circuits followed by the tools to insert the components from the library. You will also learn to make corrections on the database for the same. Chapter four contains the information about the wires and wire numbers which is the basic for all the circuits designs. Fifth chapter covers the PLC layout creation in detail. From the sixth chapter you will get a clear idea about the annotation. The final chapter deals with the panel layout and different types of reports generation which helps you to create a details project reports. Also this courseware gives the detailed knowledge on database clarification of electronic components from manufactures’s catalogue; for better understanding, the about topics were explained with the step by step with application sequence with the suitable hands-on. We assure you of a world class learning experience at C-DAC MOHALI ! Contents INTRODUCTION 4 1. 8051 MICROCONTROLLER 7-27 2. AVR MICROCONTROLLER 28-38 3. PRINTED CIRCUIT BOARD 39-44 4. ARM MICROCONTROLLER 45-58 5. PIC. 59-63 6. BIBLIOGRAPHY AND REFERENCES. 64. INTRODUCTION A microcontroller is a programmable logic and integrated circuit which can be programmed to do a number of tasks. Its possible to control just about anything with the program written by the user. An embedded system can be defined as computing device that has computer hardware, either with software embedded in it as one of its most important components. It may be an independent system or a part of a larger system. The emergence of embedded system is a recent development. As a scientific description it resembles state of microelectronics. Today a challenge is similar to back then except that stakes are probably higher. Embedded system will appear in virtually all devices and intelligent devices have tendency to oust their “stupid” counterparts from market place, just like CD players have ousted gramophones players. These embedded systems are heterogeneous. Since they are mixtures of hardware and software, trade-off is an important design decisions. They combine computer science and digital electronics. Modern embedded systems are often based on microcontrollers(i.e. CPUs with integrated memory or peripheral in faces) but ordinary microprocessors (using external chips for memory and peripheral interface circuits ) are still common , especially in more complex systems . A common standard class of dedicated processors is the digital signal processor (DSP). Physically these systems range from portable devices such as digital watches and mp3 players , to large stationery installation like traffic lights, factory controller and largely complex systems like hybrid vehicles, MRI and avionics. Embedded technology is now in its prime and wealth of knowledge available is mind blowing. However, most engineers have common complaints. There are no comprehensive resources available over the internet which deals with the various designs and implementation issues of this technology. Intellectual properties regulations of many corporations are partially to blame for this also. The tendency to keep technical knowhow within a restricted group of researchers. Before embarking ,its important first to cover exactly what embedded systems are . They are considered when the cost of implementing a product designed in software on a microprocessor and small amount of hardware, is cheaper, more reliable or better for some other reason than a discrete hardware design. Such systems are based upon real time response whose correctness depends on the timeless of its response. HISTORY OF EMBEDDED SYSTEMS In the earliest years of computer in 1930-40s computers were sometimes dedicates to a single task, but were far too large and expensive for most kind of tasks performed by embedded computers of today overtime however the concept of programmable controllers evolved from traditional electromechanical sequencers via solid state devices to use of computer technology. One of first recognizably modern embedded systems was the APOLLO guidance computer and developed by Charles stark draper at the MIT instrumentation laboratory. At the project’s interception ,the Apollo guidance computer was considered riskiest item in the Apollo projects as its employed ,then newly developed monolithic integrated circuits to reduce the size n weight and earliest mass production embedded systems was the autonetics D-17 guidance computer for minuteman missiles in 1961,it was built from transistors logic and had a hard disk for the main memory when the minuteman 2nd went to production in 1966, the D-17 was replaced with new computer that was a 1st high volume used for integrated circuits. Since the early applications in 1960, embedded systems have come down in price and there has been dramatic rise in processing power n functionality. The 1st microprocessor e.g. Intel 4004 was designed for calculator and other small systems but still required many external memory and support chips. In 1978 nation engineering manufacturers association released a ‘Standard’ for programmable microcontrollers including almost any computer based controllers such as single board computers ,numerical and event based controllers . First embedded system was APOLLO GUIDANCE COMPUTER. 1. IN 1961, Autonetics D-17 guidance computer used in missile. 2. Microprocessor INTEL 4004 was designed. MICROPROCESSORS. Microprocessor is used as a general purpose processor when large embedded software has to be located in the external memory chips. In general, a microprocessor is a single VLSI chip that has a CPU. CPU executes information stores in memory. Micro processors are being excessively used in the field of instrumentation and central .the students are studding the subjects are supposed to learn the architecture of a typical microprocessor and get general information about it based control system . the course in addition will provide a relevant knowledge of microprocessor based circuits being used in industrial process application. The subject will deal in detail the configuration and instructional pair configuration systems and working of various peripheral interface chips .the course will cover 8051 in detail with sufficient exposure to industrial applications .computer plays a vital role in present life more so, in profession life of diploma engineers should be well conserved with these environments .in order to enable the student use the computer effectively in the problem solving , this course offers the modern programming languages like C, and expositions to various engineering application software’s. MICROCONTROLLERS. • Microcontroller is a single chip VLSI unit having limited capabilities. • No addition of external memory. • Microcontroller is of 8bit, 16bit, 32bit and 64 bits. • General characteristics of embedded systems perform a single as well as multitasking • Increasingly high performance and real time constrained • Power, cost and reliability are important considerations. • HW-SW systems. • Software is used for more features and flexibility. • Hardware (processors, memory etc. are used for performance and security). 1. 8051 MICROCONTROLLER 1.1 Functions Ability to execute set of instructions. To excess external memory chips with read and write operations. To interface with input output devices . 1.2 Components CPU,Memory, RAM ,ROM, internal timers Example:- ADC and DACs, UART for serial communication Internal EEPROM, modes.PWM 1.3 Architecture 2 types are there:- 1.3.1 VON NEUMANN It has only a bus for data transfer and instruction fetches. but both functions can’t be performed at the same time 1.3.2 HAVARD ARCH. Separate data and instructions buses, works simultaneously. 1.4 PIN CONFIGURATION OF MICROCONTROLLER 8051 1.4.1 ALE/PROG:- Address latch enable for latching the lower byte of address with a constant rate of 1/6th of oscillator frequency. This pin is also used for program pulse input during EEPROM programming. 1.4.2 PSEN Program store enable is read strobe to external program memory. when the device is executing out of external program memory, PSEN is activated twice each machine cycle .PSEN is not activated when the device is executing out of internal program memory 1.4.3. EA/VPP When EA is held high the CPU executes out of internal program memory. Holding EA low forces the CPU to execute out of external memory regardless of the program counter value. In the 80C31,EA must be externally wired low .In the EPROM devices ,this pin also receives the programming supply voltage during EPRPOM programming. 1.4.4 RST It is an input and is active high upon applying a high pulse to this pin, The microcontroller will reset and terminate activities also named as power on RST. 1.4.5 PORT 0 Its 8 bit bidirectional port it can sink 8 TTL loads also used for multiplex low order address and data bus to external memory to which pull ups are required 1.4.6 PORT 1 It’s an 8 bit bidirectional I/O port. It will source current due to internal pull-ups. 1.4.7 PORT 2 It emits high order address bite that used 16 bit addresses while emitting it uses strong pull-ups 1.4.8 PORT 3 Performs following functions P3.0 RxD(serial input port). P3.1 TxD(serial output port) P3.2 INT0(external interrupt 0). P3.3 INT1(external interrupt 1). P3.4T0(timer 0 external input). P3.5T1 timer 1 external input). P3.6 WR(external data memory write strobe). P3.7 RD external data memory read strobe). 1.4.9 XTAL1: Input to the inverting oscillator amplifier. 1.4.10 XTAL2: Output from the inverting oscillator amplifier. 1.4.11 VCC: Supply voltage. 1.4.12 VSS: Circuit ground potential. 1.5 Memory Organization. The 8051 has three general types of memory. to effectively program the 8051 it is necessary to have a basic understanding of these memory types. The memory types are illustrated in the following graphic. They are: on chip memory, external code memory and external RAM on chip memory refer to any memory(code, ram or other) that physically exists on the microcontroller itself. External code memory is code memory that resides off-chip. This is often in the form of an external EPROM. this is often in the form of standard static RAM or flash RAM. 1.5.1 Code Memory. code memory is the memory that hold the actual 8051 program that is to be run. This memory is limited to 64k and comes in many types and shapes code memory may be found on chips ,either burned into the microcontroller as ROM or EPROM. Code may also be stored completely off-chip in the external ROM or more commonly, An external EPROM .flash RAM is also another popular method of storing a program. When the program is stored on- chip the 64k maximum is often reduced to 4k,8k or 16k.this varies depending on the version of the chip that is being used . each version offers specific capabilities and one of the distinguishing factor from chip to chip is how much ROM/EPROM the chip has 1.5.2 External RAM . An obvious opposite internal ram. The 8051 also support what is called external ram As the name suggest , external ram is random access memory is found of chip. Since the memory is of chip it is not as flexible in terms of accessing and is also slower. For example ,to increment to an internal ram location by one require only one instructions and one instructions cycle to increment a one bit value stored in external ram required 4 instructions and 7 instructions cycle. In the case .external memory is 7 times slower. 1.5.3 On Chip Memory. As mentioned at the beginning of this chapter, The 8051 includes a certain amount of on-chip memory on-chip memory is really one of two types : Internal RAM and special function register memory. The layout of the 8051’s internal memory is presented in the memory map The80 bytes remaining if the internal memory , from address 30h through 7fh, may used by user variable that need to be accessed frequently or at high-speed. This area is also utilized by the microcontroller as a storage area for the operating stack. This fact severally limits the 8051s stack since these 80 bytes has to be shared between the stack and user variables. 1.5.4 Internal RAM . 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,R6and R7 ). The registers are generally used to assist in manipulating values and moving data from one memory location to another . for example , to add the value of R4 to the Accumulator, we would execute the following instruction : ADD A, R4 Thus if the accumulator (A) contained the value 6 and R4 contained the value 3 , the accumulator would contain the value 9 after this instruction was executed . But watch out ! As the memory map shows , the 8051 has four distinct register banks when the 8051is first booted up , register bank 0 (addresses 00h through 07h ) is used by default however , your program may instruct the 8051 to used by 1 of the alternate banks ; i.e., register banks 1,2 or 3. In this case R4 wall no longer be the same as internal RAM address 04h. 1.5.5 Bit Memory The 8051 , being a communications – oriented micro controller , gives the use ability to access a number of bit variables . These variables may be either one or There are 128 bit variables available to the user , numbered 00h through 7FH. The user may use of these variables with commands such as SETB and CLR . For example , to sit bit number 24 (hex) to one you would execute the instruction SETB 24h It is important to note Bit Memory is really a part of internal RAM . In fact, the 128 bit variables occupy the 16 bytes of internal RAM from 20h through 2Fh 1.6 Special function register A Map of the on chip memory area called the special function register (S F R ) space is shown in figure 1.5 note that the SFRs not all of the addresses are occupied . un occupied addresses are not implemented on the chip . read accesses to these addresses will in general return random data , and write accesses will have no effect . user software should not write is to these unimplemented location , since they may be used in other 80c51 family derivative products to invoke new features. The functions of the SFRs are described: 1.7 Accumulator ACC is the Accumulator register. The mnemonics for accumulator _ specific instructions however, refer to the accumulator simply as A . B Register: the B register is used during multiply and divide operations . for other instructions it can be treated as another scratch pad register. 1.8 Program status word The psw register contains program status information as detailed in table1.1 Program status word: The program status word (PSW) contains several status bits that reflect the current state of CPU . the PSW shown in figure 1.1, reside in the SFR space. It contains the carry bit, and two user definable status flags. The carry bits, other than severing the function of a carry bit in arithmetic operation also serve as the banks. A number of instruction refers to these RAM location as R0 through R7. The selection of which is the four is being referred to is made on the RS0 and RSI at execution time. The parity bit reflect the number of 1s in the accumulator: P=1 if the accumulator contain an odd number of 1s,P-0 if the accumulator contains an even number of 1s. thus the number of 1s in the accumulator pulse is always even. Two bits in the PSW are uncommitted and may be used as general purpose status flag. 1.9 Stack pointer. The stack pointer register is 8bits wide. It is incremented before data is stored during PUSH and call execution. While the stack may reside anywhere in on-chip RAM, the stack pointer is initialized to 07H after a reset. This cause the stack to begin tat location 08H. 1.10 Data pointer. The data pointer onsite of high byte(DPH) and low byte(DPL). Its intended function is hold a 16-bit address. It may be manipulate as a16-bit register or as two indepented 8_bit registers. Ports 0to 3: P0,P1.P2 and P3 are the SFR latches of port 0,1,2 and 3 respectively. Writing a one to a bit of a port SFR (P0,P1,P2 or P3) cause the corresponding port output pin to switch high. Writing a zero cause the port output pin to switch low. When used as a input, the external state of a port pin will be held in the port SFR(I.e. if the external state lof a pin is low, the corresponding port SSFR bit caintine a0:if it is high, the bit will contain a1) 1.11 Serial data Buffer. The serial buffer is actually two separate registers, a transmit buffer and a receive buffer. When the data is moved to SBUF , it goes to the transmit buffer and is held gore derail transmission. 1.12 Timer registers. Register pair (TH0,TL0) and (TH1,TL1) are the 16 bit counting registers for timer/ counter 0 and 1 respectively. 1.13 Control Register. Special function registers IP’IE,TMOD,SCON,PCOn contain control and status bits for the interrupt system, the timer/counter, and the serial port. They describe in later section. 1.14 Machine Cycle. The CPU takes a certain number of clock cycle to execute an instruction. These clock cycles are known as machine cycle. Crystal Frequency- It is the frequency produce by the crystal oscillator connect to microcontroller. Typical values used are 11.0592MHz and 12MHZ. 1 Machine cycle= crystal frequency/12 1.15 RISC/CISC Architecture . Microprocessor use two type of architecture, namely as RISC and CISC. These may be defined as- Complex Instruction Set Computing (CISC)- The microprocessor using CISC architecture have many instruction into it. This saves the processing time for performing task. The time saved because the required instruction are available in the microprocessor itself and it does not have to retrieve the instruction from the program stored in the external memory such as the RAM. However, the instruction built into the microprocessor affects the performance of the microprocessor. This is because more time is taken to process the instruction and also the space available at the microprocessor for processing reduce. To overcome this problem more transistors need to be built into the microprocessor to maintain the speed of microprocessor. Reduced Instruction Set Computing (RISC)- The microprocessor using RISC architecture have limited instruction built into it. This requires few transistor to be built into microprocessor to make up for the time delay in processing this instruction. The reduction in instruction also saves the space in the microprocessor. The RISC microprocessor is cheaper to build than the CISC processor 1.16 Addressing Mode An addressing mode refers to how you are addressing a given memory location. In summary, the addressing mode are as follows, with an example of each: Immediate addressing MOV A,#20h Direct addressing MOV A,30h Indirect Addressing MOV A,@R0 External direct MOVX A,@A+DPTR Code Indirect MOVC A,@A=DPTR 1.17 Instruction Set Depending on operation they perform, all instruction are divided in several group: • Arithmetic Instruction • Branch instruction • Data transfer instruction • Logic instruction • Bit-oriented instruction • INC R1- means: increment register R1 ( increment register R1) • LJMP LAB5- means: long jump LAB5 (long jump to the address marked as LAB5) • JNZ LOOP – means: jump if not zero loop • RET- returns from a subroutine • JZ TEMP – if the number in the accumulator is not 0 jump to the address marks TEMP • ADD A,R3 add R3 and accumulator • CJNE A,#20,LOOP- compare accumulator with 20. If they are not equal, jump to the address marked as LOOP. ARITHMETIC INSTRUCTIONS Mnemonic Description Byte Cycle ADD A ,Rn Adds the register to the accumulator 1 1 ADD A, direct Adds the direct byte to the accumulator 2 2 ADD A, @Ri Adds the indirect Ram to the accumulator 1 2 ADD A, #data Adds the immediate data to the accumulator 2 2 ADDC A, Rn Adds the register to the accumulator with a carry flag 1 1 ADDC A, direct Adds the direct byte to the accumulator with a carry flag 2 2 ADDC A, @Ri Adds the indirect RAM to the accumulator with a carry flag 1 2 ADDC A, #data Adds the immediate data to the accumulator with a carry flag 2 2 SUBB A, Rn Subtracts the registered from the accumulator with a borrow 1 1 SUBB A ,direct Subtracts the direct byte from to the accumulator with a borrow 2 2 SUBB A, @ri Subtracts the indirect RAM from the accumulator with a borrow 1 2 SUBB A, #data Subtracts the immediate data from the accumulator with a borrow 2 2 INC A Increments the accumulator by 1 1 1 INC Rn Increments the register by I 1 2 INC Rx Increments the direct byte by 1 2 3 INC @Ri Increments the indirect RAM by 1 1 3 DEC A Decrements the accumulator by 1 1 1 DEC Rn Decrements the register by 1 1 1 DEC Rx Decrement the direct byte by 1 1 2 DEC @Ri Decrement the indirect RAM by 1 2 3 INC DPTR Increments the data pointer by 1 1 3 MUL AB Multiplies A and B 1 5 DIV AB Divides A by B 1 5 DA A Decimal adjustment of the accumulator according to BCD code 1 1 1.18 Branch Instructions There are two kinds of branch instructions; Unconditional jump instructions; upon their execution a jump to a new location from where the program continues execution is executed . Conditional jump instruction jump to a new program location is executed only if a specified condition is met otherwise , the program normally processed with the next instruction . BRANCH INSTRUCTION Mnemonic Description Byte Cycle ACLL addr 11 Absolute subroutine call 2 6 LCALL addr 16 Long subroutine call 3 6 RET Returns from subroutine 1 4 RETI Returns from interrupt subroutine 1 4 AJMP addr 11 Absolute jump 2 3 LJMP addr16 Long jump 3 4 SJMP rel Short jump (from-128to +127 location relative to following instruction 2 3 JC rel Jump if carry flag is set Short jump 2 3 JNC rel Jump if carry flag is not set short jump 2 3 JB bit , rel Jump if direct bit is set short jump 3 4 JBC bit, rel Jump if direct bit is set and clears bit short jump 3 4 JMP @A+dptr Jump indirect relative to the DPTR 1 2 JZ rel Jump if the accumulator is zero. Shot jump 2 3 JNZ rel Jump if the accumulator is not zero . Short jump 2 3 CJNE A, direct,rel Compares direct byte the accumulator and jumps if not equal . Short jump 3 4 CJNE A, #data,rel Compares immediate data to the accumulator and jump if not equal short jump 3 4 CJN RN ,#data rel Compares immediate data to the register and jump if not equal short jump 3 4 CJNE@RI,#data,rel Compares immediate data to indirect register and jumps if not equal Short jump 3 4 DJNZ Rn,rel Decrements register and jumps if not 0, Short jump 2 3 DJNZ Rx,rel Decrements direct byte and jump if not 0. Short jump 3 4 NOP No operation 1 1 1.19 Data transfer instructions Data transfer instructions move the contents of one register to another. The register the content of which is moved remains unchanged. If they have suffix x (MOVX),the data is exchanged with external memory Mnemonic Description byte Cycle MOV A,Rn Moves the reg. To accumulator 1 1 MOV A,direct Moves direct byte to accumulator 2 2 MOV A,@Ri Moves indirect RAM to accumulator 1 2 MOV A,#data Moves immediate data to accumulator 2 2 MOV Rn, A Moves accumulator to the register 1 2 MOV Rn, direct Moves direct byte to the register 2 4 MOV Rn, #data Moves immediate data to register 2 2 MOV direct, A Moves accumulator to direct byte 2 3 MOV direct,Rn Moves register to direct byte 2 3 MOV direct,direct Moves direct byte to direct byte. 3 4 MOV direct,@Ri Moves indirect RAM to direct byte 2 4 MOV direct,#data Moves immediate data to direct byte 3 3 MOV @Ri,A Moves accumulator to indirect RAM 1 3 MOV @Ri,direct Moves direct byte to indirect RAM 2 5 MOV @Ri,#data Moves immediate data to indirect RAM 2 3 MOV DPTR,#data Moves 16 bits data to data pointer 3 3 MOVC A,@A+DPTR Moves code byte relative to the DPTR to accumulator 1 3 MOVC A,@A+PC Moves code byte relative to the PC to the accumulator 1 3 MOVX A,@Ri Moves the external RAM to the accumulator (8 bit address) 1 3-10 MOVX A,@DPTR Moves the external RAM to the accumulator (16 bit address) 1 3-10 MOVX,@Ri, A Moves accumulator to the external RAM (8 BIT) 1 4-11 MOVX @DPTR,A Moves accumulator to the external RAM (16 BIT) 1 4-11 PUSH direct Push direct byte onto stack 2 4 POP direct Pops direct byte from the stack 2 3 XCH A,Rn Exchanges the register with the accumulator. 1 2 XCH A,direct Exchanges the direct byte with the accumulator. 2 3 XCH A,@ Ri Exchanges the indirect RAM with the accumulator 1 3 XCHD A,@Ri Exchanges the low order nibble indirect RAM with the accumulator 1 3 1.20 Logic instructions Logic instruction perform logic operations upon corresponding bits of two register . LOGIC INSTRUCTION Mnemonic Description Byte Cycle ANL AND register to accumulator 1 1 ANL AND direct byte to accumulator 2 2 ANL AND indirect RAM to accumulator 1 2 ANL AND immediate data to accumulator 2 2 ANL AND accumulator to direct byte 2 3 ANL AND immediate data to direct register 3 4 ORL OR register to accumulator 1 1 ORL OR direct byte to accumulator 2 2 ORL OR indirect RAM to accumulator 1 2 ORL OR accumulator to direct byte 2 3 ORL OR immediate data to direct byte 3 4 XRL Exclusive OR register to accumulator 1 1 XRL Exclusive OR direct byte to accumulator 2 2 XRL Exclusive OR indirect RAM to accumulator 1 2 XRL Exclusive OR immediate data accumulator 2 2 XRL Exclusive Or accumulator to direct byte 2 3 XORL direct, data Exclusive OR immediate data to direct byte 3 4 CLR A Clear to accumulator 1 1 CPL A Complements the accumulator (1=0-0=1) 1 1 SWAP A Swap nibbles with in the accumulator 1 1 RLC A Rotate bits in the accumulator left 1 1 RLC A Rotate bits in the accumulator left through carry 1 1 RR A Rotate bits in the accumulator right 1 1 RRC A Rotate bits in the accumulator right through carry 1 1 1.21 TIMER/COUNTERS The MCS-51 has two 16 bit timer/ Counter register. Timer 0 and timer 1. Both can be configured to operate either as timer or event counter. In the timer function the register is increment every machine cycle. Timer/ Counters Mode Control (TMOD) register TIMER 1 TIMER 2 GATE C/T M1 M0 GATE C/T M1 M0 GATE: Gating control when set. Timer/counter X is enabled only while INTx pin is high and TRx control pin is set C/T: Timer or counter selector cleared for timer operation and set for counter operation M1 M0 Operating 0 0 8048 timer, Tlx serves as 5 bit presales 0 1 16 bit timer/ counter THx and TLx are cascaded, there is no presales 1 0 8 bit auto reload timer/counter THx hold a value which is tube reloaded into Tlx each time it overflows 1 1 (Timer 0) TL0 is an 8 bit timer/ counter controlled by standard timer 0 control bitstimer 1) timer/ counter 1 stopped Timer/counter control(TCON) Register MSB LSB TF1 TR1 TF0 TF1 TR1 TF0 TF1 TR1 BIT SYMBOL Function TCON.7 TF1 Timer 1 overflow flag. Set by hardware on timer/ counter overflow. Cleared by hard ware when processor vector to interrupt or clearing the bit in software. TCON.6 TR1 Timer 1 run control bit. Set /cleared by software to turn timer/counter on/off TCON.5 TF0 Timer 0 overflow flag. Set by hardware on timer/counter overflow. Cleared by hardware when processor vector to interrupt routine, or clearing the bit in software TCON.4 TR0 Timer 1 run control bit, set/ cleared by software to turn timer/ counter on/off TCON.3 IE1 Interrupt 1 edge flag. Set/cleared by hardware when external interrupt edge detected. Cleared when interrupt processed TCON.2 IT1 Interrupt 1 type control bit. Set/ cleared by software to specify falling edge/ low level triggered external interrupt TCON.1 IE0 Interrupt 0 edge flag. Set by hardware when external interrupt edge detected. Cleared when interrupt processed TCON.0 IT0 Interrupt 0 type control bit. Set/ cleared by software to specify falling edge/low level triggered external interrupts. 1.22 SERIAL COMMUNICATION One of the 8051s many powerful features is its integrated UART, otherwise known as a serial port. The fact that the 8051 has an integrated serial port means that you may very easily read and with value to the serial port. If it were not for the integrated serial port, writing a byte to a byte toe a serial line would be rather tedious process requiring turning on and off one of the I/O line in rapid succession to properly clock out each individual bit , including start bits, stop bits and parity bits. However , we do not have to do this . instead , we simply need to configure the serial port or read the same SFR to read a value from the serial port. The 8051 will automatically let us know when it has finished sending the character we wrote and will also let us know whenever it has received a byte so that we can process it . we do not have to worry about transmission at level—which saves us quite a bit of coding and processing time. Setting the serial port Mode. The first thing we must do when using the 8051s integrated serial port is , obviously, configure it. This let us tell the 8051 how many data bits we want the baud rate we will be using, and how the baud rate will be determine. Setting the Baud Rate. The baud rate in 8051 is programmable and it is done with the help of timer 1. There are many baud rate used in 8051 like 1200,2400,4800,9600 etc. this set by planning the value in TH1 Bit Name Bit Address Explanation of function 7 SM0 9FH Serial port mode bit 0 6 SM1 9EH Serial port mode bit 1 5 SM2 9DH Multiprocessor communication enable 4 REN 9CH Receiver enable this bit must be set in order to receive character. 3 TB8 9BH Transmit bit 8. The 9th bit to transmit in mode 2 and 3 2 RB8 9AH Receive bit 8 . the 9th bit received in mode 2 and 3 1 T1 99H Transmit flag. Set when a byte has been completely transmitted. 0 R1 98H Receive flag. Set when a byte has been completely Additionally,it is necessary to define the function of SM0 and SM1 by an additional table. SM0 SM1 Serial mode explanation Baud rate 0 0 0 8-bit shift register Oscillator/12 0 1 1 8-bit UART Set by timer 1(*) 1 0 2 9-bit UART Oscillator/32(*) 1 1 3 9-bit UART Set by timer1(*) The baud rate indicated in this table is doubled if PCON.7(SMOD) is set. Following are the steps used to serially transmit a byte to serial port- 1) Program timer one (TI) for mode 2(TMOD=20h) 2) Load TH1 with some value to set baud rate. 3) Program SCON for mode 1(SCON=50h). 4) Start timer one (T1) 5) Clear T1 6) Load SBUF with the byte to be transmitted. 7) Moniter the T1 flag bit until it becomes one using it becomes one using instruction “JNB T1,XX”. 8) go back to step 5 for next byte. 1.23 INTERRUPTS 1.23.1 Types of interrupts 1) Level triggered- In this mode, when a low level signal is applied to INT0 and INT1 then the microcontroller triggers the interrupt. after that controller stops whatever it is doing and jumps to interrupt vector table to service the interrupt 2) Edge triggered-Upon reset INT0 and INT1 are lower level triggered. for making them edge triggered IT0 and IT1 bits of TCON register are programmed .when these bits are made high then interrupts become edge triggered The 80C51 provides 5 interrupt sources. these are shown in the table .the external interruptsINT0 and INT1can each be either level activated, depending on bits IT0 and IT1 can each be either level activated or transition activated or depending on bits IT0 and IT1 in register TCON .the flags that actually generate these interrupts are bits IE0 and IE1 in TCON .when an external interrupt is generate, the flag that generated it is cleared by the hardware. Interrupt Interrupt flag Interrupt flag address External 0 IE0 000 3h Timer0 TF0 000 Bh External 1 IE1 001 3h Timer1 TF1 001 Bh Serial R1/T1 002 3h The timer 0 and timer 1interrupts are generated by TF0 and TF1 which are set-up by a rollover in their respective timer /counter register. when a timer interrupt is generated the flag that generated it is cleared by the on chip hardware when the service routine is vectored to . the serial port interrupt is generated by the logical OR of RI and TI. 1.23.2 Interrupt Enable Register To enable an interrupt ,IE registers must be programmed. following tables show the bits of IE registered and their functions Bit Symbol Function IE.7 EA Disables all interrupt. if EA =0,no interrupt will be acknowledge. if EA=1,each interrupt sources is individually enabled and disabled by setting or clearing its enable bit IE.6 - Reserved IE.5 - Reserved IE.4 ES Enabled or disabled the serial port interrupt if EA=0,the serial port interrupt is disabled IE.3 ET1 Enabled or disabled the timer 1 over flow interrupt. if ET1 =0,the timer 1 interrupt is disabled IE.2 EX1 Enabled or disabled external interrupt 1.if EX=0 external interrupt is disable IE.1 ET0 Enabled or disabled the timer 0 or flow interrupt if ET=0 the timer 0 interrupt is disabled IE.0 EX0 Enabled or disabled external interrupt 0.if EX=0 external interrupt is disable All of the bits that generate interrupts can be set or cleared by software, with the same result as though it had been set or cleared by hardware. that is interrupt can be generated or pending interrupts can be canceled in software. each of these sources can be individual enable or disabled by setting or clearing a bit in special function register IE.IE also contains a global bit, EA which disables all interrupt at once Steps in executing an interrupt- 1) The microcontroller finishes the current instruction it is executing & saves the address of next instruction on the stack 2) It also saves the current status of all interrupts internally 3) It jumps to a fixed location in the memory at address given in the interrupt vector table 4) Upon executing RETI instruction, the microcontroller returns to the place where it was interrupted. Interfacings. +5V power supply. Interfacing switch to microcontroller 8051. Fig. show interfacing to port 0 or any pin to be used as a input pin is kept as HIGH. Otherwise it will be read as LOW by default .when the switch is not pressed the 10k register provides current needed for logic one. Closer of switch provides logic 0 to the controller PIN 1.24 Interfacing LED to microcontroller In fig. anode is connected to a register to Vcc and cathode is connected to controller pin so when this pin is high, LED is OFF and when pin in LOW ,LED is ON . Interfacing 7-seg display to microcontroller :- These are basically 7 LED’s. 2 types are there :- Common anode where all segment share the same anode Common cathode where all segment share the same cathode . In common anode in order to turn ON ,segment corresponding pin must be set to 0 and 1 to OFF. 1.25 Interfacing ADC 0808 to 8051 In lot of embedded systems controller needs to take analog input .most of sensors and transducers such as temperature, humidity, pressure are analog. For interfacing these sensors to microcontroller we require to convert the analog output of these sensors to digital so that the controller can read it. Some microcontroller have built in analog to digital converter so there is no need of external ADC. For microcontroller that don’t have internal ADC external ADC is used. 2. AVR MICROCONTROLLER Does this mean that the microcontroller is another name for a computer…? The answer is NO! The computer on one hand is designed to perform all the general purpose tasks on a single machine like you can use a computer to run a software to perform calculations or you can use a computer to store some multimedia file or to access internet through the browser, whereas the microcontrollers are meant to perform only the specific tasks, for e.g., switching the AC off automatically when room temperature drops to a certain defined limit and again turning it ON when temperature rises above the defined limit. There are number of popular families of microcontrollers which are used in different applications as per their capability and feasibility to perform the desired task, most common of these are 8051, AVR and PIC microcontrollers. 2.1 History of AVR AVR was developed in the year 1996 by Atmel Corporation. The architecture of AVR was developed by Alf-Egil Bogen and Vegard Wollan. AVR derives its name from its developers and stands for Alf-Egil Bogen Vegard Wollan RISC microcontroller, also known as Advanced Virtual RISC. The AT90S8515 was the first microcontroller which was based on AVR architecture however the first microcontroller to hit the commercial market was AT90S1200 in the year 1997. AVR microcontrollers are available in three categories: 1. Tiny AVR – Less memory, small size, suitable only for simpler applications 2. Mega AVR – These are the most popular ones having good amount of memory (upto 256 KB), higher number of inbuilt peripherals and suitable for moderate to complex applications. 3. Xmega AVR – Used commercially for complex applications, which require large program memory and high speed. The following table compares the above mentioned AVR series of microcontrollers: Series Name Pins Flash Memory Special Feature TinyAVR 6-32 0.5-8 KB Small in size MegaAVR 28-100 4-256KB Extended peripherals XmegaAVR 44-100 16-384KB DMA , Event System included 2.2 Importance Of AVR They are fast: AVR microcontroller executes most of the instructions in single execution cycle. AVRs are about 4 times faster than PICs, they consume less power and can be operated in different power saving modes. Let’s do the comparison between the three most commonly used families of microcontrollers. 8051 PIC AVR SPEED Slow Moderate Fast MEMORY Small Large Large ARCHITECTURE CISC RISC RISC ADC Not Present Inbuilt Inbuilt Timers Inbuilt Inbuilt Inbuilt PWM Channels Not Present Inbuilt Inbuilt AVR is an 8-bit microcontroller belonging to the family of Reduced Instruction Set Computer (RISC). In RISC architecture the instruction set of the computer are not only fewer in number but also simpler and faster in operation. The other type of categorization is CISC (Complex Instruction Set Computers). 2.3 The Performance Equation The CISC approach attempts to minimize the number of instructions per program, sacrificing the number of cycles per instruction. RISC does the opposite, reducing the cycles per instruction at the cost of the number of instructions per program. 2.4 Architecture of AVR The AVR microcontrollers are based on the advanced RISC architecture and consist of 32 x 8-bit general purpose working registers. Within one single clock cycle, AVR can take inputs from two general purpose registers and put them to ALU for carrying out the requested operation, and transfer back the result to an arbitrary register. The ALU can perform arithmetic as well as logical operations over the inputs from the register or between the register and a constant. Single register operations like taking a complement can also be executed in ALU. We can see that AVR does not have any register like accumulator as in 8051 family of microcontrollers; the operations can be performed between any of the registers and can be stored in either of them. AVR follows Harvard Architecture format in which the processor is equipped with separate memories and buses for Program and the Data information. Here while an instruction is being executed, the next instruction is pre-fetched from the program memory. Since AVR can perform single cycle execution, it means that AVR can execute 1 million instructions per second if cycle frequency is 1MHz. The higher is the operating frequency of the controller, the higher will be its processing speed. We need to optimize the power consumption with processing speed and hence need to select the operating frequency accordingly. There are two flavors for Atmega8515 microcontroller: 1. Atmega8515:- Operating frequency range is 0 – 16 MHz and operating voltage range is 4.5V to 5.5V 2. Atmega8515L:- Operating frequency range is 0 – 8 MHz and operating voltage range is 2.7V to 5.5V If we are using a crystal of 8 MHz = 8 x 106 Hertz = 8 Million cycles, then AVR can execute 8 million instructions. 2.5 Naming Convention.! The AT refers to Atmel the manufacturer, Mega means that the microcontroller belong to Mega AVR category,8 signifies the memory of the controller, which is 16KB. As you have seen in the article for interfacing switching to microcontroller normally the port pin is high but when a switch is pressed the controller pin gets a low signal and we come to know that a switch has been pressed. One end of switch is connected to the port pin whereas other end is connected to the ground. In case of matrix key pad both the end of switches are connected to port pin over here we have considered a 4x3 matrix keypad that is 4 rows and 3 columns. So in all 12 switches, have been interfaced using just seven lines. • 2.6 The pin diagram of Atmega8 microcontroller Pin Diagram - Atmega8 2.6.1 Memory. It has 8 Kb of Flash program memory (10,000 Write/Erase cycles durability), 512 Bytes of EEPROM (100,000 Write/Erase Cycles). 1Kbyte Internal SRAM 2.6.2 I/O Ports . 23 / line can be obtained from three ports; namely Port B, Port C and Port D. 2.6.3 Interrupts. Two External Interrupt source, located at port D. 19 different interrupt vectors supporting 19 events generated by internal peripherals. 2.6.4 Timer/Counter Three Internal Timers are available, two 8 bit, one 16 bit, offering various operating modes and supporting internal or external clocking. 2.6.5 SPI (Serial Peripheral interface) ATmega8 holds three communication devices integrated. One of them is Serial Peripheral Interface. Four pins are assigned to Atmega8 to implement this scheme of communication. 2.6.6 USART One of the most powerful communication solutions is USART and ATmega8 supports both synchronous and asynchronous data transfer schemes. It has three pins assigned for that. In many projects, this module is extensively used for PC-Micro controller communication. 2.6.7 TWI (Two Wire Interface) Another communication device that is present in ATmega8 is Two Wire Interface. It allows designers to set up a commutation between two devices using just two wires along with a common ground connection, As the TWI output is made by means of open collector outputs, thus external pull up resistors are required to make the circuit. 2.6.8 Analog Comparator A comparator module is integrated in the IC that provides comparison facility between two voltages connected to the two inputs of the Analog comparator via External pins attached to the micro controller. 2.6.9 Analog to Digital Converter Inbuilt analog to digital converter can convert an analog input signal into digital data of 10bit resolution. For most of the low end application, this much resolution is enough. The “internal architecture block diagram” of Atmega8 2.7 HARDWARE:Interfacing done with microcontrollers 2.7.1 RESET AND OSCILLATORY CIRCUITRY: 2.7.2 LED INTERFACING TO 8051 MICROCONTROLLER: 2.7.3 RELAY SWITCH INTERFACING TO MICROCONTROLLER 8051: 2.7.4 INTERFACING MAX232 TO 8051 MICROCONTROLLER FOR SERIAL COMMUNICATION: 2.7.5 INTERFACING LCD TO 8051 MICROCONTROLLER: 2.7.6 INTERFACING STEPPER MOTOR TO 8051 MICROCONTROLLER: 2.7.7 INTERFACING ADC TO 8051 MICROCNTROLLER: 2.7.8 INTERFACING KEYPAD TO 8051 MICROCONTROLLER: 3. PRINTED CIRCUIT BOARD. A printed circuit board (PCB) mechanically supports and electrically connects electronic components using conductive tracks, pads and other features etched from copper sheets laminated onto a non-conductive substrate. PCBs can be single sided (one copper layer), double sided (two copper layers) or multi-layer. Conductors on different layers are connected with plated-through holes called vias. Advanced PCBs may contain components - capacitors, resistors or active devices - embedded in the substrate. Printed circuit boards are used in all but the simplest electronic products. Alternatives to PCBs include wire wrap and point-to-point construction. PCBs require the additional design effort to lay out the circuit but manufacturing and assembly can be automated. Manufacturing circuits with PCBs is cheaper and faster than with other wiring methods as component are mounted and wired with one single part. Furthermore, operator wiring errors are eliminated. When the board has only copper connections and no embedded components it is more correctly called a printed wiring board (PWB) or etched wiring board. Although more accurate, the term printed wiring board has fallen into disuse. A PCB populated with electronic components is called a printed circuit assembly (PCA), printed circuit board assembly or PCB assembly (PCBA). The IPC preferred term for assembled boards is circuit card assembly (CCA),[1] for assembled backplanes it is backplane assemblies. The term PCB is used informally both for bare and assembled boards. A printed circuit board (PCB) mechanically supports and electrically connects electronic components using conductive tracks, pads and other features etched from copper sheets laminated onto a non-conductive substrate. PCBs Conductors on different layers are connected with plated-through holes called vias. Advanced PCBs may contain components - capacitors, resistors or active devices - embedded in the substrate. 3.1 Methods To Manufacture PCB. Printed circuit boards are used in all but the simplest electronic products. Alternatives to PCBs Subtractive, additive and semi-additive processes . The two processing methods used to produce a double-sided PWB with plated through holes. Subtractive methods remove copper from an entirely copper-coated board to leave only the desired copper pattern: 1. Silk screen printing uses etch-resistant inks to protect the copper foil. Subsequent etching removes the unwanted copper. Alternatively, the ink may be conductive, printed on a blank (non-conductive) board. The latter technique is also used in the manufacture of hybrid circuits. 2. Photoengraving uses a photo mask and developer to selectively remove a photo resist coating. The remaining photo resist protects the copper foil. Subsequent etching removes the unwanted copper. 3. PCB milling uses a two or three-axis mechanical milling system to mill away the copper foil from the substrate. A PCB milling machine (referred to as a 'PCB Prototype') operates in a similar way to a plotter, receiving commands from the host software that control the position of the milling head in the x, y, and (if relevant) z axis. Data to drive the Prototype is extracted from files generated in PCB design software and stored in HPGL orGerber file format. In additive methods the pattern is electroplated onto a bare substrate using a complex process. The advantage of the additive method is that less material is needed and less waste is produced. In the full additive process the bare laminate is covered with a photosensitive film which is imaged (exposed to light though a mask and then developed which removes the unexposed film). The exposed areas are sensitized in a chemical bath, usually containing palladium and similar to that used for through hole plating which makes the exposed area capable of bonding metal ions. The laminate is then plated with copper in the sensitized areas. When the mask is stripped, the PCB is finished. Semi-additive is the most common process: The unpatented board has a thin layer of copper already on it. A reverse mask is then applied. (Unlike a subtractive process mask, this mask exposes those parts of the substrate that will eventually become the traces.) Additional copper is then plated onto the board in the unmasked areas; copper may be plated to any desired weight. Tin-lead or other surface plantings are then applied. The mask is stripped away and a brief etching step removes the now-exposed bare original copper laminate from the board, isolating the individual traces. Some single-sided boards which have plated-through holes are made in this way. General Electric made consumer radio sets in the late 1960s using additive boards. The (semi-)additive process is commonly used for multi-layer boards as it facilitates the plating-through of the holes to produce conductive vias in the circuit board. include wire wrap and point-to-point construction. PCBs require the additional design effort to lay out the circuit but manufacturing and assembly can be automated. Manufacturing circuits with PCBs is cheaper and faster than with other wiring methods as component are mounted and wired with one single part. Furthermore, operator wiring errors are eliminated. When the board has only copper connections and no embedded components it is more correctly called a printed wiring board (PWB) or etched wiring board. Although more accurate, the term printed wiring board has fallen into disuse. A PCB populated with electronic components is called a printed circuit assembly (PCA), printed circuit board assembly or PCB assembly (PCBA). The IPC preferred term for assembled boards is circuit card assembly (CCA),[1] for assembled backplanes it is backplane assemblies. The term PCB is used informally both for bare and assembled boards. The two processing methods used to produce a double-sided PWB with plated through holes. Subtractive methods remove copper from an entirely copper-coated board to leave only the desired copper pattern: . 3.2 Steps to run ORCAD software:- 1 Open up the OrCAD software. Every OrCAD product available on the market from Cadence comes with the OrCAD Capture feature, so any current version of OrCAD PCB or version of OrCAD EE will have Capture. 2.Click "File" and open up a new design. 3.Highlight the "Place" menu and select "Part." Select the part's library and select the part. You may also start typing in the part's name. 4.Select a location to place the part in the schematic page. Be sure you have all other design elements accounted for before you place the part. 5.Right-click on the part to edit the details. Make sure you select the part first. 6.Choose "Place wire" under the "Place" menu to place wires on your circuit and connect multiple electrical components. 7.Find intersections of overlapping wires and create junctions. To do this, simply click on the intersection. 3.3 Traces Make your ground and power traces thicker than your signal traces. Not only will the thicker traces carry more current, but the size difference makes it instantly recognizable as to which traces are for power and which are for signals. That reduces the likelihood of mistakenly hooking a power trace to a signal pin or a signal trace to a power capacitor. 3.4 Pad . A portion of exposed metal on the surface of a board to which a component is soldered. PTH pads on the left, SMD pads on the right. 3.5 Panel . A larger circuit board composed of many smaller boards which will be broken apart before use. Automated circuit board handling equipment frequently has trouble with smaller boards, and by aggregating several boards