Showing posts with label Microcontroller. Show all posts
Showing posts with label Microcontroller. Show all posts

Wednesday, 28 September 2011

Traffic Light


8051 MICROCONTROLLER BASED EXPERIMENT (SIMPLE CONTROL APPLICATIONS)
                                                                               TRAFFIC LIGHT CONTROLLER
AIM:
            To write an assembly language program to control the traffic light signal using the microprocessor 8085
APPARATUS REQUIRED:
                                    8051 kit, power chord
THEORY:
                        A simple contraption of a traffic control system is shown in the figure where the signaling lights are simulated by the blinking or ON – OFF control of LED’s.  The signaling lights for the pedestrian crossing are simulated by the ON – OFF control of dual colour LED’s.
                        A model of a four road – four lane junction, the board has green, yellow and red LED’s which are the green, orange and red signals of an actual systems. 12 LEDs are used on the board.  In addition 8 dual colour LEDs are used which can be made to change either to red or to green.
                        The control of the LEDs is as follows:
                        The board communicates with the microprocessor trainer by means of a 26 core cable which is connected to the output pins of any parallel port of trainer.
                        The outputs (i.e. port) are the inputs to buffers 7406 whose outputs drive the LEDs.  The buffered output applied to the cathode of the LEDs decides whether it is ON or OFF.                   
  
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
410A
410B
410C
410D
410E
410F
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
411A

SUBROUTINE

411B
411C
411D
411E
411F
4120
4121


4122
4123

4124
4125
4126

4127

4128
4129

412A
412B
412C
21
00
45
0E
0C
7E
D3
0F
23
7E
D3
0C
23
7E
D3
0D
CD
1B
41
23
0D
C2
09
41
C3
00
41


C5
0E
05
11
FF
FF
1B


7A
B3

C2
21
41

0D

C2
1E

41
C1
C9
START








LOOP1



















DELAY

LOOP3


LOOP2













LXI


MVI

MOV
OUT

INX
MOV
OUT

INX
MOV
OUT


CALL

DELAY
DCR
JNZ


JMP




PUSH
MVI

LXI


DCX


MOV
ORA

JNZ



DCR

JNZ



POP
RET

H, 4500 H


C, OC H

A, M
OF H

H
A, M
OC H

H
A, M
OD H


DELAY

H
C
LOOP 1


START




B
C, 05

D, FFFF


D


A, D
E

LOOP 2



C

LOOP 3



B
Initialize the HLReg. Pair to 4500 H

Initialize the count Reg.  C to OC H
Initialize the ports of 8255.


Send the data to switch ON / OFF
The LED’s through port A.
Switch ON / OFF the LED’s through port B



Call the subroutine delay
Get the next data and decrement the count.
If the count is not zero go to instruction labeled “LOOP 1”
Jump unconditionally to the instruction labeled “START”


Save the contents of BC Reg. Pair to stack pointer.
Initialize Reg. C to hold data 05 H.
Get the data FFFF H in DE Reg. Pair.
Decrement the content of DE Reg. Pair
Check whether the contents of DE Reg. Pair is zero.
If the contents of DE Reg. Pair is not zero go to instruction labeled LOOP 2
Decrement the content of Reg. C
If the contents of Reg. C is not zero go to instruction labeled “LOOP 3”
Move the contents of stack pointer to BC Reg. Pair
Return to the main program.




RESULT:
Thus an ALP  to control the traffic light signal was written and executed.

KEYBOARD CONTROL

Aim
To write an assembly language program to read a key code and scan from keyboard.
Program
Code segment
Assume cs: code , ds:code
Org 1000h
Mov si,1200h
Mov ah,00h ;                         bios call for key status read
Int 16h
Mov [si] , ah ;                       store the key code
Inc si
Mov [si], ah ;                        store the scan code
Mov ah, 4ch ;                        dos call for program termination
Int 21h
Code ends
End

Result:
Thus keyboard, display control and file manipulation program are executed by using BIOS/DOS call.

