Shop OBEX P1 Docs P2 Docs Learn Events
Trouble with stripe following program - Can't seem to figure this out. — Parallax Forums

Trouble with stripe following program - Can't seem to figure this out.

ericmc2ericmc2 Posts: 6
edited 2011-11-21 15:45 in BASIC Stamp
Hi,
I am having some trouble with the Stripe Following program. Both of the IR units seem to work when I run the "TestBothIrAndIndicators.bs2", but I am getting really bizarre reactions when I try to run "Stripe Following BoeBot.bs2". I am using black tape on the back of a large board which is somewhat reflective, but I am in a well lit room with cream colored walls, so the surface (not covered by black tape) is close to white.
Any help would be great....

Here is the code I am running:

'
(TITLE)

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


'McCarthy
'Following a Stripe


DEBUG "Charge"


'
(Constants)



Kpl CON 35
Kpr CON -35
Setpoint CON 3


CenterPulse CON 750


'
(Variables)



freqSelect VAR NIB
irFrequency VAR WORD
irDetectLeft VAR BIT
irDetectRight VAR BIT
distanceLeft VAR NIB
distanceRight VAR NIB
pulseLeft VAR WORD
pulseRight VAR WORD


'
(Initialization)



FREQOUT 4, 2000, 3000


'
(Main ROutine)



DO

GOSUB Get_Ir_Distances
'Calculate proportional output.

pulseLeft = SetPoint - distanceLeft * Kpl + CenterPulse
pulseRight = SetPoint - distanceRight * Kpr + CenterPulse


GOSUB Send_Pulse


LOOP


'
(Subroutine Get IR Distances)



GET_Ir_Distances:
distanceLeft = 0
distanceRight = 0
FOR freqSelect = 0 TO 4
LOOKUP freqSelect, [3700,38250,39500,40500,41500], irFrequency

FREQOUT 8,1,irFrequency
irDetectLeft = IN9
distanceLeft = distanceLeft + irDetectLeft


FREQOUT 2,1,irFrequency
irDetectRight = IN0
distanceRight = distanceRight + irDetectRight
NEXT
RETURN


'
(Subroutine Get Pulse)



Send_Pulse:
PULSOUT 13,pulseLeft
PULSOUT 12,pulseRight
PAUSE 5
RETURN

Comments

  • ericmc2ericmc2 Posts: 6
    edited 2011-11-20 19:59
    Wait,
    realizing this may be a hardware issue. getting desired response if IR are really close to ground level ( I am testing by holding rear ball about an inch off the the table). I am already using a 1k ohm (brown-black-red) resistor.
  • ElectricAyeElectricAye Posts: 4,561
    edited 2011-11-20 20:09
    attachment.php?attachmentid=78421&d=1297987572
  • ercoerco Posts: 20,256
    edited 2011-11-21 11:20
    Yes, probably a hardware issue. Getting reliable readings depends on close proximity and proper LED/phototransistor orientation.
  • ericmc2ericmc2 Posts: 6
    edited 2011-11-21 14:27
    OK, so I am able to get the robot to run pretty well along the stripe.... but only if the sensors are practically on the ground. Definitely nothing further than one inch will trigger. I am going to meet up with a few others today to troubleshoot, I will post any info I get.
    Thanks,
    E
  • ercoerco Posts: 20,256
    edited 2011-11-21 15:04
    Up to an inch is doing very good!

    Different black tapes will reflect IR differently. Scribbler 1 sensors required fat black lines printed on a computer printer, which gives much more of a matte (dull) finish which absorbs IR more than reflecting it.

    You could try spray painting your tape (or lines) with ultra flat black paint, that may work better than plain tape.
  • ericmc2ericmc2 Posts: 6
    edited 2011-11-21 15:45
    Yes, that makes good sense. Also, I am using a somewhat reflective board (not plain white) which the tape is attached to, this might be an issue as well. Eitherway, as you can see, the IR sensors are VERY close, less than the inch I said earlier....
    (See Pics)
    IMG_9826.jpg
    IMG_9843.jpg
    1024 x 683 - 74K
    1024 x 683 - 76K
Sign In or Register to comment.