Professional Documents
Culture Documents
ECX4236
NAME: Y.M.L.KUMARA
DATE: 22,23/09/2010
GROUP: CL05
Experiment 01
Write an ALP to generate the PWM signal having 25% duty cycle with 40Hz.
Step 01
Calculation
Required frequency=40Hz
Then time period =1/40 = 25000 micro seconds
Required time for delay loop= 25000/100=250 Micro seconds
Let’s find the time value= 65536-250=65286 dec
=ff06H
Then TL0=06H and TH0=ffH
ORG 0H
DELAY:
MOV TMOD ,#01H
ORG 7000H
MAIN:CLR P1_6
MONITOR:
CLR P1_6
MOV R5,#25
ACALL DELAY
SETB P1_6
CLR P1_4
MOV R5,#75
ACALL DELAY
SETB P1_4
SJMP MONITOR
DELAY:
MOV TMOD ,#01H
Finally check the result with Oscilloscope and it gives 38.461Hz signal because of this deviation is
due to instructions delay that omitted in the programme.
Volts
2.5
2 1 1234 time
OBSERVATION
= 26ms
= 38.46Hz
Experiment 02
Write a ALP to display character “A” on LCD display
ORG 7000H
MOV A,65
CLR 90H
MOV DPTR, #0FFF3H
MOVX @DPTR,A
MOV R0,#0
DJNZ R0,$
DJNZ R0,$
CLR 91H
SETB 91H
END
Experiment 03
Figure below depicts the waveform of quadrature outputs of the quadrature encoder of a DC
motor. Channel “A” connected to T0 pin and channel “B” connected to T1 pin of the 8051
microcontroller. Table 3.1 and table 3.2 depict gray coding of quadrature outputs as follows.
Write an assembly language program to identify the speed and rotational direction (whether the
clockwise or counter‐clockwise) of the encoder using 8051 counters.
Step 01
Write a ALP to light a LED when it’s clockwise and light an another LED when anticlockwise.
Assume above A & B signals are connected to I3 and I2 respectively.
ORG 7000H
CLR TF0
SETB P3_4
SETB P3_5
MOV TMOD,#6H
MOV TL0,#0FEH
SETB TR0 ; START TIMER 0
FOLLINGEDGE:
JNB P3_5,CLOCKWISE
CLR P1_6
RET
CLOCKWISE:
CLR P1_4
RET
END
Step 02
Write a ALP to display “C” on LCD when clockwise and “A” when anticlockwise. Assume above A
& B signals are connected to I3 and I2 respectively.
ORG 7000H
CLR TF0
SETB P3_4
SETB P3_5
MOV TMOD,#6H
MOV TL0,#0FEH
SETB TR0 ;START TIMER 0
CLOCKWISE:
MOV R5,#67
LCALL LCD
RET
LCD:
MOV A,R5
CLR 90H
MOV DPTR,#0FFF3H
MOVX @DPTR,A
MOV R0,#0
DJNZ R0,$
DJNZ R0,$
CLR 91H
SETB 91H
RET
END
Step 03
Write an ALP to make delay 1minutes.
ORG 7000H
CLR P1_5
CLR TF1
MOV TMOD,#10H
ACALL DELAY
SETB P1_5
DELAY:
H1: MOV R2,#0AH
H2: MOV R3,#64H
H3: MOV TL1,#0A0H
MOV TH1,#15H
SETB TR1
Write an assembly language program to identify the speed and rotational direction (whether the
clockwise or counter‐clockwise). Display “C” on LCD when clockwise and “A” when anticlockwise
and speed in RPM.
ORG 7000H
CLR TF0
SETB P3_4
SETB P3_5
MOV TMOD,#6H
MOV TL0,#0FEH
SETB TR0 ;START TIMER 0
FOLLINGEDGE:
LCALL 4100H
JNB P3_5,CLOCKWISE
MOV R5,#65
LCALL LCD
RET
CLOCKWISE:
MOV R5,#67
LCALL LCD
RET
LCD:
MOV A,R5
CLR 90H
MOV DPTR,#0FFF3H
MOVX @DPTR,A
MOV R0,#0
DJNZ R0,$
DJNZ R0,$
CLR 91H
SETB 91H
RET
ACALL DELAY
MOV R5,TH0
LCALL LCD
MOV R5,TL0
LCALL LCD
DELAY:
H1: MOV R2,#0AH
H2: MOV R3,#64H
H3: MOV TL1,#0A0H
MOV TH1,#15H
SETB TR1