Shop OBEX P1 Docs P2 Docs Learn Events
basic stamp in C — Parallax Forums

basic stamp in C

ch2845ch2845 Posts: 6
edited 2010-01-07 19:08 in BASIC Stamp
i am a C and java programmer and i happen to have a very old Basic Stamp 2 sumo-bot. i haven't had much experience with Basic Stamps but when i tried programming it i found i did not care for PBASIC very much. after doing a LOT of research i found that you can really only program this with 2 languages: PBASIC or Assembly. that is basically a choice between high level programming and bare bones low level programming. so this got me wondering, if the basic stamp can be programmed in assembly, can i use some kind of C compiler to compile the code into assembly and then upload it to the robot?

Comments

  • ZootZoot Posts: 2,227
    edited 2010-01-06 22:42
    You can not code a Basic Stamp in assembly (rather, if you did, you would permanently be overwriting the "pre-burned" Pbasic Interpreter).

    In theory, you could create a C compiler that would tokenize into a ready-to-download Pbasic token stream, but I don't see that it would be worth it.

    There are some C compiler's available for the Propeller and a few for the SX (both of which can be programmed in Basic-like languages, assembly, and C with third-party compilers).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • ch2845ch2845 Posts: 6
    edited 2010-01-07 15:48
    thats too bad. the robot i have seems to already be hardcoded in assembly. the only way to control the robots movements is by sending in pre-programmed constants which the robot interprets to do very basic movements such as forward, backward, left or right. i can't program it to move the left wheel forward for instance, i believe that is do to some other IC board on the robot that both wheels are connected to.

    the main reason i really wanted to switch it to C is because of the functions. the largest drawback from PBasic i see is the inability of making real functions. for instance, what if i want to make a function where you input a value and it outputs a value?in PBasic i would have to make two values beforehand and then i wouldn't be able to clear the memory when i'm. i also can't find any way to include multiple files in PBasic.

    just curious though, has anyone tried to overwrite the interpreter?is there any public alternative to the PBasic interpreter for the basic stamp?
  • ZootZoot Posts: 2,227
    edited 2010-01-07 16:11
    There's no point to overwriting the interpreter -- at that point you would have, essentially, a PIC or an SX on a small PCB with a power regulator, RS-232 level shifter and EEPROM. You would not be able to re-burn the interpreter either, as the interpreter is protected Parallax IP and is only available "pre-burned" on a regular Stamp or on an SX/PIC for the OEM Stamp intrepeter chips.

    You could build a board like that for less than $6 or so and program it using a variety of compilers. Some users at the forums even sell PCBs for mounting Propellers or SXes on a Stamp-like footprint, with level-shifter circuitry and an EEPROM.

    If you like your 'bot, but don't like the Stamp, you may want to pull the Stamp and use some other controller.

    Lastly, I don't see how the 'bot is hard-coded in assembly, if it is indeed a Stamp, as you can not program a Stamp in assembly. Is it possible that there is a Pbasic program running on the Stamp already that handles yet more external commands? You said the only way to control the movements is pre-programmed constants? Or is is it possible the Stamp is programmed in Pbasic but that there is some slave board or micro on the 'bot that handles things like servo outs, etc., based on commands from the Stamp?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • davejamesdavejames Posts: 4,047
    edited 2010-01-07 16:12
    ch2845,

    The "interpreter" is what makes a Basic Stamp, a Basic Stamp. Without it, it would be an empty PIC microcontroller.

    Programming in PBasic is a different world especially for those coming from higher level languages. There are certainly restrictions, but considering the Stamp's target market, it is really quite powerful and relatively easy to use.

    To answer your last two questions, no - I haven't tried to overwrite the interpreter and no, I don't know of any other interpreter for the Basic Stamp.

    Regards,

    DJ

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • ercoerco Posts: 20,256
    edited 2010-01-07 16:22
    The C-Stamp is fast &·cheap with lots of i/os, but it won't plug into a Boe-Bot.

    http://www.c-stamp.com/

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"If you build it, they will come."
  • ch2845ch2845 Posts: 6
    edited 2010-01-07 17:10
    well... that answered pretty much all my questions smile.gif. i would love to rip out the Basic stamp and put something like an arduino in there (only because its cheap), however i am not using a Boe-Bot, i am using something much older than it. in fact its so old that the only way i could get information on it was by using the Way-Back machine. the basic stamp is built streight into the main board making it just about impossible to remove it. also as you might notice, there are two PIC chips in there. one is the one from the basic stamp, the other is the actual controlling board. that one i believe is just doing whatever the basic stamp tells it to do. however the second PIC chip is programmed to only require general commands. for instance, you send it a number which it then interprets as "Forward" and it moves forward for 200ms. you cannot tell it to go forward for 300ms for 500ms or any odd number of milliseconds. nor can you tell it to for one motor instead of both.

    therefore perhaps a better response to this problem is to bypass the PIC chip all together somehow. or else reprogram it, although i don't know how you would do either of those options.

    the site for the robot is here: http://web.archive.org/web/20080702002546/http://www.tabrobotkit.com/
    the schematics for it are here: http://web.archive.org/web/20070202034512/www.tabrobotkit.com/pdfs/MHR_RevF.pdf
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2010-01-07 17:17
    Is the bot in question?
    http://www.parallax.com/dl/docs/prod/robo/sumobotman.pdf

    The board seems to have a smd pbasic chip so it can't be easily replaced.
    The manual contains programs to let the bot move.

    More resources
    http://www.parallax.com/tabid/768/txtSearch/sumo/List/0/SortField/4/Default.aspx


    regards peter

    Post Edited (Peter Verkaik) : 1/7/2010 5:30:33 PM GMT
  • ch2845ch2845 Posts: 6
    edited 2010-01-07 17:51
    thats the problem its not that robot. its this robot: sumobotlayout.jpg
    the full schematics of
    the robot are here:web.archive.org/web/20070202034512/www.tabrobotkit.com/pdfs/MHR_RevF.pdf

    the problem is that the Basic stamp is not a module that can be removed from the board, it is part of the board
  • ForrestForrest Posts: 1,341
    edited 2010-01-07 18:10
    Hey, I have that robot also. You're correct about it's capabilities. It's essentially a BS2 tacked onto a PIC controlled robot. You can use the bundled IR remote control to operate the robot, program the BS2 to control the robot thru the PIC controller or simply use it as a small BS2 development platform. If you do the later, be sure and unplug the two red/black motor cables. This will prevent the robot from shooting across you desk when you apply power [noparse];)[/noparse]
  • ZootZoot Posts: 2,227
    edited 2010-01-07 18:14
    That's an OEM BS2, so technically it's a PIC pre-burned w/Stamp interpreter code, an external EEPROM, RS-232 interface, etc. And I guess a slave PIC to handle PWM and IR modulation and the like???

    You could probably hack into the programming pins for the "Stamp" PIC, but again, what's the point? Even if you don't like Pbasic, you will fit way more actually useful code into the Stamp (2k of interpreted code) vs. 2k of PIC assembly, though it runs much slower and can't do RTCC rollovers, interrupts, etc.

    Or just remove the whole circuit board and roll your own controller/motor-driver smile.gif using a Propeller, SX, AVR or the like.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • ercoerco Posts: 20,256
    edited 2010-01-07 18:32
    That TAB Sumo robot is a discontinued "collectible" now. Someone·will either pay for it (Ebay) or trade you for a Boe-Bot or better. You could hack it, but it's limited and you won't go too far with it.·IMHO it's worth more (to someone) unmodified.

    I have a couple of the "other" style TAB robots from the "Build Your Own Robot" kit: http://www.amazon.com/TAB-Electronics-Build-Your-Robot/dp/0071387870 Cute·little robots. They are IR controlled and·have several sensors. There are several different selectable behaviors in ROM, but you can't program it as delivered.··There is an empty socket designed to accept a BS2, so you can add one and have a programmable robot.

    I'm no fan of the exposed worm gears which pick up dirt and wear quickly, but for what it is, it's a good first robot for beginners. All powered by a single 9V battery, even the two motors. Never seen that anywhere else.

    414TDZEW2CL._SS400_.jpg

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"If you build it, they will come."
  • ch2845ch2845 Posts: 6
    edited 2010-01-07 18:43
    i've been trying to unplug those wires for a while smile.gif. they just won't come off though without damaging the ports it seems. i was about 10 when i built it so i may have shoved the plugs in to far. i've lately been using it as a dev platform by aiming the remote at the robot, flipping the switch and hitting the stop button before it has a chance to do anything. it just seems a waste to have all those electronics pre-soldered into the board and not be able to use them. it would be great if it was possible to reprogram the PIC chip. however it is only using up 2 pins of the basic stamp so i'll probably just use it as a dev board and attempt to pry the motor plugs out smile.gif

    ps: this was a reply to the post above the post above the post above smile.gif. i wrote it before the previus two where submitted

    Post Edited (ch2845) : 1/7/2010 6:48:33 PM GMT
  • ch2845ch2845 Posts: 6
    edited 2010-01-07 19:08
    i suppose its really not worth trying to modify. like erco, said its a collectible. i could probably use it as a dev board as is without damaging it and then at some point either sell it or just keep it (its the first robot i ever owned, and it resulted in me eventually wanting to pursue a career in robotics).
Sign In or Register to comment.