Shop OBEX P1 Docs P2 Docs Learn Events
Stamp 2 architecture question — Parallax Forums

Stamp 2 architecture question

TintinTintin Posts: 37
edited 2006-07-29 17:08 in BASIC Stamp
Maybe somebody can clearify a concern that's been bothering....
Here is a code snippet from a thermostat project I did a while ago:

(...)

TEMPERATURE VAR Byte

(...)

REQUEST_TEMP:

·HIGH ENABLE_TEMP····························································· ' enable temp chip
·SHIFTOUT DQ, CLK, LSBFIRST, [noparse][[/noparse]READ_TEMP]························· · ' ask to read temp
·SHIFTIN DQ, CLK, LSBPRE, [noparse][[/noparse]POINT\1, TEMPERATURE\7, SIGN\1]·· ' write as var TEMPERATURE
·LOW ENABLE_TEMP···························································· ·' disable temp chip
RETURN

(...)

Simply consider·the that·the·REQUEST_TEMP subroutine is looped·constantly·.· The·bs2 executes 4000 inst/sec and if we assume each line above is an instruction (incuding RETURN), and neglect all other·delay times, the·variable TEMPERATURE is written to once every 5 instructions.·

This means every 1.25 ms we write to TEMPERATURE.· Thus, after 3.5 hours we would have written to that variable 10 000 000 times.

My QUESTION:· Is the variable TEMPERATURE a eeprom memory location? If so, would·this program fail after 3.5 hours?· If not, where is the variable stored?

Thanks for the help,
Frank

Comments

  • stamptrolstamptrol Posts: 1,731
    edited 2006-07-29 11:20
    By declaring TEMPERATURE as a byte variable, it uses RAM.

    Every time the temperature device was queried, it reloaded the new temp into the TEMPERATURE variable.

    No worries with wearing out the eeprom!

    However, if you wanted to permanently store a particular value, use the WRITE command. See the help file on READ/WRITE.

    Tom
  • TintinTintin Posts: 37
    edited 2006-07-29 11:31
    Thanks for the fast reply!· Apart from running out, can anything happen to the·RAM on the pic? (like wear out?)

    Thanks again

    ·
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-07-29 12:25
    Tintin -

    RAM locations can not "wear out", On the PBASIC Stamp, only EEPROM can wear out.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • FranklinFranklin Posts: 4,747
    edited 2006-07-29 17:08
    In real life you may have variables that get written many times over the life of the program but this should not be a problem. In a real application you would have something else to do between reads of the temperature and if not you would put the stamp to sleep for a while (or something similar)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
Sign In or Register to comment.