Shop OBEX P1 Docs P2 Docs Learn Events
Data logger/memory question — Parallax Forums

Data logger/memory question

UweUwe Posts: 18
edited 2005-11-27 17:26 in BASIC Stamp
I am working on a device which will record temperature and possibly additional values over a period of time for later retrival.
By reading the posts here I got my BS2p to store and recall numbers from an 24LC32 but the following questions came up:

Is an eeprom the best device to store data of this kind, 500 to 1000 r/w per day?

Also, I'd like to store the number of events recorded in a memory location on the memory chip, so that upon retrival I first read that number and then I know how much to download.
But the numbers may get very big, up to the number of memory locations on the memory chip, how do I manage this??

Uwe

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-11-27 06:04
    If you store something every minute that would be 1440 (24 x 60) readings per day. If you used a two-byte counter for days you could you could store 179 years worth of data. So, with two 2-byte values you can probably store and point to anything you need -- it's just a matter of math to calculate the record offset in your EEPROM.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Philip GamblinPhilip Gamblin Posts: 202
    edited 2005-11-27 06:05
    To keep count of the number of events, create a word sized variable, "count" and initialize it to 0.· Place in the· event loop
    count=count +1. This way, each time an event occurs, count is incremented by one and uses only 2 bytes in which to store the value. A· WORD sized variable can hold a value up to 65,000 or so.
  • UweUwe Posts: 18
    edited 2005-11-27 14:11
    I guess my question needs to be reworded then, how do I store a word, 2 bytes, in my eeprom.
    I tried and it gave me problems not wanting to store more than 255.
    In the I2COUT command there is a provision for longer addresses, but not for longer data.

    Also, would you recommend an eeprom for this application?

    Uwe
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-11-27 15:24
    I2C is a byte-oriented protocol, so you simply need to store the constituent bytes.· The standard is low-byte, then high-byte.· For example:

    · I2COUT·SDA, slaveAddr, eeAddr.BYTE1\eeAddr.BYTE0, [noparse][[/noparse]myData.BYTE0, myData.BYTE1]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • TiboTibo Posts: 81
    edited 2005-11-27 15:59
    Hi, already said, but reworded :
    Philip Gamblin said...
    To keep count of the number of events, create a word sized variable, "count" and initialize it to 0. Place in the event loop
    count=count +1. This way, each time an event occurs, count is incremented by one and uses only 2 bytes in which to store the value. A WORD sized variable can hold a value up to 65,000 or so.

    means : you can store the counter in RAM (as "count" variable) and if you really need persistance, you can write it down in eeprom before power off (soft power off), since RAM looses data when unpowered.
    ++
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-11-27 17:26
    Hi Uwe

    Practically every data logger of this sort needs a real time clock (RTC) so that your readings can be time stamped and coordinated with real clock time. Many RTCs (Such as the popular DS1302 or DS1307) include provision for backup power, from a capacitor or lithium coin cell, to keep the clock running even when power is down. Those RTCs also include a few bytes of general purpose RAM, which is the perfect place to store the pointer to keep track of where you are in the log file. It is RAM, so you can write to it without any worry of wearing it out, but it is battery backed, so you won't lose it during a reset or power failure.

    For EEPROM, if the eeprom inside the BS2p is not enough, try the 24LC256 or 24LC512. There are lots of app notes here, and they give you 32kbytes or 64kbytes of memory for your log file.

    Another way to approach the memory pointer is to start with all locations erased to $ff. Then as the memory becomes filled, it is possible to search the memory at startup to locate the last record written and position the pointer to the next free record location. However, it is much easier to maintain a pointer in a battery backed clock chip.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
Sign In or Register to comment.