Shop OBEX P1 Docs P2 Docs Learn Events
Basic Stamp 1 Symbols (Variables) — Parallax Forums

Basic Stamp 1 Symbols (Variables)


What was that catch about writing to a register?

You have to create a variable first?

I would like to avoid getting stuck in that endless loop again.

Comments

  • PublisonPublison Posts: 12,366
    edited 2017-09-26 18:31
    Do you have a copy of the Basic Stamp Manual?

    It can be downloaded at:

    https://www.parallax.com/product/27218

  • Publison

    Let me look at manual and come up with a specific question.

    I think some of the registers you can write to directly with HIGH/LOW type commands

    or input/output.

    You can write binary b'11111111' to them.That is just an example.

    Let me read a little and see.
  • PublisonPublison Posts: 12,366
    edited 2017-09-26 19:19
    If you go to the help menu in the Pbasic Stamp IDE,under Help, Basic Stamp Help, PBasic Language Reference search for "Write". That will tell you what parameters are allowed for each processor.
  • microcontrollerusermicrocontrolleruser Posts: 1,194
    edited 2017-09-26 19:33
    Pub

    Good steer! I forgot about going in that way.

    Have been going to reference manual pdf or paper.

    Lots of interesting stuff.Scratchpad ram. I can relate to that.

    Can start out with Stamp 1. I think it writes to scratch ram.

  • ercoerco Posts: 20,244
    Sounds like you may want the PINS command for the BS1.

  • Now that would be I/O

    I think PIN is just an extra to write to a certain pin.

    That should be writing to a register or two to have the pin be input/output and high/low.

    Let me see if there are general purpose registers.I think there are.

    Maybe that was the catch. They can only be written to by variables.

    It does say there is scratch ram.

    That is on chip data memory.
  • microcontrolleruser,

    The BS1 does not have Scratchpad RAM nor does the BS2. Only the BS2e, BS2sx, BS2p, BS2pe, and BS2px have it.
    Refer to page 92 of the BASIC Stamp Manual because it says that ScratchPad RAM uses the GET and PUT commands.
    https://www.parallax.com/sites/default/files/downloads/27218-Web-BASICStampManual-v2.2.pdf

    The BS1 is very limited and most of the Parallax texts were written for the BS2 and What's a Microcontroller was written so that even teenagers can learn how to program and use the BS2.
    https://www.parallax.com/sites/default/files/downloads/28123-Whats-a-Micro-v3.0.pdf
  • microcontrollerusermicrocontrolleruser Posts: 1,194
    edited 2017-09-27 06:23
    Genetix

    Edit:You caught me! Have not had time to work on it yet!

    That's okay. It does not look like something I want to start with anyhow.Stamp 1 it is.End Edit.

    This reminds me to say 'one thing at a time/then explain it' when I write.

    'The purpose of the PIN directive is to give an alias to an I/O pin and let the compiler determine whether a given line of code requires a numeric value for the pin, the output bit for that pin, or the input bit for that pin'

    That is from PINS directive.

    What? Could they repeat that in English please?

  • There are W0 to W5 General Purpose registers.

    You can name them with a variable.

    Next is finding out how to load a value to a variable.

    Goal is to see if if value show up in Memory Map or you can use a Debug statement.

    Think there was a thing about Memory Map shows you what 'Program says is in there' not what is really in there.
  • Regarding PIN:

    Some statements require a number corresponding to the I/O pin number (like 0-7). Other statements require a bit mask with a single 1 bit corresponding to the I/O pin. This made it difficult for people to document I/O pin usage in that they needed two symbols, one for the pin number and another for a bit mask. Thus, Parallax created the useful kludge of the PIN directive which allows the use of a single symbol for an I/O pin and lets the compiler figure out which form the statement requires.

  • Thank you very much for the insight that they headed in one direction and

    then another.

    I was wondering about that.

    Okay.I will keep an eye out for that.

    SIDE NOTE Found one of my dev boards supports 16F54 (what a Basic Stamp is underneath) so that sub project will move along!
  • Mike GreenMike Green Posts: 23,101
    edited 2017-09-27 13:57
    There are 8 predefined variables in the BS1, PORT and W0 through W6. Strictly speaking they're memory locations, not hardware registers. PORT and W6 have special uses. W6 is used internally for GOSUB and RETURN statements. If you don't call any subroutines, you can use W6 as a variable. PORT is used internally to communicate with the I/O pins. The high order byte is used to set the I/O pin direction (input vs. output). The low order byte is used to set the output pin state or to read an input pin's state. Usually the I/O statements and individual bit names of PORT are much more convenient to use than directly using PORT.

    You can declare aliases to these predefined variables. You can't create any other variables. There are also predefined names for the individual bytes of each word and for the bits of PORT and W0.

  • Predefined. That's today's word. 'Now go ahead. You say it.' It's a nice day in Mr. Parallax's World.

    I am side stepping I/O commands right now.

    Did see GET and PUT for Ubicom based Stamps.

    What about Memory Map actually being what's in there?
  • Remember that PBasic is an interpreted language. It's compiled into a very compact bytecode, not PIC instructions, that's stored in a 256 byte EEPROM separate from the PIC. Similarly, the variables are kept in a 16 byte area of real memory somewhere in the PIC. There's no way for a PBasic program to access any other memory.
  • JonnyMacJonnyMac Posts: 8,912
    edited 2017-09-27 16:53
    You have to be a little careful with the PINx variables in the BS1. A common error that I see with EFX-TEK customers is this:
      SEROUT PIN7, OT2400, ("Yada, yada, yada")
    
    ...when they actually mean:
      SEROUT 7, OT2400, ("Yada, yada, yada")
    
    In the former case, the interpreter will read the state of PIN7 (which will be high/1 because a pull-up is used with OT baud modes); this will cause the SEROUT to be directed to pin 1 which was not the intended behavior.
    What about Memory Map actually being what's in there?
    This is a map of the EEPROM; code builds from the bottom working up, user data is stored at the top. In the BS1, location 255 in the EEPROM is the size of the program.

    Back in the DOS days of the BS1, there was an EEPROM command in the language that would cause the binary data that would written to the EEPROM to be saved in a file. I used this data to create my own DOS-based map (written in Turbo Pascal to mimic the DOS DEBUG memory dump output). Parallax took this and made it far more useful. Mind you, my project was back in 1994. I wanted the map so that I could experiment with different coding styles to see the effect on EEPROM use. Originally, the only thing the DOS editor had was a low-resolution progress bar.
  • GenetixGenetix Posts: 1,740
    edited 2017-09-27 21:12
    microcontrolleruser,

    I've never used a BS1 so I am not very familiar with it but remember that it uses PBASIC 1.0 which is different than the PBASIC 2.5 that the BS2 uses.

    The BS1 uses a system variable called PINS to change the output value of each I/O pin. The BS2 equivalent is OUTS.
    PBASIC 2.5 has a PIN "directive" which allows you to assign an I/O pin to a variable.
    Don't get the 2 mixed up which is why I keep saying just use the BS2 because What's a Microcontroller explains much of this.

    Mike, Jon,
    Is there a What's a Microcontroller or something similar for the BS1?

    BTW Jon, welcome back to the Forum.
  • microcontrollerusermicrocontrolleruser Posts: 1,194
    edited 2017-09-27 21:28
    Genetix

    I think the way to go for the Stamp 1 is the Nuts and Volts articles in the archives here.

    I saw a Stamp 1 starter kit on Ebay with a book. Don't remember the title of it.

    It might still be there for reference. Might just be early version of What's...

  • JonnyMacJonnyMac Posts: 8,912
    edited 2017-09-27 22:30
    As as been indicated, the best source of BS1 material is the original BS1 app notes, and N&V columns by Scott Edwards and myself (I was Jon Williams back then). If anyone has links to those PDFs, I'd be grateful if you'd share them (they changed with web site updates).

    I still write a lot of BS1 code, especially this time of year as the EFX-TEK Prop-1 (BS1-based, not Propeller-based) is a very popular controller for Halloween and Christmas decorators. People usually start with this kit:

    -- http://www.efx-tek.com/topics/prop-1_starter.html

    These get a lot of use in simple props and small-scale industrial devices (e.g., a paint skimmer in a metal works in NC). One customer (entertainment venue) put 80 of them in a box to twinkle faux candles on a big Christmas tree. They use the Prop-1 for small props and displays in other areas of the venue.

    PBASIC 1 is very small and not very fast, but for small projects it it can be quite useful. I know a lot of tricks since I started programming the BS1 in early 1994. I recently compressed a substantial BS2 program into the BS1 that my customer just couldn't muster. When he asked if I could do it, I replied, "Yes, but you won't be able to understand the code." It took a few hours (that's a LONG time for a BS1 program) but I did make it work. My customer called me with a chuckle. The only thing he could understand was the part he needed to understand: the lock/unlock sequence (this was for an escape room puzzle). Here's the cool bit: He buys the Prop-1 controller from us for about $40, adds some reed switches, LED faux candles, a mag lock, and a small box, and sells it to his customers for $700. It's a nice profit and powered by the original Parallax microcontroller.
  • microcontrollerusermicrocontrolleruser Posts: 1,194
    edited 2017-09-28 01:08
    'If anyone has links to those PDFs, I'd be grateful if you'd share them (they changed with web site updates).'

    Jonny

    Who's website changed? Parallax or Nuts and Volts?

    Edit Good!

    Parallax BS1 and BS2 and SX App Notes still there on Parallax!

    So are Nuts and Volts articles.

    You almost gave me a heart attack!

    Wow! Nuts and Volts cleaned out their old Stamp articles. That's kind of ungrateful to people who put them on the map!

    Have to think about that.
  • VonSzarvasVonSzarvas Posts: 3,273
    edited 2017-09-28 06:36
    Important Quote from member signature:
    .
    *It's "Jon" or "JonnyMac" -- please don't call me "Jonny"

  • JonnyMac wrote: »
    As as been indicated, the best source of BS1 material is the original BS1 app notes, and N&V columns by Scott Edwards and myself (I was Jon Williams back then). If anyone has links to those PDFs, I'd be grateful if you'd share them (they changed with web site updates).

    I have copies of N&V volumes 1 through 8 if that would help.

Sign In or Register to comment.