0% found this document useful (0 votes)
13 views205 pages

Embedded System

The document provides an overview of the 8051 microcontroller, detailing its architecture, features, and instruction set. It distinguishes between microcontrollers and microprocessors, highlighting the integrated components of microcontrollers like RAM, ROM, and I/O ports. Additionally, it explains various addressing modes and arithmetic and logical instructions specific to the 8051 microcontroller.

Uploaded by

sophimanoharan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
13 views205 pages

Embedded System

The document provides an overview of the 8051 microcontroller, detailing its architecture, features, and instruction set. It distinguishes between microcontrollers and microprocessors, highlighting the integrated components of microcontrollers like RAM, ROM, and I/O ports. Additionally, it explains various addressing modes and arithmetic and logical instructions specific to the 8051 microcontroller.

Uploaded by

sophimanoharan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 205
Anna University ECE - Reg 2021 Saad Click on clouds to navigate other departments a= <> http://www.poriya www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 UNIT-I 8051 MICROCONTROLLER Microcontrollers for an Embedded System — 8051 — Architecture — Addressing Modes — Instruction Set — Program and Data Memory ~ Stacks ~ Interrupts— Timers/Counters — Serial Ports Programming. licrocontrollers for Embedded syste VA Microcontroller is a single chip computer. ¥ ACPU with all the peripherals like RAM, ROM, /O Ports, Timers, and ADCs etc. on the same chip. For Ex: Motorola 681 1, Intel 8051, Zilog Z8 and PIC 16X ete. Microprocessor: ¥ ACPUbuilt into a single VLSI chip V Itisa generakpurpose device and additional external circuitry is added to make ita microcomputer. V The microprocessor contains arithmetic logic unit (ALU), Control unit, Instruction register, Program counter (PC), clock circuit (internal or external), reset circuit (internal or external) and registers. called a microprocessor. ¥ But the microprocessor has no on chip /O Ports, Timers, Memory etc. S For example, Intel 8085 is an 8-bit microprocessor and Intel 8086/8088 a 16-bit microprocessor. Y The block diagram of the Microprocessor is shown in Fig.1 Arithmetic and Logic Unit (ALU) Accumulator Working Registers [Program Counier Stack Pointer GP) eo Clock Circuit Fig.1: Block diagram of a Microprocessor. i htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unita MICROCONTROLLER : YA microcontroller is an integrated single chip, which consists of CPU, RAM, EPROM/PROM/ROM, VO ports, timers, interrupt contoller. ¥ Forexampk, Intel $051 is 8-bit microcontroller and Intel $096 is 16-bit microcontroller. Y The block diagram of Microcontroller is shown in Fig.2. ce Ca ol Pay Teo! a Fig.2.Block Diagram of a Microcontroller Distinguish between Microprocessor and Microcontroller S.No Microprocessor Microcontroller T | A microprocessor is a general ‘A microcontroller is a dedicated chip which purpose de vice. is abo called as single chip computer. 2 | Anmicroprocessor does notcontain [A microcontroller includes RAM, ROM, on chip 1/0 Ports, Timers, serial and parallel interface, timers, Memories etc. interrupt circuitr} ingle c 3 _| Microprocessor is used as the CPU | Microcontroller is used to performcontroF in microcomputer system. oriented applications. 4 | Microprocessor instructions are | Microcontroller instructions are both bit nibble or byte addressable addressable as well as byte addressable. 3 | Microprocessor based system | Microcontroller based system design is design is complex and expensive _| simple and cost effective 6 |The Instruction st of | The instruction scts are simple with loss microprocessor is complex with | number of instructions. large number of instructions. AEE A EIR EERE ER EERE EEE ARE PEELED EEE ER EERE RE htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 4.2: _ INTEL 8051 MICRCONTROLLER: Draw the architectural block diagram of 8051 microcontroller and explain. (NOV 2011, MAY 2010, NOV 2009, NOV2008, May 2008, MAY 2007, MAY 2006, NOV 2016, May 2016) Features of 8051 Microcontroller: ‘The 8051 isan 8-bit Controller: The CPU can works ononly 8 bits of data at atime Y The 8051 has + 128bytes of RAM AK bytes of on-chip ROM ‘Two timers One serial port Four /O ports, each 8 bits wide + 6 interrupt sources ARCHITECTURE & BLOCK DIAGRAM OF 8051 MICROCONTROLLER: It has hardware architecture with RISC (Reduced Instruction Set Computer) concept. ‘The block diagram of 8051 microcontroller is shown in Fig 3. 8051 has 8-bit ALU. ALU can perform all the 8-bit arithmetic and logical operations in one machine cycke. ‘The ALU is associated with two registers A & B Aand B Registers: The A and B registers are special function registers. SNNN 8 A & B registers hold the results of many arithmetic and logical operations of 8051. The A register is also called the Accumulator. A register is used as a general register to accumulate the results ofa large number of instructions SNLSN By default, it is used for all mathematical operations and data transfer operations between CPU and external memory. Y The B register is mainly used for multiplication and division operations along with A register. * Be MULAB : DIVAB, Y It has no other function other than as a store data. R registers: V CR" registers are a set of ei it registers that are named RO. RI, ete. up to R7. Y These registers are used as auxiliary registers in many operations. v The registers are also used to temporarily store values, htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 External Ipterrupts ak On chip : Interrupt ETC | Counter inputs control —_ 128 Bytes Timer) le } RAM Timer 0 }+—— in Bus Control 4 W/O ports Serial Port ce oe ‘i PSEN ALE Po P2 PI P3 TaD BAD Fig3. Block Diagram of 8051 Microcontroller Program Counter (PO) ¥ 8051 has a 16-bit program counter. The program counter holds address of the next instruction to be executed. ¥ After execution of one instruction, the program counter is incremented. Data Pointer Register (DPTR): Vitis 16-bitregister which is the only user-accessble. Y DPTR is used to point the data. 8051 will access external memory at the address indicated by DPTR. Y DPTR canalso be used as two 8-registers DPH and DPL. Stack Pointer Register (SP) = Y tis an$-bit register which stores the address of the stack top. ~ When a value is pushed onto the stack, the 8051 first increments the value of SP and then stores the value. ‘Similarly when a value is popped off the stack, the 8051 returns the value from the memory location indicated by SP and then decrements the value of SP. Since the SP is only 8-bit wide. It is incremented or decremented by two. SP is modified directly by the 8051 by six instructions: PUSH, POP, ACALL, LCALL, RET, and RETI. It is ako used intrinsically whenever an interrupt és triggered. s SAN N htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 Block Diagram Fig 3a: Internal architecture diagram of 8051 Microcontroller a B RO we] | nm [om] 95] RZ Pc PC (Program counter) Fig: Structure of registers 5 htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in v v v £73491 EMBEDDED SYSTEM ANDIOT DESIGN Program Status Register (PSW): Give PSW of 8051 and describe the use of each bit in PSW. (NOV 2015) Unit-2 ‘The 8051 has an 8-bit PSW register which is also known as Fhg register. In the 8-bit register only 6-bits are used by 8051. The two unused bits are user definable bits. In the 6-bits, four of them are conditional flags. They are Carry CY, Auxiliary Carry-AC, Parity-P, and Overflow-OV. These flag bits indicate some conditions of result after an instruction was executed. D7 Do ac] ro fast wsefow — |r ‘The bits PSW3 and PSW4 are denoted as RSO and RSI. ‘These bits are used to select the bank registers of the RAM location, ‘The meaning of various bits of PSW register is shown below. cy Psw7 Cary Flag AC PSW6 Auxiliary Carry Flag FO PSWS Flag 0 available for general purpose RSI Psw4 Register Bank select bit 1 RSO PSW3 Register bank select bit 0 ov Psw2 Overflow flag, _ PSW.i User definable flag P Pswo Parity flag set/cleared by hardware. Y The selection of the register Banks and their addresses are given below. RSI RSO Register Bank ‘Address o o 0 (00H-07H 0 T T O8H-OFH 1 0 2 10H-17H T T 3 1S IFA htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 RAM & ROM: ‘The 8051 microcontroller has 128 bytes of Internal RAM and 4KB ofon chip ROM. Code memory holds program that is to be executed. Program Address Register holds address of the ROM/Flash memory. Y Data Address Register hols address of the RAM. 1/0 ports: v Y The RAM is also known as Data memory and the ROM is knownas program (Code) memory. v v Y The 8051 microcontroller has 4 parallel 1/O ports, each of 8-bits. Y So, it provides 32 1/0 lines for connecting the microcontroller to the peripherals. V The four ports are PO (Port 0), PI (Port! ), P2 (Port 2) and P3 (Port3). ADDRESSING MODES OF 8051 : Explain different types addressing modes of 8051 microcontroller. (NOV 2008, NOV 2015, April 2017) Y The way in which the data operands are specified is known as the addressing modes. There are various methods of denoting the data operands in the instruction. Y The 8051 microcontroller supports 5 addressing modes. They are 1. Immediate addressing mode 2. Direct Addressing mode 3. Register addressing mode 4, Register indirect addressing mode 5. Indexed addressing mode Immediate addressing mode: The addressing mode in which the data operand is a constant and it is a pam of the instruction itself is known as Immediate addressing mode. Y Normally the data mustbe preceded by a # sign, Y This addressing mode can be used to transfer the data into any of the registers including DPTR. Examples: + MOVA,#27H : The data (constant) 27 is moved to the accumulator register + ADDRI, #45 H : Add the constant 45 to the contents of the accumulator * MOV DPTR, #8245H — : Move the data 8245 into the data pointer register. 7 htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in T3491 EMBEDDED SYSTEM ANDIOTDESIGN Unit-a Direct addressing mode: Inthe addressing mode, the data operand is in the RAM location (00 -7FH) and the address of the data operand is given in the instruction Y The direct addressing mode uses the lower 128 bytes of Internal RAM and the SFRs Examples: * MOVRI, 42H : Move the contents of RAM location 42 into R1 register * MOV 49H, A. : Move the contents of the accumulator into the RAM location 49. * ADDA,S6H : Add the contents of the RAM location 56 to the accumulator Register addressing mode: Y In the addressing mode, the data operands are available in the registers. Examples: * MOV ARO : Move the contents of the register RO to the accumulator * MOV PI,R2 ‘Move the contents of the R2 register into port | + MOVRS, R2 : This is invalid. The data transfer between the registers is not allowed. Register Indirect addressing mode: Y Inthe addressing mode, a register is used as a pointer to the data memory block. Examples: + MOV A,@ RO Move the contents of RAM location whose address is in RO into A (accumulator) * MOV @ RI, B: Move the contents of B into RAM location whose address is held by RI + When RO aud RI are used as pointers, they must be preceded by @ sign Y Advantage: It makes accessing the data more dynamic than static as in the case of direct addressing mode. Indexed addressing mode: Y This addressing mode is used in accessing the data elements of lookup table entries, located in program ROM. Example: MOVC A, @ A+DPTR "The 16-bit register DPTR and register A are used to form the address of the data element stored in on- chip ROM. INSTRUCTIONS SET OF 8051: Discuss in detail the 8051 instruction set. (NOV 2008) Arithmetic instructions: htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 With example, explain arithmetic instructions in 8051 microcontroller. (NOV 2012) v ADD + &bitaddition between the accumulator (A) and a second operand. + The result is always in the accumulator. + The CY flagi set/reset appropriately. y ADDC + 8-bit addition between the accumulator, a second operand and the previous value of the CY fag. + Useful for 16-bit addition in two steps. + The CY flag is set/reset appropriately. v DAA + Decimaladjust the accumulator. + Format the accumulator into a proper 2 digit packed BCD number. + Operates only on the accumulator. + Works only afier the ADD instruction. v SUBB + Subtract with Borrow. + Subtract an operand and the previous value of a borrow (carry) flag from the accumulator. + AGA- - CY. + The result is always saved in the accumulator. + The CY flag is set/reset appropriately. + Increment the operand by one. + The operand can be a register, a direct address, an indirect address, the data pointer. v DEC + Decrement the operand by one. + The operand can bea register, a direct address, an indirect address. ¥ MULAB/DIVAB + Multiply A by B and place result in A and B registers. + Divide A by B and ple quotient in A register & remainder in B register. htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in T3491 EMBEDDED SYSTEM ANDIOTDESIGN Unit-a Logical instructions in 8051. ¥_ANL : Itperforms AND logical operation between two operands. > Work on byie sized operands or the CY flag. + ANLA,Rn + ANLA, direct + ANLA, @Ri + ANLA, #data + ANIL direct, A + ANI direct, #data + ANLC,bit + ANLC, (bit Y ORL: Itperiorms OR logical operation between two operands, > Work on byie sized operands or the CY flag. + ORLA,Rn + ORL A, direct * ORLA, @Ri + ORLA, #data v XRL > Works on bytes only. + XRLA,Rno + XRL A, direct Y¥ CPL/CLR > Complement / Ckar. > Work on the accumulator or a bit. + CLRPI2 * CPLR vy RL/RLC/RR/RRC > Rotate the accumulator. + RL and RR without the carry + RLCand RRC miate through the carry. + SWAP A: Swap the upper and lower nibbles of the accumulator. 10 htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 Data transfer instructions in 8051. Briefly explain the data transfer instructions available in8051 microcontroller . (NOV 2014) Mov > 8-bitdata transfer for internal RAM and the SFR. * MOVA,Rn * MOV A. direct + MOVA, @Ri + MOVA, #data + MOVRaA + MOV Ra, direct + MOV Ra, #data + MOV direct, A + MOV direct, Ra + MOV direct, direct + MOV direct, @Ri + MOV direct, #data + MOV @Ri,A + MOV @Ri, direct + MOV @Ri, #data v MOV > L-bitdata transfer involving the CY flag + MOVC. bit + MOVbi,C v Mov » 16-bit data transfer involving the DPTR: + MOV DPTR, #data v¥ MOVC > Move Code Byte + Load the accumulator with a byte fiom program memory. + Must use indexed addressing + MOVC A, @A+DPTR + MOVC A, @A+PC a htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 v¥ MOVX > Data transfer between the accumulator and a byte fromexternal data memory. + MOVX A, @Ri + MOVX A, @DPTR + MOVX @RiA +» MOVX @DPTR, A v PUSH/POP > Pushand Pop a data byte onto the stack. > The data byte is identified by a direct address from the internal RAM locations. + PUSH DPL + POP 40H v XCH > Exchange accumulator and a byte operand + XCH A,Rn + XCH A, direct * XCH A, @Ri vy XCHD > Exchange lower digit of accumulator with the lower digit of the memory location specified. + XCHD A, @Ri + The lower 4-bits of the accumulator are exchanged with the lower 4-bits of the internal memory location identified indirectly by the index register. + The upper 4-bits of each are not modified. Boolean (or) Bit manipulation instructions in 8051. Y This group of instructions is associated with the single-bit operations of the 8051. Y This group allows manipulating the individual bits of bit addressable registers and memory locations as wellas the CY flag. + The P, OV, and AC flags cannot be directly altered. Y This group includes: + Set, clear, and, or complement, move. + Conditional jumps. v CLR htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 + Clear a bit or the CY flag. + CLRPLI + CLRC v SETB + Setabitor the CY flag. + SETBA2 + SETBC v CPL + Complement a bit or the CY flag. + CPL40H; Complement bit 40 of the bit addressable memory + OR/AND abit with the CY flag. + ORL — C, 20H: OR bit 20 of bit addressable memory with the CY flag + ANL — C, 34H; AND bit 34 of bit addressable memory with the CY flag. v Mov + Data transfer between a bit and the CY flag. + MOV C, 3FH; Copy the CY flagto bit 3F of the bit addressable memory. + MOV P1.2,C; Copy the CY flagto bit 2 of PI. ¥ IC/INC + Jump toa relative address if CY is set /cleared, ¥ JB/INB + Jump toa relative address if'a bit is set / cleared. + IB ACC2, Short Jump — SJMP + Usesan 8-bit signed offset relative to the 1* byte of the next instruction. + Long Jump - LIMP + Usesa 16-bit address. 2 htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 + 3 byte instruction capable of referencing any location in the entire 64K of program memory. > Absolute Jump — AIMP + Uses an I L-bit address. + 2 byte instruction + The 11-bit address is substituted for the lower 11-bits of the PC to cakculate the 16-bit address of the target. + The location referenced must be within the 2K Byte memory. > Indirect Jump — IMP + IMP @A+DPTR Y The 8051 provides 2 forms for the CALL instruction: > Absolute Call— ACALL + Uses an 11-bit address similar to AIMP + The subroutine must be within the same 2K page. > Long Call- LCALL + Usesa 16-bit address similar to LIMP + The subroutine can be anywhere. > Both forms push the 16-bit address of the next instruction on the stack and update the stack pointer. Y The 8051 provides 2 forms for the return instruction: > Return fom subroutine — RET + Pop the return address fiom the stack and continue execution there, > Return fom Interrupt Service Routine — RETI + Pop the return address fom the stack. + Continue execution at the address retrieved from the stack. + The PSW is not automatically restored. ¥ The 8051 supports 5 different conditional jump instructions. > ALL conditional jump instructions use an 8-bit signed offset. > Jump on Zero -IZ/ INZ + Jump if the A==0/A !=0 ‘+ The check is done at the time of the instructionexecution. 4 htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 > Jump on Carry — JC /INC + Jump if the C flag i > Jump on Bit— JB / INB + Jump if the specified bit is set /cleared. set / ckared. + Any addressabk bit canbe specified. » Jump if the Bit is set then Clear the bit — JBC + Jump if the specified bit is set. + Thenclear the bit. Y Compare and Jump if Not Equal — CINE > Compare the magnitude of the two operands and jump if they are not equal. + The values are considered to be unsigned. + The Camy flag is set/ cleared appropriately. + CINE A, direct. rel + CINE Rn, #data, rel + CINE @Ri, #data, rel Decrement and Jump if Not Zero — DINZ. > Decrement the first operand by | and jump to the location identified by the second operand if the resulting value is not zero. + DINZ. Rael + DINZ. direct, rel > NOP —No operation Memory organization Explain in detail the intemal memory organization of 8051 microcontroller (NOV 2014, May 2012, NOV 2011, NOV 2010, May 2010, MAY 2009, NOV 2008, NOV 2007) ¥ The 8051 microcontroller has 128 bytes of Internal RAM and 4kB of on chip ROM. ‘The RAM is also known as Data memory and the ROM is knownas program (Code) memory. Code memory holds the actual 8051 program to be executed. In 8051, memory is limited to 64KB. ‘Code memory may be found on-chip, as ROM or EPROM. It may also be stored compketely off-chip in an external ROM/ EPROM. ‘The 8051 has only 128 bytes of Internal RAM but it supports 64KB of external RAM. SNSNNNN htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 Y Since the memory is off-chip, it is not as flexible for accessing and is also slower. Structure of Internal RAM OF 8051(Data Memory) = Explain the Data memory structure of 8051. (NOV 201 Y Internal RAM is found on-chip on the 8051. So it is the fastest RAM available. ¥ Its flexible in terms of reading, writing and modifying its contents. Y Internal RAM is volatile. ¥ When the 8051 is reset, internal RAM is cared. Y The 128 bytes of internal RAM is organized as belbw. ~ Four register banks (Bank0, Bank1, Bank2 and Bank3) each of 8-bits (total 32 bytes). ” Thedefault bank register is Bank0. Y The remaining Banks are selected with the help of RSO and RS1 bits of PSW Register. Y 16 bytes ofbit addressable area and ¥ 80 bytes of general purpose area (Scratch pad memory) of internal RAM as shown inthe diagram below. V This area is utilized by the microcontroller as a storage area for the operating stack. V The 32 bytes of RAM from address 00 H to IFH are used as working registers organized as four banks ofeight registers each, Y The registers are named as RO-R7. Y Each register can be addressed by its name or by its RAM address. Forexample: MOVA,R7— or ~MOVR7,#05H Bit addressible area (16 Bytes) Regivter Rank 3 Register Baak 2 Regiter Bank 1 a Register a Bank 0 Byte INTERNALRAM. tlvases 16 htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in v v v v v Structure of Internal ROM (On-chip ROM / Program Memory / Code Memo £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 The 8051 microcontroller has 4KB of on chip ROM, but it can be extended up to 64K B. This ROM is ako called program memory or code memory. The CODE segment is accessed using the program counter (PC) for opcode fetches and by DPTR for data, The external ROM is ‘counter exceeds OFFFH. accessed when the EA pin is connected to ground or the contents of program When the Internal ROM address is exceeded the 8051 automatically fetches the code bytes from the external program memory. FFFFH External ROM OFFFH Internal ROM o000H SPECIAL FUNCTION REGISTERS (SFRs) Write the available special function registers in 8051. Explaineach register with its format and functions. (April 2017, NOV 2015) In 8051 microcontroller, there are registers which uses the RAM addresses from 80h to FFh. They are used for certain specific operations. ‘These (SFRs). ers are called Special Function Registers ¥ Mos of SERs are bit addressable and other few registers are byte addressable. In these SFRs, some of them are related to I/O ports (PO, P1, P2 and P3) and some of them are for control operations (TCON, SCON & PCON). Remaining are the auxiliary SFRs, that they dont directly configure the 8051. The list of SFRs and their functional names are given below. ‘The * indicates the bit addressable SFRs 7 htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unita S.No ‘Symbol Name of SFR ‘Address (Hex) T AC ‘Accumulator ‘050 2 BF B Register OF0 3 PSw* Program Status word regnier ‘ODO a SP ‘Stack Pointer Register ar 3 DPL Data pointer low byte 82 DPTR DPiT Data pointer high byte 83 6 PO* Port 0 80 PIF Por T 90 8 Pa Port 2 Ox 9 Ps Por 3 OB 10 1P* Tnterrupt Priority control 0B8 1 TE* Interrupt Enable control OAS 12 MOD Timer mode register 3 3 TCON* Timer control register Ey 14 THO Timer 0 Higher byte 8C 5 TO Timer 0 Lower byte BA 16 THI Timer I Higher byte 38D 17 TL Timer I lower byte 8B 8 SCON* Seral control register 8 19 ‘SBUF Serial buffer register 9 20 PCON Power control register a7 Table: Special Function Registers STACK in8051 Microcontroller: VY The stack is a part of RAM used by the CPU to store information temporarily, Y This information may be either data or an address. 18 htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 Y The register used to access the stack is called the Stack pointer (SP). Y SPs an8-bit register. So, it can take values of 00 to FF H. Y When the 8051 is powered up, the SP register contains the value (17.ie the RAM location value 08 is the first location being used for the stack by the 8051 controller. Y There are two important instructions to handle stack. One is the PUSH and the other is the POP. The loading of data from CPU registers to the stack is done by PUSH. Y The loading of the contents of the stack back into a CPU register is done by POP. Interrupts: Explain interrupt structure of 8051 microcontroller. (NOV 2011, MAY 2009) Interrupt Structure: Y An interrupt is an external or intemal event that disturbs the microcontroller to inform it that a device needs its service. Y The program which is associated with the interrupt is called the interrupt service routine (ISR) or interrupt handler. ¥ Upon receiving the interrupt signal, the microcontroller finishes current operation and saves the PC on stack. Jumps to a fixed location in memory depending on type of interrupt. Y Starts to execute the interrupt service routine until RETI. Y Uponexecuting the RETI the microcontroller returns to the place where it was interrupted. Get_ pop PC from stack. Y The 8051 microcontroller has FIVE interrupts in addition to Reset. They are © Timer 0 overflow Interrupt © Timer 1 overflow Interrupt «External Interrupt 0(INTO) © External Interrupt 1 (INT) ‘© Serial Port Interrupt ¥ Each interrupt has a specific place in code memory where program execution begins. © External Interrupt 0: 0003 H + Timer Ooverflow: 000BH 19 htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 © External Interrupt 1: 0013 H © Timer loverflow: 001BH © Serial Interrupt: 0023 H Y Upon reset all Interrupts are disabled & do not respond to the Microcontroller. Y These interrupts must be enabkd by software. This is done by an 8-bit register called Interrupt Erable Regster (IE). Interrupt Enable Register : 5A |— ES Eex1 | ero | Exo EA. : Global enabk/disable. To enable the interrupts, this bit must be set " .- :Undefined-reserved for future use. * BT2:Enabk /disable Timer 2 overflow interrupt. + ES. : Enable/disabk Serial port interrupts. "ETI: Enabk /disable Timer 1 overflow interrupt. * EX1: Enabk/disable External interruptl. * ETO: Enable /disable Timer 0 overflow interrupt. * EXO: Enabk/disable External interrupt Y Upon reset, the interrupts have the following priority from top to down. The interrupt with the highest PRIORITY gets serviced first. 1. External interrupt 0 (INTO) 2. Timer interrupt (TFO) 3. External interrupt 1 (INTI) 4, Timer interrupt] (TF1) 5. Serial communication (RI+T1) Y Priority canalso be set to “his or “low” by &-bit IP register. 20 htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 —|— Jer] es [eri}pxi [ero |exo * IP.6:reserved + IP.5: Timer 2 interrupt priority bit (8052 only) + IP4: Scrial port interrupt priority bit + 1P3:Timer | interrupt priority bit * P.2: External interrupt 1 priority bit © IP.1: Timer 0 interrupt priority bit + 1P.0:External interrupt 0 priority bit PROGRAMMING TIMERS OF 8051. 1. Explain the different modes of operation of timers in 8051 in detail with its associated registers. Describe different modes of operation of time rs /counte rs in 8051 with its associated registers. (NOV 2009, MAY 2009. May 2007, May 2016) Draw and explain the functions of TCON and TMOD registers of 8051. (Dec 2008) Explain the on-chip timer modes of an 8051 Microcontroller. (April 2010, NOV 2016) Timer Registers. Y The 8051 has two timers/counters, they can be used eitheras timers (used to generate a time delay) or as event counters. TIMER 0: Y Timer 0 is a 16-bit register and canbe treated as two 8-bit registers (TLO & THO). Y These registers can be accessed similar to any other registers like A, B or R1 etc v Ex: The instruction MOV TLO,#07 moves the value 07 into lower byte of Timer). ¥ Similarly MOV R1, THO saves the contents of THO in the RI register. a htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 DIS a) THO TLO 5 TIMER 1: Y Timer 1 is also a 16-bitregister and can be treated as two 8-bit registers (TLI & THI). Y These registers can be accessed similar to any other registers like A, B or Rlete Ex: The instruction MOV TLI,#05 moves the value 05 into lower byte of Timer1. Y Similarly MOV RO,THI saves the contents of THI in the RO register. D1s Do LUT ATT THL Z TL > TMOD (Timer mode Register): The various operating modes of both the timers T0 and TI are set by 2 TMOD register. TMOD is 8-bit register. The lower 4 bits are for Timer 0 ‘The upper 4 bits are for Timer 1 SVN Ineach case, + The lower bits are used to set the timer mode + The upper 2 bits to specify the operation DT DO cate] C/T| yy Mo |care]c/T| M1 | Mo Timer) Timer 0 htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 GATE: Y This bit is used to start or stop the timers by hardware. ¥ When GATES I, the timers can be started / stopped by the external sources. ¥ When GATE= 0, the timers can be started or stopped by software instructions like SETB TRx or CLR TRx, C/T (Counter/Timer): ¥ This bit decides whether the timer is used as delay generator or event counter. When C/T =0, timer is used as delay generator. v ¥ When C/T =1, timer is used as an event counter. Y The clock source for the time delay is the crystal frequency of 8051. ¥ The clock source for the event counter is the external clock source. M1,MO0 (Mode): Y These two bits are the timer mode bits. The timers of the 8051 canbe configured in four modes Mode0, Model, Mode2 & Mode 3. ¥ The selection and operation of the modes is shown below. SNo] Mo MI Mode ‘Ope ration T 0 0 Mode0 | 13-bit Timer mode. 8-bit Timer/counter THx with TLx as 5-bit prescaler 2 0 T Model | 16-bit Timer mode.16-bi timer counter ‘THx and TLx are cascaded. There is no presacler a T 0 Mode2 | &-bitauto reload. & bit auto reload timer/counter. THx holds a value which is to be reloaded TLx each time it overflows a T T Mode3 | Split timer mode 23 htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 Mode 0: 13 bit Timer mode 8 bits 5 bits TF goes high Overflow ct=0 =0TR when FFFF>0 flag Mode 1: 16 bit Timer mode a TF goeshigh Overflow when FFFF > 0 flag Mode 2: 8 bit auto reload mode JS overnow cr=0 TR Reload TF goes high when FF +0 Mode 3: Split Timer mode Figure: Modes of operation of Timer 4 htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in T3491 EMBEDDED SYSTEM AND IOT DESIGN Unita TCON (Timer control register) Y TCON (timer control) register is an 8-bit register. TCON register is a bit-addressable register. 7 6 5 4 3 2 1 ° TF TRI TFo ‘TRO 11 ™ 1E0 170 Bit Bit Description Number | Mnemonic] 7 TFI _ | Timer I overflow flag (Ckared by hardware when processor vectors to interrupt routine. Set by hardware on timer/counter overflow, when the timer | register overflows 6 TRI | Timer I run control bit (Ckar to turn off time/counter 1. Set to turn on timer/counter 1. 5 TF) | Timer0 overflow flag (Ckared by hardware when processor vectors to interrupt routine. Set by hardware on timer/counter overflow, when the timer 0 register overflows] a TRO | TimerO run control bit Ckar to turn off time/counter 0. Set to turn on timer/counter 0. 3 TE] __| External interupt I edge flag (Ckared by hardware when interrupt is processed if ed ge-triggered. Set by hardware when external interrupt is detected on INTI pin. 2 TT] | Exermal interrupt I type contol bit Char to select low level active (level triggered) for external interrupt 1 Set to select falling edge active (edge triggered) for external interrupt 1. T TE0 | External interrupt 0 edge flag (Ckared by hardware when interrupt is processed if ed ge-triggered. Set by haniware when external interrupt is detected on INTO pin. 0 THO | External interrupt 0 type control bit Ckar to select low kvel active (level triggered) for external interrupt 0. Set to select falling edge active (edge triggered) for external interrupt 0. Timers of 8051 do starting and stopping by either software or hardware control For using software to start and stop the timer where GATE-O ‘The start and stop of the timer are controlled by software using TR (timer start) bits TRx and CLRx The SETB instruction starts it, and it is stopped by the CLR instruction. ‘These instructions start and stop the timers as longas GATE=0 in the TMOD register ‘The hardware way of starting and stopping the timer is achieved by making GATE=1 in the TMOD register. Syn 25 htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 The following are the characteristics and operations of mode 1: 1. Itis a 16-bit timer. . Itallows valve from 0000 to FFFFH, 3. Value to be loaded into the timer register TL and TH. 4. After TH and TL are loaded with a 16-bit initial valuc, the timer must be started © This is done by SETB TRO for timer 0 and SETB TRI fortimer 1 5. Afier the timer is started, it starts to count up © It counts up until it reaches its limit of FFFFH ‘© When itrolls over from FFFFH to 0000, it sets hi a flagbit called TF (timer flag) © Each timer has its owntimer flag. @ There are TFO for timer 0, and TF1 for timer 1 JU TF goes high Overflow when FFFF>0 flag Ce tod TR 6. Timer flagcan be monitored, ‘© When this timer flag is raised, to stop the timer with the CLR instructions. © CLR TRO and CLR TRI, for timer0 and timer 1 respectively. © Afier the timer reaches its limit and rolls over. ‘© Inorder to repeat the process, TH and TL must be reloaded with the original value and TF must be reloaded to 0. To generate a time delay 1. Load the TMOD register indicating which timer is to be used and which timer mode is selected. 2. Load registers TL and TH with initial count value. 3. Start the timer 4. Keep monitoring the timer flag (TF) with the JNB TEX , target to see if it is raised ‘* Get out of the loop when TF becomes high 5. Stop the timer 6. Clear the TF flag for the next round 26 htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 7. Go back to Step 2 to load TH and TL again. Example 1: In the following program, we create a square wave of 50% duty cycle (with equal portions high and low) on the PLS bit. Timer 0 is used to generate the time delay. Analyze the program. (Nov 2014) MOV TMOD,#01 Timer 0, mode 1(16-bit mode) HERE: MOV TLO.#0F2H — ;TLO=F2H, the low byte MOV THO0OFFH — 0 To generate a time delay 1. Load the TMOD value register indicating which timer is to be used, and the timer mode (mode 2) is selected. 2. Load the TH register with the initial count value. 3. Start timer. 4. Keep monitoring the timer flag (TF) with the NB TFx, target, to see whether it is raised Get out of the loop when TF goes high 5. Clear the TF flag. 6. Go back to Stepd, since mode 2 is auto reload. Example 5: Assume XTAL= 11,0592 MHz, find the flequency ofthe square wave generated on pin P10. MOV TMOD,#20H__ ;T1/8-bid/auto reload MOV THI#5 STH SETB TRI ;start the timer 1 BACK: INBTF1,BACK till timer rolls over CPLPLO PLO to hi, lo CLR TFL celear Timer I flag SJMP BACK smode 2 is auto-reload ~ In mode 2, no need to reload TH since it is auto-reload. ¥ Now (256 - 05) x 1.085 ts =251 x 1.085 1s = 272.33 us is the high portion of the puke. Y Since it is 50% duty cycle square wave, the period T is twice. Y Asaresult T= 2 x 272.33 pts = 544.67 pis and the frequency = 1.83597 kHz §.2: Timers as counters Timers can also be used as counters. Which are used for counting events happening outside the 8051. 20 htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 © When itis wed as a counter, itis a pulse outside of the 8051 that increments the TH, TL register. © TMODand TH, TL registers are the same as in timer concept, except the source of the frequency. * The C/T bit in the TMOD register decides the source of the clock for the timer © When C/T= 1, the timer is used asa counter and gets its pulses from outside the 8051. © The counter counts up as pulses are fed from pins 14 and 15. © these pins are called T0 (timer 0 input) and T (timer 1 input) Timer with external input (Mode 1 Timer Overflow external flag input pin 3.4 or 3.5 T igh CT=1 F goes TR when FFFF -> 0 Timer with external input (Mode 2) Timer Overflow external flag input pin 3.4 or 3.5 cr=1 Reload TF goes high when FF > 0 v IfGATE= |, the start and stop of the timer are done externally through pins P3.2 and P33 for timers 0 and I, respectively Y This hardware allows starting or stopping the timer externally at any time via a simpk switch a htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 INTO Pin Pin 3.2 or 3.3 Y The frequency for the timer is always 1/12th the frequency of the crystal attached to the 8051. Port 3 pins used for Timers 0 and 1 Pin PortPin Function Description 14 PS To Timer/counter 0 external input 15 P35 T1 Timer/counter 1 external input Example 6: Assuming that clock pulses are fed into pin T1, write a program for counter | in mode 2 to count the pulses and display the state of the TL1 count on P2, which connects to 8 LEDs. Solution: MOV TMOD.#01100000B counter 1, mode 2. C/T=1 external pubes MOV THI,#0 yckar THI SETB P3.5 smake TI input AGAIN: — SETB TRL ‘start the counter BACK: MOV A\TLI sget copy of TL MOV P2,.A display it on pos 2 INBTFI,Back keep doing, if TF CLR TRI ‘stop the counter 1 CLR TFL smake TF=0 SIMP AGAIN skeep doing it ¥ Notice in the above program the role of the instruction SETB P3.5. V Since ports are set up for output when the 8051 is powered up. Y So, we make P3.5 an input port by making it high 2 htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 Y Inother words, we must configure (set high) the TI pin (pin P3.5) to allow pulses to be fed into it. 5.3: SERIAL COMMUNICATION 2. Explain the serial programming of 8051 with its associated registers. (May 2014, 2013)(Or) Explain how to program for sending and receiving data serially using 8051 (April 2010, 2011) Explain 8051 serial port programming with examples. (May 2016, NOV 2012) Explain the serial modes of operation of 8051 microcontroller. (May 2007) RS232 It is an interfacing standard RS232. It was set by the Electronics Industries Association (EIA) in 1960, ‘The standand was set long before the advent of the TTL logic family. Its input and output voltage levels are not TTL compatible. In RS232, a0 is represented by-3 0 -25 V, while a 1 bit is +3 to +25 V. SSNS IBM introduced the DB-9 version of the serial /O standard. yea eaus Handshake signals of MODEM. DTR (data terminal ready) © When DIR= DSR (data set ready) © When DSR=! indicate that it is ready for communication. indicate that it is ready for communication RTS (request to send) htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 ‘© Itasserts RTS to signal the modem that it has a byte of data to transmit. CTS (clear to send) * It is to receive, it sends out signal CTS, DCD (data carrier detect) © The modem asserts signal DCD to inform the DTE that a valid carrier has been detected. RI (ring indicator) ‘© Anoutput fiom the modemand an input to a PC indicates that the telephone is ringing. MAX232, A line driver (MAX232) is required to convert RS232 voltage levels to TTL levels, and vice versa. ‘+ 8051 has two pins that are used specifically for transferring and receiving data serially. + These two pins are called TxD and RxD and are part of the port 3 (P3.0 and P3.1). © These pins are TTL compatible. © They require a line driver to make them RS232 compatible. 8051 MAX232 pai} i111 cr. TxD} 4 2{? 33 2 DB-9 Baud rate: © The bau rates in 8051 are programmable. © 8051 divides the crystal frequency by 12 to get machine cycle frequency. © 8051 UART circuitry divides the machine cycle frequency by 32. 11.0592 MHz Machine cycle freq 28800 Hz 921.6 kHz To timer 1 To set the Baud rate © Timer 1 is wed to set baud rate using THI register 4 htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 ‘Baud rate THI (decimal)| — THI(Hex) 9600 3 FD 4800 “6 FA 2400 “12 Fa 1200 —h BS Explain in detail the serial communication registers of the 8051. (NOV 2009) SBUF: elt &-bit register used for serial communication. © Fora byte data to be transferred via the TxD line: ‘+ Byte must be placed in the SBUF register. + Bytes are framed with the start and stop bits and transferred serially via the TxD line. + SBUF holds the byte of data when itis received by 8051 RxD line. © When the bits are received serially via RxD. © 8051 de-frames byte by eliminating the stop and start bits. register used to program the start bit, stop bit and data bits of data framing, ‘SMO ‘SMI ‘SMZ REN TBS RBS TT RI Bit Bit Description Number | Mnemonic| SCON7 | SMO_ | Scrialpoxt mode specifier SCON6 | SMI_ | Serialport mode specifier SCONS | SM2_| Used for multiprocessor communication SCON4 | REN | SevCkared by software to emble/disable reception SCON3 | TBS | Not widely used SCON2 | RBS | Not widely used SCONT | T_ | Transmit interrupt flag. Set by hardware at the begin of the stop bit mode T. ‘And cleared by software SCON.O| RI | Receive interrupt flag. Set by hardware at the begin of the stop bit node 1. ‘And cleared by software as htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 SMO, SM1: Serial port mode specifiers SMO SML 0 0 Serial Mode oO 1 Serial Mode 1; 8-bitdata, 1 stop bit, 1 start bit 1 0 Serial Mode 2 1 1 Serial Mode 3 In programming the 8051 to transfer character bytes serially 1. TMOD register is loaded with the value 20H, indicating the use of timer I in mode 2 (8-bit auto- reload) to set band rate. 2. The THI is baded with one of the values to set baud rate for serial data transfer. 3. The SCON register is loaded with the value 5OH, indicating serial mode 1, where an 8-bit data is framed with start and stop bits. 4. TRI is set to 1 to start timer 1 5. Tis cleared by CLR TI instruction. 6. The character byte to be transfered serially is written into SBUF register. 7. The TI flag bit is monitored with the use of instruction INB TI, xx, to see if the character has been transferred completely. 8. To transfer the next byte, go to step 5. Write a program for the 8051 to transfer letter “A” serially at 4800 baud, continuously. Solution: MOV MOD, #20H :timer 1, mode 2 (auto reload) MOV THI,#6 4800 baud rate MOV SCON, #50H :8-bit, I stop, REN enabled SETB TRI ‘starttimer 1 MOV SBUF, #°A”_ :ketter “A” to trtansfer JNB TIHERE — ;wait forthe last bit cLR TL yekear TI for next char SIMP AGAIN keep sending A The steps that 8051 goes through in transmitting a character via TxD 36 htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 1. The byte character to be transmitted is written into the SBUF register 2. The start bit is transferred 3. The &-bit character is transferred on bit at a time 4. The stop bit is transferred © Itisduring the transfer of the stop bit that 8051 raises the TI flag, indicating that the ast character was transmitted 5. By monitoring the TI flag, we make sure that we are not overloading the SBUF + Ifwe waite another byte into the SBUF before TI is raised, the un-transmitted portion of the previous byte will be lost. 6. Afier SBUF is loaded with a new byte, the TI flag bit must be forced to 0 by CLR TI in onder for this new byte to be transferred By checking the TI flag bit, we know whether or not the 8051 is ready to transfer another byte ‘+ It must be noted that TI flag bit is raised by 8051 itself when it finishes data transfer ‘© It must be cleared by the programmer with instructionCLR TI + If'we write a byte into SBUF before the TI flag bit is raised, we risk the loss of a portion of the byte being transferred © The T1bit can be checked by the instruction JNB TI,xx Using an interrupt. Write a program for the 8051 to transfer “YES” serially at 9600 baud, 8-bit data, 1 stop bit do this continuously. (May 2006) Solution: MOV TMOD, #20H :timer 1, mode 2 (auto reload) MOV THI, #3 :9600 baud rate MOV SCON, #50H ;8-bit, 1 stop, REN enabled SETB TRI start timer 1 AGAIN: — MOV A,#“Y" transfer “Y” ACALL TRANS MOV A.#“E” —— stransfer “E” ACALL TRANS, MOV A,#“S" transfer “S” ACALL TRANS 2 htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 SIMP_ AGAIN keep doing it ‘serial data transfer subroutine TRANS: MOV SBUF,A load SBUF HERE: JNB TIHERE — ;wait forthe last bit cLR TI sget ready for next byte RET ~ In programming the 8051 to receive character bytes serially 1. TMOD register is loaded with the value 20H, indicating the use of timer 1 in mode (8-bit auto-reload) to set bau rate 2. THI is loaded to set baud rate 3. The SCON register is loaded with the value SOH, indicating serial mode 1, where an 8-bit data is framed with start and stop bits 4. TRI is set to I to start timer 1 5. RI is cleared by CLR RI instruction 6. The RI flag bit is monitored with the use of instruction JNB RIL, xxto sce if anentire character has been received yet 7. When RI is raised, SBUF has the byte, its contents are moved into a safe place, 8. To receive the next character, go to step 5. Write a program for the 8051 to receive bytes of data serially and put them in PI, set the baud rate at 4800, 8- bit data and 1 stop bit. (NOV 2016) Solution: MOV TMOD, #20H ;timer 1, mode 2 (auto reload) MOV THI,#6 +4800 baud rate MOV SCON, #50H ;8-bit, 1 stop, REN cnabled SETB TRI sstarttimer 1 HERE: INB RI, HERE wait forchar to come in MOV A,SBUF saving incoming byte in A MOV PI, send to port CLR RI sget ready to receive next byte SIMP_HERE :keep getting data 38 htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in T3491 EMBEDDED SYSTEM ANDIOTDESIGN Unit-a In receiving bit via its RxD pin, 8051 goes through the following steps. 1. Itreceives the start bit © Indicating that the next bit is the first bit of the character byte it is about to receive 2. The 8-bit character is received one bit at time 3. The stop bit is received ‘© When receiving the stop bit 8051 makes RI = |, indicating that an entire character byte has been received. 5. Affer the SBUF contents are copied into a safe place. © The RI flag bit must be forced to 0 by CLR RI in order to allow the next received character byte to be placed in SBUF. ‘© Failure to do this causes loss of the received character There are two ways to increase the baud rate of data transfer © To use a higher frequency crystal © To change abit in the PCON register PCON © PCON register is an 8-bit register ‘© When 8051 is powered up, SMOD is zero. © We can set it to high by software and thereby double the baud rate + GF1, GFO: Gencral flag bits MOV A,PCON iplace a copy of PCON in ACC SETB ACC.7 jmake D7=1 MOV PCON,A ;changing any other bits htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in Unit-2 £73491 EMBEDDED SYSTEM ANDIOT DESIGN Totimer Machine cycle freq XT 1To set meal 921.6 kHz 28800 Hz the Baud rate PIN Diagram of 8051 Microcontroller: Explain Pin details of 8051 microcontroller. (MAY 2006) Describe the functions of the following signals in 8051. RST, EA, PSEN and ALE. (NOV 2015) Y The 8051 microcontroller is available as a 40 pin DIP chip and it works at +5 volts DC. Y Among the 40 pins, a total of 32 pins are allotted for the four parallel ports PO, P1, P2 and P3 ie each port occupies 8-pins. Y The remaining pins are VCC, GND, XTAL1, XTAL2, RST, EA ,PSEN. XTALL, XTAL2: Y These two pins are connected to Quartz crystal oscillator which runs the on-chip oscillator. The quartz crysial oscillator is connected to the two pins along with a capacitor of 30pF as shown in the circuit, Y If use a source other than the crystal oscillator, it will be connected to XTALI and XTAL2 is left unconnected. liana TAL RST: V The RESET pinis an input pin and itis anactive high pin. VY Whena high pulse is applied to this pin, the microcontroller will reset and terminate all activities. Y Upon reset all the registers will reset to 0000 Value and SP register will reset to 0007 value. 40 htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 EA (extemal Access): ¥ Thispin is anactive bw pin Y This pin is connected to gound when microcontroller is accessing the program code stored in the external memory. V This pin is connected to Voc when it is accessing the programcode in the on chip memory. PSEN (program Store Enable): v This Y When the microcontroller is accessing the program code stored in the external ROM. this pin is connected to the OF (Output Enabk) pin of the ROM. ALE (Address latch enable): This is an an output pin which is active low. yutput pin, which is active high, ¥ This ALE pin will demultiplex the address and data bus. ¥ When the pin is high, the Address/ Data bus will act as address bus, otherwise the Address/ Data bus will act as Data bus. Proc Vee pricd2 0.0 (AD0) P1243 P0.1 (ADI) p1st4 0.2 (AD2) pratds 0.3 (AD3) piste 0.4 (AD4) preC|7 [1 P05 (ADs) eurcds [5 P06 (A068) RstC]9 32 |= Pa.7 (07) irxoyP30C}1e —-gQ54 31/5 caver arxo) p34 4 30 | avePROS (NTO) P32] 12 29|5 psen (INTT) P3.3 (]13 28 |) p2.7 (15) (ro) P34} 14 277 p26 ara) ayp3sh45 26 [A p25 ats) (WR) P36] 16 25 7) 2.4 (A12) (RD) P37] 17 24/5 p23 (any x12] 18 235) P22 iatoy ava 19 221 pa.4 a9} GNo C] 20 21 [5 P2018) ‘Figure: Pin diagram of 8051 a htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in T3491 EMBEDDED SYSTEM AND IOT DESIGN Unita P0.0- P0.7(AD0-AD7) = Y The port 0 pins multiplexed with Address/data pins. Y Ifthe microcontroller is accessing external memory, these pins will act as addresv/data pins, otherwise they are used for Port 0 pins. P2.0- P2.7 (A8-A15) = Y The por? pins are multiplexed with the higher order address pins ¥ When the microcontroller is accessing external memory, these pins provide the higher order address byte, otherwise they act as Port2 pins. PLO- PLT: Y These 8-pins are dedicated to perform input or output port operations. P3.0- P3.7: V These &-pins are meant for Port3 operations and also for some control operations like read, Write, Timer), Timerl, INTO, INTI, RxD and TxD. Program 1: Using timers in 8051 write a program to generate square wave 100ms, 50% duty eyele. (NOV 2014, May 2016, May 2012) MOV TMOD, #01 Here: MOV TLO, #D7 MOV THO, #B4 CPLP13 SETB TRO Again: INB TP), Again CLR TRO CLR TFO SIMP Here htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan.in £73491 EMBEDDED SYSTEM ANDIOT DESIGN Unit-2 Program 2: Write an 8051 ALP to multiply the given number 48H and 30H. (April 2017) Mrcmonis ‘Commons ‘Opcode ‘Operand MOV [AHS ‘Store datal in accumulator MoV | B#30 ‘Store data2 in B register MUL | AB :Multiply both MOV | DPTR#4500 _| sInitialize memory location MOVX | @DPTRA ‘Store lower order result INC DPTR :Go to next memory location Mov | AB ;Store higher order result Movx | @DPTR.A L1:SJMP | LI Stop the program Program 3: Write a program to add two 16 bit numbers. The numbers are 8C8D and S8D8C. Place the sum in R7 and R6. R6 should have the lower byte. (NOV 2010) Mnemonics ‘Comments ‘Opeode Operand MOV [A,#8D ‘Store LSB datal in accumulator MOV | B.#8C Store LSB data2 in B register ADD AB :Add both MOV | R6,A Store LSB result Mov | A.#8c {Store MSB datal in accumulator Mov (| B,#8D Store MSB data? in B register ADD AB ;Add both MoV [RIA Store MSB result LI:SIMP | Li Stop the program “a htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan. in UNIT- 1] EMBEDDED SYSTEMS Embedded System Design Process — Model Train Controller — ARM Processor — Instruction Set Preliminaries — CPU — Programming Input and Ouput — Supervisor Mode — Exceptions and Trap Models for programs ~ Assembly, Linking and Loading — Compilation Techniques — Program Level Performance Analysis. Examples Oo poeo00000 htips://play. google. com/store/apps/details ?id Definition of Embedded system: © An embedded system is a system that has software embedded in to computer-hardware. which makes a system dedicated for an application (s) or specific part of an application or product or part of a larger system. ‘+ Anembedded system is any device that includes a programmable computer but is not itself intended to be a general-purpose computer. ‘* Systems are the electronic systems that contain a microprocessor or a microcontroller, but ‘we do not think of them as computers— the computer is hidden or embedded in the sys Examples and Applications of Embedded systems Applications em, Telecom Smart Cards, Missiles and Satellites, Computer Networking, Digital Consumer Electronics, and Automotive oe po00000 ‘Mobile phone Digital camera Robots Point of sales terminals Automatic Chocolate Vending Machine ‘Stepper motor controllers for a robotics system Washing or cooking system Multitasking toys m.poriyaan. poriyaan www.Poriyaan. in Challenges in Embedded System: ‘What are the Challenges in Embedded systems? (May 2012, 14, November 2008, May 2023) ‘The Challenges in Embedded systems are How much hardware do we need? For the great deal of control over the amount of computing power, we cannot only select microprocessor used but also the amount of memory and peripheral device etc. ‘The choice of hardware must meet both performance deadlines and manufacturing cost constraints. How do we meet deadlines? Brute - force way to meet deadline by speedup the hardware so that the program runs faster. Increase in speed makes the system more expensive and alo increasing the CPU clock rate. How do we minimize power consumption? Inbattcry powered applications, power consumption is very important. Innon-battery powered applications, excessive power consumption can increase heat. One way to consume less power is to run the system more slowly. But slow down the system can obviously lead to missed deadlines. Careful design is required to slow down the non-critical parts of the machine. How do we design for upgradeability? Hardware platform may be used over several product generations or for several different versions of a product in the same generation with few or no changes. Hardware is designed such that the features are added by changing software. Does it really work? Reliability is very important when selling products. Reliability is important because running system try to eliminate bugs will too late and fixing bugs will more expensive. 1.1 COMPLEX SYSTEMS AND MICROPROCESSORS 1 APC is mot iiself an embedded computing system, although PCs are ofien used to build ‘embedded computing systems. But a fax machine ora clock built from a microprocessor is anembedded computing system. 2 This means that embedded computing system design is a useful skill for many types of product design. Automobiles, cell phones, and even household appliances make extensive use of microprocessors. 2 Designers in many fields must be able to identify where microprocessors can be used, design a hardware platform with VO devices that can support the required tasks, and implement software that performs the required processing. 2 Computerengineering, like mechanical design or thermodynamics, is a fundamental discipline that can be applied in many different domains. But of course, embedded computing system design docs not stand alone. htips://play. google. com/store/apps/details 7id=com.poriyaan.poriyaan www.Poriyaan. in 1 Many of the challenges encountered in the design of an embedded computing system are not computer engineering—for example, they may be mechanical or analog electrical problems. 1.1 Embedding Computers Briefly explain about the history of embedding computers with an example (April 2010) Give building block of one consumer electronic product application system built using a typical embedded processor and highlight its tvo features that make its rok effective (Dec 2022/0 an2023) 1 Computers have been embedded into applications since the earliest days of computing. One exampk is the Whirlwind, a computer designed at MIT in the late 1940s and early 1950s. Whirlwind was alo the first computer designed to support real-time operation and was originally conceived as a mechanism for controlling an aircraft simulator. 1 Even though it was extremely large physically compared to today's computers (e.g., it contained over 4,000 vacuum tubes), its complete design from components to system was attuned to the needs of realtime embedded computing 1 The utility of computers in replacing mechanical or human controllers was evident from the very beginning of the computer era—for example, computers were proposed to control chemical processes in the late 1940s. 1A microprocessor is a single-chip CPU. Very large scale integration (VLSI) stet the acronym is the name technology has allowed us to puta complete CPU ona single chip since 1970s, but those CPUs were very simple. 1 The first microprocessor, the Intel 4004, was designed for an embedded application, namely, a calculator. ‘The calculator was not a general-purpose computer—it merely provided basic arithmetic functions. However, Ted Hoff of Intel realized that a general-purpose computer programmed properly could implement the required function, and that the computer-on-a- chip could then be reprogrammed for use in other products as well. 1 Since inte grated circuit design was (and still is) an expensive and time-consuming process, the ability to reuse the hardware design by changing the software was a key breakthrough. 1 The HP-35 was the first handheld calculator to perform transcendental functions [Whi72]. It was introduced in 1972, so it used several chips to implement the CPU, rather thana single-chip microprocessor. 1 However, the ability to write programs to perform math rather than having to design digital circuits to perform operations like trigonometric functions was critical to the successful design of the caiculator. 1 Automobile designers started making use of the microprocessor soon after single-chip CPUs became available. 1 The most important and sophisticated use of microprocessors in automobiles was to control the engine: determining when spark plugs fire, controlling the fueV/air mixture, and so on. ‘There was a trend toward electronics in automobiles in general—electronic devices could be used to replace the mechanical distrbutor. 1 But the big push toward microprocessor-based engine control came from two nearly simultaneous developments: The oil shock of the 1970s caused consumers to place much htips://play. google. com/store/apps/details ?id m.poriyaan. poriyaan www.Poriyaan. in higher value on fuel economy, and fears of pollution resulted in laws restricting automobile engine emissions. 1 The combination of low fuel consumption and low emissions is very difficult to achieve; to meet these goals without compromising engine performance, automobile manufacturers turned to sophisticated control algorithms that could be implemented only with microprocessors. 1 Microprocessors come in many different levels of sophistication; they are usually classified by their word size. 1 An &-bit microcontroller ix designed for low-cost applications and includes on-board memory and 1/0 devices: a 16-bit microcontroller is offen used for more sophisticated applications that may require either longer word lengths or off-chip VO and memory; and a 32-bit RISC microprocessor offers very high performance for computation-intensive applications. 1 A programmable CPU was used rather than a hardwired unit for two reasons: First, it made the system easier to design and debug; and second, it allowed the possibility of upgrades and using the CPU for other purposes. 1 A high-end automobile may have 100 microprocessors, but even inexpensive cars today use 40 microprocessors. Some of these microprocessors do very simple things such as detect whether seat belts are in use. Others control critical functions such as the ignition and braking systems. 1 There are many houschokd uses of microprocessors. The typical microwave oven has at least one microprocessor to control oven operation. Many houses have advanced thermostat systems, which change the temperature level at various times during the day. 1 The moderncamera is a prime example of the powerful features that can be added under microprocessor control. Digital television makes extensive use of embedded processors. 1 Insome cases, specialized CPUs are designed to execute important algorithms, an example the CPU designed for audio processing in the SGS Thomson chip set. This processor is designed to efficiently implement programs for digital audio decoding. BMW 850i brake and stability control system: 1 The BMW 850i was introduced with a sophisticated system for controlling the wheek of the car. An antilock brake system (ABS) reduces skidding by pumping the brakes. 1 An automatic stability control (ASC +T) system intervenes with the engine during mareuvering to improve the car’s stability. These systems actively control critical systems of the car; as control systems, they require inputs from and output to the automobile. 1 Let’s first look at the ABS. The purpose of an ABS is to temporarily release the brake ona wheel when it rotates too slowly—when a wheel stops turning, the car starts skidding and becomes hard to control. Itsits between the hydraulic pump. which provides power to the brakes, and the brakes themselves as seen in the following diagram, htips://play. google. com/store/apps/details ?id m.poriyaan. poriyaan www.Poriyaan. in 1 This hookup allows the ABS system to modulate the brakes in order to keep the wheels from locking. 1 The ABS system uses sensors on each wheel to measure the speed of the wheel The wheel speeds are used by the ABS system to determine howto vary the hydraulic fluid pressure to prevent the wheels from skidding. Sensor Hydraulic pump Sensor Antilock brake system (ABS) I The ASC+Tsystem’s job is to control the engine power and the brake to improve the car’s stability, 1 The ASC+Tcontroks four different systems: throttk, ignition timing, differential brake, and (on automatic transmission cars) gear shifting. 1 The ASC + T can be turned off by the driver, which can be important when operating with tire snow chains. 1 The ABS and ASC+ T must ckarly communicate because the ASC + T interacts with the brake system. Since the ABS was introduced several years earlier than the ASC + T, it was important to be able to interface ASC + Tto the existing ABS module. as well as to other existing electronic modules. 1 The engine and control management units include the electronically controlled throttle, digital engine management, and ekctronic transmission control. The ASC +T control unit has two microprocessors on two printed circuit boards, one of which concentrates on logic- relevant components and the other on performance-spccific components. htips://play. google. com/store/apps/details ?id m.poriyaan. poriyaan www.Poriyaan. in 1.1 Characteristics of Embedded Computing Applications Enumerate the characteristics of embedded computing systems. (NOV/DEC 2010, May 2014, May 2023) Embedded computing is in many ways much more demanding than the sort of programs that ‘you may have written for PCs or workstations. Functionality is important in both general. Purpose computing and embedded computing, but embedded applications must meet many other constraints as well. (On the one hand, embedded computing systems have to provide sophisticated functionality: 2 Complex algorithms: The operations performed by the microprocessor may be very sophisticated. For example, the microprocessor that controls an automobile engine must perform complicated filtering functions to optimize the performance of the car while minimizing pollution and fuel utilization. 1 User interface: Microprocessors are frequently used to control compx user interfaces that may include multiple menus and many options. The moving maps in Global Positioning S ystem (GPS) navigation are good examples of sophisticated user interfaces. To make things more difficult, embedded computing operations must often be performed to meet deadlines: 2 Real time: Many embedded computing systems have to perform in real is not ready by a certain deadline, the system breaks. 1 Insome cases, failure to meet a deadline is unsafe and caneven endanger lives. In other cases, missing a deadline does not create safety problems but does create unhappy customers—missed deadlines in printers, for example, can result in scrambled pages. 1 Multirate: Not only must operations be completed by deadlines, but many embedded computing systems have several real-time activities going on at the same time. ‘ime — if the data 2 They may simultaneously contol some operations that run at slow rates and others that run at high rates. Multimedia applications are prime examples of multirate behavior. 1 The audio and video portions of a multimedia stream run at very different rates, but they must remain closely synchronized. Failure to meet a deadline on either the audio or video portions spoils the perception of the entire presentation. 1 Power and energy:Power consumption directly affects the cost ofthe hardware, since a larger power supply may be necessary. 1 Energy consumption affects battery life, which is important in many applications, as well as heat consumption, which can be important even in desktop applications. 1 Manufacturing cost: The total cost of building the system is very important in many cases Manufacturing cost is determined by many factors, including the type of microprocessor used, the amount of memory required, and the types of /O devices. htips://play. google. com/store/apps/details ?id m.poriyaan. poriyaan www.Poriyaan. in l htips://play. google. com/store/apps/details ?id 1.2 THE EMBEDDED SYSTEM DESIGN PROCESS: Briefly explain about the steps involved in embedded system design. (NOV/DEC 2006, 2007, 2009, May 2012, April 2018, Dec20) Designing with Computing platforms (Dec2022/Jan 2023, May 2023) ‘The embedded system design process aimed at two objectives. First, it will give usan introduction to the various steps in embedded system design before wwe delve into them in more detail. Second, it will allow us to consider the design methodology itself. A design methodob gy is important for three reasons. First, it allows us to keep a scorecard on a design to ensure that we have done everything ‘we need to do, suchas optimizing performance or performing functional tests. Second, it allows us to develop computer-aided design tools. Developing a single program that takes ina concept for an embedded system and emits a competed design would be a daunting task, but by first breaking the process into manageable steps, we can work on. automating the steps one ata time. Third, a design methodology mikes it much easier for members ofa design team to communicate. By defining the overall process, team members can more easily understand what they are supposed todo, what they should receive fiom other team members at certain times and ‘what they are to hard off when they complete their assigned steps. Since most embedded systems are designed by teams, coordination is perhaps the most important rok of a well-defined design methodology. In this top-down view, we start with the system requirements. Inthe next step, specification, we create a more detailed description of what we want. But the specification states only how the system behaves, not how it is built. ‘The details of the system’s internals begin to take shape when we develop the architecture, which gives the system structure in terms of large components. ‘Once we know the components we need, we can design those components, including both software modules and any specialized hardware we need. Based on those components, we can finally build a complete system m.poriyaan. poriyaan www.Poriyaan. in Requirements tem integration prem inte Major levels of abstraction in the design process. 1 The top-downdesign will begin with the most abstract description of the system and conclude with concrete details. The alternative is a bottom-up view in which we start with components to build a system. 1 Bottom-up design steps are shown in the figure as dashed-line arrows. We need bottom-up ssign because we do not have perfect insight into how later stages of the design process will turnout. 1 Decisions at one stage of design are based upon estimates of what will happen later: How fast can we make a particular function run? How much memory will we need? How much system bus capacity do we need? We also need to consider the major goak of the design. ‘Manufacturing cost. Performance (both overall speed and deadlines); and Power consumption. ‘We must also consider the tasks we need to perform at every step in the design process. At each step in the design, we add detail: 0D We must analyze the design at each step to determine how we can meet the Specifications. 0 We must then refine the design to add detail. D We must verify the design to ensure that it s cost, speed and so on. po00 meets all system goals, such as om.poriyaan.poriyaan www.Poriyaan. in 1.2.1 Requirements 1 Charly, before we design a sysiem, we must know what we are designing. The initial stages of the design process capture this information for use in creating the architecture and components 1 We generally proceed in two phases: First, we gather an informal description from the customers known as requirements, and we refine the requirements into a specification that contains enough information to begin designing the system architecture. 1 Separating out requirements analysis and specification is often necessary because of the large gap between what the customers can describe about the system they want and what the architects need to design the system. 1 Consumers of embedded systems are usually not themselves embedded system designers or even product designers. Their understanding of the system is based on how they envision users’ interactions with the system, They may have unrealistic expectations as to what can be done within their budgets; and they may also express their desires in a language very different from system architects’ jargon. 1 Capturing a consistent set of requirements from the customer and then massaging those requirements into a more formal specification is a structured way to manage the process of ‘translating from the consumer’s language to the designer's. 1 Requirements may be functional or nonfunctional. We must of course capture the basic functions ofthe embedded system, but functional description is offen not sufficient. Typical nonfunctional requirements include: Performance: The speed of the system is often.a major consideration both for the usebility of the system and for its ultimate cost. As we have noted, performance may be a combination of soft performance metrics such as approximate time to perform a user-level functionand hard deadlines by which a particular operation must be completed. 1 Cost: The target cost or purchase price for the system is almost always a consideration. Cost typically has two major components: manufacturing cost includes the cost of components and assembly; nonrecurring engineering (NRE) costs include the personnel and other costs of designing the system 1 Physical size and weight: The physical aspects of the final system can vary greatly depending upon the application. An industrial control system for an assembly line may be designed to fit into a standard-size rack with no strict limitations on weight. A handheld device typically has tight requirements on both size and weight that can ripple through the entire system design. 1 Power consumption: Power, of course, is important in battery-powered systems and is often important in other applications as well. Power can be specified in the requirements stage in terms of battery life—the customer is unlikely to be able to describe the allowable wattage. 1 Validating a set of requirements is ultimately a psychological task since it requires understanding both what people want and how they communicate those needs. One good htips://play. google. com/store/apps/details ?id m.poriyaan. poriyaan www.Poriyaan. in ‘way to refine at least the user interface portion of a system's requirements is to build a mock-up. 1 The mock-up may we canned data to simulate functionality ina restricted demonstration, and it may be executed on a PC or a worksiation. But it should give the customer a good idea of how the system will be used and how the user can react to it. 1 Physical, nonfunctional models of devices can also give customers a better idea of characteristics suchas size and weight. Sample requirements form. Inputs Outputs Functions Performance ‘Manufacturing cost Power Physical size and weight 1 Requirements analysis for big systems can be complex and time consuming. However, capturing a rektively small amount of information in a clear, simple format isa good start toward understanding system requirements, 1 To introduce the discipline of requirements analysis as part of systemdesign, we will use a simple requirements methodology. We can use the requirement form as a checklist in considering the basic characteristics of the system. 1 Name: This is simple but helpful. Giving a name to the project not only simplifies talking about it to other people but can also crystallize the purpose of the machine. 1 Purpose: This should be a brief one- or two-line description of what the system is supposed 1o do, If youcan’t describe the essence of your system in one or two lines, chances are that you don't understand it well enough, 1 Inputs and outputs: These two entries are more complex than they seem. The inputs and outputs fo the system encompass a wealth of detail 1 Types of dara: Analog electronic signals? Digital data? Mechanical inputs? 1 Data characteristics: Periodically arriving data, such as digital audio samples? Occasional user inputs? How many bits per data element? 1 Types of VO devices: Buttons? Analog/digital converters? Video displays? 1 Functions: This is 2 more detailed description of what the systemdoes. A good way to approach this is to work from the inputs to the outputs: When the system receives an input, what does itdo? How do user interface inputs affect these functions? How do different functions interact? 10 htips://play. google. com/store/apps/details ?id m.poriyaan. poriyaan www.Poriyaan. in 1 Performance: Many embedded computing systems spend at least some time controlling physical devices or processing data coming from the physical world. In most of these cases, the computations must be performed within a certain time frame. It is essential that the performance requirements be identified early since they must be carefully measured during implementation to ensure that the system works properly. 1 Manu facturing cost: This includes primarily the cost of the hardware components. Even if you don't know exactly how much youcan afford io spend onsysiem components, you should have some idea of the eventual cost range. Cost has a substantial influence on architecture: A machine that is meant to sell at$10 most likely has a very different internal structure than a $100 system, 1 Power: Similarly, you may have only a rough idea of how much power the system can consume, but a little information can go a long way. Typically, the most important decis is whether the machine will be battery powered or plugged into the wall. Battery-powered ‘machines must be much more careful about how they spend energy. 1 Physical size and weight: You should give some indication of the physical size of the system to help guide certain architectural decisions. A desktop machine has much more {flexibility in the components used than, for exampke, a lapel mourted voice recorder. htips://play. google. com/store/apps/details ?id m.poriyaan. poriyaan www.Poriyaan. in a l l htips://play. google. com/store/apps/details ?id 1.3 DESIGN EXAMPLE: MODEL TRAIN CONTROLLER ‘Enumerate the steps involved in design of model t ‘Train Controller with suitable diagrams and explain (Nov/Dec 2018) (Dec 2022/Jan 2023) 1.3.1 Requirements Before we can create a system specification, we have to understand the requirements. Here is a basic set of requirements for the system: controller. (NOV/DEC 2007, Dee 2010, May 2012, Nov 2017, April 2018, Dec20, Apr21, Dee 21) or Design a Model Inorderto learn how to use UML to model systems, we will specify a simple system, a model train controller. The user sends messages to the ain with a control box attached to the tacks. The controlbox may have familiar controls such as a throttle, emergency stop button, and so on. Since the train receives its electrical power from the two rails of the track. the control box can send signals to the train over the tracks by modulating the power supply voltage. As shown in the figure, the control panel sends packets over the tracks to the receiver on the train. ‘The train includes analog electronies to sense the bits being transmitted and a control system to set the tain motor’s speed and direction based on those commands. ch packet includes an address so that the console can control several trains on the same track; the packet ako includes an error correction code (ECC) to guard against, transmission errors. This is a one-way communication system the model train cannot send commands back to the user. We start by analyzing the requirements for the train control system. We will base our system ona real standard developed for model trains.We then develop two specifications: a simple, high- vel specification and thena more detailed specification. ‘The console shall be able to control up to eight trains ona single track. ‘The speed of each train shall be controllable by a throttle to at least 63 different levels in each direction (forward and reverse). ‘There shall be an inertia control that shall allow the user to adjust the responsiveness of the train to commanded changes in speed. ‘There shall be an emergency stop button. Anerror detection scheme will be used to transmit messages Higher inertia means that the train responds more slowly to a change in the throttle, simulating the inertia ofa large train. The inertia control will provide at least eight different levels. m.poriyaan. poriyaan www.Poriyaan. in Putting the requirements into chart format: Name Model train controler Purpose Conirol speed of up to eight model trains Tapuls Throttle, inertia setting, emergency stop, 0 ‘Oupats ‘number Train control signals Functions Set engine speed based upon inertia seitin Performance respond to emergency stop Can update train speed at least 10 times per second “Manufacturing cost 350 Power Physical size and weight TOW (plugs into wall) Console shoukl be comfortable for wo hands, approximate size of standard keyboard; weight<2 pounds Recetver, motor controller ~~ 7 pe Power supply + ! + Console sn " Header | Address | Command | foc] |[Motr][ nexwve ‘Signaling the train htips://play. google. com/store/apps/details ?id m.poriyaan. poriyaan www.Poriyaan. in Let’s consider the entries in the form: A Model train control system 1 Name: This is simple but helpful. Giving a name to the project not only simplifies talking about it to other people but can ako crystallize the purpose of the machine, 1 Purpose: This should be a brief ore- or two-line description of what the system is supposed to do. If you can’t describe the essence of your system in one or two lines, chances are that you don’t understand it well enough. 1 Inputs and outputs: These two entries are more complex than they seem. The inputs and outputs to the system encompass a wealth of detail: 1 Types of data: Analogelectronic signals? Digital data? Mechanical inputs? 1 Data characteristics: Periodically arriving data, such as digital audio samples? Occasional user inputs? How many bits per data element? 1 Types of VO devices: Buttons? Ansloy/digital converters? Video displays? 1 Functions: This is a more detailed description of what the systemdoes. A good way to approach this is to work from the inputs to the outputs, htips://play. google. com/store/apps/details ?id m.poriyaan. poriyaan www.Poriyaan. in ‘When the system receives an input, what does it do? How do user interface inputs affect these functions? How do different functions interact? 2 Performance: Many embedded computing systems spend at least some time controlling physical devices or processing data coming from the physical world. 1 In mostof these cases, the computations must be performed within a certain time frame. It is essential that the performance requirements be identified early since they must be carefully measured during implementation to ensure that the system works properly. 1 Manufacturing cost: This includes primarily the cost of the hardware components. Even if you don’tknow exactly how much you can afford to spend on system components, you should have some idea of the eventual cost range. Cost has a substantia! influence on architecture. 1 A mochine that is meant to sell at $10 most likely has a very different internal structure thana $100 system 1 Power: Similarly, you may have only rough idea of how much power the system can consume, but a little information can go a long way. Typically, the most important decision is whether the machine will be battery powered or plugged into the wall. Battery- powered machines must be much more careful about how they spend energy. 1 Physical size and weight: Youshould give some indication of the physical size of the system to help guide certain architectural decisions. A desktop machine has much more flexibility in the components used than, for example, a lape mounted voice recorder. 1.3.2 DCC 1 The Digital Command Control (DCC) was created by the National Model Railroad Association to support interoperable digitally-controlled model trains. 1 Hobbyists stated building homebrew digital control systems in the 1970s an ‘Marklin developed its own digital control system in the 1980s. 1 DCC was created to provide a standard that could be built by any manufacturer so that hobbyists could mix and match components from multiple vendors. ‘The DCC standard is given in two document O Standard S-9.1, the DCC Electrical Standard, defines how bits are encoded on the rails for transmission. 0 Standard S-9.2, the DCC Communication Standard, defines the packets that carry information. 0 Any DCC-conforming device must meet these specifications. DCC also provides several recommended practices. These are not strictly required but they provide some hints to manufacturers and users as to how to best use DCC. 1 The DCC standard does not specify many aspects ofa DCC train system. It doesn’t define the control panel, the type of microprocessor used, the programming language to be wed, or many other aspects of a real model train system. 1 The standard concentrates on those aspects of system design that are necessary for interoperability. 15 htips://play. google. com/store/apps/details ?id m.poriyaan. poriyaan

You might also like