Module5 1 Merged
Module5 1 Merged
8051 Interrupts
Atria Institute of Technology 0000h
0001h
Reset
Department of Electronics and Communication Engineering MOV TMOD,#20H ;T1/8-bit/auto reload 0003h INT0
MOV TH1,#5 ;TH1 = 5 0004h
SETB TR1 ;start the timer 1 …….
BACK: JNB TF1,BACK ;till timer rolls over 000Bh T0
CPL P1.0 ;P1.0 to hi, lo 000Ch
CLR TF1 ;clear Timer 1 flag
……
SJMP BACK ;mode 2 is auto-reload
0013h INT1
……
001Bh T1
8051 Interrupts and Interfacing Application ……
0023h Serial COM
By,
Module-5 NATARAJA N
….
0030h Main
Asst. Prof, Dept. of ECE,
Atria IT-Bangalore. 0031h
…….
Module-5 8051 Interrupts and Interfacing Application Interrupts Module-5 8051 Interrupts and Interfacing Application Interrupts
8051 Interrupts:
Polling can monitor the status of several devices and serve each of them as certain
An interrupt is an external or internal event that interrupts the microcontroller to inform it that a
conditions are met
device needs its service
The polling method is not efficient, since it wastes much of the microcontroller’s time by
A single microcontroller can serve several devices by two ways: Interrupts & Polling polling devices that do not need service
Interrupts ex. JNB TF,target
Whenever any device needs its service, the device notifies the microcontroller by sending
it an interrupt signal The advantage of interrupts is that the microcontroller can serve many devices (not all at
Upon receiving an interrupt signal, the microcontroller interrupts whatever it is doing the same time)
and serves the device Each devices can get the attention of the microcontroller based on the assigned
The program which is associated with the interrupt is called the interrupt service routine priority
(ISR) or interrupt handler For the polling method, it is not possible to assign priority since it checks all devices in a
Polling round-robin fashion
The microcontroller continuously monitors the status of a given device The microcontroller can also ignore (mask) a device request for service
When the conditions met, it performs the service This is not possible for the polling method
After that, it moves on to monitor the next device until every one is serviced.
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Interrupts Module-5 8051 Interrupts and Interfacing Application Interrupts
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Interrupts Module-5 8051 Interrupts and Interfacing Application Interrupts
Serial communication has a single interrupt that belongs to both receive and ORG 0 ;wake-up ROM reset location
transfer LJMP MAIN ;by-pass int. vector table
;---- the wake-up program
ORG 30H
MAIN: Only three bytes of ROM space
.... assigned to the reset pin. We put
the LJMP as the first instruction
END and redirect the processor away
from the interrupt vector table.
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Interrupts Module-5 8051 Interrupts and Interfacing Application Interrupts
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Interrupts Module-5 8051 Interrupts and Interfacing Application Interrupts
Example 11-1
To enable an interrupt, we take the following steps: Show the instructions to (a) enable the serial interrupt, timer 0
interrupt, and external hardware interrupt 1 (EX1),and (b) disable
1. Bit D7 of the IE register (EA) must be set to high to allow the rest of register to take
(mask) the timer 0 interrupt, then (c) show how to disable all the
effect interrupts with a single instruction.
2. The value of EA Solution:
If EA = 1, interrupts are enabled and will be responded to if their corresponding (a) MOV IE,#10010110B ;enable serial,
bits in IE are high ;timer 0, EX1
If EA = 0, no interrupt will be responded to, even if the associated bit in the IE Another way to perform the same manipulation is
register is high SETB IE.7 ;EA=1, global enable
SETB IE.4 ;enable serial interrupt
SETB IE.1 ;enable Timer 0 interrupt
SETB IE.2 ;enable EX1
(b) CLR IE.1 ;mask (disable) timer 0
;interrupt only
(c) CLR IE.7 ;disable all interrupts
D7 D0
EA -- ET2 ES ET1 EX1 ET0 EX0
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Interrupts Module-5 8051 Interrupts and Interfacing Application Interrupts
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Interrupts Module-5 8051 Interrupts and Interfacing Application Interrupts
Example 11-4
Write a program to generate a square wave if 50Hz frequency on pin
... P1.2. This is similar to Example 9-12 except that it uses an interrupt
;--The main program for initialization for timer 0. Assume that XTAL=11.0592 MHz
ORG 0030H ;after vector table space Solution:
MAIN: MOV TMOD,#02H ;Timer 0, mode 2 ORG 0
MOV P0,#0FFH ;make P0 an input port LJMP MAIN
MOV TH0,#-92 ;TH0=A4H for -92 ORG 000BH ;ISR for Timer 0
MOV IE,#82H ;IE=10000010 (bin) enable CPL P1.2
;Timer 0 MOV TL0,#00
SETB TR0 ;Start Timer 0 MOV TH0,#0DCH
RETI
BACK: MOV A,P0 ;get data from P0 ORG 30H
MOV P1,A ;issue it to P1 ;--------main program for initialization
SJMP BACK ;keep doing it loop MAIN:MOV TM0D,#00000001B ;Timer 0, Mode 1
;unless interrupted by TF0 MOV TL0,#00
END MOV TH0,#0DCH
MOV IE,#82H ;enable Timer 0 interrupt
SETB TR0
HERE:SJMP HERE
END
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Interrupts Module-5 8051 Interrupts and Interfacing Application Interrupts
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Interrupts Module-5 8051 Interrupts and Interfacing Application Interrupts
Example 11-5
Level-Triggered Interrupt: Assume that the INT1 pin is connected to a switch that is normally
In the level-triggered mode, INT0 and INT1 pins are normally high
high. Whenever it goes low, it should turn on an LED. The LED is
connected to P1.3 and is normally off. When it is turned on it should Vcc
If a low-level signal is applied to them, it triggers the interrupt stay on for a fraction of a second. As long as the switch is pressed low, P1.3 to LED
the LED should stay on.
Then the microcontroller stops whatever it is doing and jumps to the interrupt INT1
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Interrupts Module-5 8051 Interrupts and Interfacing Application Interrupts
Sampling Low Level-Triggered Interrupt: To ensure the activation of the hardware interrupt at the INTn pin, make sure that
Pins P3.2 and P3.3 are used for normal I/O unless the INT0 and INT1 bits in the IE the duration of the low-level signal is around 4 machine cycles, but no more
register are enabled
This is due to the fact that the level-triggered interrupt is not latched
After the hardware interrupts in the IE register are enabled, the controller keeps
Thus the pin must be held in a low state until the start of the ISR execution
sampling the INTn pin for a low-level signal once each machine cycle
According to one manufacturer’s data sheet,
The pin must be held in a low state until the start of the execution of ISR
If the INTn pin is brought back to a logic high before the start of the
execution of ISR there will be no interrupt 1 MC
If INTn pin is left at a logic low after the RETI instruction of the ISR, another
4 machine cycles
interrupt will be activated after one instruction is executed To INT0 or
1.085us INT1 pins
4 1.085us
note: On reset, IT0 (TCON.0) and IT1 (TCON.2) are both
low, making external interrupt level-triggered
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Interrupts Module-5 8051 Interrupts and Interfacing Application Interrupts
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Interrupts Module-5 8051 Interrupts and Interfacing Application Interrupts
Sampling Edge- Triggered Interrupt: Regarding the IE0 and IE1 bits in the TCON register, the following two points must be
In edge-triggered interrupts emphasized
The external source must be held high for at least one machine cycle, and then held When the ISRs are finished (that is, upon execution of RETI), these bits (TCON.1 and
low for at least one machine cycle TCON.3) are cleared, indicating that the interrupt is finished and the 8051 is ready
to respond to another interrupt on that pin
The falling edge of pins INT0 and INT1 are latched by the 8051 and are held by
During the time that the interrupt service routine is being executed, the INTn pin
the TCON.1 and TCON.3 bits of TCON register
is ignored, no matter how many times it makes a high-to-low transition
Function as interrupt-in-service flags RETI clears the corresponding bit in TCON register (TCON.1 or TCON.3)
It indicates that the interrupt is being serviced now and on this INTn pin, and no There is no need for instruction CLR TCON.1 before RETI in the ISR
new interrupt will be responded to until this service is finished associated with INT0
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Interrupts Module-5 8051 Interrupts and Interfacing Application Interrupts
Example 11-7
What is the difference between the RET and RETI instructions? SERIAL COMMUNICATION INTERRUPT
TI (transfer interrupt) is raised when the last bit of the framed data, the stop bit, is
Explain why we can not use RET instead of RETI as the last
instruction of an ISR.
transferred, indicating that the SBUF register is ready to transfer the next byte
Solution: RI (received interrupt) is raised when the entire frame of data, including the stop bit,
Both perform the same actions of popping off the top two bytes of the is received
stack into the program counter, and marking the 8051 return to where
it left off. In other words, when the SBUF register has a byte, RI is raised to indicate that the
However, RETI also performs an additional task of clearing the received byte needs to be picked up before it is lost (overrun) by new incoming
interrupt-in-service flag, indicating that the servicing of the interrupt serial data
is over and the 8051 now can accept a new interrupt on that pin. If
you use RET instead of RETI as the last instruction of the interrupt
service routine, you simply block any new interrupt on that pin after
the first interrupt, since the pin status would indicate that the interrupt
is still being serviced. In the cases of TF0, TF1, TCON.1, and
TCON.3, they are cleared due to the execution of RETI.
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Interrupts Module-5 8051 Interrupts and Interfacing Application Interrupts
TI
0023H
RI
Serial interrupt is invoked by TI or RI flags
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Interrupts Module-5 8051 Interrupts and Interfacing Application Interrupts
Example 11-8
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 ;-----------------SERIAL PORT ISR
transferred serially. Assume that XTAL=11.0592. Set the baud rate at ORG 100H
9600. SERIAL: JB TI,TRANS;jump if TI is high
Solution: MOV A,SBUF ;otherwise due to receive
ORG 0000H CLR RI ;clear RI since CPU doesn’t
LJMP MAIN RETI ;return from ISR
ORG 23H TRANS: CLR TI ;clear TI since CPU doesn’t
LJMP SERIAL ;jump to serial int ISR
RETI ;return from ISR
ORG 30H
MAIN: MOV P1,#0FFH ;make P1 an input port END
MOV TMOD,#20H ;timer 1, auto reload
MOV TH1,#0FDH ;9600 baud rate The moment a byte is written into SBUF it is framed and transferred
MOV SCON,#50H ;8-bit,1 stop, ren enabled serially. As a result, when the last bit (stop bit) is transferred the TI is
MOV IE,10010000B ;enable serial int. raised, and that causes the serial interrupt to be invoked since the
SETB TR1 ;start timer 1 corresponding bit in the IE register is high. In the serial ISR, we check
BACK: MOV A,P1 ;read data from port 1 for both TI and RI since both could have invoked interrupt.
MOV SBUF,A ;give a copy to SBUF
MOV P2,A ;send it to P2
SJMP BACK ;stay in loop indefinitely
...
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Interrupts Module-5 8051 Interrupts and Interfacing Application Interrupts
Example 11-9
Write a program in which the 8051 gets data from P1 and sends it to
P2 continuously while incoming data from the serial port is sent to P0. ...
Assume that XTAL=11.0592. Set the baud rata at 9600. ;-----------------SERIAL PORT ISR
ORG 100H
Solution: SERIAL: JB TI,TRANS;jump if TI is high
ORG 0000H MOV A,SBUF ;otherwise due to receive
LJMP MAIN MOV P0,A ;send incoming data to P0
ORG 23H CLR RI ;clear RI since CPU doesn’t
LJMP SERIAL ;jump to serial int ISR RETI ;return from ISR
ORG 30H TRANS: CLR TI ;clear TI since CPU doesn’t
MAIN: MOV P1,#0FFH ;make P1 an input port RETI ;return from ISR
MOV TMOD,#20H ;timer 1, auto reload END
MOV TH1,#0FDH ;9600 baud rate
MOV SCON,#50H ;8-bit,1 stop, ren enabled
MOV IE,10010000B ;enable serial int.
SETB TR1 ;start timer 1
BACK: MOV A,P1 ;read data from port 1
MOV P2,A ;send it to P2
SJMP BACK ;stay in loop indefinitely
...
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Interrupts Module-5 8051 Interrupts and Interfacing Application Interrupts
Example 11-10
Clearing RI and Write a program using interrupts to do the following: ...
MOV IE,10010010B ;enable serial int.
TI before RETI (a) Receive data serially and sent it to P0,
(b) Have P1 port read and transmitted serially, and a copy given to SETB TR1 ;start timer 1
P2, SETB TR0 ;start timer 0
(c) Make timer 0 generate a square wave of 5kHz frequency on P0.1. BACK: MOV A,P1 ;read data from port 1
Assume that XTAL-11,0592. Set the baud rate at 4800. MOV SBUF,A ;give a copy to SBUF
MOV P2,A ;send it to P2
Solution:
ORG 0 SJMP BACK ;stay in loop indefinitely
LJMP MAIN ;-----------------SERIAL PORT ISR
ORG 000BH ;ISR for timer 0 ORG 100H
CPL P0.1 ;toggle P0.1 SERIAL:JB TI,TRANS;jump if TI is high
RETI ;return from ISR MOV A,SBUF ;otherwise due to receive
ORG 23H ; MOV P0,A ;send serial data to P0
LJMP SERIAL ;jump to serial interrupt ISR CLR RI ;clear RI since CPU doesn’t
ORG 30H RETI ;return from ISR
MAIN: MOV P1,#0FFH ;make P1 an input port
TRANS: CLR TI ;clear TI since CPU doesn’t
MOV TMOD,#22H;timer 1,mode 2(auto reload)
RETI ;return from ISR
MOV TH1,#0F6H;4800 baud rate
END
MOV SCON,#50H;8-bit, 1 stop, ren enabled
MOV TH0,#-92 ;for 5kHZ wave
...
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Interrupts Module-5 8051 Interrupts and Interfacing Application Interrupts
Example 11-11 We can alter the sequence of interrupt priority by assigning a higher priority to any one of
Discuss what happens if interrupts INT1, TF0, and INT0 are
activated at the same time. Assume priority levels were set by the
the interrupts by programming a register called IP (interrupt priority)
power-up reset and the external hardware interrupts are edge- To give a higher priority to any of the interrupts, we make the corresponding bit in the
triggered. IP register high
Solution: When two or more interrupt bits in the IP register are set to high
If these three interrupts are activated at the same time, they are While these interrupts have a higher priority than others, they are serviced
latched and kept internally. Then the 8051 checks all five interrupts
according to the sequence of Table 11-13
according to the sequence listed in Table 11-3. If any is activated, it
services it in sequence. Therefore, when the above three interrupts
are activated, IE0 (external interrupt 0) is serviced first, then timer 0
(TF0), and finally IE1 (external interrupt 1).
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Interrupts Module-5 8051 Interrupts and Interfacing Application Interrupts
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Interrupts Module-5 8051 Interrupts and Interfacing Application Interrupts
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Interrupts Module-5 8051 Interrupts and Interfacing Application Interrupts
Example 11-14
PROGRAMMING IN C Write a C program that continuously gets a single bit of data from P1.7
and sends it to P1.0, while simultaneously creating a square wave of
The 8051 compiler have extensive support for the interrupts 200 s period on pin P2.5. Use Timer 0 to create the square wave.
They assign a unique number to each of the 8051 interrupts Assume that XTAL = 11.0592 MHz.
Solution:
We will use timer 0 mode 2 (auto-reload). One half of the period is
Interrupt Name Numbers
100 s. 100/1.085 s = 92, and TH0 = 256 - 92 = 164 or A4H
External Interrupt 0 (INT0) 0 #include <reg51.h>
Timer Interrupt 0 (TF0) 1 sbit SW =P1^7;
sbit IND =P1^0;
External Interrupt 1 (INT1) 2 sbit WAVE =P2^5;
Timer Interrupt 1 (TF1) 3 void timer0(void) interrupt 1 {
WAVE=~WAVE; //toggle pin
Serial Communication (RI + TI) 4 }
void main() {
Timer 2 (8052 only) (TF2) 5 SW=1; //make switch input
TMOD=0x02;
TH0=0xA4; //TH0=-92
IE=0x82; //enable interrupt for timer 0
It can assign a register bank to an ISR while (1) {
This avoids code overhead due to the pushes and pops of the R0 – R7 registers IND=SW; //send switch to LED
}
}
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Interrupts Module-5 8051 Interrupts and Interfacing Application Interrupts
Example 11-16
Write a C program using interrupts to do the following: .....
(a) Receive data serially and send it to P0
(b) Read port P1, transmit data serially, and give a copy to P2 void main() {
(c)Make timer 0 generate a square wave of 5 kHz frequency on P0.1 unsigned char x;
Assume that XTAL = 11.0592 MHz. Set the baud rate at 4800. P1=0xFF; //make P1 an input
Solution: TMOD=0x22;
TH1=0xF6; //4800 baud rate
#include <reg51.h>
sbit WAVE =P0^1; SCON=0x50;
TH0=0xA4; //5 kHz has T=200us
void timer0() interrupt 1 {
WAVE=~WAVE; //toggle pin IE=0x92; //enable interrupts
} TR1=1; //start timer 1
TR0=1; //start timer 0
void serial0() interrupt 4 {
if (TI==1) { while (1) {
TI=0; //clear interrupt x=P1; //read value from pins
}
else { SBUF=x; //put value in buffer
P0=SBUF; //put value on pins P2=x; //write value to pins
RI=0; //clear interrupt }
}
} }
.....
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application LCD Module-5 8051 Interrupts and Interfacing Application LCD
LCD Interfacing
LCD Connections:
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application LCD Module-5 8051 Interrupts and Interfacing Application LCD
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application LCD Module-5 8051 Interrupts and Interfacing Application LCD
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application LCD Module-5 8051 Interrupts and Interfacing Application LCD
Display on LCD
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application LCD Module-5 8051 Interrupts and Interfacing Application LCD
RS 0
R/W 1
En L-H
D7 Busy Flag
Communication
Using Busy Flag
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application LCD Module-5 8051 Interrupts and Interfacing Application LCD
Module-5 8051 Interrupts and Interfacing Application TX Module-5 8051 Interrupts and Interfacing Application RX
Transmit serially Receive serially void display(unsigned char value) void main()
#include<reg51.h> 6b. Write an ALP to transfer data serially at 4800
baud rate continuously. Check the output on serial #include<reg51.h> { {
void main()
window1. sbit rs=P3^7; P2=value; char data1;
{
char A[]="microcontrollerlab,0"; sbit rw=P3^6; rs=1; lcdinit();
unsigned char i=0; sbit en=P3^5; rw=0; TMOD=0x20;
//P3=0x03; void delay(unsigned int time) en=1; TH1=0xFD;
TMOD=0x20; { delay(50); SCON =0x50;
TH1=0xFD; unsigned int i,j; en=0; TR1=1;
SCON=0x50; for(i=0;i<time;i++) delay(50); while(1)
TR1=1; for(j=0;j<5;j++); } {
while(1)
} void lcdinit(void) while(SBUF!=0x0D)
{
while(A[i]!='\0') void lcdcmd(unsigned char value) { {
{ { lcdcmd(0x38); while(RI==0);
SBUF=A[i]; P2=value; delay(50); data1=SBUF;
while(TI==0); rs=0; lcdcmd(0x0E); RI=0;
TI=0; rw=0; delay(50); display(data1);
i++; en=1; lcdcmd(0x01); delay(50);
} delay(50); delay(50); }
i=0;
en=0; lcdcmd(0x06); }
}
delay(50); delay(50); }
} }
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application DAC
8051 Interrupts and Interfacing Application 8-input DAC means 256 Discrete Voltage Values.
Similarly we can go for 12,16-bit…. DAC
By,
Module-5 NATARAJA N
Asst. Prof, Dept. of ECE,
Atria IT-Bangalore.
Module-5 8051 Interrupts and Interfacing Application DAC Module-5 8051 Interrupts and Interfacing Application DAC
MC1408(DAC0808):
The Total Current Provided by Iout is a function of Iref & D0-D7 Inputs
We take Iref =2mA , Max Iout =1.99mA
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application DAC Module-5 8051 Interrupts and Interfacing Application DAC
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application DAC Module-5 8051 Interrupts and Interfacing Application DAC
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application DAC Module-5 8051 Interrupts and Interfacing Application DAC
Write a ALP to Generate a Sine Wave using DAC0808. Show the Calculation for Full Scale Voltage of 10V at the output.
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application DAC Module-5 8051 Interrupts and Interfacing Application DAC
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Stepper Motor
A
Atria Institute of Technology
Bengaluru-560024
Department of Electronics and Communication Engineering
N
Stepper Motor:
Translates Electrical Pulses into Mechanical
S
D B Movement
Disk Drive, Robotics etc…. for Position Control
It Consists of Rotor & Stator
By,
Module-5 NATARAJA N Fig: Rotor Alignment
Asst. Prof, Dept. of ECE,
Atria IT-Bangalore.
Module-5 8051 Interrupts and Interfacing Application Stepper Motor Module-5 8051 Interrupts and Interfacing Application Stepper Motor
0 0
A A
Step # A B C D HEX S Step # A B C D HEX
1 0 1 1 0 6 1 0 1 1 0 6
N
N N
0 1 0 S N S N 1
S S
D B D B
N
1 C 1 C
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Stepper Motor Module-5 8051 Interrupts and Interfacing Application Stepper Motor
0 0
A A
S Step # A B C D HEX S Step # A B C D HEX
1 0 1 1 0 6 1 0 1 1 0 6
N N
2 0 0 1 1 3
0 S N S N 1 1 N S N S 0
D B D B
S S
N N
1 C 1 C
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Stepper Motor Module-5 8051 Interrupts and Interfacing Application Stepper Motor
0 1
A A
S Step # A B C D HEX N Step # A B C D HEX
1 0 1 1 0 6 1 0 1 1 0 6
N S
2 0 0 1 1 3 2 0 0 1 1 3
1 N S N S 0 1 N S N S 0 3 1 0 0 1 9
D B D B
S N
N S
1 C 0 C
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Stepper Motor Module-5 8051 Interrupts and Interfacing Application Stepper Motor
1 1
A A
N Step # A B C D HEX N Step # A B C D HEX
1 0 1 1 0 6 1 0 1 1 0 6
S S
2 0 0 1 1 3 2 0 0 1 1 3
1 N S N S 0 3 1 0 0 1 9 0 S N S N 1 3 1 0 0 1 9
D B D B 4 1 1 0 0 C
N N
S S
0 C 0 C
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Stepper Motor Module-5 8051 Interrupts and Interfacing Application Stepper Motor
1
A Program:
N Step # A B C D HEX
1 0 1 1 0 6
S
2 0 0 1 1 3
0 S N S N 1 3 1 0 0 1 9
D B 4 1 1 0 0 C
N
S
0 C
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Stepper Motor Module-5 8051 Interrupts and Interfacing Application Stepper Motor
1 1
A Step Angle: Min degree of Rotation Associated with Single Step A
N N
Step per Revolution: Total No. of Steps need to Rotate one
S Complete rotation(360 degree) S Step Angle: 90 Degree
Step per Revolution =4
Eg: Step Angle = 2𝑜 if No. of Steps per Revolution is 180. No. of Rotor Teeth =4/4 =1
0 S N 0 S N Moves per 4-Step Sequence =360
S N 1 S N 1
After Completing every 4 Steps, The Rotor move only one tooth
D B Pitch D B
N In a Stepper Motor with 200 Step per Revolution, the Motor has N
50 Teeth since 4 X 50 =200 Steps.
S S
0 C 0 C
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Stepper Motor Module-5 8051 Interrupts and Interfacing Application Stepper Motor
Ex: Write a Program to rotate a motor 64 Degree in the Clock wise. The Motor has a step angle of 2 Degree.
Use the 4-StepSequence.
Table: Normal 4-Step Sequence (Two Phase Sequence)
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Stepper Motor Module-5 8051 Interrupts and Interfacing Application Stepper Motor
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Stepper Motor Module-5 8051 Interrupts and Interfacing Application Stepper Motor
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT
Module-5 8051 Interrupts and Interfacing Application Stepper Motor Module-5 8051 Interrupts and Interfacing Application Stepper Motor
Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT Atria Institute of Technology NATARAJA N, Dept. of ECE, AIT