Shop OBEX P1 Docs P2 Docs Learn Events
My Boe Bot is afraid of the dark — Parallax Forums

My Boe Bot is afraid of the dark

bgthreebgthree Posts: 14
edited 2007-01-22 17:09 in Robotics
I'm trying to do the flashlight follower Boe Bot and have had pretty good success. It works perfectly in all conditions except very dark. It still works when it's very dark, but it gets "jittery". It still responds to the light correctly, but it jitters and vibrates and when going straight only goes at about half speed.

I took a look at the capacitor discharge times in a very dark room, and those don't exceed 65535. I tried different size capacitors and that didn't help.

I tinkered with the Pause 20 for the servo signal and that didn't help.

Here is my code:

' {$STAMP BS2}
' {$PBASIC 2.5}

Rdisch VAR Word
Ldisch VAR Word
diff VAR Word

counter VAR Word

right PIN 12
left PIN 13

Reye PIN 1
Leye PIN 0

DO

HIGH Reye
HIGH Leye

PAUSE 1

RCTIME Reye, 1, Rdisch
RCTIME Leye, 1, Ldisch

diff = (Rdisch + Ldisch) / 12

IF (Ldisch > (Rdisch + diff)) THEN
GOSUB RotR
' DEBUG HOME, "Going.Right.............", CR

ELSEIF (Rdisch > (Ldisch + diff)) THEN
GOSUB RotL
' DEBUG HOME, "Going.Left...............", CR

ELSE
GOSUB Gostr8
' DEBUG HOME, "Else.Condition.Happening.Going.Straight..........", CR
ENDIF

PAUSE 15

DEBUG HOME, "diff = ", DEC5 diff, CR
DEBUG "Rdisch = ", DEC5 Rdisch, CR
DEBUG "Ldisch = ", DEC5 Ldisch, CR

LOOP

'
SubRoutines

Gostr8:
FOR counter = 1 TO 5
PULSOUT right, 650
PULSOUT left, 850
NEXT
RETURN

RotR:
FOR counter = 1 TO 5
PULSOUT right, 800
PULSOUT left, 800
NEXT
RETURN

RotL:
FOR counter = 1 TO 5
PULSOUT right, 700
PULSOUT left, 700
NEXT
RETURN

Thanks for any suggestions yeah.gif

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-01-22 17:09
    You can probably expect something like this to some degree since in total darkness the RCTIME will take longer time to discharge and therefore cause more delay in the loop. Normally there are two ways of reducing this, but the first won’t work for you because you do not have the recommended delays in the servo loops. Normally you would have a 20mS PAUSE there but you do not have this, which in and of itself could cause your servos to be overdriven and jittery. A second option would be to change the capacitor size to a smaller value and change your calculations. In any event your code should probably be restructured similar to the Fast IR Roaming code to best handle this.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.