Shop OBEX P1 Docs P2 Docs Learn Events
Reading compass information — Parallax Forums

Reading compass information

AndreiAndrei Posts: 15
edited 2009-06-14 23:23 in BASIC Stamp
Hi,
I am new with programing and I have one question: I have line follower robot. The start and stop are the same, it's like a circuit. How could I make my robot to turn automaticly at the same angle(at the stop point) as it was when it started following the line?

Thank you, Andrei

Comments

  • MSDTechMSDTech Posts: 342
    edited 2009-06-07 20:16
    Andrei,
    This depends a little on how you have the line sensors configured. I used 4 QTI sensors with the center two closely spaced and the out two set further away from the center pair. I determine when my BOE-BOT comes to the end of a line by monitoring the outer sensors and recording when they see an intersecting line. When I lose the line on the center two sensors and no line is sensed on the sides, the robot will rotate, monitoring for the line. The following snippet of code is the routine called when the line is lost:
    Rotate_Right_to_Line:
    L_Speed = L_Stop + (LeftS * AdjustL * 3)
    R_Speed = R_Stop - (RightS * AdjustR * 3) 'Reverse direction
    GOSUB Set_Servos
    DO
    GOSUB Check_QTIs
    PAUSE 10
    LOOP UNTIL ((QTIs | %1101) = %1111)
    Last_QTI = %0000 'To force the program to use SELECT logic.
    RETURN
    Since the program was written to be used on a much larger robot in the robotics club I was teaching, all actions were programmed in subroutines (makes it easier to change hardware without changing the logic).

    Called Subroutines:
    Set_Servos - routine to send speed commands to the servo pal used on the BOE-BOT. This was replaced by a pair of HB-25's in the final robot.
    Check_QTIs - subroutine to return the current status of the QTI sensors in a nib size variable (QTI)

    Variables and Constants:
    L_Speed and R_Speed are variables with the desired pulse width for the servos.
    L_Stpp, LeftS, AdjustL, R_Stop, RightS and AdjustR are constants used to calibrate the operation of the robot. Again, going to different hardware is much easier if you only need to adjust one constant than search through the code.

    I uploaded a video of the program in operation at www.youtube.com/watch?v=zbhg4OPLQBI

    Post Edited (MSDTech) : 6/8/2009 2:30:22 AM GMT
  • AndreiAndrei Posts: 15
    edited 2009-06-07 21:40
    Thank you very much. I will try this too, even if I didn't wanted to make a connection between the line folower and the compass. I just wanted after following the line to turn at the same angle as it was when it started to follow the line.

    Thanks again very much.
  • AndreiAndrei Posts: 15
    edited 2009-06-14 21:24
    How should I proceed if I want my robot to read informations from the compass and then turn 90 degrees in one direction?
  • FranklinFranklin Posts: 4,747
    edited 2009-06-14 23:23
    I would start by reading the documentation that came with the compass. If it was from Parallax there is sample code for using it on the page where it is sold.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
Sign In or Register to comment.