Problem with Boe Bot Infrared
shinn89
Posts: 3
Hi. I am given a project using Boe Bot Educational Robot Kit. Our given task is that the robot has to travel a circle in the provided track, which is pretty similar to the "Activity #3:Following A Stripe: in the guide book. Our group's bot has a problem where only the right Infrared is working and the left does not detect or react anything. The bot spins around and did not make the bot to keep moving on the track. We programmed it with Basic Stamp according to the program provided in that guide book. Is there something wrong with the program?
This is what is writen in our Basic Stamp
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running !"
'
[ Constants ]
Kpl CON -35
Kpr CON 35
SetPoint CON 2
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, [37500, 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, pulseRight
PULSOUT 12, pulseLeft
PAUSE 5
RETURN
This is what is writen in our Basic Stamp
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running !"
'
[ Constants ]
Kpl CON -35
Kpr CON 35
SetPoint CON 2
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, [37500, 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, pulseRight
PULSOUT 12, pulseLeft
PAUSE 5
RETURN
Comments
You can't see the IR LED glow with your eyes, but you can see it when viewed through a camera/cellphone. Try that.
Are you sure both of your servos work and are hooked up properly? Just try this:
a: PULSOUT 13, 800
PULSOUT 12, 700
PAUSE 20
goto a
Is there a program just to check if the IR sensors are working correctly?
If the program isn't working as expected, then it's time to isolate each component and make sure each component can work on its own.
erco suggested testing the servos. If the servos work correctly then you'll want to test the IR sensors.
When you say your using the "guide book", what is its title (and edition)? Is it "Robotics with the BOE-Bot"? If so which version.
Which page is the program you typed from?
It's easier for us to read code you post if you use code tags. Here's a link to learn how to use code tags.