EEPROM Full
Robot Jay
Posts: 12
I wrote a program for my BS2 to controll a bipedal robot.· After a certain amount of coding, the BASIC Editor told·me that the EEPROM was full (understandably, because the program I have written is very large.)· So I took my·BS2 stamp out of the BOE and put in my BS2px24 stamp assuming (because of the specs that came with my BS2px) that the BS2px would have a larger EEPROM size.· I downloaded the BASIC Editor v2.2.5, and load and run the program I wrote for the BS2 (changing the ' {$STAMP BS2} line to ' {$STAMP BS2px}).· I run the program and get the same EEPROM Full error.· I have not actually changed the size of the program between the two stamp versions.· Why is this happening?· As far as I can tell, the stamp is not damaged and is being read correctly,· it's just seems that the editor is not reading the correct EPROM size.· Any help will be appreciated.· Thanks!
Comments
http://www.parallax.com/dl/docs/cols/nv/vol3/col/nv87.pdf
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
I just ran into the same issue with maxing out a bs2p40. Is there a simpler way to understand how to take what I have done to this point, without starting over and using the extra ram? I read the article but don't see how to apply it to my existing situation, since it was not planned. I can't runb what I have now, its over by maybe 20 lines which maybe can be reduced back to where it will fit, but there is a long way to go still.
I do not want to start over hopefully.
Thanks
I backtracked and converted a byte to a nib, and also noticed that I am using a LOT of the following code throughout the prog which is eating up some memory, so the obvious solutionhere is For Next and count to number and move on... right?
a short of example I am using in a lot of places to blink an led
LOCK_LATCH_M = 1
PAUSE 100
LOCK_LATCH_M = 0
PAUSE 100
LOCK_LATCH_M = 1
PAUSE 100
LOCK_LATCH_M = 0
After replacing these with For Next, assuming thatthat is the most pratical conservation method to do the task, what about vaiable name lengths? Does that add to the waste as well? or what about ' comments?
If you want help decreasing your program's size, it's probably best to attach your entire program. (Be sure to attach it and not just copy it into your message.)
Any time you see the same code duplicated repeatedly in your program, it's a sure sign that you should make a subroutine.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
If your program has user interaction, pay special attention to prompts and text, in statements like,
DEBUG "Please enter the time for lock to latch"
If there is much text like that, you are better off with a short subroutine that reads it out of the DATA eeprom. It takes up a lot more space when it is encoded as part of the command. Also, if it is in DATA statements, you can put it in a different bank and reference it with STORE, READ and WRITE, and free up space in the program bank.
Initialization routines can often go in one bank, and then shift into another bank for the main running program. And a a third bank can hold the user configuration routines. It all depends on the application of course, and it does take some planning. But you can make the bank structure work for you.
There are some small ways to save space too. For example, PAUSE 128 will take less eeprom space than PAUSE 100. The Stamp stores the powers of 2 in a particularly efficient manner. It saves ust a few bits, but with the original Stamp I was often in the situation of shaving bit by bit, like a serious backpacker saves fractions of an ounce.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
I am trying to find some example of how I would take the 2k program I have now, and add to it so that it all still functions somehow as a whole, simlutaneously. If programs are having to load in and out to maintain real time monitoring of buttons and sensors, while simultaneously maintaining leds for status etc, it does not seem possble that I can simply park the first half of the program and shift it back and forth fast enough to function as needed.
'{$STAMP BS2P, file1.bsp, file2.bsp, ...}
Be sure to read up on this in the manual, under editor: advanced compilation. When you complle a program linked in that way, all of the banks are downloaded to your Stamp at one swoop.
When your program needs to jump from one bank to another, use the RUN N command, where N is 0,..,7. Similarly, to access data stored in different banks, use the STORE N command. Look up those in the manual, too. All the banks share the variables, both RAM and SPRAM, but you have to be sure they are declared in the same order in all the banks that will affect them. Some routines (for user configuration, for example, or for simple data storage) are natural candidates for separate banks. There is no automatic way to jump from a bank to a "subroutine" in another bank, but there are workarounds, essentially by managing your own go and return vectors. The article referenced goes into that. Also, this page (although dated) might have some material of interest:
www.emesys.com/BS2SX.htm
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
I guess the next test is to see if any variables stated in slot 0 are still in tact in slot 1. If not then I suppose the obvious answer is copy and paste from the first programif in fact the same i/o and var are required in program2. This is just as simple as GOTO, except it is called RUN 1, RUN 2 etc.
More testing to do, but thanks!
Original code:
Trimmed version:
You really should use indentation in your code. It doesn't add to the program size and it makes it much easier to read. To indent multiple lines in MacBS2, highlight the lines and press Cmd+].
My version eliminates redundant tests (e.g. you don't need to test for "OM = 1" on one line and "OM = 0" on the next). It also eliminates the duplicated code in SET_A_0 and SET_A_1.
I noticed that the call to Wait_Pfin falls through into CHECK_LEFT_M which then returns to the main program loop. It never gets back to CHECK_A_POS_M. Is that intentional?
Here's another example:
modified:
The first "IF lm = 0" was unnecessary. You only need to enclose the whole routine in the "IF lm = 1" test. The second "IF lm = 0" was unnecessary because the previous line had tested for lm = 1.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
Fortunately I learned a little about the Run 0, Run 1 etc. I am now thinking of cleaner faster ways to run my code now that it is pretty simple just to copy your setup over, and keep adding conditions. What I am thinking is to make Program one be just the If condition page for speed, then, have another program with all the work code. Question is, I doubt it would be easy to for exmple Run 1 Check_A_Position_M. I am guessng it would have to reask all the questions again which wouldn't be bad, but a nicer way would be to go straight to the appropriate label in slot 1(based on conditions) from slot 0 and strat working, rather than scanning for conditions from scratch.
Idon't sdee a methodf yet though.
Thank a lot for the schooling
ON flag GOTO SUB1, SUB2, SUB3, SUB4 ' Perform appropriate action
Beware of a common stumbling block when sharing variables between programs. You have to have your variables declared exactly the same in every program. It's best to define all your variables in one location in program 0 and then copy that code to all your other programs.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
I haven't seen ON command, so I assume you are illustrating:
if flag = x then sub1
or to use the flag for more than two options:
if flag = %1111 goto sub3
Edit: It is in the MacBS2 help file, just not in the drop-down index. Select "OUTPUT" and then scroll up a few pages.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows