Basic Stamp 2 Memory


I am going by the Help in Basic Stamp Editor here.

There is virtually no match up between Pbasic and PIC assembler with these instructions.

Should I just stop looking and just go with first Pbasic instruction I find that does 'what I want it to do"?

Saw something about a 16 bit word in Help. No. None of that with the PIC16F54 that stamp is made from.
Experimenter

WANTED SX BLITZ JAVELIN STAMP P24 & P40 DEMO BOARD SX48/52 BOARD APPMODS NO JUNK
«1

Comments

  • 57 Comments sorted by Date Added Votes
  • Yes, there is virtually no match between PBasic and PIC assembler. Yes, you should just stop looking and go with the parts of PBasic that do 'what you want it to do'. PBasic was never intended to have a relationship with PIC 16F54 instructions or architecture. If you want, get a copy of PIC Basic Pro 3 which is a compiler from ME Labs that translates a version of PBasic into PIC instructions. They have a free trial available and the free and student versions handle something very close to PBasic 1.

  • Thanks Mike

    Okay. Armed with that viewpoint I will putter around with some of this hardware here.

    Is that Parallel I/O set of instructions what I think it is?

    For using the old 14 pin LCD?

    If so that is just what we need.
    Experimenter

    WANTED SX BLITZ JAVELIN STAMP P24 & P40 DEMO BOARD SX48/52 BOARD APPMODS NO JUNK
  • Enjoy puttering. Remember that, if your questions are not just rhetorical, you need to supply more information like what "Parallel I/O" and what "old 14 pin LCD".

  • How about this?

    Hook up the 14 pin LCD, run one of the instructions and see if it does anything.

    We'll figure it out. Thanks anyhow.
    Experimenter

    WANTED SX BLITZ JAVELIN STAMP P24 & P40 DEMO BOARD SX48/52 BOARD APPMODS NO JUNK
  • microcontrolleruser,

    You can't use the LCD in 8-bit mode because you will not have I/O pins to control the signals.

    If you look at BS1 Application Notes, you will see if you use 4-bit mode then the LCD will use 6 pins and you will only be left with 2.

    Serial LCDs cost more but they only need 1 I/O pins so you have 5 more pins that you can do other stuff with.
    These typical use a microcontroller to control the LCD and receive commands from whatever device it's hooked up to.

    Nuts and Volts #31 also uses the LCD in 4-bit mode.
    Nuts and Volts #32 uses a 595 to save I/O pins and it also has code for other size LCDs since surplus modules may not be 16x2.
    The 595 uses half the I/O pins and you can get modules with a 595 on it or buy a "backpack" that attaches to the back of the LCD.

    Nuts and Volts #40 uses a 164 to save Input pins which might come in handy later.
    Nuts and Volts #43 uses a 165 also saves input pins by taking Parallel inputs and making them Serial.

    All of the above are in Volume #1.

    Nuts and Volts #110 (Volume 5) uses a 595 to control 8 LEDs.

    Volume #6
    Nuts and Volts #119 uses a Ping Ultrasonic sensor and #120 uses an RFID Reader.
    Nuts and Volts #126 uses a ULN2003 to make an electronic candle.

    Nuts and Volts #135 (Volume #7) deals with Advanced BS1 Programming.

  • microcontrollerusermicrocontrolleruser Posts: 1,155
    edited November 14 Vote Up0Vote Down

    Thank you Genetix

    Here's pic of 16X2 14 pin LCD

    Here's dataheet

    http://www.futurlec.com/LED/LCD16X2.shtml

    It may be same as Parallax 14 pin LCD from way back.

    Parallax one came with cable and single inline connector for breadboard.



    300 x 148 - 19K
    Experimenter

    WANTED SX BLITZ JAVELIN STAMP P24 & P40 DEMO BOARD SX48/52 BOARD APPMODS NO JUNK
  • microcontrollerusermicrocontrolleruser Posts: 1,155
    edited November 14 Vote Up0Vote Down

    This is from Basic Stamp Editor/Help menu/PBasic Language Reference/Commands by category/Paralllel I/O
    Explanation
    The three LCD commands (LCDCMD, LCDIN and LCDOUT) allow the BS2p, BS2pe, or BS2px to interface directly to standard LCD displays that feature a Hitachi 44780 controller (part #HD44780A). This includes many 1 x 16, 2 x 16, and 4 x 20 character LCD displays.

    The Hitachi 44780 LCD controller supports a number of special instructions for initializing the display, moving the cursor, changing the default layout, etc. The LCDCMD command is used to send one of these instructions to the LCD. It is most commonly used to initialize the display upon a power-up or reset condition. Note that LCDCMD, LCDIN and LCDOUT use a 4-bit interface to the LCD which requires a specific initialization sequence before LCDIN and LCDOUT can be used. Specifics on the initialization sequence will follow.
    Experimenter

    WANTED SX BLITZ JAVELIN STAMP P24 & P40 DEMO BOARD SX48/52 BOARD APPMODS NO JUNK
  • microcontrolleruser,

    Nuts and Volts #77 (Volume 3) has a diagram with all the LCD pins and it matches the link that you provided.
    #80 and #87 use a BS2p with an LCD.

    #109 (Volume 5) has an LCD connected to a BS2p through and I2C I/O expander so only 2 pins are needed; it uses the BS2p's I2C commands.

    You will find all the BASIC Stamp commands and other information including examples in the BASIC Stamp Manual.

    For the BS2, StampWorks is one of the best resources on programming and hooking up devices.
    Most of the articles and books use the BS2.

    I started with the BS2 and it's a great learning tool but the Propeller is so much better and a lot more versatile.
    The Propeller can be programmed in Assembly, C, Forth, PropBASIC, and my favorite Spin which is a lot more powerful PBASIC-like language.

  • Genetix

    Could I get you to slow down a little please?

    I can only do one thing at a time.

    Do the Pbasic programs have subroutines for each letter, A-Z and 0-9?

    Is there an LCD sample program in Stamp Editor or Stamp Editor Help?
    Experimenter

    WANTED SX BLITZ JAVELIN STAMP P24 & P40 DEMO BOARD SX48/52 BOARD APPMODS NO JUNK
  • microcontrolleruser,

    Most of the code for doing what you want is in the Parallax 2x16 LCD documentation.
    https://www.parallax.com/downloads/2x16-parallel-lcd-product-documentation
    https://www.parallax.com/downloads/2x16-parallel-lcd-basic-stamp-sample-code

    The problem is that there isn't enough room on the display for everything that you want.
    The display is 32 characters but is takes 36 to display both numbers and letters.

    The programs are easy to change if you wanted to display just numbers or letters but not both.
    Change the text inside the quotes in the EEPROM DATA section of the program to either all of the letters or all of the numbers.
    Then in the PROGRAM CODE section of the program, change the ending value of the FOR from 27 to 25 if using letters or 9 if using numbers.

    Just be sure to wire the LCD using the schematic on Page 2 or the code won't work.

  • microcontrollerusermicrocontrolleruser Posts: 1,155
    edited November 14 Vote Up0Vote Down
    Genetix

    Thank you!

    "Most of the code for doing what you want is in the Parallax 2x16 LCD documentation."

    THAT is what we were trying to think of!

    "The problem is that there isn't enough room on the display for everything that you want.
    The display is 32 characters but is takes 36 to display both numbers and letters."

    Sorry. No that is not what I meant.

    We have an assembler lesson coming up for Alpha Numeric Display (old name for LCD display).
    Writing to the display
    To write to the display you first of all set the address of the cursor
    (where you want the character to appear). The Cursor address locations
    are shown in Figure 10.3 Line1 address starts at 80H. Line2 address starts
    at C0H.
    Then tell the display what the character code is, e.g. A has the code 41H,
    B has the code 42H, C is 43H, 0 is 30H, 1 is 31H, 2 is 32H etc.
    To print an A on the screen – first enable the display, send 2 to PORTA,
    send the code 41H to PORTB and CLOCK this data.
    These instructions have been written in the Subroutine Section so all you
    have to do is CALL A.
    To write HELLO on the display the program would be:
    CALL H
    CALL E
    CALL L
    CALL L
    CALL O

    Just want to relate this to PBasic way.

    Experimenter

    WANTED SX BLITZ JAVELIN STAMP P24 & P40 DEMO BOARD SX48/52 BOARD APPMODS NO JUNK

  • Genetix

    Thank you for the LCD link!

    That's the old 14 pin Parallel LCD.

    Just what we were looking for.

    We will just use the Serial LCD and look at the Pbasic 'Commands'.
    Experimenter

    WANTED SX BLITZ JAVELIN STAMP P24 & P40 DEMO BOARD SX48/52 BOARD APPMODS NO JUNK
  • microcontrollerusermicrocontrolleruser Posts: 1,155
    edited November 14 Vote Up0Vote Down
    Here's the plan.

    Load the code for this LCD in editor.

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

    Hook up hardware. Our LCD may be non-backlit one.

    Stare at code. Adjust to Pbasic commands. Including what is going on with memory registers.

    Will have questions at that point.
    Experimenter

    WANTED SX BLITZ JAVELIN STAMP P24 & P40 DEMO BOARD SX48/52 BOARD APPMODS NO JUNK
  • There is no direct correspondence between PIC suggestions for driving the LCD vs. PBasic suggestions. PORTA is probably used to implement the first group of Stamp I/O pins (0-7) and PORTB is probably used to implement the second group of Stamp I/O pins (8-15), but the PBasic interpreter uses a word in RAM to implement what PBasic sees as all 16 I/O pins, then copies this automatically to the hardware registers that actually provide the I/O pins. You can't manipulate the I/O ports (PORTA, PORTB, PORTC) directly from PBasic.
  • microcontrolleruser,

    #1 BASIC is a high-level language while Assembly works at the hardware level.
    #2 The way the exercise wants you to write your program may be great for learning but it's extremely wasteful if you try to apply it.
    #3 What exactly are you trying to do because PBASIC programming has few similarities with Assembly?
    Also the commands will vary from chip to chip so you may have to do things differently on another device.

    If you want to know all the gritty details then look at the Hitachi HD44780 datasheet because it's all in there except for code examples.
  • microcontrollerusermicrocontrolleruser Posts: 1,155
    edited November 15 Vote Up0Vote Down
    Thank you Mike

    "There is no direct correspondence between PIC suggestions for driving the LCD vs. PBasic suggestions. "

    Using Pbasic as is will be fine.

    Thank you Genetix

    "What exactly are you trying to do because PBASIC programming has few similarities with Assembly?"

    I will settle for just doing the LCD experiments both ways. Albeit the PIC one is aways in the future. Doing inputs now.

    Will do Stamp 2 sample code for non-backlit LCD.
    Experimenter

    WANTED SX BLITZ JAVELIN STAMP P24 & P40 DEMO BOARD SX48/52 BOARD APPMODS NO JUNK
  • microcontrolleruser,

    I will probably get in trouble for saying this but it sounds like the Arduino may be a better fit for you.
    You can get Arduino boards, sensor modules, and code all over the place.
    I just purchased an Arduino starter kit recently so I can look at and run other people's code.
    The Arduino uses C which is not my favorite language but the libraries make it very easy to write applications.
  • ' =========================================================================
    '
    '   File...... Serial_LCD_Demo.BS2
    '   Purpose... Basic Serial LCD use, including customer characters
    '   Author.... (c) Parallax, Inc. -- All Rights Reserved
    '   E-mail.... support@parallax.com
    '   Started...
    '   Updated... 11 FEB 2005
    '
    '   {$STAMP BS2}
    '   {$PBASIC 2.5}
    '
    ' =========================================================================
    
    
    ' -----[ Program Description ]---------------------------------------------
    
    
    ' -----[ Revision History ]------------------------------------------------
    
    
    ' -----[ I/O Definitions ]-------------------------------------------------
    
    TX              PIN     0               ' serial output to LCD
    
    
    ' -----[ Constants ]-------------------------------------------------------
    
    #SELECT $STAMP
      #CASE BS2, BS2E, BS2PE
        T2400       CON     396
        T9600       CON     84
        T19K2       CON     32
      #CASE BS2SX, BS2P
        T2400       CON     1021
        T9600       CON     240
        T19K2       CON     110
    #ENDSELECT
    
    LcdBaud         CON     T19K2
    
    LcdBkSpc        CON     $08             ' move cursor left
    LcdRt           CON     $09             ' move cursor right
    LcdLF           CON     $0A             ' move cursor down 1 line
    LcdCls          CON     $0C             ' clear LCD (use PAUSE 5 after)
    LcdCR           CON     $0D             ' move pos 0 of next line
    LcdBLon         CON     $11             ' backlight on
    LcdBLoff        CON     $12             ' backlight off
    LcdOff          CON     $15             ' LCD off
    LcdOn1          CON     $16             ' LCD on; cursor off, blink off
    LcdOn2          CON     $17             ' LCD on; cursor off, blink on
    LcdOn3          CON     $18             ' LCD on; cursor on, blink off
    LcdOn4          CON     $19             ' LCD on; cursor on, blink on
    LcdLine1        CON     $80             ' move to line 1, column 0
    LcdLine2        CON     $94             ' move to line 2, column 0
    
    LcdCC0          CON     $F8             ' define custom char 0
    LcdCC1          CON     $F9             ' define custom char 1
    LcdCC2          CON     $FA             ' define custom char 2
    LcdCC3          CON     $FB             ' define custom char 3
    LcdCC4          CON     $FC             ' define custom char 4
    LcdCC5          CON     $FD             ' define custom char 5
    LcdCC6          CON     $FE             ' define custom char 6
    LcdCC7          CON     $FF             ' define custom char 7
    
    
    ' -----[ Variables ]-------------------------------------------------------
    
    idx1            VAR     Byte
    idx2            VAR     Byte
    char            VAR     Byte
    newChar         VAR     Byte
    
    
    ' -----[ EEPROM Data ]-----------------------------------------------------
    
    '                       C#----  Data----------------------------------
    CC0             DATA    LcdCC0, $0E, $1F, $1C, $18, $1C, $1F, $0E, $00
    CC1             DATA    LcdCC1, $0E, $1F, $1F, $18, $1F, $1F, $0E, $00
    CC2             DATA    LcdCC2, $0E, $1F, $1F, $1F, $1F, $1F, $0E, $00
    Smiley          DATA    LcdCC3, $00, $0A, $0A, $00, $11, $0E, $06, $00
    
    Msg2            DATA    "IS VERY COOL!  ", 3
    
    
    ' -----[ Initialization ]--------------------------------------------------
    
    Reset:
      HIGH TX                               ' setup serial output pin
      PAUSE 100                             ' allow LCD to initialize
    
    DnLoad_Custom_Chars:
      FOR idx1 = 0 TO 35                    ' download 4 characters
        READ CC0 + idx1, char               ' get data from table
        SEROUT TX, LcdBaud, [char]          ' send to LCD
      NEXT
    
    
    ' -----[ Program Code ]----------------------------------------------------
    
    ' Clear the display and remove cursor and blinking attributes.
    
    Main:
      SEROUT TX, LcdBaud, [LcdBLoff, LcdOn1, LcdCls]
      PAUSE 250
      SEROUT TX, LcdBaud, ["THE BASIC STAMP"]
    
    
    ' Scroll "chomper" animation across LCD line 2
    
    Animation:
      FOR idx1 = 0 TO 15                    ' scroll across line
        READ (Msg2 + idx1), newChar         ' read new character
        FOR idx2 = 0 TO 4                   ' animate a current position
          LOOKUP idx2, [0, 1, 2, 1, newChar], char
          SEROUT TX, LcdBaud, [(LcdLine2 + idx1), char]
          PAUSE 75
        NEXT
      NEXT
    
    
    ' Flash LCD backlight (works only with backlit model)
    
    Flash:
      FOR idx1 = 1 TO 4
        SEROUT TX, LcdBaud, [LcdBLon]
        PAUSE 750
        SEROUT TX, LcdBaud, [LcdBLoff]
        PAUSE 250
      NEXT
    
      GOTO Main
      END
    
    
    ' -----[ Subroutines ]-----------------------------------------------------
    
    Experimenter

    WANTED SX BLITZ JAVELIN STAMP P24 & P40 DEMO BOARD SX48/52 BOARD APPMODS NO JUNK

  • Could somebody explain this program please?

    What is going to do?
    Experimenter

    WANTED SX BLITZ JAVELIN STAMP P24 & P40 DEMO BOARD SX48/52 BOARD APPMODS NO JUNK
  • The program is pretty well documented. As it says at the top, it's a demonstration program for a serial LCD written for a Basic Stamp. It shows how custom characters can be used, demonstrates many of the control codes (commands) for the LCD. What don't you understand after looking at the program and its comments?

  • Thanks Mike

    " What don't you understand after looking at the program and its comments?"

    Why it is all over the place with what it is doing.

    Here. The code in this manual is more what I was expecting.

    https://www.parallax.com/sites/default/files/downloads/27979-Parallax-Serial-LCDs-Product-Guide-v3.1.pdf

    Here's one of two snippet codes from manual.
    ' {$STAMP BS2} 
    ' {$PBASIC 2.5} 
    TxPin         CON    0 
    Baud19200    CON    32 
      HIGH TxPin  
                  ' Set pin high to be a serial port 
      PAUSE 100                 ' Pause for Serial LCD to initialize 
      SEROUT TxPin, Baud19200, ["Hello, this text will wrap."]
    
    Experimenter

    WANTED SX BLITZ JAVELIN STAMP P24 & P40 DEMO BOARD SX48/52 BOARD APPMODS NO JUNK
  • There's no question that the product guides and sample code have become very thorough in recent years. The product guide you just referenced is version 3.1. The earlier version you referred to dates from 2005 ... over 13 years ago. Nuts and Volts Vol 1, Cols 31 and 32 also discuss in some detail the use of parallel LCDs. These articles (very well written by Jon Williams) date from 1997 and the sample code shows a starting date of 1994. The parallel and serial LCDs are old products, originally developed and sold by Scott Edwards (see Jon's article).

    What don't you understand about using the LCD? There's more than enough documentation and code samples available, maybe not as well organized as you might want and in one place for what's essentially an obsolete product.
  • microcontrolleruser,

    Your LCD is PARALLEL so any serial code will not work as is.

    StampWorks has a whole chapter on using a Parallel LCD (p. 83) which uses much of the same information as Nuts and Volts #31 and 32.
    https://www.parallax.com/downloads/stampworks-experiment-kit-manual
    https://www.parallax.com/downloads/stampworks-basic-stamp-source-code

    The code you use depends on which BASIC Stamp module you are using and is it a BS!, BS2, BS2sx, or a BS2p?

    The code in StampWorks and in the Nuts and Volts articles follows the Hitachi HD44780 Chipset datasheet.
    https://www.parallax.com/downloads/hitachi-hd44780-chipset-datasheet

    And if you look on the Internet you will find code and very detailed explanations on how to use the HD44780.
    Most LCDs use an HD44780 or an equivalent chip.

    Serial LCDs have a microcontroller that acts as a 'bridge' between your uC and the HD44780 so that is why the code is much simpler.
    The current Parallax Serial LCD has a small piezo speaker on it and there is a command to play tones from it; plain LCDs can't do this.

  • Thank you Genetix

    "Your LCD is PARALLEL so any serial code will not work as is."

    The LCD we already have is serial 27976.

    The one on the way (soon) is bare one with pin header soldered on back.

    Thank you Mike

    "What don't you understand about using the LCD? There's more than enough documentation and code samples available"

    While I'm waiting for parallel LCD I will run code on serial LCD we have.

    When parallel one gets here will run Pbasic code on that one.

    We have enough info on serial LCD.

    I don't want to dig into Pbasic code right now.

    Just run the samples and get an overview.

    Experimenter

    WANTED SX BLITZ JAVELIN STAMP P24 & P40 DEMO BOARD SX48/52 BOARD APPMODS NO JUNK
  • microcontrolleruser,

    This text uses the Serial LCD and only the Hitachi HM55B compass is no longer available.
    https://www.parallax.com/downloads/smart-sensors-and-applications-text
    https://www.parallax.com/downloads/smart-sensors-code-and-spreadsheet

    Chapter 1 is on the Serial LCD and Chapter 7 displays sensor data from the Ping ultrasonic sensor and the Memsic Accelerometer.

    Parallax still sells the Ping and Memsic if you want to do most of the chapters.
    https://www.parallax.com/product/28015
    https://www.parallax.com/product/28017

    Chapter 4 is on the Hitachi HM55B Compass Module which hasn't been available in years but might be on ebay.
  • microcontrollerusermicrocontrolleruser Posts: 1,155
    edited November 16 Vote Up0Vote Down
    "The current Parallax Serial LCD has a small piezo speaker on it and there is a command to play tones from it; plain LCDs can't do this. "

    Ours has the speaker on the back but it is not backlit like one sold now.

    There is a note in manual about with or without speaker which code to use or something . About revisions.

    Thank you for looking up all the manuals or documents.

    Will get out a Homework board and connect up LCD.
    Experimenter

    WANTED SX BLITZ JAVELIN STAMP P24 & P40 DEMO BOARD SX48/52 BOARD APPMODS NO JUNK


  • Have Homework board and LCD on the workbench.

    Any tips on how the pins are on power up?

    Which is the equivalent of configuration on PIC only user does not do anything because Parallax did it already for you.

    Still in process of looking all that up.

    Will say Stamp 2 module uses PIC16F57 SSOP 28 pin device.

    As PIC it has 20 I/O pins 4 PORTA, 8 PORTB and 8 PORTC.

    ICSPDAT and ICSPCLK on are two of the pins, rest are available. Will look at Stamp2 module schematic.

    Now it's getting fun!
    Experimenter

    WANTED SX BLITZ JAVELIN STAMP P24 & P40 DEMO BOARD SX48/52 BOARD APPMODS NO JUNK
  • PublisonPublison Posts: 10,469
    edited November 16 Vote Up0Vote Down

    Have Homework board and LCD on the workbench.

    Any tips on how the pins are on power up?

    Which is the equivalent of configuration on PIC only user does not do anything because Parallax did it already for you.

    Still in process of looking all that up.

    Will say Stamp 2 module uses PIC16F57 SSOP 28 pin device.

    As PIC it has 20 I/O pins 4 PORTA, 8 PORTB and 8 PORTC.

    ICSPDAT and ICSPCLK on are two of the pins, rest are available. Will look at Stamp2 module schematic.

    Now it's getting fun!

    You have to look at Parallax data sheets, not PIC. What is at the pins on a BS.. is up to what Parallax wanted to put there.
    Infernal Machine

  • Thanks Publison

    Here's manual for serial homework board. No schematic.

    Where is the schematic for it?
    Experimenter

    WANTED SX BLITZ JAVELIN STAMP P24 & P40 DEMO BOARD SX48/52 BOARD APPMODS NO JUNK
  • microcontrollerusermicrocontrolleruser Posts: 1,155
    edited November 16 Vote Up0Vote Down
    Making do with USB schematic right now.

    https://www.parallax.com/sites/default/files/downloads/555-28188-HomeWork-Board-USB-Schem-v1.0.pdf

    Lots of interesting stuff there.Very neat work they did.

    PortA is for EEPROM and serial pins.

    PORTB and PORTC end up as your I/O pins.

    Those 16 pins.

    Are they inputs or output at power up?

    Are the outputs low or high?




    Experimenter

    WANTED SX BLITZ JAVELIN STAMP P24 & P40 DEMO BOARD SX48/52 BOARD APPMODS NO JUNK
Sign In or Register to comment.