Shop OBEX P1 Docs P2 Docs Learn Events
Confused about variable memory for different stamps — Parallax Forums

Confused about variable memory for different stamps

GobiasGobias Posts: 5
edited 2009-04-07 01:50 in BASIC Stamp
Hi, I'm writing code for an RFID application that uses breadth first search to calculate a "route" for a certain placement of a given number of tags. The number of nodes(tags) is 7 total right now, but I need to expand that number to 15-20.

For variables, I need to declare many 1 x 7 array to set up an adjacency matrix, etc. I only have a BS2 and I'm already running out of memory for declaring variables. Here are my current variable declarations:

#IF __No_SPRAM #THEN
buf VAR Byte(10) ' RFID bytes buffer
#ELSE
chkChar VAR Byte ' character to test
#ENDIF

tagNum VAR Nib ' from EEPROM table
idx VAR Byte ' tag byte index
char VAR Byte ' character from table

currentPos VAR Nib ' current position
previousPos VAR Nib ' previous position
maxPos VAR Nib ' maximum position aka destination

AdjI VAR Bit(7) 'adjacency matrices for tags/nodes I-VII
AdjI(1) = 1
AdjI(6) = 1

AdjII VAR Bit(7)
AdjII(0) = 1
AdjII(2) = 1

AdjIII VAR Bit(7)
AdjIII(1) = 1
AdjIII(3) = 1

AdjIV VAR Bit(7)
AdjIV(2) = 1
AdjIV(4) = 1

AdjV VAR Bit(7)
AdjV(3) = 1
AdjV(5) = 1

AdjVI VAR Bit(7)
AdjVI(4) = 1
AdjVI(6) = 1

AdjVII VAR Bit(7)
AdjVII(0) = 1
AdjVII(5) = 1

buffer VAR Bit(7)
color VAR Nib(7)
parent VAR Nib(7)
d VAR Nib(7)
search VAR Nib
search1 VAR Nib
destTag VAR Nib

In the Stamp Editor when I run it in BS2 mode it gives the "out of variable space" error, but not in modes BS2p, BS2pe, and BS2Px. When I look at the product page, every stamp has a 26 bytes for variables... So if they all have the same space reserved for variables, why will the BS2p stamps accept my code and regular BS2 won't? Do the BS2p stamps actually have more variable memory?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-04-06 04:22
    I don't know what you're doing when you run the Stamp Editor, but there are indeed only 26 bytes for variables and your program will not work the way you think it will when you try to run it. There's also only 2K bytes available for your single program even though many of the Stamps have larger EEPROMs than 2K. The program memory is divided up into 2K "slots" that work like overlay areas rather than one program space.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-04-06 04:28
    It looks like your program uses less than 26 bytes unless the _No_SPRAM compile-time value is true. The BS2 doesn't have SPRAM, so your program will require an additional 9 bytes and will get the error message. The BS2p Stamps have "scratchpad RAM" and the conditional compilation doesn't need the additional 9 bytes because the information (RFID info) gets read directly into the scratchpad RAM and you don't get the error message.
  • GobiasGobias Posts: 5
    edited 2009-04-06 05:37
    Ah yes good catch, that makes perfect sense.

    Even so, I guess it would be impossible to implement my 20 tag system on a BS2 as it would require several 20-byte sized arrays. Do you know of anything else that the Parallax serial RFID reader can interface with? I did see the thread about connecting it to a computer, but my project needs the reader to be mobile.

    Thanks for your help.
  • SRLMSRLM Posts: 5,045
    edited 2009-04-06 07:06
    You sound like you're in a computer science course ('breadth first search'). If you feel comfortable with programming why don't you try the propeller? If you don't want to go that far, then you can head to the shack and buy some EEPROMS to store your data.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-04-06 13:41
    If your data doesn't change a lot, you could use the EEPROM of the Stamp to store your data using the READ / WRITE / DATA statements. All of the Stamps except for the BS2 have additional 2K "slots" of EEPROM. The BS2p models particularly make this easy to use. It does begin to "wear out" after about 100,000 writes to the same location, but, if you're careful, this can be made to take many years to occur. As SRLM mentions, you can also attach external EEPROM to use for storing data.
  • GobiasGobias Posts: 5
    edited 2009-04-07 01:50
    I think I'm just going to reduce my total number of tags to 5. Even though this saves so much space, I still need to purchase a BS2p. Although, it was unavoidable because there is another BS2 application using the PING sensors that needs to be combined with the RFID, and the PING application already has declared a whopping 10 words of variables.

    Now I need to decide which to purchase: BS2p or BSpe... BS2p has twice the program execution speed as BS2pe, but its current draw @ 5V is more than twice also.

    Can you guys tell from my attached code (it's about 80% done) if it will run super slow on the BS2p?
Sign In or Register to comment.