Shop OBEX P1 Docs P2 Docs Learn Events
eeprom full — Parallax Forums

eeprom full

bigfreshbigfresh Posts: 16
edited 2008-04-02 16:44 in BASIC Stamp
I've programmed my bs2 to control 5 record players, with most lines of the main subroutine code indicating an on/off state for all 5 of the players. Other lines signify a duration of time for how long an on/off state will perform. Very straightforward. See attached file...

A problem though. I've reached a point where when i send my program to the stamp I get an "eeprom full" error, which would mean my now 8k program has reached stamp capacity. I'd love to be able to make the program a bit longer, and i dont really see how i could make it more efficient--the code is essentially a non-repetitive musical score that cant be condensed into loops. I could make my variables physically shorter, but If i want to double or triple the size of my program, thats not going free up enough space.

So I'm very much a beginner at this--can anyone think of some relatively simple solutions to give me more space? Are there other databanks that i can access? Can the stamp run compresed code and if so, how can i compress it? It's probably possible to attach an SD card to the stamp but i honestly dont need that much room and its probably not terribly easy...any other suggestions? 8k really isnt very much room!

Thanks for your help

-brian

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-03-29 03:35
    There is no way to increase the program space with external memory, if that's what you're angling at.· You could use external memory to store/retrieve values for variables (i.e. "line") and other data.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-03-29 04:05
    bigfresh -

    The PBASIC Stamp BS-2 only has 2K of memory onboard. There is no way that you could be using up 8K as you suspect you are doing. What you probably have done is used up the 2K of onboard memory. The way to determine how much memory you have used is to look at the Memory Map (a button in the PBASIC Stamp IDE).

    The only choice you have now is to use a PBASIC Stamp with a larger memory. This is accomplished by using any larger Stamp in the BS-2 family. The next step up would be the BS-2SX, but many folks opt for the BS-2p instead. The BS-2p has a slightly larger instruction set and scratchpad ram which is easier to use than that found on the BS-2SX.

    On these larger Stamps the memory is NOT configured in a linear fashion. It is comprised of 8 X 2K BANKs of memory. Thus, you use 2K eight times (so to speak).

    If you decide to use a larger Stamp, let us know and we'll point you in the right direction for using this banked memory.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Involvement and committment can be best understood by looking at a plate of ham and eggs. The chicken was involved, but the pig was committed. ANON
  • TGTG Posts: 36
    edited 2008-03-29 04:18
    this post reminds me of something I have been wondering for a long time.

    If instead of the STAMP is purchased from Parralax, a user goes the OEM route from Parralax. The user buys the individual components. Instead of buying the stock memory, can the user couple a larger memory component?
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-03-29 04:19
    Comes up all the time -- No.
  • TGTG Posts: 36
    edited 2008-03-29 05:54
    gotcha...why is that. I am not too familiar with the hardware side. Is it merely a limitation put into place or really hardware driven?
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-03-29 07:41
    TG -

    If you're asking if this is an arbitrarary limitation, the answer is no. The underlying processor chip contains only a finite amount of memory, and that's all there is available. Other processor chips may support directly mapped, external memory. This processor does not.

    Most folks don't seem to have a problem with the concept of fixed memory, and some fairly sophisticated programs have been written using the 8 x 2K memory available on the larger Stamps.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Involvement and committment can be best understood by looking at a plate of ham and eggs. The chicken was involved, but the pig was committed. ANON
  • skylightskylight Posts: 1,915
    edited 2008-03-29 11:09
    I'm not sure but i may have read somewhere here that an excessive use of gosubs can use up memory?
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-29 14:36
    The GOSUB chapter in the manual indicates that the BS1 can have 16 GOSUBs in a program, but BS1 programs are quite limited in size and complexity anyway. The BS2 can have 256 GOSUBs in a program and that limit applies to each 2K "slot" program.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-03-29 14:37
    Yes, rumor has it.· :)· As Monk said, "I'm L-O-L'ing out loud."
  • bigfreshbigfresh Posts: 16
    edited 2008-03-29 15:14
    This is all pretty disappointing..I cant really afford to buy another stamp at this point. So I guess I'm stuck then?

    pj allen-- you attached a bs2 file in one of your posts...you changed the variables to CON and removed the GOSUBs altogether. do you see this saving memory or are you just using preferred conventions?

    thanks..
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-29 15:23
    It sounds like your issue is where to store data. Have you looked at the DATA / READ / WRITE statements? That increase the amount of data stored in the Stamp's memory by 50% at least since the assignment statements and GOSUBs don't have to be repeated. Another possibility would be to add an external EEPROM which is easy to do for data (not program). There are relatively cheap EEPROMs with capacities up to 128K bytes (the 24C1025 for example). You'd have to write a program just to download the data to the EEPROM, but that's not hard. There are articles in the Nuts and Volts columns series in the Downloads area of Parallax's website that give examples of using external EEPROMs with a Stamp and show how to handle the I2C protocol needed.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-03-29 15:35
    I didn't want to completely re-write your program, just improve it a bit, so that you could see some benefit while retaining the form you created.· All of those GOSUBs were what was killing your program (i.e. EEPROM Full),·it was wasteful to GOSUB just to do a PAUSE.··[noparse][[/noparse]You also had that OUTS = ~Line instruction as part of that GOSUB, but that was unnecessary.]· It freed up a lot of memory.

    So far as the CONs, if a value is fixed then it should be a CON.· No sense in declaring a bunch of values as VARs and burning a lot of I/O RAM for their being fixed values.

    Don't know what you mean by "stuck", Bruce Bates mentioned an option and I did, too.

    Post Edit -- error, error· See robots42's posts.

    Post Edited (PJ Allen) : 3/29/2008 5:37:52 PM GMT
  • robots42robots42 Posts: 27
    edited 2008-03-29 16:32
    Hi
    I have just rewritten your program to use DATA and READ. There is now nearly enough room for four times the amount of DATA.
    see Brian.BS2

    I have also rewritten bigfresh.bs2 so it works.
    There is nearly enough room for twice the DATA
    see bigfresh2.bs2

    David
  • robots42robots42 Posts: 27
    edited 2008-03-29 16:46
    Well that was interesting, I got an error page on uploading.

    I don't know why I wrote re bigfresh2.bs2
    "There is nearly enough room for twice the DATA"
    Actually there is just enough room for a bit more program.
    see bigfresh2.bs2

    Using DATA is a powerfull way of storing information.

    I will upload one at a time.

    David
  • robots42robots42 Posts: 27
    edited 2008-03-29 16:47
    Now bigfresh2.bs2
    David
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-03-29 17:33
    David/robots42,

    You are super-right!· (What's the use of "Line ="?)
  • robots42robots42 Posts: 27
    edited 2008-03-30 00:58
    (What's the use of "Line ="?)
    Did you mean why Line =command.LOWBYTE in

    IF command.HIGHBYTE=%10000000 THEN 'if the top bit is set then it is a Line comand
    Line =command.LOWBYTE
    OUTL = ~Line

    it was just to strip off the highbyte but is entirely unnecessary!
    OUTL will strip it off anyway.

    David
  • bigfreshbigfresh Posts: 16
    edited 2008-03-30 01:00
    pj allen / david -- i really appreciate multiple options you've generously wrote for me. unfortunately i wont be able to test this until next week, but if the DATA WORD method actually provides 4x the space, it really means i wont have to upgrade stamps or even hookup external memory...but as i understand, that method would lend itself well to external memory because the program is basically stored as variables. i may have some questions come test-time, but thanks so much, this is priceless help.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-03-30 01:03
    in re. "(What's the use of "Line ="?)" -- I was referring to its·use in the original, that's all.

    bigfresh -- go robots42's way

    ·
  • bigfreshbigfresh Posts: 16
    edited 2008-03-30 02:05
    I guess the use of Line = ? would have made it unnecessary to write the inversion (~) on every line of binary in the original. As you may remember from my inversion thread a few weeks ago, that little tilde is wholly crucial for my sanity... smile.gif
  • robots42robots42 Posts: 27
    edited 2008-03-30 05:28
    regarding the ~

    just noticed an editing error in bigfresh2.bs2, should only be one ~ not ~~

    MAIN:

    Time = supershort
    OUTL = ~~%10000 : PAUSE Time


    should be

    MAIN:

    Time = supershort
    OUTL = ~%10000 : PAUSE Time


    oops
    David
  • robots42robots42 Posts: 27
    edited 2008-03-30 23:46
    Well last night I was thinking. So tonight......
    By using TimeCommand codes instead of Values the DATA value code for Time can fit in a byte.
    And by setting the top bit for Line DATA then we can test whether the DATA byte is a Line entry or a TimeCommand Code entry.
    So I got rid of all the Word entries in DATA.

    Now there is room for seven times as much DATA as you have.
    Program Brian2.bs2

    David
  • bigfreshbigfresh Posts: 16
    edited 2008-03-31 00:10
    wow, david, nice job!! to be honest, i might stick with the DATA WORD method for now as it's a little more human-readable to have just 5 bits of binary (rather than the last 5) as my usable code, but amazing to have the option should i need 7x times the room.... but it really shows how powerful the DATA command is, and how it could be scaled up if i have more devices to control...
    much appreciated,
    brian
  • robots42robots42 Posts: 27
    edited 2008-03-31 00:33
    you could always have
    DATA 128 + %xxxxx '%xxxxx for the five bits of data, the 128 sets the top bit of the byte as before.
    it would be just the same size in the Stamp but more readable.

    David
  • bigfreshbigfresh Posts: 16
    edited 2008-04-02 15:13
    thanks david, you have officially solved all my problems smile.gif
  • robots42robots42 Posts: 27
    edited 2008-04-02 16:44
    Glad to be able to help.
    I have spent quite a bit of time writing small 4th generation languages for the BS2 where the program resides in DATA statements and is interpreted by the PBasic BS2 program. These have been to control Biped robots, both TecFoot, the precursor to Toddler, and the Ambler range as well as Loki and Hextor. For example this is the program for TecFoot which makes TecFoot walk forward avoiding obstacles using two ultrasonic 'Ping' sensors
    D_Do DATA S4,USon,PSoff,D,Dowalk
    Dowalk DATA F,D,Dowalk

    D_Do is the default Do done on reset,;S4 sets the servo speed to 4; USon enables the Ultrasonic sensors; PSoff disables the user-pot control of speed; D Dowalk transfers control to DoWalk.
    DoWalk only has one walking command F, the robot takes a step forward (and turns depending on the result of the ultrasonic information), then transfers control to itself again. Changing the program is easy and doesn't invlove writing more pBasic unless other commands are added to the language.
    http://www.davidbuckley.net/DB/TecFootManual/TecFoot.htm
    http://www.davidbuckley.net/DB/TecFootManual/TECFOOT.BS2
    http://www.davidbuckley.net/DB/Ambler.htm
    http://www.davidbuckley.net/DB/Loki.htm
    http://www.davidbuckley.net/DB/Hextor.htm
    David
Sign In or Register to comment.