Line tracer robot


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2004
    Location
    malawi
    Posts
    11

    Default Line tracer robot

    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.

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    By what you provide, it will look like almost this
    Code:
    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 ?
    Last edited by mister_e; - 20th January 2005 at 01:29.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Nov 2004
    Location
    malawi
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    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 ,
    Attached Images Attached Images  

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

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

    Code:
    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
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Nov 2004
    Location
    malawi
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    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

  6. #6
    Join Date
    Nov 2004
    Location
    malawi
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    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

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Talking

    Great to know that guy!

    Good luck!
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Replies: 0
    Last Post: - 2nd February 2009, 23:23
  2. Using input from Switch to control a loop
    By MrRoboto in forum mel PIC BASIC
    Replies: 9
    Last Post: - 2nd February 2009, 05:02
  3. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  4. Need Help - Line Tracer Robot
    By pidot in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 10th August 2007, 14:58
  5. having problems with Hantronix 20x4 lcd
    By Rhatidbwoy in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 22nd December 2005, 12:22

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts