Trouble with stripe following program - Can't seem to figure this out.
ericmc2
Posts: 6
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
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
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.
Thanks,
E
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.
(See Pics)