Shop OBEX P1 Docs P2 Docs Learn Events
BS2sx meets highschool robotics team — Parallax Forums

BS2sx meets highschool robotics team

ArchiverArchiver Posts: 46,084
edited 2003-10-21 00:16 in General Discussion
Well, after screwing ourselves over last "season" at SME, our team
started rebuilding our robot and reprogramming using an EDURobotics
kit. After ~10 revisions, we're close to getting our "baby" to go
through a maze - but not close enough. How can I keep motors going
for a certain ammount of time without going to the mainloop?
For example, I'm trying to make our robot make a HARD left turn but
I can't since it resamples each loop and halfway through the turn,
the front sensor reads false. Can I keep the motors set to a certain
power output or set the sensor for a period of time? I can't use
PAUSE because motor output it stopped. I can post the current logic
if you want, it uses two IR sensors.

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-10-20 12:24
    --- In basicstamps@yahoogroups.com, "tc_lawabider"
    <tc_lawabider@y...> wrote:
    > Well, after screwing ourselves over last "season" at SME, our team
    > started rebuilding our robot and reprogramming using an EDURobotics
    > kit. After ~10 revisions, we're close to getting our "baby" to go
    > through a maze - but not close enough. How can I keep motors going
    > for a certain ammount of time without going to the mainloop?
    > For example, I'm trying to make our robot make a HARD left turn but
    > I can't since it resamples each loop and halfway through the turn,
    > the front sensor reads false. Can I keep the motors set to a
    certain
    > power output or set the sensor for a period of time? I can't use
    > PAUSE because motor output it stopped. I can post the current logic
    > if you want, it uses two IR sensors.


    Why not setup a counter variable. When the sensor is triggered the
    motors should go into Hard Left turn mode for say 50 times through
    the main loop. The idea is that the sensor puts the robot into hard
    left mode, but only the conclusion of 50 (or whatever) passes through
    the main loop will end the hard left.
  • ArchiverArchiver Posts: 46,084
    edited 2003-10-21 00:16
    We've done well in the RI/SME maze over the last several years.

    First, your left wall sensor should not be pointed directly to the left. About
    a 45 degree angle works best. We did this to anticipate the left hand turns
    better. Last winter we tried to get sonar to work and gave up. Apparently, the
    45 degree angle gave substantial information on the BOEBot's direction. That
    is: If the BOEBot was angling toward the wall, the wall appeared closer. If the
    BOEBot was angling away from the wall, the wall appeared farther away.

    Second, the front sensor implementation is almost trivial compared to the side
    sensor. So, get the BOEBot to run parallel to the wall without wavering in or
    out. Then incorporate the left turn. Once that is working properly, then
    incorporate the front sensor for right turns.

    Third, you need some distance adjustment to allow for the difference in lighting
    from location to location, and even time of day (critical at Rochester last
    year!). We use 500 ohm trimmers to adjust the current to the IR LEDs.

    We used the BS2 in 2001 and 2002 then change to the BS2SX for 2003. The BS2SX
    gave much better distance sensing than the BS2. To get the break frequencies we
    ran the BS2SX in a loop that tried to sense the wall ten times and recorded the
    number of hits. If it saw the wall, then it got a 10. If it didn't see the
    wall, then it got a zero. We did this every 25 Hertz from 32,500 to 38,750
    Hertz. In BS2SX code that is "FOR F = 13000 TO 15500 STEP 10". We also did
    this for every distance from 1 inch to 20 inches. StampDAQ really helped! Then
    we looked for the largest differences at the various distances.

    Here is the BS2SX code that still used the pulsout to run the servos (we also
    converted to Pololu for 2003):

    '{$STAMP BS2sx}
    pc VAR Word
    sc VAR Word
    l_values VAR Byte
    f_values VAR Byte
    lvalues VAR Byte
    fvalues VAR Byte
    counter VAR Nib
    IR_freq VAR Word
    OUTPUT 5
    OUTPUT 12
    LOW 13
    LOW 14


    main:
    GOSUB check_sensors
    ' fvalues = 6
    ' lvalues = 1
    ' debug cls, "front = ", dec fvalues, " left = ", dec lvalues
    IF lvalues = 0 THEN hlt
    BRANCH fvalues, [noparse][[/noparse]side,ert,rt,rt,hrt,hhrt,hhhrt]
    side:
    BRANCH lvalues, [noparse][[/noparse]hlt,lt,elt,straight,ert,rt,hrt]
    GOTO main


    check_sensors:

    IF sc <> 1 THEN left
    l_values = 0
    FOR counter = 0 TO 5
    LOOKUP counter, [noparse][[/noparse]15310,15290,14800,14530,14240,13870], IR_freq
    FREQOUT 12,1, IR_freq
    l_values.LOWBIT(counter) = ~IN10
    NEXT
    lvalues = NCD l_values
    sc = 0
    RETURN

    left
    f_values = 0
    FOR counter = 0 TO 5
    LOOKUP counter, [noparse][[/noparse]15150,14670,14380,13900,13490,13060], IR_freq
    FREQOUT 5,1, IR_freq
    f_values.LOWBIT(counter) = ~IN7
    NEXT
    fvalues = NCD f_values
    sc = 1
    RETURN



    hlt: '12" dia
    PULSOUT 13, 2300
    PULSOUT 14, 1850
    PAUSE 10
    GOTO main


    lt: '22" dia
    PULSOUT 13, 2300
    PULSOUT 14, 1800
    PAUSE 10
    GOTO main



    elt: '1' after 5'
    PULSOUT 13, 2300
    PULSOUT 14, 1680
    PAUSE 10
    GOTO main


    straight: 'Straight R 2300 L 1400
    PULSOUT 13, 2300
    PULSOUT 14, 1400
    PAUSE 10
    GOTO main


    ert: '1' after 5'
    PULSOUT 13, 2100
    PULSOUT 14, 1400
    PAUSE 10
    GOTO main


    rt: '22" dia
    PULSOUT 13, 1950
    PULSOUT 14, 1400
    PAUSE 10
    GOTO main


    hrt: '12" dia
    PULSOUT 13, 1900
    PULSOUT 14, 1400
    PAUSE 10
    GOTO main


    hhrt: '8" dia
    PULSOUT 13, 1850
    PULSOUT 14, 1400
    PAUSE 10
    GOTO main


    hhhrt 'Pivot
    PULSOUT 13, 1800
    PULSOUT 14, 1400
    PAUSE 10
    GOTO mail

    Good luck at Marion in April.

    Rick

    [noparse][[/noparse]Non-text portions of this message have been removed]
Sign In or Register to comment.