Shop OBEX P1 Docs P2 Docs Learn Events
QTI line follower and infra red headlines — Parallax Forums

QTI line follower and infra red headlines

MarjolijnMarjolijn Posts: 2
edited 2010-10-22 08:00 in BASIC Stamp
HI,

I am new in to robotics. And i did the examples in "Robotics with the Boe-bot"
Now I have some problems wich I just can't figure out.

Does anybody know how you combine the function infrared headlights with the QTI line follower?

I have two Robots; one of them makes the black line wich the other Boe-Bot follows with the QTI line follower system. I don't want them to bump in to each other, so it would be great if the line follow robot can detect the other boe-bot with the infra red headlights...


I put the two scripts of both functions after each other in to subroutines, like combining the whispers with the infra red in all kind of combinations. I tried several ideas wich didn't work out.
:-(

I don't have any idea what kind of script would work out together with the servo's...


Would be very happy is someone can give me some hints or script solutions.

Thanx

chrs Marjolijn

Comments

  • FranklinFranklin Posts: 4,747
    edited 2010-10-21 16:08
    It would help us if you would include your existing code when you ask for code help.
  • MarjolijnMarjolijn Posts: 2
    edited 2010-10-22 08:00
    Franklin wrote: »
    It would help us if you would include your existing code when you ask for code help.
    Ok. offcourse, that would be helpfull.

    This is my latest script. It doesn't work at all. it sounds so simple; just two detecting routines wich can tell the servo's what to do... For me it isn't.

    Here is my script:

    ' Robotics with the Boe-Bot - Deadline_eiberttip.bs2
    ' Make forward, left, right, and backward movements in reasable subroutines.
    'run the p12 servo for twice as long.

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}


    irDetectLeft VAR Nib
    irDetectRight VAR Nib
    pulseleft VAR Word
    pulseRight VAR Word
    loopCount VAR Byte
    pulseCount VAR Byte


    FREQOUT 4, 2000, 3000




    qtis VAR Nib
    OUTB = %1111



    begin:
    DO


    FREQOUT 2, 1, 38500
    irDetectright = INB

    FREQOUT 8, 1, 38500
    irDetectleft = INB

    DIRB = %1111
    PAUSE 0
    DIRB = %0000
    PAUSE 0
    qtis = INB

    IF (irDetectLeft = 1) AND ( irDetectRight = 1) THEN
    GOTO linefollower:

    ELSEIF (irDetectLeft = 0) AND (irDetectRight = 0)THEN
    ab:
    pulseCount = 1
    pulseLeft = 850
    pulseRight = 650
    ELSEIF (irDetectRight = 1) THEN
    cd:
    pulseCount = 10
    pulseLeft = 650
    pulseRight = 650
    ELSEIF ( irDetectLeft = 1) THEN
    ef:
    pulseCount = 10
    pulseLeft = 850
    pulseRight = 850
    ELSE
    gh:
    pulseCount = 15
    pulseLeft = 650
    pulseRight = 850
    ENDIF

    FOR loopCount = 1 TO pulseCount
    PULSOUT 13, pulseLeft
    PULSOUT 12, pulseRight

    RETURN

    linefollower:
    SELECT qtis

    CASE (irDetectLeft = 1) AND (irDetectTight = 1)THEN
    GOTO linefollowersub
    ELSE
    GOTO begin
    linefollowersub
    CASE %1000
    PULSOUT 13, 650
    PULSOUT 12, 650
    CASE %1100
    PULSOUT 13, 750
    PULSOUT 12, 650
    CASE %0100
    PULSOUT 13, 800
    PULSOUT 12, 650
    CASE %0110
    PULSOUT 13, 850
    PULSOUT 12, 650
    CASE %0010
    PULSOUT 13, 850
    PULSOUT 12, 700
    CASE %0011
    PULSOUT 13, 850
    PULSOUT 12, 750
    CASE %0001
    PULSOUT 13, 850
    PULSOUT 12, 850
    CASE ELSE
    PAUSE 3

    ENDSELECT

    RETURN

    LOOP
Sign In or Register to comment.