# Boe-bot for The Chair Challenge II

It complete the requirementes asked in "The Chair Challenge II"

Find out my new project here.

Hope it respect all parameters in the challenge:

# "The Chair Challenge!"

Requirements:

1. Robot can be placed in any position and place operator prefers before start
2. 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)
3. Now the robot should try to drive around each of the 4 legs of a chair, like the orange arrow

• Result:
1. Robot was placed at the chair left side, in it direction.
2. The robot spins 10 times over itself before start the task.
3. The robot drives around each of the 4 legs, like the orange arrow.

• Picts:

• Code:

# "The Chair Challenge!"

Requirements:

1. Robot can be placed in any position and place operator prefers before start
2. 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)
3. Now the robot should try to drive around each of the 4 legs of a chair, like the orange arrow

• Result:
1. Robot was placed at the chair left side, in it direction.
2. The robot spins 10 times over itself before start the task.
3. 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

## Comment viewing options

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.

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)

I've pulsed RC servos at 13 ms intervals and gotten better torque and seemingly quicker response out of them. I think I heard some RC speed controls will not operate well with a higher pulse rate though, but do not have specifics on which one had the problem.
Nothing better then try diferent ones and take your own conclusions. I'm trying to migrate to stepper motors now, but they are much harder to controll.
Thanks. for the info. Have you used picaxe. What do you think is better. Im using picaxe now and bs2 is starting to gather dust. How about the cost? Good work on the challenge!

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...

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.