Boe-bot for The Chair Challenge II
Find out my new project here.
Hope it respect all parameters in the challenge:
"The Chair Challenge!"
Requirements:
- Robot can be placed in any position and place operator prefers before start
- Robot must then spin around it´s own center at least 10 times before step 3. (so we know it is actually navigating on it´s own)
- Now the robot should try to drive around each of the 4 legs of a chair, like the orange arrow
- Result:
- Robot was placed at the chair left side, in it direction.
- The robot spins 10 times over itself before start the task.
- The robot drives around each of the 4 legs, like the orange arrow.
- Picts:



- Code:
"The Chair Challenge!"
Requirements:
- Robot can be placed in any position and place operator prefers before start
- Robot must then spin around it´s own center at least 10 times before step 3. (so we know it is actually navigating on it´s own)
- Now the robot should try to drive around each of the 4 legs of a chair, like the orange arrow
- Result:
- Robot was placed at the chair left side, in it direction.
- The robot spins 10 times over itself before start the task.
- The robot drives around each of the 4 legs, like the orange arrow.
- Code:
'(I know it is not that cute.. it may be simplified, but i was afraid of gaping time to finish the task, since I'm with school projects in hands.. maybe I tune it up later)
' {$STAMP BS2}
' {$PBASIC 2.5}
' {$PORT COM6}
'---------- VARS ----------'
pulseCount VAR Byte
irdetectleft VAR Bit
irdetectrigth VAR Bit
fase VAR Byte
'---------- TEST ----------'
'---------- START ----------'
GOSUB Spin '5 Spins on it own center
GOSUB Spin '5 Spins on it own center
fase = 0
'--------- MAIN CODE ---------'
DO
FREQOUT 8,1,39500 'activate IR
irdetectleft=IN9
FREQOUT 2,1,39500 'activate IR
irdetectrigth = IN0
'-- states machine --'
SELECT fase 'find beguin position
CASE 0
IF (irdetectleft=0) AND (irdetectrigth=0) THEN
fase = fase + 1
LOW 1
ELSEIF (irdetectrigth=0)THEN
GOSUB Slow_Spin
HIGH 1
ELSE
GOSUB Soft_Spin
ENDIF
CASE 1 'turn around the first chair leg
GOSUB Slow_Around_Leg
HIGH 1
GOSUB Forward
GOSUB Around_Leg_Large
GOSUB Forward
GOSUB Slow_Around_Leg
GOSUB Slow_Around_Leg
GOSUB Slow_Around_Leg
LOW 1
fase = fase + 1
CASE 2 'find and sping on the 2nd leg
IF (irdetectleft=0) AND (irdetectrigth=0) THEN
GOSUB Slow_Around_Leg
HIGH 1
GOSUB Forward
GOSUB Around_Leg
'GOSUB Forward
LOW 1
fase = fase + 1
ELSEIF (irdetectrigth=0)THEN
HIGH 1
GOSUB Slow_Forward
ELSE
HIGH 1
GOSUB Slow_Forward
ENDIF
CASE 3 'find and sping on the 3rd leg
IF (irdetectleft=0) AND (irdetectrigth=0) THEN
GOSUB Slow_Around_Leg
HIGH 1
GOSUB Forward
GOSUB Around_Leg
GOSUB Forward
GOSUB Slow_Around_Leg
LOW 1
fase = fase + 1
ELSEIF (irdetectrigth=0)THEN
GOSUB Slow_Forward
ELSE
GOSUB Slow_Forward
ENDIF
CASE 4 'find and sping on the 4th leg
IF (irdetectleft=0) AND (irdetectrigth=0) THEN
GOSUB Slow_Around_Leg
HIGH 1
GOSUB Forward
GOSUB Around_Leg_Large
GOSUB Slow_Around_Leg
GOSUB Slow_Around_Leg
GOSUB Slow_Around_Leg
GOSUB Forward
LOW 1
fase = fase + 1
ELSEIF (irdetectrigth=0)THEN
HIGH 1
GOSUB Slow_Forward
ELSE
HIGH 1
GOSUB Slow_Forward
ENDIF
CASE ELSE 'stop at end of task
DO
GOSUB Stay
LOOP
ENDSELECT
LOOP
'---------- SPIN ----------'
Spin:
FOR pulseCount = 0 TO 255
PULSOUT 13,850
PULSOUT 12,850
PAUSE 45
NEXT
RETURN
Soft_Spin:
FOR pulseCount = 0 TO 10
PULSOUT 13,770
PULSOUT 12, 770
PAUSE 45
NEXT
RETURN
Slow_Spin:
FOR pulseCount = 0 TO 5
PULSOUT 13,755
PULSOUT 12,755
PAUSE 45
NEXT
RETURN
'---------- BASIC ----------'
Stay:
FOR pulseCount = 0 TO 255
PULSOUT 13,750
PULSOUT 12,750
PAUSE 45
NEXT
RETURN
Forward:
FOR pulseCount = 0 TO 40
PULSOUT 13, 650
PULSOUT 12, 850
PAUSE 20
NEXT
RETURN
Slow_Forward:
FOR pulseCount = 0 TO 50
PULSOUT 13, 740
PULSOUT 12, 760
PAUSE 20
NEXT
RETURN
'---------- LEGS ----------'
Around_Leg:
FOR pulseCount = 0 TO 110
PULSOUT 13,735
PULSOUT 12, 850
PAUSE 40
NEXT
RETURN
Around_Leg_Large:
FOR pulseCount = 0 TO 150
PULSOUT 13,735
PULSOUT 12, 850
PAUSE 40
NEXT
RETURN
Slow_Around_Leg:
FOR pulseCount = 0 TO 10
PULSOUT 13,735
PULSOUT 12, 850
PAUSE 40
NEXT
RETURN




@ Tue, 2008-12-16 10:28
PAUSE QUESTION
good work! i am still trying to do the challenge using picaxe.. still struggling on the code. lol. I also have a bs2 and the book said that the servo needs a 20ms pause. why did you use pause 45 and 40 on other part?
One lifetime is too short to learn everything.
@ Tue, 2008-12-16 10:48
20msis the minimu, but if
20msis the minimu, but if you pause more time, you will get the wells spining for more time. (If you pause 2 much, they will stop)
Never more used BS2 since this robot, now i'm only using arduino. (bad that don't have time to robots lately)
@ Thu, 2008-12-18 04:23
Minimum?
@ Thu, 2008-12-18 14:18
Nothing better then try
@ Thu, 2008-12-18 03:20
Thanks. for the info. Have
@ Thu, 2008-12-18 14:17
I never used picaxe but for
I never used picaxe but for sure the price/expansability the picaxe is beter that bs2.
Personaly Arduino is better that picaxe, can't tell it for sure because never use picaxe, but of what i read, i will keep working with Arduino the next times...
@ Tue, 2008-04-15 16:52
Thanks for the compliments.
Thanks for the compliments,
when i recive them, i will make some robot with this servo controler and this servos to everyone learn how to use it, as i will..
Thanks everyone, and good luck to the next challenge.
If anyone have questions about this robot, just do it, and i will try answer the best i can.
@ Tue, 2008-04-15 16:02
CONGRATIOLATIONS!
You have won the challenge with honor!!
I am very impressed, and I can only say congratulations, well done, A+!
I will contact you for your address so I can mail you the price!
WM
@ Thu, 2008-04-10 17:50
Brilliant!
@ Thu, 2008-04-10 18:27
Thanks for your comment