Too many varibles - Not enough varible space
HIBITDAC
Posts: 40
I need help with expanding the amount of variables and size of variables. If I add a 16K EEprom chip will that enable me to have more varibles?
Thanks
Thanks
Comments
The usual tools in this case is to:
1. Reuse variables. Not all variables are used at the same time, and often the content can be discarded afterwards.
2. Compress variables. Try looking for ways to use smaller size variables.
1. If it has little variation (like body temperature), shrink the size of the variable, then add an offset to it in your calculations.
2. If it has larger, but known variations, like the different PULSOUT values when running servos, consider using a small variable and the LOOKUP/LOOKDOWN commands.
3. If your BS2 model has a scratchpad RAM, use that to 'PUSH'/'POP' variables you need to keep unchanged.
4. Identify varibales that are constants and replace them with constant declarations.
How often will the variables change after being set from your menu?
Depending on how often they change, they could be saved into one of the EEPROM banks.
Thanks
Thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
I think, too, that your program -- especially being as big as it is -- would benefit from the guidelines set forth in "The Elements of PBASIC Style" (it's in the Help file).· You have several lines that use internal register names, like...
· IF IN3 = 1 THEN Some_Label
... which can make a program difficult to follow and/or troubleshoot.· In one case:
· IF IN4 = 1 THEN on
... you'll have a problem if you want to engage PBASIC 2.5 syntax as ON is a new keyword (in ON-GOSUB and ON-GOTO).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
Post Edited (Jon Williams) : 5/2/2005 11:32:54 PM GMT
To give a specific example, if you free up your RAM space such that you can have a nib variable that points at an outlet, you could consolodate all of your on-off subroutines to just two:
Outlet_On:
· theOutlet = 15 - theOutlet + 1
· AUXIO
· HIGH theOutlet
· RETURN
Outlet_Off:
· theOutlet = 15 - theOutlet + 1
· AUXIO
· LOW theOutlet
· RETURN
And if this project is still in development or you plan to build more than one, you could reduce your cost by adding a couple 74HC595s and a 74HC165 to a 24-pin Stamp module.· You don't seem to be taking advantage of any BS2p features, aside from the extra pins on the BS2p40.· With two 74HC595s you could turn three IO pins into 16 outputs, and by using just two more pins, you'd get eight digital inputs from the 74HC165.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
Post Edited (Jon Williams) : 5/2/2005 11:49:28 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
You then use the "READ" command to copy the data from EEPROM to a working variable, and "WRITE" to write the data from a working variable back to EEPROM. Note the EEPROM does have a write limitation of 1 million cycles or so -- so you don't want to write to it every 10 mSecs, because you can wear it out. But for rarely read data it is perfect.
If you're concerned about that, you can use an external eeprom like the 26L640 using SHIFTOUT/SHIFTIN commands. Then should you wear out the external EEPROM, you simply replace it.
And read up on the 'scratch pad' ram -- using 'GET' and 'PUT', you can read data from SP locations into working variables, use them, then 'PUT' the results back into scratch pad ram. It does not have the write-cycle limitation of EEPROM.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
push and pop arent commands... is there a way you can access the scratch pad like a stack? did someone develop a stack adt?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
" Hey! Why is there silicone on my hemostats?"
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
Thanks alot
Samuel
serout 9,16624,[noparse][[/noparse]bin out15]---will display the output state for pin15 on the main side
I've tried
serout 9,16624,[noparse][[/noparse]bin aux15]
and
serout 9,16624,[noparse][[/noparse]bin aux15]
Thanbks again
Sauel
note that you cn only have either the main or the aux set of pins active at one time. This means you'll have to store the value in a variable or Scratchpad RAM first.
· AUXIO
· state = OUT15
· MAINIO
· SEROUT Sio, Baud, [noparse][[/noparse]BIN1 state]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
Thanks for all the help I really apprecite it.
Samuel