Shop OBEX P1 Docs P2 Docs Learn Events
bs1 source code — Parallax Forums

bs1 source code

ArchiverArchiver Posts: 46,084
edited 2004-01-08 18:28 in General Discussion
Hello,

I just recently started working with basic stamps, bs2-home work
board, sumo-bot, and now a bs1-ic. There is plenty of documentation
on the bs2 but I am having trouble finding anything on the bs1. In
particular I am trying to add reverse and turn to my breadbot
constucted from directions in nuts and volts mag by Robert Nansel. I
can get all whiskers to do a reverse but cannot figure out how to add
turn (left or right whiskers) or about face (front bumper). studying
the syntax is not helping I am more of a do type of person. anyway
any help would be appreciated.


thanks Jon

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2004-01-07 10:36
    With BS1 support in our latest compiler you'll start seeing more BS1
    projects from us -- I've already used the BS1 a couple times in my Nuts
    & Volts column, in fact, the February column has to do with a simple
    robot core using the BS1 and a Pololu motor controller.

    If you do a search on the Net you'll find lots of BS1 code (many of my
    old programs are still floating around cyberspace).

    As far as your specific question, just keep in mind that turning is
    caused by rotating the motors in opposite directions. So, if you can
    make your bot go forward and go in reverse, you're almost there. Let's
    say you want to process a whisker input by backing up, turning, then
    continuing. You process would go something like this:

    On whisker input...
    * both motors reverse
    * pause long enough to back up
    * whisker-side motor forward
    * pause for turn
    * both motors forward

    Your actual code will depend on the type of motors you're using, the
    inputs and how they operate, etc.

    -- Jon Williams
    -- Applications Engineer, Parallax
    -- Dallas Office


    Original Message
    From: peterman921 [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=zXIsmkKD_InZZLPVUa7qRCQ4jJdeNwIs4a2gWI-mdtGqVQTyNEQ4SFDV9FnXPm3u_krELt_AMQFacA]signjon@e...[/url
    Sent: Tuesday, January 06, 2004 10:17 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] bs1 source code


    Hello,

    I just recently started working with basic stamps, bs2-home work
    board, sumo-bot, and now a bs1-ic. There is plenty of documentation
    on the bs2 but I am having trouble finding anything on the bs1. In
    particular I am trying to add reverse and turn to my breadbot
    constucted from directions in nuts and volts mag by Robert Nansel. I
    can get all whiskers to do a reverse but cannot figure out how to add
    turn (left or right whiskers) or about face (front bumper). studying
    the syntax is not helping I am more of a do type of person. anyway
    any help would be appreciated.


    thanks Jon



    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject
    and Body of the message will be ignored.


    Yahoo! Groups Links

    To visit your group on the web, go to:
    http://groups.yahoo.com/group/basicstamps/

    To unsubscribe from this group, send an email to:
    basicstamps-unsubscribe@yahoogroups.com

    Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/




    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
  • ArchiverArchiver Posts: 46,084
    edited 2004-01-08 05:38
    --- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
    wrote:
    > With BS1 support in our latest compiler you'll start seeing more BS1
    > projects from us -- I've already used the BS1 a couple times in my
    Nuts
    > & Volts column, in fact, the February column has to do with a simple
    > robot core using the BS1 and a Pololu motor controller.
    >
    > If you do a search on the Net you'll find lots of BS1 code (many of
    my
    > old programs are still floating around cyberspace).
    >
    > As far as your specific question, just keep in mind that turning is
    > caused by rotating the motors in opposite directions. So, if you
    can
    > make your bot go forward and go in reverse, you're almost there.
    Let's
    > say you want to process a whisker input by backing up, turning, then
    > continuing. You process would go something like this:
    >
    > On whisker input...
    > * both motors reverse
    > * pause long enough to back up
    > * whisker-side motor forward
    > * pause for turn
    > * both motors forward
    >
    > Your actual code will depend on the type of motors you're using, the
    > inputs and how they operate, etc.
    >
    > -- Jon Williams
    > -- Applications Engineer, Parallax
    > -- Dallas Office





    so each action has its own line in the code with a short pause
    between actions? I was trying basically two then statements after the
    if


    'straight line drive routine
    '

    drive:
    IF drive_direction <> fwd THEN drive_reverse

    drive_forward:
    l_spd = lstop + l_drive_speed
    r_spd = rstop - r_drive_speed
    GOTO drive_loop

    drive_reverse:
    l_spd = lstop - l_drive_speed
    r_spd = rstop + r_drive_speed

    drive_loop:
    FOR delta = 0 TO drive_distance
    PULSOUT left, l_spd
    PULSOUT right, r_spd
    PAUSE pauseval
    IF fbumper = bump THEN drive_reverse
    IF lwhisker = bump THEN drive_reverse
    IF rwhisker = bump THEN drive_reverse

    NEXT delta
    RETURN



    thanks for the help

    Jon
  • ArchiverArchiver Posts: 46,084
    edited 2004-01-08 18:28
    If you're looking to do a rover type bot you can simplify your code a
    bit. And before I forget, it's bad practice to GOTO a subroutine (there
    is nothing on the GOSUB stack when you hit RETURN and this can lead to
    problems). You can construct a rover like this:

    Setup:
    DIRS = %11000000 ' motors on P7 (L) and
    P6 (R)

    Main:
    PAUSE 20 ' standard servo
    refresh delay
    bumpers = PINS & %00000011 ' bumpers on P1 (L) and
    P0 (R)

    BRANCH bumpers, [noparse][[/noparse]Fwd, Go_Left, Go_Right, About_Face]

    Fwd:
    PULSOUT LMotor, LStop + LDriveSpeed
    PULSOUT RMotor, RStop - RDriveSpeed
    GOTO Main

    Go_Left:
    PULSOUT LMotor, LStop
    PULSOUT RMotor, RStop - RDriveSpeed
    GOTO Main

    Go_Right:
    PULSOUT LMotor, LStop + LDriveSpeed
    PULSOUT RMotor, RStop
    GOTO Main

    About_Face:
    PULSOUT LMotor, LStop
    PULSOUT RMotor, RStop
    PAUSE 20

    ' reverse
    FOR idx = 1 TO 50 ' adjust for backup
    distance
    PULSOUT LMotor, LStop - LDriveSpeed
    PULSOUT RMotor, RStop + RDriveSpeed
    PAUSE 20
    NEXT

    ' spin
    FOR idx = 1 TO 100 ' adjust for 180 turn
    PULSOUT LMotor, LStop + LDriveSpeed
    PULSOUT RMotor, RStop + RDriveSpeed
    PAUSE 20
    NEXT

    GOTO Main


    You can use this (with some tweaking) as a starting point for your bot.

    -- Jon Williams
    -- Applications Engineer, Parallax
    -- Dallas Office



    Original Message
    From: peterman921 [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=2cYCEnQpF_raPvUNqtUiDp9lOz0ogqgo-eS3k-J3tSuWCGqlj6p5h2TA0TBCX-skMbpQ5--J7_DG]signjon@e...[/url
    Sent: Wednesday, January 07, 2004 11:39 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Re: bs1 source code

    so each action has its own line in the code with a short pause
    between actions? I was trying basically two then statements after the
    if


    'straight line drive routine
    '

    drive:
    IF drive_direction <> fwd THEN drive_reverse

    drive_forward:
    l_spd = lstop + l_drive_speed
    r_spd = rstop - r_drive_speed
    GOTO drive_loop

    drive_reverse:
    l_spd = lstop - l_drive_speed
    r_spd = rstop + r_drive_speed

    drive_loop:
    FOR delta = 0 TO drive_distance
    PULSOUT left, l_spd
    PULSOUT right, r_spd
    PAUSE pauseval
    IF fbumper = bump THEN drive_reverse
    IF lwhisker = bump THEN drive_reverse
    IF rwhisker = bump THEN drive_reverse

    NEXT delta
    RETURN



    thanks for the help

    Jon



    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject
    and Body of the message will be ignored.


    Yahoo! Groups Links

    To visit your group on the web, go to:
    http://groups.yahoo.com/group/basicstamps/

    To unsubscribe from this group, send an email to:
    basicstamps-unsubscribe@yahoogroups.com

    Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/




    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
Sign In or Register to comment.