Continue to Site

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.

  • 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.

Line follower program

Status
Not open for further replies.

raitl

New Member
Having problems with creating a LF program for my bot. I got an example from the net (Linbot) and tried to modify it to work for me. But I'm using 3 sensors instead of 4 so I'm guessing there's something about SENSOR_REG that I have missed or overlooked. Probably wrong bits or something... Any ideas?

Code:
CLRF SENSOR_REG       
MOVF L_AD_REG,W
SUBWF VR_AD_REG,W
BTFSC STATUS,C
BSF SENSOR_REG,0       

MOVF C_AD_REG,W
SUBWF VR_AD_REG,W
BTFSC STATUS,C
BSF SENSOR_REG,1

MOVF R_AD_REG,W 
SUBWF VR_AD_REG,W
BTFSC STATUS,C
BSF SENSOR_REG,2



MOVLW B'00000111'  
ANDWF SENSOR_REG,W  
ADDWF PCL   
GOTO NO_LINE   
GOTO LEFT_LINE  
GOTO CENTER_LINE  
GOTO LEFT_CENTER_LINE 
GOTO RIGHT_LINE  
GOTO NUL_LINE   
GOTO RIGHT_CENTER_LINE 
GOTO CENTER_LINE
 
compiles fine and even works when covering left sensor.

And would like to post another question without making a new topic... how do I change first 4 or last 4 bits of a port? Controlling two stepper motors with PORTB and would like to give the steppers different speeds via changing the pause between steps. That means I need to change one motor status without touching the other... can't figure this out...
 
Status
Not open for further replies.

Latest threads

Back
Top