Shop OBEX P1 Docs P2 Docs Learn Events
variable space with DS1320 — Parallax Forums

variable space with DS1320

RandyRandy Posts: 79
edited 2009-02-03 03:13 in BASIC Stamp
I have a temperature logger built around a BS2pe·that also logs time. I am using a DS1302 and use all of the time elements, seconds to year. I am using six bytes and one nibble of variable space. Many elements use only one, two or three bits but are sent as bytes. As they are sent as bytes, even though some of the data is just pad bits, I must allocate a byte to recieve them. I can not figure out how to use the space from those pad bits to store the information and recover some of the wasted variable space. I have been through my·program a thousand times and just can not find a spare bit of variable space. Many·variables are already doing double duty in different parts of the program. I have something I want to add to the program and it will require a byte. I have also been cheating as I have not been using 10 year. As I expect this to run well into the future this is going to be a problem down the road. Ideas?

Randy

Comments

  • Carl HayesCarl Hayes Posts: 841
    edited 2009-02-02 05:07
    If you have several quantities you want to store in the DS1302, and some are three bits, others one bit, etc., why not allocate a single byte of your variable space, corresponding to one byte in the DS1302, to store several of your quantities?

    For example, if you have two three-bit quantities (call them B3a and B3b) and two one-bit quantities (call them B1a and B1b), you could store them all in a single byte of your variable space and a single corresponding byte of the DS1302.

    There are several ways of addressing these quantities individually in your variable space, even though they're stored in different parts of the same byte; but you will have to read and write a whole byte's worth at a time to/from the DS1302.

    No need to waste any space at all as "pad bits" either in your variable space or in the DS1302.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · -- Carl, nn5i@arrl.net
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-02-02 16:16
    Randy,

    Each value in the DS1302 (you may want to adjust your subject using the pencil icon) uses the entire byte. Values for seconds, minutes, hours, are stored as BCD and use two nibbles, which is one byte. There is no way to whittle that down. One option you can try is re-using variables. At any point in the program the BASIC Stamp can only do one thing at a time. In terms of getting the time from the DS1302 the only purpose served is to display the time and possibly compare it for some other operation. One that is complete the variables can be used for other tasks until the DS1302 is read again. I hope this helps. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2009-02-02 17:13
    Randy,

    You say you are out of variable space. But are you taking advantage of the scratchpad RAM in the BS2pe (127 bytes there), and the RAM in the DS1302 clock chip as Carl pointed out? With those resources, there should be no need to run out of variable space.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • RandyRandy Posts: 79
    edited 2009-02-03 03:13
    Thanks for the response. Tracy you in particular may have some insight to my problem. This is a temperature logger using StampDAQ for comunication. I am taking eleven temperatures using a TLC2543 and storing them with a date/time stamp in a 24LC128. I am storing the eeprom address in the DS1302 clock RAM. When I down load to DAQ I grab the starting address and the current address from the clock RAM. Using a FOR NEXT loop the data is moved from the eeprom to DAQ. Six bytes for time (I am cheating on the year by not using tens of years, it should be one more byte), ten bytes for temperature and one word for a temperature that can have negative values. One word for the eeprom address and a word for the ending eeprom address. A byte to determine if it is AM or PM, a byte to hold the value of if I am just downloading or clearing the data. There are two more bytes or one word that I can't seem to remember at the moment but they are there. I have been through this thing a thousand times trying to find a variable that I can reuse with no luck.
    I could use 24 hour format and save a byte but it would be hard to read. I am not the only one that reads the data. The whole program uses five slots and I do use the scratch pad RAM. Some of the variables are reused within the slot to determine where the program needs to go and for reseting the eeprom address etc. I have one more byte of info I would like to store and download if I can find the space. At the moment I need to go find the two bytes I can't remember.
    Thanks to all that ponder this.
    Randy
Sign In or Register to comment.