• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Robot follower HELP PLZ its just small thing can't fix it :(

Status
Not open for further replies.

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


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:
 

Attachments

ericgibbs

Well-Known Member
Most Helpful 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:

hi,
Got your zip, trying the *.asm in Oshonsoft Sim.

Could you explain in a little more detail, the text marked in BLUE, I dont fully understand.:)
 
Last edited:

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:

hi,
Got your zip, trying the *.asm in Oshonsoft Sim.

Could you explain in a little more detail, the text marked in BLUE, I dont fully understand.:)
well i mean that when i start the robot i need to check its turn on by turning the led that can be shown in the figure. and also im having trouble with the motor right when i press on the push button it goes to the left and it must go to the right. this is what i mean . if there is anything unclear just tell me .
 

ericgibbs

Well-Known Member
Most Helpful Member
hi,
This is the result:

1.Power up.
> no drive to motors.

2.FWD pressed
> B2 & B4 ON

3. STOP pressed
> no drive to mtrs

4. RIGHT pressed
> no drive to mtrs

5. LEFT pressed
> B1 & B3 ON


NOTE: RA4 the ENABLE is an open drain, requires a pullup resistor, say 10K

I will look some more.

EDIT: its a fuzzy drawing I have misread a pin number.
 
Last edited:

ericgibbs

Well-Known Member
Most Helpful Member
hi,
Revised results.
assignments:
A0=fwd
A1=stop
A2= enable sw
A3=right
A4=left
.
B0=led

B1=right1
B2=right2

B3=left1
B4=left2

Result:

Enable & fwd = B2 & B4

Enable & right = B1 & B3

Enable & left = B2 & B4

Enable & stop = no mtrs

Note: fwd and left calling same pins!

The led on B0, appears to flash for only 10mSec.?
 

goldfish300

New Member
hi,
This is the result:

1.Power up.
> no drive to motors.

2.FWD pressed
> B2 & B4 ON

3. STOP pressed
> no drive to mtrs

4. RIGHT pressed
> no drive to mtrs

5. LEFT pressed
> B1 & B3 ON


NOTE: RA4 the ENABLE is an open drain, requires a pullup resistor, say 10K

I will look some more.

EDIT: its a fuzzy drawing I have misread a pin number.
so what i have to doin this case
4. RIGHT pressed
> no drive to mtrs

and i have fix the drawing see the attachment.
 

Attachments

ericgibbs

Well-Known Member
Most Helpful Member
hi,
Rerun the last asm you posted.

You are turning ON the led, when the ENABLE switch is set, for only 10mSecs!!

You will not see it flash.

Code:
MAIN_START
	BTFSC	ENABLE; if enable ON then
	BSF		START; turn ON led
        ;else
	CALL 	DELAY_10MS; call 10ms delay
	BCF		START; [COLOR="Red"]ALWAYS[/COLOR] on return switch OFF led.
	RETURN
 

ericgibbs

Well-Known Member
Most Helpful Member
ya im using it.
but still can't fix it.
i don't know how to fix the led ??
As we point out, a 10mS flash is too short to see.

Do you want the LED on B.0 to be lit while the 'enable' switch is ON.??
 

ericgibbs

Well-Known Member
Most Helpful Member
yes thats what i want
hi,
A simple fix.

Code:
MAIN_START
	BTFSC	ENABLE; if enable ON then
	BSF		START; turn ON led
        ;else
	BTFSS        ENABLE    ;;;;CALL 	DELAY_10MS; call 10ms delay
	BCF		START; switch OFF led.
	RETURN
If you want to change the LED on/off while the program runs, call the MAIN_START in the program
 

goldfish300

New Member
I fix that but nothing happen it still not turning on the led :(
its really make me confused
IS THERE A PROBLEM IF I TALK TO U OVER MSN OR WHAT EVER U WANT ?
 
Last edited:

ericgibbs

Well-Known Member
Most Helpful Member
I fix that but nothing happen it still not turning on the led :(
its really make me confused
IS THERE A PROBLEM IF I TALK TO U OVER MSN OR WHAT EVER U WANT ?
hi,
If the ENABLE switch is closed, before you power up the PIC, the led should light.
Unless you call the routine again the ENABLE switch will not control the LED.

It works OK in my simulator.

Are the other push buttons working with the PIC.?

The ENABLE switch pulldown resistor is not shown on your diagram.???
 
Last edited:

goldfish300

New Member
well thx anyway for the hard work . its seems its not gonna work :(
i have put the pulldown resistor and ENABLE switch is closed and the led didn't turn on even after i click on the enable.
ya the pic works fine with motor and the push buttons all works except the led thing.
10x for the fast help.
peace .
 
Last edited:

ericgibbs

Well-Known Member
Most Helpful Member
well thx anyway for the hard work . its seems its not gonna work :(
i have put the pulldown resistor and ENABLE switch is closed and the led didn't turn on even after i click on the enable.
ya the pic works fine with motor and the push buttons all works except the led thing.
10x for the fast help.
peace .
hi,
The enable must be ON before you put power to the PIC.

Are you sure the led is ok,? do a test on the led with a 270R to +5v, [disconnect from the PIC B.0 before you do]

You should really have a 220R from the PIC pin to the led as standard.

As the other push buttons are doing something it means the PIC is running.

Check the B.0 pin for any change in output and the A.4 pin to ensure that your enable switch is operating the A.4 input.

Lets know what you find.:)

The LED works fine in simulation.

EDIT:
If you want to chat, click the CHAT on the menu.. I'll be there for a while.
 
Last edited:

ericgibbs

Well-Known Member
Most Helpful Member
If you want to chat, click the CHAT on the menu.. I'll be there for a while.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top