Shop OBEX P1 Docs P2 Docs Learn Events
Jon need programming tip — Parallax Forums

Jon need programming tip

GuidoGuido Posts: 195
edited 2004-10-27 15:36 in BASIC Stamp
Jon,
I have a simple one for you today. I am trying to run 3 DS1620 Temperature Sensors and wondering if there is a trick of the trade to not use so much variable space? Or is just the case with the stamp?Here is a basic example.

RstPin······· VAR· Nib····································· ' DS1620.3 (1 of 3)
RdTmp······ CON· $AA····································· ' READ TEMPERATURE
tempIn····· ·VAR· Word···································· ' RAW TEMPERATURE
tempC········VAR· Word···································· ' Celsius
tempF······· ·VAR· Word···································· ' Fahrenheit
ADDR1······· VAR· Word···································· ' INSIDEADDRESS FOR TIME/DATE STAMP
TL1············ VAR· Word···································· ' INSIDE LOW TEMPERATURE WORD
TH1··········· ·VAR· Word···································· ' INSIDE HIGH TEMPERATURE WORD
ADDR2····· · VAR· Word···································· ' OUTSIDE ADDRESS FOR TIME/DATE STAMP
TL2········· · ·VAR· Word···································· ' OUTSIDE LOW TEMPERATURE WORD
TH2········· ··VAR· Word···································· ' OUTSIDE HIGH TEMPERATURE WORD
ADDR3···· ·· VAR· Word···································· ' SHED ADDRESS FOR TIME/DATE STAMP
TL3·········· ·VAR· Word···································· ' SHED LOW TEMPERATURE WORD
TH3········· ·VAR· Word···································· ' SHED HIGH TEMPERATURE WORD

THANK YOU
Guido

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2004-10-27 15:36
    Each 'BYTE' var holds 0..256 as a value. A standard technique is to reduce the resolution of your data (by using a scaling algorithm) into a smaller set of values.

    Another approach is to use the EEPROM (or an external EEPROM) to hold values. That way, you can reuse a 'TempLow' and 'TempHigh' variable for Raw, Inside, Outside, or Shed temperatures, holding the values long enough in TempLow and TempHigh to read or write them to the eeprom. Also, I believe an eeprom address is a byte, not a word.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-10-27 15:36
    If you don't need the Celsius and Fahrenheit temps, you can certainly save some space there. Also, you can use a CONstant + offset for the addresses; and you might consider temporary variables as you can't deal with more than one thing at a time.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
Sign In or Register to comment.