variable space with DS1320
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
Randy
Comments
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
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
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
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