You are on page 1of 6

School of Electronics and Communication Engineering

4th Sem ECE/ECM - Microcontrollers and Applications [B20EN0403]

1a) Calculating the total machine cycle = 3m 5M


Calculating time delay = 2m
Given machine cycle = 1.085 µsec (12/11.0592MHz) , Time delay?
Instruction Cycles Total Machine Cycles
Delay: MOV R2, #100 1 1
Again: MOV R3, #50 1 100
Here NOP 1 5000
NOP 1 5000
NOP 1 5000
DJNZ R3, Here 2 10000
DJNZ R2, Again 2 200
RET 2 2
Total (C) = 25303

Time delay = C x 1.085µsec = 25303 x 1.085µsec = 27.45 msec

1b) Modes & Operation 5

i) MOV TMOD, #20h – (1.5m)


Timer 1 as an interval timer in mode 2
Timer 0 as interval timer in mode 0
Start/stop operation of both timers controlled by software

ii) MOV TMOD, #51h – (1.5m)


Timer 1 as an event counter in mode 1
Timer 0 as an interval timer mode 1
Start/stop operation of both timers controlled by software.

iii) MOV TMOD, #18h – (2m)


Timer 1 as an interval timer in mode 1, start/stop operation of both timer
controlled by software
Timer 0 an interval timer in mode 0, start/stop operation controlled by hardware
(INT0 pin)

2a) List different operating modes of timers – 1m 5


Steps to generate timer delay in mode 1 operations – 4m
M1 M0 Mode Operating Mode
0 0 0 13-bit Timer/Counter
TH1 TL1
8-bit 5-bit
0 1 1 16-bit Timer/Counter
TH1 TL1
8-bit 8-bit
1 0 2 8-bit auto reload Timer/Counter
[TH1 hold a value that is to be reloaded
into TL1 each time when TF1 overflow]
1 1 3 Split Timer Mode

Steps
1. Initialized TMOD for the required Timer0/1 and mode 0/1/2
2. Load the initial count value in register TL and TH
!"# %"&'(&)*#
Initial Value = Maximum value – [Required delay x +,
]+1
3. Start the timer using instruction SETB TR0/1 (bit of TCON register)
4. Wait until the timer flag TF0/1 of TCON register is set [Remember TF0/1 = 1
when timer overflows the maximum value]
5. Stop the timer using instruction CLR TR0/1 (bit of TCON register)
6. Clear TF0/1 flag
7. Repeat from step 2 for the next delay.

2b) 8051-LCD interfacing circuits – 2m 5


explaining use of register select, read/write, and enable pins of LCD – 1mx3=3m

Read/Write(RW)
• This signal is used to write the data/cmd to LCD and reads the busy flag of
LCD.
• For write operation the RW should be LOW and for read operation the
R/W should be HIGH.
Register Select(RS)
• The LCD has two register namely a Data register and Command register.
• Any data that needs to be displayed on the LCD has to be written to the
data register of LCD.
• Command can be issued to LCD by writing it to Command register of
LCD.

This signal is used to differentiate the data/cmd received by the LCD.

If the RS signal is LOW then the LCD interprets the 8-bit info
as Command and writes it Command register and performs the action as
per the command.
• If the RS signal is HIGH then the LCD interprets the 8-bit info as data and
copies it to data register. After that the LCD decodes the data for
generating the 5x7 pattern and finally displays on the LCD.
Enable(EN):
• This pin is used to send the enable trigger to LCD.
• After selecting the data/cmd register, Selecting the Write operation. A
HIGH-to-LOW pulse has to be send on this enable pin which will latch the
info into the LCD register and triggers the LCD to act accordingly

3a) a) Significance of the SCON register. 5


Diagram – 1m
Explaining the Significance of SCON reg– 4m

• SCON is an 8-bit register used to program the start bit, stop bit, and data bits of
data framing.
• This register is used to configure baud rate, synchronization clock source.
• It contains status bits which indicate whether the data is transmitted completely
and any new data is received.
• SM0, SM1 - They determine the framing of data by specifying the number of bits
per character, and the start and stop bits

