Google

Jul 14, 2008

Three phase latching relay programming for pic microcontroller 16f873a

I m using pic16f873a microcontroller and ICD2 Debugger cum programmer

I will give you brief introduction about my application.I need to toggle the relay on and off continuously.During on condition i need to check the continuity of relay contacts.For that i gave +5v supply to the relay contacts.output of this contact is given to microcontroller 25th pin.If the relay contact is working i will increase the relay test count and this count should written into the EEPROM.I f relay contact is not working micrcontroller should wait until the contact works.


TEST BSF PORTB,2 ;Set Turn off Relay
CALL DELAY
BCF PORTB,2 ;Clear Turn off Rly
CALL DELAY
CALL DELAY
CALL DELAY
CLRF PORTB
BSF PORTB,1 ;Set Turn on Rly
CALL DELAY
BCF PORTB,1 ;Clear Turn on Rly
CALL DELAY
CALL DELAY
CALL DELAY
MOVF PORTB,W
MOVWF CTAT_STATUS
BTFSS CTAT_STATUS,4
GOTO $-3
MOVLW 01H
MOVWF DATA_EE_ADDR
CALL READ
MOVWF DATA_TCNTL
MOVLW 00H
MOVWF DATA_EE_ADDR
CALL READ
MOVWF DATA_TCNTH
INCFSZ DATA_TCNTL,1
GOTO STORE
INCFSZ DATA_TCNTH,1
GOTO STORE
STORE MOVF DATA_TCNTL,W
MOVWF DATA_EE_DATA
MOVLW 01H
MOVWF DATA_EE_ADDR
CALL WRITE
MOVF DATA_TCNTH,W
MOVWF DATA_EE_DATA
MOVLW 00H
MOVWF DATA_EE_ADDR
CALL WRITE
GOTO TEST



if the code do not work on the application then follow the instructions
connect ground to relay contact and check for 0 in program also have a pull up for microcontrolloer pin.
for current program go for pull down resistor.
that should solve your problem.

You might be also interested in:

:: MASM 611 SOFTWARE
:: bit reversal and sorting programs
:: Find Square Root of a hexadecimal number in assembly language
:: common intreview questions on 8086

No comments: