PDA

View Full Version : Line tracer robot



cibotsan
- 20th January 2005, 00:35
Dear all especially Steve.
I had design a line tracer robot for my college. My knowledge about micro controller is very basic that why a needs your help.
for you info.
pic 16F877A
' input
portb.1 = Left Sensor (LS)
portb.2 = Center Sensor (CS)
portb.3 = Right Sensor (RS)

iam using 3 photo sensor.

' Output
portb.4 = Left Motor FWD. (LM_FWD)
portb.5 = Left Motor REV. (LM_REV)
portb.6 = Right Motor FWD. (RM_FWD)
portb.7 = Right Motor REV. (RM_REV)

iam using "H" bridge to driving my 2 DC motor.
What i want to know is,
1. How to control the robot, like this operation

LS(0) CS(1) RS (0) LM_FWD(FULL SPEED) RM_FWD (FULL)
LS(1) CS(1) RS (0) LM_FWD(HALF SPEED) RM_FWD (FULL)
LS(1) CS(1) RS (0) LM_FWD(MIN SPEED) RM_FWD (MAX)
LS(0) CS(1) RS (1) LM_FWD(HALF) RM_FWD (MAX)
LS(0) CS(0) RS (1) LM_FWD(MAX SPEED) RM_FWD (MIN)

2. another things is how to control
if the 3 Sensor = 1 3 times cross 4 junction, the robot will stop and turn 90 deg left (for example)

which is easier using PWM or Pulseout?
Please guy help me.

mister_e
- 20th January 2005, 01:24
By what you provide, it will look like almost this


TRISB=%00001111


LM_FWD var PORTB.4
LM_REV var PORTB.5
RM_FWD var PORTB.6
RM_REV var PORTB.7

MaskPORTB var byte
PeriodHALF var word ' Variable for Half Speed period (pulsout)
PeriodMIN var word ' Variable for Min Speed period (pulsout)

' You'll have to determine value for PeriodMIN & PeriodHALF here

PORTB=0

Start:
MaskPORTB=(PORTB>>1) & $07 ' get only B1,B2,B3 value
Select case maskportb

'LS(0) CS(1) RS (0) LM_FWD(FULL SPEED) RM_FWD (FULL)
case 2
LM_FWD =1
RM_FWD =1

'LS(1) CS(1) RS (0) LM_FWD(HALF SPEED) RM_FWD (FULL)
case 3
pulsout LM_FWD, PeriodHALF
RM_FWD=1

'LS(0) CS(1) RS (1) LM_FWD(HALF) RM_FWD (MAX)
case 6
pulsout LM_FWD, PeriodHALF
RM_FWD=1

'LS(0) CS(0) RS (1) LM_FWD(MAX SPEED) RM_FWD (MIN)
case 4
LM_FWD = 1
pulsout RM_FWD,PeriodMIN
end select
goto start

be sure of the way you interpret your sensor... i'm not sure about the info you provide.


2. another things is how to control
if the 3 Sensor = 1 3 times cross 4 junction, the robot will stop and turn 90 deg left (for example)


you mean ?

cibotsan
- 20th January 2005, 04:34
Thanks again steve for your solution.

quote:
--------------------------------------------------------------------------------
2. another things is how to control
if the 3 Sensor = 1 3 times cross 4 junction, the robot will stop and turn 90 deg left (for example)

--------------------------------------------------------------------------------

what i trying to do is ( reffer to attached file) the robot move follow the line and after cross the 3rd junction the robot will stop and after few second robot will turn CCW and stop again when the line sensor is detected the 90 deg line.
sorry for my bad english ,

mister_e
- 20th January 2005, 15:53
sorry for my bad english
that's familiar to me... i'm french.

BTW, your picture helps a lot to figure out what you want to do.

Have a counter variable, and check for your three sensor signal comming...



MyCounter VAR BYTE
MyCounter=0


' Add this line to the SELECT CASE stuff
CASE 7 'when all 3 sensor tripped
IF MyCounter<3 then
MyCounter = MyCounter + 1
ELSE
Gosub LetsTurn90Degree
ENDIF

cibotsan
- 21st January 2005, 11:43
You always not dissapointed me steve,what a generous person you are .Right now iam out station, so after comming back, i will try it and give the result, thanks again steve
regards
fanzi

cibotsan
- 30th January 2005, 15:14
dear Steve,
I try already, and it was sucessfull. Many thanks to you Steve. i learned how to make linetracer robot from you.
regards
fauzi

mister_e
- 30th January 2005, 15:36
Great to know that guy!

Good luck!