Shop OBEX P1 Docs P2 Docs Learn Events
newbie question Counting events — Parallax Forums

newbie question Counting events

joecamaro68joecamaro68 Posts: 8
edited 2008-03-04 22:38 in BASIC Stamp
Hello I have a newbie question. I built a circuit that cycles a valve open and close. I would like to count each open close cycle and store this number in a variable. The question is, can I store this and retrieve later? I can not keep the stamp conected to my computer because I am also using a data loger to look at the event.
·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-04 16:21
    There are many ways to store counts like this. Look at the sections of the PBasic Manual about the READ and WRITE statements for one way using the EEPROM used to store your program since there's usually a small amount of memory unused for the program.
  • terry_bearterry_bear Posts: 84
    edited 2008-03-04 16:43
    As usual, I can't add much to Mike's words of wit.

    I did something similar (logged max and min temperatures in my well house) as my first useful project. Something that I learned: make sure that your power source is reliable. A battery (if it's the right one) is good, unless you are using a BS2px which draws a lot more current than some Stamps. Of course, my application had to run for a week at a time, and I took NO steps to conserve power, such as removing the pilot light. I use a separate program to read the stored data, but the Read routine can be written into the main logging program. I can bring the Stamp into the house and ask the PC to interrogate it. Did that through DEBUG

    Just some food for thought,

    Terry
  • joecamaro68joecamaro68 Posts: 8
    edited 2008-03-04 17:08
    Thanks Mike. This looks like what I need. and thank you Terry. When you load the read program, the data stored will stay intact? (unless the program is huge?)
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-04 17:19
    With the Stamps, the only portion of the EEPROM that's overwritten is the portion containing the new program that's downloaded. This includes portions of the EEPROM that are initialized with DATA statements (read that section of the manual too). Everything else is left alone. You just have to pick portions of the EEPROM for your data from the "everything else".

    Remember that locations in the EEPROM can be written a limited but large number of times (100,000 to 1,000,000). Don't WRITE to a location that already contains the value you want and that will help a lot.
  • terry_bearterry_bear Posts: 84
    edited 2008-03-04 17:45
    Joecamaro,

    As Mike says, the data will stay intact, as long as you don't inadvertently store it in space that the program will use, TheParallax inof on EEPROM usage is fairly clear, however...

    Mike, I panicked when I first read about the limited number of WRITES that you could do. Then I did the math and discovered that It wouldn't be a problem in my application for 10-25 years or so. It will probably outlive me! I did make sure that I only save record highs and lows, however!
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-04 17:51
    terry_bear,
    In many applications, the write limitations won't be a problem. If there's an error or poor design in your program though and it writes to the same location in EEPROM only ten times a second, that location will begin to wear out within a day (800,000+ writes).
  • terry_bearterry_bear Posts: 84
    edited 2008-03-04 22:38
    Mike,

    I did wake up and realize that! (I first heard about this some ago by the way) Itis a good point to keep in mind when prototyping, however, and I appreciate that (I could see myself wondering why a program that worked yesterday quit today!)

    Joecamaro, I think that I sorta hi-jacked your thread; sorreee!

    Regards,

    Terry






























    pro
Sign In or Register to comment.