Shop OBEX P1 Docs P2 Docs Learn Events
Issue With Switching Basic Stamps — Parallax Forums

Issue With Switching Basic Stamps

AMUSERNAMEAMUSERNAME Posts: 3
edited 2012-02-10 06:31 in BASIC Stamp
I am working on a program that will display letters on a 5x7 LED grid. However, I started out the program using a BS2 Stamp. After realizing how long the program was going to be, I switched to a BS2px Stamp, but it doesn't seem to be recognized, is displaying the same amount of memory in a Memory Map. It is filled after approximately 700 lines. Any advice on getting it recognized?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-02-07 06:40
    It's recognized. The additional memory is provided as 2K "slots", essentially one separate program per slot. You can only do a GOTO (RUN actually) to the beginning of another slot. Variables can be shared from one slot to another which is how information gets passed back and forth.

    Probably a lot of your program is occupied by the font information. You can easily store tables in another slot by creating a separate program consisting of just DATA statements and reading them using READ statements. That's how I'd store the font information.
  • AMUSERNAMEAMUSERNAME Posts: 3
    edited 2012-02-07 06:54
    You are right about the font information. My basic setup at the moment is a 5x7 grid that is separated into 12 pins. Pins 1-7 are the horizontal rows, and pins 8-12 are the vertical columns. The pins are wired into two latches that will later be used to store the programs. The latches are wired to the basic stamp. The end goal is to plug a controller for a USB keyboard into the stamp, type a key, and have the grid display the symbol. The current program is very inefficient, however. Because I don't want every light on the grid to light, I need to write the letters one column at a time. The current process for "A" for example, is:

    A: 'Capital letter A
    FOR Anyword = 1 TO 75
    HIGH 1 'Column 1
    HIGH 2
    HIGH 3
    HIGH 4
    LOW 6
    LOW 12
    GOSUB CLOCK
    PAUSE 1
    LOW 1
    LOW 2
    LOW 4
    HIGH 12 'Column 2
    HIGH 5
    HIGH 6
    LOW 11
    GOSUB CLOCK
    PAUSE 1
    LOW 5
    LOW 6
    HIGH 11
    HIGH 7 'Column 3
    LOW 10
    GOSUB CLOCK
    PAUSE 1
    LOW 3
    LOW 7
    HIGH 10
    HIGH 3 'Column 4
    HIGH 5
    HIGH 6
    LOW 9
    GOSUB CLOCK
    PAUSE 1
    LOW 3
    LOW 5
    LOW 6
    HIGH 9
    HIGH 1 'Column 5
    HIGH 2
    HIGH 3
    HIGH 4
    LOW 6
    LOW 8
    GOSUB CLOCK
    PAUSE 1
    LOW 1
    LOW 2
    LOW 3
    LOW 4
    HIGH 8
    NEXT
    RETURN

    How would I make this more efficient?
    Anyword is my variable.
  • Martin_HMartin_H Posts: 4,051
    edited 2012-02-07 07:00
    Here's a nuts and volts column on multi-bank programming:

    http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/vol3/col/nv87.pdf

    It took me a bit of time to understand it, but works well once you get the knack. You break your program into tasks and use the scratch pad area to store the destination task and the return task, as well as save variables if you need to. RAM is shared so if you use the same variables between banks you can pass argument easily as well. Here's some example code I wrote two years ago:

    MashUp_Sensors.BSE

    MashUp_Main.BSE

    Some of the Basic Stamps allow reading and writing cross bank which really helps since code and data don't share the same bank. The BS2e doesn't so I don't have experience using that feature.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-02-07 08:09
    I'm not sure how you have things arranged from your description. You can store each of 5 7-bit columns in a byte or you can store each of 7 5-bit rows in a byte depending on your hardware and how you want to scan things. You then use OUTH or OUTL to output the whole piece (row or column) in one statement. The easiest thing is to output a 7-bit column at a time since that means that you're only "wasting" a single bit of the 8-bit group. You can use the 8th bit for an input without being affected by the outputs or you can add some extra operations and OR that 8th I/O pin value in before assigning it to OUTH or OUTL. Assuming you're outputting a column at a time, you'd have 5 bytes per character in a table with as many 35 byte entries as you want for characters (probably 128). That's more than 2K, but you could split the table into two 64 character tables and select which of two slots to fetch the entries from. The BS2px also has a scratchpad RAM area which you could use for a display buffer using the GET and PUT statements. The net result would be a couple of nested FOR loops for characters and columns and not a lot of code within the loops. This would be set up as a subroutine and called whenever the display buffer was changed.
  • AMUSERNAMEAMUSERNAME Posts: 3
    edited 2012-02-10 06:31
    Sorry about being so slow to reply to this post. Thank you for your help Mike, and I looked through the Nuts and Volts document you provided Martin. Thanks.

    At the moment, the status of my project is unclear, as I may be replacing the current display with a more complex one with a higher resolution. However, I didn't understand the memory storage of the stamps before you helped. Thanks.
Sign In or Register to comment.