BIOS/DOS CALLS – FILE MANIPULATION
AIM:
To open a file using DOS calls.
ALGORITHM:
1.      Initialize the data segment, file name and the message to be displayed.
2.      Set the file attribute to create a file using a DOS call.
3.      If the file is unable t o create a file display the message 
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
FILENAME DB “SAMPLE.DAT”, “$”
MSG DB 0DH, 0AH, “FILE NOT CREATED”, ODH, OAH, “$”
DATA ENDS
CODE SEGMENT
START:          MOV AX, DATA
                        MOV DS, AX
                        MOV DX, OFFSET FILENAME
                        MOV CX, 00H
                        MOV AH, 3CH
                        INT 21H
                        JNC LOOP1
                        MOV AX, DATA
                        MOV DS, AX
                        MOV DX, OFFSET MSG
                        MOV AH, 09H
                        INT 21H
LOOP1           MOV AH, 4CH
                        INT 21H
CODE ENDS
END START
RESULT:
    Thus the file manipulation using DOS calls is written and executed.

BIOS /DOS CALL, KEYBOARD, CONTROL, DISPLAY FILE MANIPULATION USING 8086
BIOS/DOS CALLS – DISPLAY CONTROL
AIM:
      To display a message on the CRT screen of a microcomputer using DOS calls.
ALGORITHM:
1.      Initialize the data segment and the message to be displayed.
2.      Set function value for display.
3.      Point to the message and run the interrupt to display the message in the CRT.
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
MSG DB 0DH, 0AH, “GOOD MORNING” , ODH, OAH, “$”
DATA ENDS
CODE SEGMENT
START:    MOV AX, DATA
                  MOV DS, AX
                  MOV AH, 09H
                  MOV DX, OFFSET MSG
                  INT 21H
                  MOV AH, 4CH
                  INT 21H
CODE ENDS
END START
RESULT:
Thus the  message is displayed on the CRT screen of a microcomputer using DOS calls

Stepper Motor


8051 MICROCONTROLLER BASED EXPERIMENT (SIMPLE CONTROL APPLICATIONS)
STEPPER MOTOR
AIM:
            To write an assembly language program to run a stepper motor at different speed using 8051.
APPARATUS REQUIRED:
                                    8051 kit, power chord
ALGORITHM:
1.      Start the program.
2.      Move the address location to DPTR.
3.      Move the content of DPTR to A.
4.      PUSH the higher and lower byte address to DPH and DPL.
5.      Move immediate data to respective register.
6.      Give the delay signal to run the motor.
7.      Move the content of A TO dptr.
8.      POP the higher and lower byte address to DPH and DPL.
9.      Increment the DPTR.
10. End the program.

PROGRAM:    
ADDRESS
LABEL
OPCODE
MNEMONICS
OPERAND
4100
START
90,45,00
MOV
DPTR, #4500
4103

78,04
MOV
R0,#04
4105

E0
MOVX
A,@DPTR
4106

C0,83
PUSH 
DPH
4108

C0,82
PUSH
DPL
410A

90,FF,C0
MOV
DPTR, #FFC0
410D

7A,01
MOV
R2, #04
410F

79,22
MOV
R1, #0FF
4111
DLY1
7B,FF
MOV
R3, #0FF
4113
DLY
DB,FF
DJNZ
R3,DLY
4115

D9,FC
DJNZ
R1,DLY1
4117

DA,FA
DJNZ
R2,DLY1
4119

F0
MOVX
@DPTR,A
411A

D0,82
POP
DPL
411C

D0,83
POP
DPH
411E

A3
INC
DPTR
411F

D8,E4
DJNZ
R0,J0
4121

80,DD
SJMP
START
4123


END

4500
09,05,06,0A

FORWARD DATA: 09, 05, 06,0A
REVERSE DATA: 0A, 06, 05, and 09.
FAST DATA: 0F, 0A, 01, 02.
RESULT:
            Thus the stepper motor is observed to be rotating in different speed.