Shop OBEX P1 Docs P2 Docs Learn Events
Basic Stamp 2 Memory - Page 2 — Parallax Forums

Basic Stamp 2 Memory

2»

Comments

  • The Basic Stamp Syntax and Reference Manual is the "bible" on the Stamps. You can download it for free from Parallax or buy a paper edition. Pages 82-84 discuss how the I/O pins are used, initialized, etc.
  • microcontrolleruser,

    Look in the BASIC Stamp Manual.

    I/O pins default to input (DIRx = 0) on power-up.
    If you change them to output though, they will be defaulted to low (OUTx = 0).

  • Thank you Mr Green

    Have two Stamp Manual books and it's an icon on desktop.

    Thank you Genetix

    "I/O pins default to input (DIRx = 0) on power-up.
    If you change them to output though, they will be defaulted to low (OUTx = 0). "

    Input and outputs are PIC TRIS with a 1 for input and a 0 for output.

    Found out why Parallax says 470 ohm resistor for LED and PIC practice is 680.

    Homework board already has 220 ohm resistor on pin. 220 plus 470 equals 690.

    "The fruit doesn't fall far from the tree"

  • "Input and outputs are PIC TRIS with a 1 for input and a 0 for output"
    It doesn't matter what the PIC documentation says. The PBasic interpreter that's stored in the Stamp's flash memory is a program. Like any program, it goes through some initialization code before the user interacts with it. In this case, the I/O pins are initialized to input mode on a reset and the output buffer is initialized to zeroes. The size of a current limiting resistor for use with an LED has to do with the amount of current an I/O pin can handle or a group of I/O pins along with the forward voltage of the LED, not "PIC practice". The 220 Ohm value was chosen to prevent damage to an I/O pin if the pin were to be connected to another pin in the opposite state or directly to Vss or Vdd while in the opposite state.

  • "It doesn't matter what the PIC documentation says"

    Sure does if you are trying to figure out what Parallax does to make a Stamp and the Stamp Editor.

    "it goes through some initialization code before the user interacts with it."

    You call it initialization. I learned configuration. Config line plus Configuration section of code.

    All you saying about resistors. How about protecting LED from burning out?

    ANYBODY KNOW WHERE SCHEMATIC IS FOR SERIAL HOMEWORK BOARD?






  • Here is stray post

    Got out board and LCD.

    Here is some of preparation to be done.

    s you can see from the table, there is also a fourth
    choice called Test. Use this Test mode to confirm
    that the power and ground to the LCD are hooked up correctly before you send it any data. Move the dip
    switches to the Test setting and turn on the power.
    The LCD display should turn on with the backlight on
    (models 27977, 27979) and display the following text:
    Parallax, Inc.
    www.parallax.com
    If you don’t see the text at first, try adjusting th
    e LCD contrast by turning the pot labeled “Increase
    Contrast” with a screwdriver. Turn it in the directio
    n of the arrow to make the characters show up more
    clearly. If you still don’t see the characters, go back
    and check your electrical connections and try again.
    Once you’ve successfully completed test mode, move th
    e dip switches to the correct positions to select
    the baud rate you want to use for your application.


    Any tips about connecting up LCD?
  • kwinnkwinn Posts: 8,697
    ....
    All you saying about resistors. How about protecting LED from burning out?

    The 220 ohm resistor Mike mentioned would limit the current to a level (~13ma) that will not damage leds.

  • Thank you Kwinn

    At this point how about we just say there are the resistors on all the pins and leave it there?

    Back to Basic Stamp memory.

    Here's Wikipedia article on Interpreter.

    https://en.wikipedia.org/wiki/Interpreter_(computing)

    Your program is not acting on the PIC at all.

    That was already a done deal when Paralllax's interpreter program was compiled and the Stamp was programmed at the factory.

    The Stamp is taking your 'program' and 'performing' according to what PIC like features have been included in interpreter.

    Maybe Chip Gracey can confirm that if he remembers from doing it.

    So. You could look at the way a Stamp operates as a simulator or alias.

    Also. Digging into the Stamp is 'shadow boxing'. To really know you would have to see the interpreter program.







  • microcontrollerusermicrocontrolleruser Posts: 1,194
    edited 2018-11-17 15:40
    Let me make this clearer. Let's use an SX as an example.

    Your SX program uses the SX registers. The Stamp program does not use the PIC registers.

    Those are being used by the interpreter. The interpreter is a layer between you and the PIC16F57.

    That is why the 'Memory read' with Stamp tells you it is not reading the Stamp it is telling you how much 'memory' you have used.

    That should help.
  • Let me make this clearer. Let's use an SX as an example.

    Your SX program uses the SX registers. The Stamp program does not use the PIC registers.

    Those are being used by the interpreter. The interpreter is a layer between you and the PIC16F57.

    That is why the 'Memory read' with Stamp tells you it is not reading the Stamp it is telling you how much 'memory' you have used.

    That should help.

    Can you quote the post you are making reference to and by who?
  • kwinnkwinn Posts: 8,697
    I think it is a bit more involved than that. From what I have read about the Basic Stamps it sounds like the PIC is pre-programmed with a bytecode interpreter. Your Basic program is compiled into bytecodes by the Pbasic IDE/Editor running on a PC/Netbook and downloaded to the PIC. The PIC assembly language instructions then perform the functions specified by the bytecodes.
  • "what PIC like features have been included in interpreter"
    You've got that backwards. You start with what features you would like your "ideal" microcontroller to have, trim them back to the point where you're likely to fit the features into a "real" device like the PIC16F57, then write a program (the interpreter) to emulate the "ideal" instruction set.

    There used to be a book, written by a 3rd party, that described the interpretive code format for the BS1. Unfortunately I don't have that link anymore. The author wrote small program fragments, dumped the binary files created by the Stamp Basic compiler, and carefully analyzed the changes in the binary files. The interpretive code is very very compact ... not surprising when the program size was limited to 256 bytes.

    There has not been a corresponding analysis of the BS2 code format. That would be more difficult given the larger language accepted and the lack of interest. Parallax still considers this information as proprietary. Fortunately, Parallax has committed to open source for new products. The Propeller 2 is and will be all open source. The Propeller 1 has been redone in Verilog which is open source.

  • "Can you quote the post you are making reference to and by who? "

    Going by Wikipedia article.

    "I think it is a bit more involved than that.'

    Yes there is. That is just a simplified explanation. The Stamp IDE and the 'program' that you enter yield actions from the Stamp.

    Using an SX or a PIC there is a direct matchup between your program and the result.

    Guess the big difference is you can read the device with SX and PIC. You cannot with Stamp.

    " You start with what features you would like your "ideal" microcontroller to have, trim them back to the point where you're likely to fit the features into a "real" device like the PIC16F57, then write a program (the interpreter) to emulate the "ideal" instruction set.
    "

    That is a good way to say it too.

    When all is said and done. Now I am ready to use Stamp on it's own terms.



  • PublisonPublison Posts: 12,366
    edited 2018-11-17 17:26
    "Can you quote the post you are making reference to and by who? "

    Going by Wikipedia article.

    Again, can you post a link to the quote?

  • Last time. Here's the Wikipedia link.

    https://en.wikipedia.org/wiki/Interpreter_(computing)

    First section describes how an interpreter like Pbasic works.

  • "The interpreter is a layer between you and the PIC16F57"
    Absolutely true. Some positive things an interpreter does: insulate the user (programmer) from some of the weirder features of the hardware ... often timing problems; provide features (virtual hardware) not directly available in the "real" hardware like a UART or 16-bit word oriented arithmetic, multiply and divide operations. Some negative things an interpreter does: create inefficiencies ... adds interpreter overhead to the actual speed of the hardware.

    "it is not reading the Stamp it is telling you how much 'memory' you have used"
    Also true. The user's program is stored in an EEPROM that's external to the PIC16F57 - for the BS2, PIC16C56A for the BS1. For the BS1, it's a 256 byte EEPROM. For the BS2, it's a 2K byte EEPROM. That's the user memory that's reported. The number of data bytes is small, fixed and no record is kept of which are used.
  • https://en.wikipedia.org/wiki/Interpreter_(computing) Use the link icon if the forum software misinterprets what you really meant. :-)
  • microcontrollerusermicrocontrolleruser Posts: 1,194
    edited 2018-11-17 20:55
    Thank you Mike and PMRobert

    I'm good with using the Stamp as is.

    I would say the PICBasic IDE that compiles and works directly on the PIC is how I was thinking of Stamp at the beginning.

    That's off the table now.

    Micro-interpreter like Stamp works differently than that.

    Will just work with Stamp and what the manual says results will be and no go digging into it.

    For the good reason is there is no 'it'. The Stamp IDE could be altered to just run off a PC with an I/O board and work the same.

  • "The Stamp IDE could be altered to just run off a PC with an I/O board and work the same"
    Proteus does this sort of thing for a variety of microcontrollers. At one point, they had a version that simulated a Basic Stamp along with some
    simple peripheral hardware (pushbuttons, LEDs, small motors, etc.). Now they only support ARM,
    NXP, TI, Atmel, PIC, AVR. Cost is $250 minimum to over $6000 depending on the number of users,
    which processors, commercial vs. educational, etc.

  • Thank you Mike

    I think it would be wise to to say Pbasic is a high level language AND it is interpreted.

    Running C on a PIC is a high level language with no interpreter.

    You had a good point about Stamp program being in EEPROM.

    Program on SX or PIC is stored on them.

    SX and PIC are microcontrollers while the Stamp is a Micro-interpreter.

    Now I'm ready to use the Stamp knowing how it works a little better.



  • "while the Stamp is a Micro-interpreter"
    It depends on your point of view. They're all microcontrollers with program and data memory on chip along with an execution unit (CPU). All of them (SX, PIC, AVR, whatever) don't normally bring the address and data busses off chip. The Stamp interpreter is a program that runs on either a PIC or SX and "pretends" to be a Basic Stamp microcontroller with the program stored in an external I2C EEPROM. To the Stamp interpreter, the EEPROM is an external I2C device. Try not to force a distinction between a Basic Stamp, SX, or PIC. There isn't really much of one.

    PBasic is a medium to high level language. On the Basic Stamps, it's interpreted. If you use PICBasic and carefully constrain the language elements used so it's compatible with PBasic, you have native execution on a PIC microcontroller. It all depends ...
  • microcontrolleruser,

    Chip grew up in the age of 8-bit Microsoft BASIC microcomputers so it shouldn't be a surprise that PBASIC functions similarly.

    The 220 Ohm resistors on the Homework board will limit how much current flow back into an I/O pin.
    If you were to make a mistake and 5V went into the I/O pin, it would burn it out had that resistor not been there.

    If you have only have a few LEDs then you can use whatever resistor value that you want, but for a lot of LEDs there is a limit on how much current is available.
    If you look at the chapter on the 7-segment display in "What's a Microcontroller?" you will see that 1K resistors are used.

  • Thanks Mike and Genetix

    Will be using the Stamp more often now.
  • The article Mike mentioned, about the internal operation of the Basic Stamp 1 interpreter, is still available here...
    http://www.mcmanis.com/chuck/Robotics/stamp-decode.html
    A process of deduction.

    Chip had to be clever to fit the interpreter into the limited PIC memory. It is not bytecode that respects byte boundaries. Instead, it is at bit-code, in the sense that the instructions and operands are variable length.

    There was another deep look, Inside the BASIC Stamp II, by Brian Forbes, self-published, but it is hard to find.

  • microcontrolleruser,

    I don't know what your background is but the BASIC Stamp was designed for those of us who grew up in the microcomputer BASIC era.

    If this is all new to you then you might be better off starting out with something like an Arduino which is also very easy to use but uses C.
    Otherwise skip the Stamp and start with the Propeller which can use C, BASIC, or a graphical language called BlockyProp.

    It would be nice if we knew what your long term plans were other than dabbling with this and that and everything in between.

    For a long time I was resistant to move to the Propeller because Spin, the native's native language, is different than PBASIC.
    I found about 3/4 is the same which made the transition easier and now I love working in Spin.
    There are a few diehards out there who stick with the BS2 because the Propeller is different.
    There are more language choices now then I started.

    If you decide to stick with the BS2 then I will help you out as much as I can but you should always have the BASIC Stamp Manual ready to go.
    The StampWorks text is probably one of the best collections of circuits and code in one place so you should definitely look at that.
    What's a Microcontroller will get you started though so use that one first.

    As always, ask questions if you don't understand something or are not sure what to do.
  • Mike GreenMike Green Posts: 23,101
    edited 2018-11-18 23:12
    Ditto on "What's a Microcontroller?" and "StampWorks". There's also the beginning of a "What's a Microcontroller?" for the Propeller using C as the language. I suspect this will eventually be completed, but with BlocklyProp as the main programming language and C for more advanced topics (since BlocklyProp generates C code).
  • microcontrollerusermicrocontrolleruser Posts: 1,194
    edited 2018-11-19 05:12

    Thank you Genetix and Mike

    "dabbling with this and that and everything in between."

    That's all I can do right now.

    Yes. The Basic Stamp books are very good.
Sign In or Register to comment.