Forum Update - Announcement about May 10th, 2018 update and your password.

Making a BS2 from scratch

Hello, I have heard that the BS2 Interpreter is a PIC module, and that is is not in itself programmed, that it simply reads the PBASIC tokens and executes them. Is it possible to get that PIC module and find the PBASIC "tokenizer" program, load it, then us it as a replacement interpreter on a BS2?

Comments

  • 30 Comments sorted by Date Added Votes
  • Hello, I have heard that the BS2 Interpreter is a PIC module, and that is is not in itself programmed, that it simply reads the PBASIC tokens and executes them. Is it possible to get that PIC module and find the PBASIC "tokenizer" program, load it, then us it as a replacement interpreter on a BS2?
    I don't think that Parallax has made the interpreter source of binary available. That is essentially the "family jewels".

  • AwesomeCronk,

    You have it wrong!
    The PIC is programmed with the PBASIC interpreter.
    The PBASIC program is stored in an external EEPROM as tokens.
  • David
    I see what You mean. I think I would just have to get the SSOP version of the interpreter that Parallax has.

    Genetix
    I thought that the PIC was the large "Interpreter" on the bottom half of the module. If not, then where is it?

    Thanks guys.
  • Mike GreenMike Green Posts: 22,735
    edited May 4 Vote Up0Vote Down
    The PIC is the large chip on the bottom half / third of the module. The PBasic "interpreter" is a program that Parallax programs into PICs that they sell as OEM "interpreter" chips. This program is not available and can't be read from "interpreter" chips. It's proprietary (secret).
  • The Bs2 is just a PIC16F57 in the OEM version. So you just use a basic compiler from Mikroe or microchip to program the blanks with the hex file. The blank PIC's cost less than a dollar each.
  • jmgjmg Posts: 11,513
    edited May 4 Vote Up0Vote Down
    Hello, I have heard that the BS2 Interpreter is a PIC module, and that is is not in itself programmed, that it simply reads the PBASIC tokens and executes them. Is it possible to get that PIC module and find the PBASIC "tokenizer" program, load it, then us it as a replacement interpreter on a BS2?

    Parallax used to sell a programmed PIC, to allow you to build a Stamp in any form factor.
    Does not seem to be on the website anymore ?

    Edit : since found one here
  • There are several pre-programmed PICs available for sale on the Basic Stamp OEM portion of Parallax's webstore.
  • Thank you, guys.

  • ' Is it possible to get that PIC module and find the PBASIC "tokenizer" program, load it,'

    No.

    They are only sold pre programmed with bootloader to work with PBasic Editor and firmware on there

    to run programs.

    You are thinking of Micromite.

    They tell you what 32MX PIC to get and you can program it one time with a PICKit 3 and then it is a Micromite.


  • So PICs are a one shot deal as far as programming?
  • If protection fuses are set to blow during programming, then yes, it is a one shot deal. If they are not set, then they can be reprogrammed.
  • Most PICs can be programmed multiple times. The datasheet for the device should tell you how many times. The PBasic "interpreter" is not available. It's the property of Parallax, has never been made available outside of Parallax, and can't be read from a pre-programmed PIC ... well, not without some very specialized and expensive equipment and know-how designed for stealing code from flashed microcontroller chips.

  • 'So PICs are a one shot deal as far as programming? '

    PIC's can be reprogrammed virtually forever like a Stamp.

    Okay. You have to get off on the right foot here and avoid any misconceptions at

    the beginning that are hard to shake off.

    Stamp are like PIC's with training wheels.

    They protect you from some of the things that take a while to learn.

    Bottom line get a Stamp 2 Board of Education or Homework board and start doing experiments in Basic.

    Keep that in mind.It's Basic language. Easy to learn.

    Later if you like this kind of thing it will be PIC's with C language.

    Or Propeller with C if you really find a home here.


  • AwesomeCronkAwesomeCronk Posts: 242
    edited May 5 Vote Up0Vote Down
    I am a long time friend of the BS2, no worries there. I am trying to get into Spin or C eventually.
  • microcontrolleruser,

    The Stamp does not have a bootloader, it's an interpreter.
    You are thinking of a Picaxe which uses a bootloader.

    Stamp programs are stored in the EXTERNAL EEPROM, not the PIC itself.
    The PIC is programmed with Parallax's Stamp PBASIC interpreter.
    When the Stamp is reset, the interpreter grabs the PBASIC tokens (program) from the external EEPROM and starts executing them.


  • Genetix

    Can that scheme be adapted to PIC and it's .hex files ?






  • Genetix

    I have a glimmer of how it works.

    The IDE sends bits to the interpreter.

    Now the interpreter I may have miscalled it a bootloader.But there is some firmware in there.

    Which I believe is using up the program and data memory on the underlying PIC.

    Hence no room for instructions anyhow.

    Then the bits are converted to assembler instructions for the PIC by this 'interpreter'.

    That about how it works?





  • kwinnkwinn Posts: 7,848
    Genetix

    I have a glimmer of how it works.

    The IDE sends bits to the interpreter.

    Now the interpreter I may have miscalled it a bootloader.But there is some firmware in there.

    Which I believe is using up the program and data memory on the underlying PIC.

    Hence no room for instructions anyhow.

    Then the bits are converted to assembler instructions for the PIC by this 'interpreter'.

    That about how it works?



    Not quite. Typically the IDE translates the Basic instructions into a number of "bytecodes", and the "interpreter" jumps to a PIC assembler subroutine based on that bytecode. A Basic instruction will produce one or more Bytecodes, and each Bytecode subroutine will be two or more PIC assembler instructions.
    In science there is no authority. There is only experiment.
    Life is unpredictable. Eat dessert first.

  • Can that be done for PIC's and it's .hex files?

    Or has it already been done with the bootloader's?

    Are you sure about the subroutine part?

    How about assembler macros?



  • Awsome Cronk

    Do you have any more questions about what Basic Stamp to use?


  • Mike GreenMike Green Posts: 22,735
    edited May 6 Vote Up0Vote Down
    The PBasic bytecodes were very carefully designed to take up minimal memory space yet be easily decoded by the PBasic interpreter. There was a book written by a non-Parallax author on the format of the bytecodes used in the BS1. He wrote lots of little programs with only very small differences between them, then compiled them with the PBasic Editor and looked at the resulting binary files to figure out what got compiled into what. There's no similar documentation on the BS2 bytecodes.

    The PBasic interpreter does not translate these bytecodes into PIC instructions. The interpreter is a PIC program that reads bytecodes from the attached EEPROM and performs the operations encoded in the bytecodes.
  • microcontrolleruser,

    The BASIC Stamp Editor does not compile programs.
    A compiler converts a program to Machine Language or the Operation Codes for each instruction.

    The BASIC Stamp Editor tokenizes the program or it encodes it a special format that tells the Interpreter what the command is what data it needs for that command.
    A tokenized program is not Machine Language so a PIC can not use it, only the PBASIC interpreter burned into the PIC of a Stamp module.

    Also, the BASIC Stamp Editor downloads the program onto the external EEPROM of the Stamp Module.
    IT DOES NOT DOWNLOAD THE PROGRAM INTO THE PIC CHIP OF THE STAMP MODULE!
    The PIC was programmed by Parallax with their PBASIC interpreter which has never been released to the public.


  • Okay.Looks like tokenizing and interpreting is only useful if you intend on packaging a language with it.

    Which brings up a question.

    Why in all this time has Parallax not added a PIC with more memory and brought out a C language?

    Okay.As far as 'Does a bootloader help with PIC's?'.Yes it does.

    It gets you part of the usefulness of a Stamp but you can still use assembler and C.



  • Awesome Cronk

    I have not forgotten about you.

    Take a look at the 'bettter' stamps.The Stamp 2 SX through the Stamp P40.

    They add a lot of features to the Basic Stamp.

    If you can solder surface mount they have processors only for $12.99 each.

    https://www.parallax.com/catalog/microcontrollers/basic-stamp/oem

    THAT is a good deal!

    Best deal in a DIP is the Stamp 2 SX.

    A rule of thumb is you always get the most chip you can for the money.

    Highest pin count, most memory and most peripherals.



  • I was only thinking of either making a multicore stamp or repairing a BS2.
  • microcontrollerusermicrocontrolleruser Posts: 955
    edited May 9 Vote Up0Vote Down
    Awesome

    One thing at a time.

    What about the BS2 repair?


  • I have had BS2 modules wear out a memory or interpreter in the past and thought that it would be more cost effective to have a memory and interpreter laying around to solder on as a replacement.

  • Yes.If you use Basic Stamp 2 DIP version then the Stamp WITH the interpreter progammed on to it and the

    EEPROM would be separate.

    Then if the DIP or the EEPROM fail you just have to replace one.

    Like the old rule.Don't buy a TV with a built in DVD player.If one goes out then you have to replace the whole thing.

    Hope that helps.


  • AwesomeCronk,

    Contact Parallax Technical Support.

    EEPROM memory cells are good for over a million writes so unless you constantly write to them they shouldn't wear out.
  • I was only thinking of either making a multicore stamp or repairing a BS2.

    Been there, done that, but interest just wasn't there....
    https://forums.parallax.com/discussion/143318/35-mini-propeller-module-propbsc-cancelled/p1

    On another thread, I posted something more related to this thread about building your own BS2PX equivalent stamp:
    For reference, about a year ago, I did a budgetary cost analysis on a build of 100 BS2PX boards based upon my own design that very closely resembles the official BS2PX because a colleague had asked about ways to lower the cost of a board he had designed around the 2PX. With buying the 2PX chip from Parallax and all other parts from standard distributors, the total part cost for a build of 100 would be around $1500. Add in some assembly costs and NREs, like a stencil, this brings the total up around $2,300.
    So, if you were to design an actual BS2PX equivalent PCB, you could make them for around $23 each when you do 100 at a time.

    To go a step further, I costed out building just 3 using OSHPark for the fabs and handsoldering the entire board. The price came out around $60 each.



Sign In or Register to comment.