Shop OBEX P1 Docs P2 Docs Learn Events
Out of variable space — Parallax Forums

Out of variable space

LanceMLanceM Posts: 5
edited 2010-01-04 21:14 in BASIC Stamp
I'm sure this is a common problem and I apologize if it has been covered a thousand times. I did do a search first and didn't find anything. I'm working on a temperature controller for a kiln. I have a DS2760 Thermocouple Kit and DS1302 Timekeeping Chip both of which I have working, but not at the same time. I'm planning to switch a thyristor to actually switch the power to the kiln on and off.

The problem is that just trying to put together a program that does both temperature and time I run out of variable space. I'm using a BS2PX. I'm starting with the example code that came with the DS2760 and DS1302 and the code is Bit and Nib where possible. What else can I do to permit myself more variable space? Do I need to add an EEPROM to the hardware and use that for storage?

Thanks for any suggestions,

Lance

Comments

  • FranklinFranklin Posts: 4,747
    edited 2010-01-04 19:32
    The best way to save on variable space is to reuse as many variables as possible in your code. You don't need to have two variables if you are not using them at the same time, assign one and use as needed. If you were to Attach your code to a message using the Attachment Manager after you click the POST REPLY button it would help in debugging for you.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • James LongJames Long Posts: 1,181
    edited 2010-01-04 19:32
    LanceM said...
    I'm sure this is a common problem and I apologize if it has been covered a thousand times. I did do a search first and didn't find anything. I'm working on a temperature controller for a kiln. I have a DS2760 Thermocouple Kit and DS1302 Timekeeping Chip both of which I have working, but not at the same time. I'm planning to switch a thyristor to actually switch the power to the kiln on and off.

    The problem is that just trying to put together a program that does both temperature and time I run out of variable space. I'm using a BS2PX. I'm starting with the example code that came with the DS2760 and DS1302 and the code is Bit and Nib where possible. What else can I do to permit myself more variable space? Do I need to add an EEPROM to the hardware and use that for storage?

    Thanks for any suggestions,

    Lance

    Lance,

    Although the BS2 doesn't have a huge amount of variable space, it is hard to believe you used it up on a kiln. There is a lot of ways to optimize code, so it is hard to say the best method.

    I personally would go back through my code to see what different ways I could change it to save space. Then you could possibly look at expanding the memory if you still do not have enough.

    James L

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    James L
    Partner/Designer
    Lil Brother SMT Assembly Services

    Are you addicted to technology or Micro-controllers..... then checkout the forums at Savage Circuits. Learn to build your own Gizmos!
  • LanceMLanceM Posts: 5
    edited 2010-01-04 20:21
    Here's the thermocouple demo code that I downloaded from Parallax. It does not seem to use many variables, but if I try to add a couple more variables to work with the DS1302 Timekeeping Chip I run out of variable space almost right away.

    Lance
  • allanlane5allanlane5 Posts: 3,815
    edited 2010-01-04 20:49
    For a BS2 program, this uses a LOT of variable space.

    For one thing, "Sign" shouldn't be a 'word', it should be a 'bit' variable.

    Personally, I like using a few "Temp1 VAR WORD: Temp2 VAR WORD" variables. Then set Temp1 and Temp2 to whatever input value is needed for a subroutine, and return results in Temp1 and Temp2, then reduce the data to a single result as early as possible, and keep that.

    For instance, "Read_Vin" is never called -- but if it was, keeping a variable around called "vIn" might or might not be needed -- the subroutine could use a 'word' variable called Temp1 to get the value.

    Post Edited (allanlane5) : 1/4/2010 8:56:50 PM GMT
  • LanceMLanceM Posts: 5
    edited 2010-01-04 21:14
    Thanks Allan, that is exactly the kind of 'thrifty programming" advise I need. All other hints and tips are very welcome!

    Thanks,

    Lance
Sign In or Register to comment.