goldfish300
New Member
well this is my project topic:
Line follower robot; the robot has two IR sensors that detect a black line. The PIC16f628 has to read the sensor values, and compare them, and then decides if the robot should turn left or right.
well i'v done the code and im trying to fix what i have and my question is when i try to enable the switch nothing happen in which a led must turn on and i don't have an error
and also the motor right problem. so anyone can help. i will post the code with the graph and see the attachmet for the file im working with
the PIC:
**broken link removed**
Line follower robot; the robot has two IR sensors that detect a black line. The PIC16f628 has to read the sensor values, and compare them, and then decides if the robot should turn left or right.
well i'v done the code and im trying to fix what i have and my question is when i try to enable the switch nothing happen in which a led must turn on and i don't have an error
and also the motor right problem. so anyone can help. i will post the code with the graph and see the attachmet for the file im working with
Code:
;LINE FFOLLOWER ROBOT USING PIC16F628,L298
#INCLUDE "P16F628A.INC"
#DEFINE PB_FORWARD PORTA, 0
#DEFINE PB_STOP PORTA, 1
#DEFINE ENABLE PORTA, 2
#DEFINE LS_RIGHT PORTA, 3
#DEFINE LS_LEFT PORTA, 4
;outputs
#DEFINE M1L1 PORTB, 1
#DEFINE M1L2 PORTB, 2
#DEFINE M2L1 PORTB, 3
#DEFINE M2L2 PORTB, 4
#DEFINE START PORTB, 0
CBLOCK 0X20
A1, A2, A3
ENDC
ORG 0X000
GOTO MAIN
MAIN
CALL SETUP
CALL MAIN_START
REPEAT
BTFSC PB_FORWARD
CALL GO_FORWARD
BTFSC PB_STOP
CALL STOP
BTFSC LS_LEFT
CALL SENSOR_LEFT
BTFSC LS_RIGHT
CALL SENSOR_RIGHT
GOTO REPEAT
GO_FORWARD
BCF M1L1
BSF M1L2
BCF M2L1
BSF M2L2
RETURN
STOP
BCF M1L1
BCF M1L2
BCF M2L1
BCF M2L2
RETURN
MAIN_START
BTFSC ENABLE
BSF START
CALL DELAY_10MS
BCF START
RETURN
SENSOR_RIGHT
BSF M1L1
BCF M1L2
BSF M2L1
BCF M2L2
BTFSS LS_RIGHT
GOTO $+3
CALL DELAY_10MS
GOTO $-3
CALL GO_FORWARD
RETURN
SENSOR_LEFT
BCF M1L1
BSF M1L2
BCF M2L1
BSF M2L2
BTFSS LS_LEFT
GOTO $+3
CALL DELAY_10MS
GOTO $-3
CALL GO_FORWARD
RETURN
DELAY_10MS
MOVLW D'5'
MOVWF A1
MOVLW D'108'
MOVWF A2
MOVLW D'5'
MOVWF A3
DECFSZ A3
GOTO $-1
DECFSZ A2
GOTO $-5
DECFSZ A1
GOTO $-9
RETURN
DELAY_1S
MOVLW D'46'
MOVWF A1
MOVLW D'189'
MOVWF A2
MOVLW D'37'
MOVWF A3
DECFSZ A3
DECFSZ A2
GOTO $-5
DECFSZ A1
GOTO $-9
RETURN
SETUP
CLRF PORTA
CLRF PORTB
BSF STATUS, RP0
CLRF TRISB
MOVLW B'00011111'
MOVWF TRISA
BCF STATUS, RP0
MOVLW B'00000111'
MOVWF CMCON
RETURN
END
the PIC:
**broken link removed**