This Project can be used with the three phase Induction motors. The circuit will take the full control of the motor and it will protect the motor from several faults such us over voltage and under voltage and the circuit will switch on the motor under safety conditions.
CLICK HERE TO DOWNLOAD FULL REPORT:
Source code
INCLUDE REG_52.PDF
PH1 EQU P3.0
PH2 EQU P3.1
PH3 EQU P3.2
LED1 EQU P1.0 ;AUTO ON
LED2 EQU P1.1 ;AUTO OFF
LED3 EQU P1.2 ;MOTOR
;ONRLY EQU P2.0
OFFRLY EQU P2.1
AUTOON EQU P2.6
AUTOOFF EQU P2.7
TIM1 EQU P2.2
TIM2 EQU P2.3
TIM3 EQU P2.4
TIM4 EQU P2.5
; ***LCD CONTROL***
LCD_RS EQU P0.0 ;LCD REGISTER SELECT LINE
LCD_E EQU P0.1 ;LCD ENABLE LINE
LCD_DB4 EQU P0.3 ;PORT 1 IS USED FOR DATA
LCD_DB5 EQU P0.4 ;USED FOR DATA
LCD_DB6 EQU P0.5 ;FOR DATA
LCD_DB7 EQU P0.6 ;FOR DATA
; ***CURSOR CONTROL INSTRUCTIONS***
OFFCUR EQU 0CH
BLINKCUR EQU 0DH
; ***DISPLAY CONTROL INSTRUCTIONS***
CLRDSP EQU 01H
ONDSP EQU 0CH
; ***SYSTEM INSTRUCTIONS***
CONFIG EQU 28H ; 4-BIT DATA,2 LINES,5X7 MATRIX LCD
ENTRYMODE EQU 6 ; INCREMENT CURSOR DON'T SHIFT DISPLAY
; ---------==========----------==========---------=========---------
DSEG ; This is internal data memory
ORG 20H ; Bit adressable memory
FLAGS: DS 1
LD1 BIT FLAGS.0
LD2 BIT FLAGS.1
MOT BIT FLAGS.2
NEW: DS 1
NEW1 BIT NEW.0
NEW2 BIT NEW.1
NEW3 BIT NEW.2
NEW4 BIT NEW.3
NEW5 BIT NEW.4
MOTT BIT NEW.5
TIM: DS 1 ;scrolling display
SCRL: DS 1 ;count for scr disp
OFF_TIME: DS 1
CSEG ; Code begins here
;---------==========----------==========---------=========---------
; PROCESSOR INTERRUPT AND RESET VECTORS
;---------==========----------==========---------=========---------
ORG 00H ; Reset
JMP MAIN
ORG 001BH ;Timer Interrupt1
JMP SCROLL
; ---------==========----------==========---------=========---------
; Main routine. Program execution starts here.
; ---------==========----------==========---------=========---------
MOV SP,#60H
MOV FLAGS,#00H
MOV NEW,#00H
MOV OFF_TIME,#00H
CLR OFFRLY
SETB LED1
SETB LED2
SETB LED3
CALL RESETLCD4
CALL INITLCD4
CALL TITLES
SETB NEW2
MOV TMOD,#11H ; Scrolling Display
MOV TL1,#08H
MOV TH1,#01H
SETB ET1
MOV SCRL,#00H
MOV TIM,#120
SETB TR1
SETB EA
UP: SETB PH1 ;
SETB PH2
SETB PH3
SETB AUTOON
SETB AUTOOFF
;Chk if motor is on
JNB AUTOON,HJ1 ;chk auto on
JNB AUTOOFF,HJ2 ;chk auto off
CALL DISP
JNB MOT,UP
JNB PH1,MOTOR_OFF
JB PH2,MOTOR_OFF
JB PH3,MOTOR_OFF
AJMP UP
UP4: JNB AUTOON,$ ;DEBOUNCE FOR AUTO ON KEY
CALL DELAY1
JNB AUTOON,$
SETB LED1
AJMP UP
HJ1: JB MOT,UP
;AUTO ON
JNB AUTOON,$
CALL DELAY1
JNB AUTOON,$
CLR LED1
UP3: JNB AUTOON,UP4
SETB NEW4
CALL DISP
JNB PH1,UP3
JB PH2,UP3
JB PH3,UP3
SETB OFFRLY
SETB MOT ;set motor bit
CLR LED3
CLR LD1
SETB MOTT
AJMP UP
HJ2: ;AUTO OFF
JNB AUTOOFF,$
CALL DELAY1
JNB AUTOOFF,$
JNB MOT,UP1
SETB NEW5
CLR LED2
CALL DELAY
AJMP SET_TIMER
UP1: AJMP UP
MOTOR_OFF:
JB LD1,UP1 ;chk motor status skip if motor is in off
SETB LED1
SETB LED2
SETB LED3
CLR MOT
CLR TR0
CLR TF0
CLR OFFRLY
SETB LD1
CLR NEW5
CLR NEW4
CLR MOTT
AJMP UP
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SET_TIMER:
SETB TIM1
SETB TIM2
SETB TIM3
SETB TIM4
SETB PH1
SETB PH2
SETB PH3
SETB AUTOOFF
JB TIM1,VB1
MOV OFF_TIME,#01H
CALL HALF_HR_DELAY
AJMP MOTOR_OFF
VB1: JB TIM2,VB2
MOV OFF_TIME,#02H
CALL HALF_HR_DELAY
CALL HALF_HR_DELAY
AJMP MOTOR_OFF
VB2: JB TIM3,VB3
MOV OFF_TIME,#03H
CALL HALF_HR_DELAY
CALL HALF_HR_DELAY
CALL HALF_HR_DELAY
AJMP MOTOR_OFF
VB3: JB TIM4,VB4
MOV OFF_TIME,#04H
CALL HALF_HR_DELAY
CALL HALF_HR_DELAY
CALL HALF_HR_DELAY
CALL HALF_HR_DELAY
AJMP MOTOR_OFF
VB4: AJMP UP
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HALF_HR_DELAY:
MOV TMOD,#11H ;time delay for 1/2 hour
MOV R5,#30 ;count for 1/2 hour (30 for 1/2 Hour)
TP1: MOV R6,#60 ;count for 1 min (60 FOR 1 MIN)
TP: CPL LED2
MOV R7,#20 ;start timer for 1 SEC (20 for 1 Sec (50ms X 20=1 sec)
UP2: MOV TL0,#0AAH
MOV TH0,#3CH
SETB TR0
FGD: JNB AUTOOFF,DFS
JNB PH1,MOTOR_OFF1
JB PH2,MOTOR_OFF1
JB PH3,MOTOR_OFF1
JNB TF0,FGD
CLR TR0
CLR TF0
DJNZ R7,UP2
DJNZ R6,TP
DJNZ R5,TP1
RET
UPP: AJMP UP
MOTOR_OFF1:
JB LD1,UPP ;chk motor status skip if motor is in off
SETB LED3
SETB MOT
CLR OFFRLY
DFS: CLR TR0
CLR TF0
CLR MOTT
RET
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DELAY:
MOV R1,#0FFH
RE1: MOV R2,#0FFH
RE: NOP
DJNZ R2,RE
DJNZ R1,RE1
RET
;**********************************************************
DELAY1:
MOV R1,#9FH
REA1: MOV R2,#0FFH
REA: NOP
DJNZ R2,REA
DJNZ R1,REA1
RET
;**********************************************************
;##########################################################
; DISPLAY ROUTINES
;##########################################################
TITLES:
MOV DPTR,#MSAG
CALL LCD_MSG
RET
MSAG:
DB 1H,81H,'3 Phase Motor',0C0H,'Protection @ LCD',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TITLE1:
MOV DPTR,#MSAG1
CALL LCD_MSG
RET
MSAG1:
DB 1H,81H,'## R Phase: ##',0C1H,'Voltage Normal ',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TITLE2:
MOV DPTR,#MSAG2
CALL LCD_MSG
RET
MSAG2:
DB 1H,81H,'## Y Phase: ##',0C1H,'Voltage Normal ',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TITLE3:
MOV DPTR,#MSAG3
CALL LCD_MSG
RET
MSAG3:
DB 1H,81H,'## B Phase: ##',0C1H,'Voltage Normal ',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TITLE11:
MOV DPTR,#MSAG4
CALL LCD_MSG
RET
MSAG4:
DB 1H,81H,'## R Phase: ##',0C0H,'Voltage ABNormal',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TITLE21:
MOV DPTR,#MSAG5
CALL LCD_MSG
RET
MSAG5:
DB 1H,81H,'## Y Phase: ##',0C0H,'Voltage ABNormal',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TITLE31:
MOV DPTR,#MSAG6
CALL LCD_MSG
RET
MSAG6:
DB 1H,81H,'## B Phase: ##',0C0H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 1H,80H,'OFF Timer: 30Min',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TIMER2:
MOV DPTR,#MSAG14
CALL LCD_MSG
RET
MSAG14:
DB 1H,80H,'OFF Timer: 1Hr',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TIMER3:
MOV DPTR,#MSAG15
CALL LCD_MSG
RET
MSAG15:
DB 1H,80H,'OFF Timer: 1:30',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TIMER4:
MOV DPTR,#MSAG16
CALL LCD_MSG
RET
MSAG16:
DB 1H,80H,'OFF Timer : 2:00',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TIMER5:
MOV DPTR,#MSAG17
CALL LCD_MSG
RET
MSAG17:
DB 0C2H,'Time : ',00H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;**********************************************************
; INITIALIZE THE LCD 4-BIT MODE
;**********************************************************
INITLCD4:
CLR LCD_RS ; LCD REGISTER SELECT LINE
CLR LCD_E ; ENABLE LINE
MOV R4, #CONFIG; FUNCTION SET - DATA BITS,
; LINES, FONTS
CALL WRLCDCOM4
MOV R4, #ONDSP ; DISPLAY ON
CALL WRLCDCOM4
MOV R4, #ENTRYMODE ; SET ENTRY MODE
CALL WRLCDCOM4 ; INCREMENT CURSOR RIGHT, NO SHIFT
MOV R4, #CLRDSP; CLEAR DISPLAY, HOME CURSOR
CALL WRLCDCOM4
RET
; **********************************************************
; SOFTWARE VERSION OF THE POWER ON RESET
; **********************************************************
RESETLCD4:
CLR LCD_RS ; LCD REGISTER SELECT LINE
CLR LCD_E ; ENABLE LINE
CLR LCD_DB7 ; SET BIT PATTERN FOR...
CLR LCD_DB6 ; ... POWER-ON-RESET
SETB LCD_DB5
SETB LCD_DB4
SETB LCD_E ; START ENABLE PULSE
CLR LCD_E ; END ENABLE PULSE
MOV A, #4 ; DELAY 4 MILLISECONDS
CALL MDELAY
SETB LCD_E ; START ENABLE PULSE
CLR LCD_E ; END ENABLE PULSE
MOV A, #1 ; DELAY 1 MILLISECOND
CALL MDELAY
SETB LCD_E ; START ENABLE PULSE
CLR LCD_E ; END ENABLE PULSE
MOV A, #1 ; DELAY 1 MILLISECOND
CALL MDELAY
CLR LCD_DB4 ; SPECIFY 4-BIT OPERATION
SETB LCD_E ; START ENABLE PULSE
CLR LCD_E ; END ENABLE PULSE
MOV A, #1 ; DELAY 1 MILLISECOND
CALL MDELAY
MOV R4, #CONFIG; FUNCTION SET
CALL WRLCDCOM4
MOV R4, #08H ; DISPLAY OFF
CALL WRLCDCOM4
MOV R4, #1 ; CLEAR DISPLAY, HOME CURSOR
CALL WRLCDCOM4
MOV R4,#ENTRYMODE ; SET ENTRY MODE
ACALL WRLCDCOM4
JMP INITLCD4
; **********************************************************
; SUB WRITES A COMMAND WORD TO THE LCD
; COMMAND MUST BE PLACED IN R4 BY CALLING PROGRAM
; **********************************************************
WRLCDCOM4:
CLR LCD_E
CLR LCD_RS ; SELECT SEND COMMAND
PUSH ACC ; SAVE ACCUMULATOR
MOV A, R4 ; PUT DATA BYTE IN ACC
MOV C, ACC.4 ; LOAD HIGH NIBBLE ON DATA BUS
MOV LCD_DB4, C ; ONE BIT AT A TIME USING...
MOV C, ACC.5 ; BIT MOVE OPERATOINS
MOV LCD_DB5, C
MOV C, ACC.6
MOV LCD_DB6, C
MOV C, ACC.7
MOV LCD_DB7, C
SETB LCD_E ; PULSE THE ENABLE LINE
CLR LCD_E
MOV C, ACC.0 ; SIMILARLY, LOAD LOW NIBBLE
MOV LCD_DB4, C
MOV C, ACC.1
MOV LCD_DB5, C
MOV C, ACC.2
MOV LCD_DB6, C
MOV C, ACC.3
MOV LCD_DB7, C
CLR LCD_E
SETB LCD_E ; PULSE THE ENABLE LINE
CLR LCD_E
CALL MADELAY
POP ACC
RET
; **********************************************************
; SUB TO WRITE A DATA WORD TO THE LCD
; DATA MUST BE PLACED IN R4 BY CALLING PROGRAM
; **********************************************************
WRLCDDATA:
CLR LCD_E
SETB LCD_RS ; SELECT SEND DATA
PUSH ACC ; SAVE ACCUMULATOR
MOV A, R4 ; PUT DATA BYTE IN ACC
MOV C, ACC.4 ; LOAD HIGH NIBBLE ON DATA BUS
MOV LCD_DB4, C ; ONE BIT AT A TIME USING...
MOV C, ACC.5 ; BIT MOVE OPERATOINS
MOV LCD_DB5, C
MOV C, ACC.6
MOV LCD_DB6, C
MOV C, ACC.7
MOV LCD_DB7, C
SETB LCD_E ; PULSE THE ENABLE LINE
CLR LCD_E
MOV C, ACC.0 ; SIMILARLY, LOAD LOW NIBBLE
MOV LCD_DB4, C
MOV C, ACC.1
MOV LCD_DB5, C
MOV C, ACC.2
MOV LCD_DB6, C
MOV C, ACC.3
MOV LCD_DB7, C
CLR LCD_E
SETB LCD_E ; PULSE THE ENABLE LINE
CLR LCD_E
NOP
NOP
POP ACC
RET
; **********************************************************
; SUB TAKES THE STRING IMMEDIATELY FOLLOWING THE CALL AND
; DISPLAYS ON THE LCD. STRING MUST BE TERMINATED WITH A
; NULL (0).
; **********************************************************
LCD_MSG:
CLR A ; Clear Index
MOVC A,@A+DPTR ; Get byte pointed by Dptr
INC DPTR ; Point to the next byte
JZ LCD_Msg9 ; Return if found the zero (end of stringz)
CJNE A,#001H,Lcd_Msg1 ; Check if is a Clear Command
MOV R4,A
CALL WRLCDCOM4 ;If yes, write it as command to LCD
JMP LCD_MSG ;Go get next byte from stringz
Lcd_Msg1: CJNE A,#0FFH,FLL ;Check for displaying full character
MOV R4,A
CALL WRLCDDATA
JMP LCD_MSG
FLL: CJNE A,#080h,$+3 ; Data or Address? If => 80h then is address.
JC Lcd_Msg_Data ; Carry will be set if A < 80h (Data)
MOV R4,A
CALL WRLCDCOM4 ; Carry not set if A=>80, it is address
JMP Lcd_Msg ; Go get next byte from stringz
Lcd_Msg_Data: ;
MOV R4,A
CALL WRLCDDATA ; It was data, write it to Lcd
JMP Lcd_Msg ; Go get next byte from stringz
Lcd_Msg9:
RET ; Return to Caller
; **********************************************************
; 1 MILLISECOND DELAY ROUTINE
; **********************************************************
MDELAY:
PUSH ACC
MOV A,#0A6H
MD_OLP:
INC A
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
JNZ MD_OLP
NOP
POP ACC
RET
MADELAY:
PUSH ACC
MOV A,#036H
MAD_OLP:
INC A
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
JNZ MAD_OLP
NOP
POP ACC
RET
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SCROLL:
DJNZ TIM,GAHJ1
CLR TR1
INC SCRL
DCDF: MOV A,SCRL
CJNE A,#01H,DFV1
JB NEW1,DFF1 ;CHK R VOL
CALL TITLE1
AJMP GAG
GAHJ1 :AJMP GAHJ
DFF1: CALL TITLE11
AJMP GAG
DFV1: CJNE A,#02H,DFV2
JB NEW2,DFF2 ;CHK Y VOL
CALL TITLE2
AJMP GAG
DFF2: CALL TITLE21
AJMP GAG
DFV2: CJNE A,#03H,DFV3
JB NEW3,DFF3 ;CHK B VOL
CALL TITLE3
AJMP GAG
DFF3: CALL TITLE31
AJMP GAG
DFV3: CJNE A,#04H,DFV4 ;MOTOR NO/OFF
JB MOTT,DFF4
CALL MOT_OFF
AJMP GAG
DFF4: CALL MOT_ON
AJMP GAG
DFV4: CJNE A,#05H,DFV5 ;AUTO ON
JNB NEW4,DFF5
CALL AUTO_ON_ON
AJMP GAG
DFF5: CALL AUTO_ON_OFF
AJMP GAG
DFV5: CJNE A,#06H,DFV6 ;AUTO OFF
JNB NEW5,DFF6
CALL AUTO_OFF_ON
AJMP GAG
DFF6: CALL AUTO_OFF_OFF
AJMP GAG
DFV6: MOV SCRL,#00H
GAG: MOV TIM,#75
GAHJ: MOV TL1,#08H
MOV TH1,#01H
SETB TR1
RETI
DISP: SETB PH1
SETB PH2
SETB PH3
JNB PH1,DRE1
CLR NEW1
AJMP DEE1
DRE1: SETB NEW1
DEE1: JB PH2,DRE2
CLR NEW2
AJMP DEE2
DRE2: SETB NEW2
DEE2: JB PH3,DRE3
CLR NEW3
RET
DRE3: SETB NEW3
RET
END
No comments:
Post a Comment