Download presentation
Presentation is loading. Please wait.
1
PROCESSORS & CONTROLLERS
Course code : 15 EM 2202 L – T – P : 2 – 2 – 2 Pre Requisite : 15 EC 1101 Credits : 4
2
PROCESSORS AND CONTROLLERS
8086 Microprocessor: Introduction to Microprocessor, Intel Microprocessor families ,8086 Microprocessor architecture, Register Organization, Pin Description, Physical Memory Organization, Modes of operation Instruction set & Assembly Language programming: Addressing modes, Instruction set, Assembler directives, simple Programs, Procedures and Macros, 8086 Interrupts.
3
PROCESSORS AND CONTROLLERS
8051 Microcontroller: Microcontroller families, 8051 Architecture, Signal Description, Register organization, Internal RAM, Special Function Registers, Interrupt control flow, Timer/Counter Operation, Serial Data Communication, and RS-232C Standard.8051 Programming & Interfacing: Addressing modes, Instruction set, Simple Programs involving Arithmetic and Logical Instructions, Timers/Counters, Serial Communication & Interrupts.
4
PROCESSORS AND CONTROLLERS
PIC Microcontroller: Introduction, Architectural overview, Memory organization, interrupts and reset, I/O ports, Timers. Interfacing: Matrix Key Board, Stepper Motor, LCD’s, DAC & ADC. using 8051 and PIC Microcontroller.
5
Microcontroller 8051
6
TIMERS The 8051 has two timers: TIMER 0 TIMER 1
8
TMOD Register Gate : When set, timer only runs while INT(0,1) is high. C/T : Counter/Timer select bit. M1 : Mode bit 1. M0 : Mode bit 0.
9
TCON Register (BIT ADRESSABLE REG)
TCON.7 - TF1: Timer 1 overflow flag. TCON.6 - TR1: Timer 1 run control bit. TCON.5 - TF0: Timer 0 overflag. TCON.4 - TR0: Timer 0 run control bit. TCON.3 - IE1: External interrupt 1 edge flag. TCON.2 - IT1: External interrupt 1 type flag. TCON.1 - IE0: External interrupt 0 edge flag. TCON.0 - IT0: External interrupt 0 type flag.
10
Concept of timer
11
GATE Control in TMOD If GATE = 1, the start and stop of the timer are done externally through pins P3.2 and P3.3 for timers 0 and 1, respectively
12
COUNTER Programming
13
Mode 1 Programming Load the TMOD value register indicating which timer (Timer0 or Timer1) is to be used and which timer mode is selected. Load registers TL & TH with initial count values. Start the timer Keep monitoring the timer flag(TF) Stop the timer. Clear TF for next round . Go back to step 2 to load TH & TL again NOTE: MODE 0 is exactly like mode-1 except that it is 13-bit timer instead 16-bit. The 13-bit timer/counter can hold values between 0000H to 1FFFH in TH-TL.
14
Mode 2 Programming Load the TMOD value register indicating which timer (Timer0 or Timer1)is to be used, and select the timer mode (mode-2). Load the TH register with the initial count value. Start the timer. Keep monitoring TF timer flag After it becomes “1” then clear the TF flag Go back to step 4 , since mode 2 is auto - reload
15
Example program for Mode1
ORG 0H MOV TMOD,# B BACK: MOV TL0,#0F0H MOV TH0,#0FFH CPL P1.0 ACALL DELAY SJMP BACK DELAY:SETB TR0 HERE: JNB TF0, HERE CLR TR0 CLR TF0 RET END
16
Example program for Mode2
ORG 0H MOV TMOD,# B MOV TH1, #05H SETB TR1 HERE: JNB TF1, HERE CPL P2.0 CLR TF1 SJMP HERE END
17
Serial Communication
18
Serial vs. parallel Communication
19
Synchronous vs. Asynchronous
Serial data communication uses two methods Synchronous Asynchronous There are special IC chips made by many manufacturers for serial communications. UART- universal asynchronous receiver-transmitter. USART- universal synchronous - asynchronous receiver-transmitter
20
Framing (Asynchronous )
23
SCON register
24
Doubling the baud rate There are two ways to increase the baud rate of data transfer in Use a higher frequency crystal. 2. Change a D7-bit to 1 in the PCON register PCON Register: ( Byte addressable)
26
Programming 8051 to transfer data serially
In programming 8051 to transfer character bytes serially, the following steps must be taken The TMOD register is loaded with the value 20H , indicating the use of Timer 1 in mode 2(8-bit auto reload) to set the baud rate The TH1 is loaded with one of the values to set the baud rate for serial data transfer( assuming XTAL= MHz). The SCON register is loaded with the value 50H indicating serial mode 1, where an 8-bit data is framed with start & stop bits. TR1 is SET to 1 to start Timer 1. TI is cleared when transmission is complete. The character byte to be transferred serially is written into SBUF register. TI is monitored for transmission . To transfer the next character go to step 5
27
Example Program for Serial Communication
ORG 0H MOV TMOD,# B------(20H) MOV TH1,#-3 MOV SCON,# B (50H) SETB TR1 AGAIN:MOV A,# ” “ ACALL TRANSFER MOV A,# ”K“ MOV A,# ”L“ MOV A,# ”U“ TRANSFER: MOV SBUF,A ACALL TRANSFER HERE: JNB TI, HERE MOV A,# ” “ CLR TI ACALL TRANSFER RET SJMP AGAIN END
28
Interrupts
29
Concept behind Interrupt
An interrupt is an external or internal event that interrupts the microcontroller to inform it that a device needs its service Upon activation of an interrupt, the microcontroller goes through the following steps 1. It finishes the instruction it is executing and saves the address of the next instruction (PC) on the stack 2. It also saves the current status of all the interrupts internally (i.e.: not on the stack) 3. It jumps to a fixed location in memory, called the interrupt vector table, that holds the address of the ISR 4. The microcontroller gets the address of the ISR from the interrupt vector table and jumps to it 5. Upon executing the RETI instruction, the microcontroller returns to the place where it was interrupted
30
Interrupts & Interrupt vectors:
31
Interrupt Enable Register
32
TCON REGISTER
34
LEVEL TRIGGERED INTERRUPT
In level triggered interrupt to ensure the activation of the hardware interrupt at the INT ‘n’ pin, make sure that the duration of the low-level signal is around 4 machine cycles.
35
In edge-triggered interrupts
The external source must be held high for at least one machine cycle, and then held low for at least one machine cycle The falling edge of pins INT0 and INT1 are latched by the 8051 and are held by the TCON.1 and TCON.3 bits of TCON register
37
Interrupt Priority register
38
EXAMPLE PROGRAMS Write a program that continuously get 8-bit data from P0 and sends it to P1 while simultaneously creating a square wave of 200 μs period on pin P2.1. Use timer 0 to create the square wave. Assume that XTAL = MHz. ORG 0000H LJMP MAIN ORG 000BH CPL P2.1 RETI ORG 0030H MAIN: MOV TMOD,#02H MOV P0,#0FFH MOV TH0,#-92 (TH0=A4H) MOV IE,#82H SETB TR0 BACK: MOV A,P0 MOV P1,A SJMP BACK END
39
EXAMPLE PROGRAMS Write a program to generate a square wave if 50Hz frequency on pin P1.2. Assume that XTAL= MHz ORG 0 LJMP MAIN ORG 000BH CPL P1.2 MOV TL0,#00 MOV TH0,#0DCH RETI ORG 30H MAIN: MOV TM0D,# B MOV TL0,#00 MOV TH0,#0DCH MOV IE,#82H SETB TR0 HERE: SJMP HERE END
40
EXAMPLE PROGRAMS Write a program in which the 8051 reads data from P1 and writes it to P2 continuously while giving a copy of it to the serial COM port to be transferred serially. Assume that XTAL= Set the baud rate at ORG 0000H ORG 100H LJMP MAIN SERIAL: JB TI,TRANS ORG 23H MOV A,SBUF LJMP SERIAL CLR RI ORG 30H RETI MAIN: MOV P1,#0FFH TRANS: CLR TI MOV TMOD,#20H RETI MOV TH1,#0FDH END MOV SCON,#50H MOV IE,# B SETB TR1 BACK: MOV A,P1 MOV SBUF,A MOV P2,A SJMP BACK
41
LCD LCD Interfacing (16X2) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Vss Vcc VEE RS R/W EN DB DB LCD
44
Addresses of 16x2 LCD 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F
CA CB CC CD CE CF
45
LCD INTERFACING TO 8051
47
STEPPER MOTOR INTERFACING
A Stepper motor is a widely used device that translates electrical pulses into mechanical movement. In applications such as disk drives, dot matrix printers & robotics, the stepper motor is used for position control Stepper motors commonly have a permanent magnet ‘rotor’( also called shaft) surrounded by a ‘stator’.
48
Stator Windings Configuration
49
Normal 4 Step Sequence Wave Drive 4 step sequence
Driving Stepper motor Normal 4 Step Sequence Wave Drive 4 step sequence CLOCKWISE STEP WINDING A WINDING B WINDING C WINDING D COUNTER CLOCKWISE 1 2 3 4 CLOCKWISE STEP WINDING A WINDING B WINDING C WINDING D COUNTER CLOCKWISE 1 2 3 4
50
Half step 8-step sequence Step Sequence
Driving Stepper motor Half step 8-step sequence Step Sequence CLOCKWISE STEP WINDING A WINDING B WINDING C D COUNTER CLOCKWISE 1 2 3 4 5 6 7 8
51
Interfacing Circuit
52
ULN2803
53
Stepper Motor Program Assuming two stepper motors are interfaced to 8051 with ULN2803 drivers. Program for normal 4-step sequence ( clock wise ) ORG 0H BACK: MOV A,#0CCH MOV P1,A ACALL DELAY DELAY: MOV A,#66H MOV R0,#0FFH MOV P1,A LOOP2: MOV R1,#80H ACALL DELAY LOOP1: DJNZ R1,LOOP1 MOV A,#33H DJNZ R0,LOOP2 MOV P1,A RET ACALL DELAY MOV A,#99H SJMP BACK END
54
Stepper Motor Program Assuming two stepper motors are interfaced to 8051 with ULN2803 drivers. Program for wave drive 4-step sequence ( clock wise ) ORG 0H BACK: MOV A,#88H MOV P1,A ACALL DELAY DELAY: MOV A,#44H MOV R0,#0FFH MOV P1,A LOOP2: MOV R1,#80H ACALL DELAY LOOP1: DJNZ R1,LOOP1 MOV A,#22H DJNZ R0,LOOP2 MOV P1,A RET ACALL DELAY MOV A,#11H SJMP BACK END
55
Stepper Motor Program Assuming two stepper motors are interfaced to 8051 with ULN2803 drivers. Program for half step 8-step sequence ( clock wise ) ORG 0H BACK: MOV A,#88H MOV A,#22H MOV P1,A MOV P1,A ACALL DELAY ACALL DELAY DELAY: MOV A,#0CCH MOV A,#33H MOV R0,#0FFH MOV P1,A MOV P1,A LOOP2: MOV R1,#80H ACALL DELAY ACALL DELAY LOOP1: DJNZ R1,LOOP1 MOV A,#44H MOV A,#11H DJNZ R0,LOOP2 MOV P1,A MOV P1,A RET ACALL DELAY ACALL DELAY MOV A,#66H MOV A,#99H SJMP BACK END
56
KEYBOARD INTERFACING
59
Keyboard Program
62
ADC(0804) INTERFACING ADCs( Analog-to-Digital Converters) are among the most widely used devices for data acquisition. A Physical quantity, like temperature, pressure, humidity, and velocity, etc., is converted to electrical ( Voltage , current) signals using a device called a transducer or sensor. We need ADCs to translate the analog signals to digital numbers, so that the microprocessor/microcontroller can read the data for further implement.
63
ADC 0804
64
Important Points on ADC 0804
Vcc It works with +5 volts and has a resolution of 8 bits. Conversion time is another major factor in judging an ADC. a. Conversion time is defined as the time it takes the ADC to convert the analog input to a digital (Binary) number. b. In ADC804 conversion time varies depending on the clocking signals applied to CLK R and CLK IN pins, but it cannot be faster than 110 μs
65
3. CLK IN and CLK R a. CLK IN is an input pin connected to an external clock source b. To use the internal clock generator (also called self- clocking), CLK IN and CLK R pins are connected to a capacitor and a resistor, and the clock frequency is determined by Typical values are R = 10K ohms and C = 150 pF. We get f = 606 kHz and the conversion time is 110 μs.
66
4. VRef/2: It is used for the reference voltage
If this pin is open (not connected), the analog input voltage is in the range of 0 to 5 volts (the same as the Vcc pin) If the analog input range needs to be 0 to 4 volts, VRef/2 is connected to 2 volts
67
5. Analog ground and digital ground
Analog ground is connected to the ground of the analog Vin. Digital ground is connected to the ground of the Vcc pin. 6. CS( Chip Select) Chip select is an active low input used to activate the ADC0804 chip. 7. RD(Read) This is an input signal and is active low. The ADC converts the analog input to its binary equivalent and holds it in an internal register. RD is used to get the converted data out of the ADC0804 chip. When CS=0, if a high-to-low pulse is applied to the RD pin, the 8-bit digital output can be read from D0-D7. The RD pin is also referred to as Output Enable(OE).
68
8. WR( Write , a better name might be “start of Conversion”) This is an active low input used to inform the ADC0804 to start the conversion process. If CS=0, when WR makes a low-to-high transition, the ADC0804 starts converting the analog input value of Vin to an 8-bit digital number 9. INTR( Interrupt, a better name might be “End of Conversion”) This is an output pin and is active low. It is normally high pin and when the conversion is completed, it goes low to signal the CPU that the converted data is ready to be picked up. After INTR goes low, we make CS=0 and send a high- to- low pulse to the RD pin to get the next analog data to be converted.
70
Timing diagram of ADC 0804
71
Interfacing circuit of ADC0804
72
Program for ADC0804 RD BIT P2.5 WR BIT P2.6 INTR BIT P2.7 MYDATA EQU P1 MOV P1,#0FFH SETB INTR CLR WR SETB WR HERE: JB INTR, HERE CLR RD MOV A,MYDATA ACALL CONVERSION ACALL DATA_DISPLAY SETB RD SJMP BACK
73
DAC(0808) INTERFACING
74
Interfacing Circuit of DAC 0808
76
Specifications related to DAC
Resolution: It can be defined as a smallest change in the output corresponding to an input change by one LSB. Accuracy: This is the measure of the difference between the actual output voltage & the expected output voltage. Full scale output voltage: This is the output voltage when binary input has the highest value. For ex: 8-bit 5V DAC have max voltage 5V-19.5mv= V.
77
Generating Staircase waveform
ORG 0H START: CLR A AGAIN: MOV P1,A ;Send data to DAC INC A ;count from 0h to FFh ACALL DELAY ;Let DAC recover CJNE A,#0FFH,GO SJMP START GO: SJMP AGAIN DELAY: MOV R0,#0FFH LOOP: DJNZ R0,LOOP RET END
78
Generating Triangular waveform
ORG 0H START0to1: CLR A AGAIN1: MOV P1,A ;Send data to DAC INC A ;count from 0h to FFh ACALL DELAY ;Let DAC recover CJNE A,#0FFH,GO1 SJMP START1to0 GO1: SJMP AGAIN1 START1to0: MOV P1,A DEC A ACALL DELAY CJNE A,#00H,GO2 DELAY: MOV R0,#0FFH SJMP START0to1 LOOP: DJNZ R0,LOOP GO2: SJMP START1to0 RET END
79
Generating Sine waveform
To generate a sine wave , we first need a table whose values represent the magnitude of the sine of angles between 00 & 3600 The values for the sine function vary from -1.0 to +1.0 for 00 & 3600 angles. Therefore, the table values are integer numbers representing the voltage magnitude for the sine of theta (θ). To generate sine wave we assume the full scale voltage of 10V for DAC output. Full scale output of the DAC is achieved when all the data inputs of the DAC are high. Therefore, to achieve the full scale 10V output, we use the following equation. VOut = 5V + ( 5 X Sin θ)
81
Example
82
Program ORG 0H MOV DPTR,#TABLE MOV R2,#COUNT BACK: CLR A MOVC MOV P1,A INC DPTR DJNZ R2,BACK SJMP AGAIN ORG 0300H TABLE: DB 128,192,238,255,238,192,128,64,17,0,17,64,128
83
Representation of Sine waveform
Volts 10 9 8 7 6 5 4 3 2 1 Degrees
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.