Shop OBEX P1 Docs P2 Docs Learn Events
code to make bo-bot do a specific task — Parallax Forums

code to make bo-bot do a specific task

lockadoclockadoc Posts: 115
edited 2006-09-30 21:40 in Robotics
I'm trying to make my bo-bot locate a golfball in a black arena
than close a bucket over the ball ,then push the ball to a loading area.
Right now all I'm looking for is a code help on the bucket part to see why i don't return to main code after it closes on the ball.

And I'll take any hints on meeting my goal.. thanks·· Bill

code to follow..........

' ROBOTICS WITH THE BOE-BOT - SUMOBOEBOT.BS2
' SEARCH FOR OBJECT, LOCK ONTO IT AND PUSH IT
' {$STAMP BS2}
' {$PBASIC 2.5}
IRDETECTLEFT··· VAR··· Bit············ ' LEFT IR READING
IRDETECTRIGHT·· VAR··· Bit············ ' RIGHT IR READING
PULSELEFT······ VAR··· Word··········· ' PULSE VALUES FOR SERVOS
PULSERIGHT····· VAR··· Word
'
{ INITIALIZATION }
·DEBUG "PROGRAM RUNNING!"
·FREQOUT 4, 2000, 3000····· ' SIGNAL START/RESET.
···· DEBUG CLS,
··· "IR Detectors",CR,
··· "Left Right",CR,
··· "
··
"
·'
{MAIN ROUTINE }
·MAIN:
·' SPIN AROUND SLOWLY UNTIL AN OBJECT IS SPOTTED
·DO
·· PULSOUT 13, 790······ ' ROTATE SLOWLY
·· PULSOUT 12, 790
·· PAUSE 105············· ' 5 MS FOR DETECTORS
·· GOSUB CHECK_IRS······ 'WHILE LOOKING FOR OBJECT
·· GOSUB Led_s
·· GOSUB BALL_CHECK
·LOOP UNTIL (IRDETECTLEFT = 0) OR (IRDETECTRIGHT = 0)
·' NOW FIGURE OUT EXACTLY WHERE THE OBJECT IS AND GO TOWARD IT
·DO
·' OBJECT IN BOTH DETECTORS -- GO FORWARD
·IF (IRDETECTLEFT = 0) AND (IRDETECTRIGHT = 0) THEN
·PULSELEFT = 800······· 'FORWARD
·PULSERIGHT = 700
·' OBJECT ON LEFT - GO LEFT
·ELSEIF (IRDETECTLEFT = 0) THEN
·PULSELEFT = 700······ 'LEFT TOWARD OBJECT
·PULSERIGHT = 700
·'OBJECT ON RIGHT - GO RIGHT
·ELSEIF (IRDETECTRIGHT = 0)THEN
·PULSELEFT = 800···· ' RIGHT TOWARD OBJECT
·PULSERIGHT = 800
·' NO OBJECT -- GO FORWARD ANYWAY, BECAUSE THE DETECTORS WILL
·ELSE····· ' MOMENTARILY SHOW
·PULSELEFT = 800······ ' "NO OBJECT" AS THE
·PULSERIGHT = 700····· ' BOE-BOT IS ADJUSTING
·ENDIF·········· ' ITS POSITION.
·PULSOUT 13,PULSELEFT···· ' APPLY THE PULSE.
·PULSOUT 12,PULSERIGHT
·PAUSE 15······ ' 5 MS FOR DETECTORS
·' CHECK IRS AGAIN IN CASE OBJECT IS MOVING
·GOSUB CHECK_IRS
·GOSUB Led_s
·LOOP
·'
{ SUBROUTINES }
·CHECK_IRS:
·FREQOUT 8, 1, 38500····· ' CHECK IR DETECTORS
·IRDETECTLEFT = IN9
·FREQOUT 2, 1, 38500
·IRDETECTRIGHT = IN0
·RETURN
·BALL_CHECK:
' Used From Whats A Microcontroller Page 79
' Made to check for ball under bucket and close
' and hold bucket closed until ball dropsfrom under bucket
IF (IN11 = 1) THEN
PULSOUT 14, 675·· 'hold open
PAUSE 50
ELSE
PULSOUT 14 ,900··· 'hold closed
PAUSE 1500
ENDIF
RETURN
·'
· ( add on leds )·
Led_s:
· FREQOUT 8, 1,38500
· IRdetectLeft = IN9
· FREQOUT 2,1,38500
· IRdetectRight= IN0
··· IF· (IRdetectLeft = 0) THEN
····· HIGH 10
··· ELSE
····· LOW 10
··· ENDIF
··· IF (IRdetectRight = 0 )THEN
····· HIGH 1
··· ELSE
····· LOW· 1
··· ENDIF
DEBUG CRSRXY,· 2,· 3,· BIN1 IRdetectLeft,
····· CRSRXY,· 9,· 3,· BIN1 IRdetectRight
····· PAUSE 10
RETURN

·

Comments

  • AImanAIman Posts: 531
    edited 2006-09-29 15:11
    Have you solved this?
  • allanlane5allanlane5 Posts: 3,815
    edited 2006-09-29 15:17
    If he cared, he'd have reposted some time since July 17, no?

    Please don't resurrect dead posts.
  • lockadoclockadoc Posts: 115
    edited 2006-09-30 21:40
    Hello,,,

    No I have not solved the task I wanted to do,,Sence I had no replies

    I rethought of how to do it, with a track for the balls to fall into, but would love to have the bobot do it instead, so if any one has any ideas to do it let me know.

    Thanks Billy
Sign In or Register to comment.