• SM2 - This enables the multiprocessing capability of the 8051


• REN (Receive Enable)
• When it is high, it allows 8051 to receive data on RxD pin
• When it is low, the receiver is disabled.
• TB8/RB8
• Not used widely, 9-bit of data to be transmitted/ received in mode 2 and
mode 3
• TI (transmit interrupt)
• When 8051 finishes the transfer of 8-bit character it raises TI flag to indicate
that it is ready to transfer another byte
• Must be cleared by software
• RI (receive interrupt)
• When 8051 receives data serially via RxD, it gets rid of the start and stop bits
and places the byte in SBUF register
• It raises the RI flag bit to indicate that a byte has been received and should be
picked up before it is lost
• Must be cleared by software

3b) Calculation/ Formulas – 1m 5


Table – 1m
Program
• Initialization the array – 2m
• Logic using while & for loop – 1m

-.// 012/3 42/.3 -.// 012/3 42/.3


• Vout = [ ,
+( ,
sin q)] V = [5 + (5 sin q)] V
56.7_92: +; <
• Resolution of DAC = = = 39.06mV
,) ,=
out V
• Voltage Values sent to DAC (D7 to D0) = >306/.7?6@ 6- ABC
Angle q Sine q Vout Voltage Values
(degree) 5V + (5sin q ) sent to DAC
0 0 5 128 d = 80 h
30 0.5 7.5 192 d = C0 h
60 0.866 9.33 238 d = EE h
90 1.0 10 255 d = FF h D7..D0 V / Volts

120 0.866 9.33 238 FFh


10
150 0.5 7.5 192 9 V = 5 + 5 * sin q
8
180 0 5 128 7
210 - 0.5 2.5 64 d = 40 h 6
80h 5
240 - 0.866 0.669 17d = 11 h
4
270 - 1.0 0 0d=0h 3
2
300 - 0.866 0.669 17
1 q /Degrees
330 - 0.5 2.5 64 0
30 90 150 210 270
360 0 5 128 330

Program
# include <reg51.h>
void main()
{
unsigned chat table [13] = {128, 192, 238, 255, 238, 192, 128, 64, 17, 0, 17, 64, 128} ;
unsigned int i ;
P0 = 0x00 ; // output port
while(1)
{
for ( i = 0; i < 13 ; i ++)
P0 = table [i];
}
}

4a) Program to send message “Good Luck” 5


• Initialization TMOD, TH1, SCON – 1.5m
• Logic – 2m
• Copying data to SBUF, Monitoring flag TI, Returning – 1.5m

ORG 00h
MOV TMOD, #20h
MOV TH1, #0FDh or MOV TH1, #-3
MOV SCON, #50h
SETB TR1
Again: MOV R2, #09
MOV DPTR, #Msg
Back: CLR A
MOVC A, @A+DPTR
ACALL Send
INC DPTR
DJNZ R2, Back
SJMP Again

Send: MOV SBUF, A


Wait: JNB TI, Wait
CLR TI
RET
Msg: DB ‘GOOD LUCK’

END

4b) Block Diagram to show interfacing of stepper motor – 1m 5


Program
• Using header file, Initializing the port as input – 1m
• Sending the values in sequence (11,22,44,88) – 2m
• Delay function – 1m

Wave Drive Mode


Steps Coil 1 Coil 2 Coil 3 Coil 4 Code in Hex

1 1 0 0 0 08

2 0 1 0 0 04

3 0 0 1 0 02

4 0 0 0 1 01

#include <reg51.h>
void delay (unsigned int x)
{
for( ; x>0 ; x-- );
}
void main ()
{
P0=0x00; // output
while(1)
{
P1 = 0x11;
delay(500);
P1 = 0x22;
delay(500);
P1 = 0x44;
delay(500);
P1 = 0x88;
delay(500);
}
}

You might also like