Running out of space for variables
Moskog
Posts: 554
Hello again!
Still working with my weather station project. I have a BS2 outside collecting·data, (wind speed and temperature so far)· then transmitting them through the parallax 433MHz TX/RX modules to another BS2 inside the house. So far I use a 2x16 LCD to display the information.
My plan is to connect the inside BS2 to a DS1302·to keep time and later to other devices.
But now I realize I got an unexpected problem. When writing programs in VB I could use almost unlimited numbers of variables. Now I already got stuck a couple of times running out of space for new ones. I have done a few things to help solve the problem by changing from word to bytes, and from bytes to nibs an so on, also tried to re-use variables in different routines.
Does anyone know if there are any ways to solve problems like this, can I use spaces other places, like the EEPROM to keep variables, any examples on how to do this?
Kjell Romma, Norway
·
Still working with my weather station project. I have a BS2 outside collecting·data, (wind speed and temperature so far)· then transmitting them through the parallax 433MHz TX/RX modules to another BS2 inside the house. So far I use a 2x16 LCD to display the information.
My plan is to connect the inside BS2 to a DS1302·to keep time and later to other devices.
But now I realize I got an unexpected problem. When writing programs in VB I could use almost unlimited numbers of variables. Now I already got stuck a couple of times running out of space for new ones. I have done a few things to help solve the problem by changing from word to bytes, and from bytes to nibs an so on, also tried to re-use variables in different routines.
Does anyone know if there are any ways to solve problems like this, can I use spaces other places, like the EEPROM to keep variables, any examples on how to do this?
Kjell Romma, Norway
·
Comments
No variables can be changed to constants as they changes all the time. But I will follow your advice and study the Syntax and Reference Manual on the EEPROM, maybe there will be something there.
I·went through·the code once again and found·several Byte-sized variables that could be removed, as changing of the program, deleting bad subroutines and things like that made those variables unused. Need a vacuumcleaner to remove those variable-leftovers sometimes!
KjellO
When you have the DS1302 real time clock hooked up, it will give you a number of bytes of general purpose RAM that can be backed up with a battery or capacitor. Very useful for things like seasonal rain accumulation or any of your accumulation variable, like min max and average. That RAM does not wear out like (eventually) eeprom.
Another option might be an upgrade to a BS2pe. It has scratchpad RAM in addition to lots of extra eeprom. The scratchpad RAM is really useful for all those accumulations.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
As I understand, an alias use the same space in RAM as the mother variable, I can have several aliases but I cant use more then one at a time, right?
On the DS1302, new horizons opens here, using its internal RAM sounds like a pretty good idea! I knew there was a number of bits available there but thought they were only to be used by the clock itself. Need to check out this!
Now I have another question as the temperature outside just went below -6C, the BS2 is told to work from 0 to +70C, my still work pretty good at -6C but how cold can the environment become before the BS2 really gets into trouble?
KjellO
The DS1302 has about 20 some bytes of scratchpad, I recall, in addition to the clock registers. I use the DS1307 (I2C interface), which has 56 bytes of scratchpad. It is essential for storing pointers and long term accumulations.
The PIC-based BS2s I have tested have all been rock solid at low temperatures. Even the ones that are not rated as "industrial". I've tested quite a few in a LCO2 environmental chamber down to -65 Celsius and they keep on ticking.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com