PDA

View Full Version : HELP:Easy Bluetooth and IR detectors



Idris
03-16-2010, 03:05 AM
Hello all,

I presently have hit a halt with a project. The purpose is to use the Roaming With IR from the BoeBot manual but i wish to relay the information back to the PC via the Easy Bluetooth and dongle and at the same time maneveur around the object. For example the left detector encounters and object,it would send a text· to the debug terminal saying "Object has been detected on the Left". Problem is that when the program is downloaded to the BoeBot, the ir detectors are stuck in a no object is detected state and no other function is working. Any assistance will be appreciated. Thank you.

here is the code that i am trying

'Master robot roaming with object detection and avoidance using IR. Also Bluetooth communications
' {$STAMP BS2}
' {$PBASIC 2.5}
irDetectLeft· VAR···· Bit
irDetectRight VAR···· Bit
pulseCount··· VAR···· Byte
rx··········· CON···· 2
tx··········· CON···· 0
led·········· PIN···· 5
buffer······· VAR···· Byte
' -----[ Initialization ]-----------------------------------------------------

' -----[ Main Routine ]-------------------------------------------------------
DO
· FREQOUT 8, 1, 38500······················· ' Store IR detection values in
··· irDetectLeft = IN9······················ ' bit variables.
· FREQOUT 2, 1, 38500
··· irDetectRight = IN0
SELECT buffer
· CASE $11
· IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN
··· HIGH 10
··· HIGH 1
· ENDIF
··· DEBUG HOME, "obstacle in front"
··· GOSUB Reply
··· GOSUB Back_Up··························· ' Both IR pairs detect obstacle
··· GOSUB Turn_Left························· ' Back up & U-turn (left twice)
··· GOSUB Turn_Left
· CASE $12
· IF (irDetectLeft = 0) THEN·························· ' Left IR pair detects
··· HIGH 10
· ENDIF
··· DEBUG HOME, "obstacle on left"
··· GOSUB Reply
··· GOSUB Back_Up··························· ' Back up & turn right
··· GOSUB Turn_Right
· CASE $13
· IF (irDetectRight = 0) THEN························· ' Right IR pair detects
··· HIGH 1
· ENDIF
··· DEBUG HOME, "obstacle on right"
··· GOSUB Reply
··· GOSUB Back_Up··························· ' Back up & turn left
··· GOSUB Turn_Left
· CASE ELSE································· ' Both IR pairs 1, no detects
··· LOW 10
··· LOW 1
··· DEBUG HOME, "no obstacle"
··· GOSUB Reply
··· GOSUB Forward_Pulse····················· ' Apply a forward pulse
ENDSELECT··································· ' and check again
LOOP
' -----[ Subroutines ]--------------------------------------------------------
Reply:
· SEROUT rx,84,[buffer]
· RETURN
Forward_Pulse:······························ ' Send a single forward pulse.
· PULSOUT 13,850
· PULSOUT 12,650
· PAUSE 20
· RETURN
Turn_Left:·································· ' Left turn, about 90-degrees.
· FOR pulseCount = 0 TO 20
··· PULSOUT 13, 650
··· PULSOUT 12, 650
··· PAUSE 20
· NEXT
· RETURN
Turn_Right:
· FOR pulseCount = 0 TO 20·················· ' Right turn, about 90-degrees.
··· PULSOUT 13, 850
··· PULSOUT 12, 850
··· PAUSE 20
· NEXT
· RETURN
Back_Up:···································· ' Back up.
· FOR pulseCount = 0 TO 40
··· PULSOUT 13, 650
··· PULSOUT 12, 850
··· PAUSE 20
· NEXT
· RETURN

Post Edited (Idris) : 3/15/2010 9:34:14 PM GMT

Franklin
03-16-2010, 04:04 AM
Where do you put data in buffer?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen

Idris
03-16-2010, 04:25 AM
i selected the buffer first and then using the case statements.would that work??

Franklin
03-16-2010, 08:37 AM
My question was where do you put anything in the buffer to test it with the case statement?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen

Idris
03-16-2010, 07:03 PM
oh sorry abt that. i did not initialize anything in the buffer. is that the reason that the code is not going through the cases??
also i am going through the 2nd sample code in this document and i see they have a msgIndex.would i need that to go through the cases?

http://www.parallax.com/Portals/0/Downloads/docs/prod/comm/30085-EasyBluetooth-v1.2.pdf

Idris
03-21-2010, 09:01 PM
any advice??

Franklin
03-22-2010, 09:05 AM
Yes, fix your code and repost the code. Use the post reply button and then attach your code with the attachment manager.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen