Shop OBEX P1 Docs P2 Docs Learn Events
Running out of space for variables — Parallax Forums

Running out of space for variables

MoskogMoskog Posts: 554
edited 2007-12-03 20:30 in BASIC Stamp
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
·

Comments

  • SandgroperSandgroper Posts: 62
    edited 2007-12-02 11:44
    See if any of the variables can be changed to constants.
  • SandgroperSandgroper Posts: 62
    edited 2007-12-02 11:51
    Oops - sorry, too quick with the enter key. Check out the DATA, READ and WRITE commands as well. You can use these to store data to EEPROM. There are some good examples in the PBASIC syntax guide.
  • MoskogMoskog Posts: 554
    edited 2007-12-02 18:16
    Sandgroper,

    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
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2007-12-02 22:41
    Some variables can be reused, and even given alias names. For example, outside temperature first, inside temperature next and output each one in turn to the display. But sometimes you really need to hang onto the variabe, for an average over time for example.

    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
  • SandgroperSandgroper Posts: 62
    edited 2007-12-03 09:51
    KjellO, let me know if you find one of those vacuum cleaners!· I could certainly do with one!·· smilewinkgrin.gif
  • MoskogMoskog Posts: 554
    edited 2007-12-03 18:12
    Tracy..

    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
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2007-12-03 20:30
    Aliases are different names for the same physical memory location. Yes, you can only use one at a time.

    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
Sign In or Register to comment.