Shop OBEX P1 Docs P2 Docs Learn Events
Getting started: Thermistor and LM34 — Parallax Forums

Getting started: Thermistor and LM34

Jeff MJeff M Posts: 6
edited 2012-04-06 19:41 in BASIC Stamp
It has been years since I played with my Basic Stamp 2, but I have a project it would be perfect for and I need some help getting started.

The project will involve monitoring the temperature of both water (30deg F - 40deg F) and air (40deg F to 110deg F).

I have ordered some LM34s but as I'm waiting for delivery, I found some Radio Shack 10k-Ohm Thermistors 271-110A.

My research of the site has lead me to http://www.parallax.com/Portals/0/Downloads/appnt/stamps/bs1Appnotes.pdf page 33 (using a thermistor) and I wanted to give it a go.

I loaded the code into the editor, but I get a syntax error
"Expected ':' or end-of-line"

at this point
"Symbol co0 = 162"

I'm guessing this has to do with this code being for a BS1 and not a BS2, but I'm having trouble figuring out what is causing it.

Thanks in advance for the help.
JM

Comments

  • Shawn LoweShawn Lowe Posts: 635
    edited 2012-04-03 09:23
    Yes, symbol is only used on the BS1. Maybe post all your code and we can help further
  • Shawn LoweShawn Lowe Posts: 635
    edited 2012-04-03 09:30
    Nevermind found it:
    ' Program THERM.BAS
    ' This program reads a thermistor with the BASIC
    ' pot command, computes the temperature using a
    ' power-series polynomial equation, and reports
    ' the result to a host PC via the Stamp cable
    ' using the debug command.
    ' Symbol constants represent factored portions of
    ' the coefficients C0, C1, and C2. "Top" and "btm"
    ' refer to the values' positions in the fractions;
    ' on top as a multiplier or on the bottom as a
    ' divisor.
    Symbol co0 = 162
    Symbol co1top = 255
    Symbol co1btm = 2125
    Symbol co2bt1 = 25
    Symbol co2top = 3
    Symbol co2btm = 50
    ' Program loop.
    Check_temp:
    pot 0,46,w0 ' 46 is the scale factor.
    ' Remember that Stamp math is computed left to
    ' right--no parentheses, no precedence of
    ' operators.
    let w1 = w0*w0/co2bt1*co2top/co2btm
    let w0 = w0*co1top/co1btm+w0
    let w0 = co0+w1-w0
    debug w0
    pause 1000 ' Wait 1 second for next
    goto Check_temp ' temperature reading.
    
    Sorry for no code brackets, cant find the button. Now i'm the new guy! lol ;)
  • Jeff MJeff M Posts: 6
    edited 2012-04-03 09:34
    Thanks for the help.

    I removed the keyword Symbol but I get the same error.
  • Jeff MJeff M Posts: 6
    edited 2012-04-03 09:44
    I managed to get the code to pass by chaing pot to RCTIME and removing the 'let':
    co0 VAR Word
    co0 = 162
    
    co1top VAR Word
    co1top = 255
    
    co1btm VAR Word
    co1btm = 2125
    
    co2bt1 VAR Word
    co2bt1 = 25
    
    co2top VAR Word
    co2top = 3
    
    co2btm VAR Word
    co2btm = 50
    
    
    ' Program loop.
    Check_temp:
    RCTIME 0,46,W0 ' 46 is the scale factor.
    ' Remember that Stamp math is computed left to
    ' right--no parentheses, no precedence of
    ' operators.
    W1 = W0*W0/co2bt1*co2top/co2btm
    W0 = W0*co1top/co1btm+W0
    W0 = co0+W1-W0
    DEBUG W0
    PAUSE 1000 ' Wait 1 second for next
    GOTO Check_temp ' temperature reading.
    

    and found the [ code ] [ / code ] tags
  • Shawn LoweShawn Lowe Posts: 635
    edited 2012-04-03 09:54
    Cool, looks like you're ready to play. Where did you find the code tags?
  • Jeff MJeff M Posts: 6
    edited 2012-04-03 10:17
    Shawn Lowe wrote: »
    Cool, looks like you're ready to play. Where did you find the code tags?
    Not sure how I found it, but the BB code is listed here:
    http://forums.parallax.com/misc.php?do=bbcode#code
  • Shawn LoweShawn Lowe Posts: 635
    edited 2012-04-03 13:22
    Oh, okay thanks!
  • Jeff MJeff M Posts: 6
    edited 2012-04-04 18:53
    Update:

    I got the code to output some data to the debug window by adding 'DEBUG DEC W0' the DEC was missing.

    Now all I get are 000000 in the window.

    Any thoughts on how to figure out what is going on?
    ' {$STAMP BS2}
    ' {$PBASIC 2.0}
    ' Program THERM.BAS
    ' This program reads a thermistor with the BASIC
    ' pot command, computes the temperature using a
    ' power-series polynomial equation, and reports
    ' the result to a host PC via the Stamp cable
    ' using the debug command.
    ' Symbol constants represent factored portions of
    ' the coefficients C0, C1, and C2. "Top" and "btm"
    ' refer to the values' positions in the fractions;
    ' on top as a multiplier or on the bottom as a
    ' divisor.
    
    co0 VAR Word
    co0 = 162
    
    co1top VAR Word
    co1top = 255
    
    co1btm VAR Word
    co1btm = 2125
    
    co2bt1 VAR Word
    co2bt1 = 25
    
    co2top VAR Word
    co2top = 3
    
    co2btm VAR Word
    co2btm = 50
    
    ' Program loop.
    Check_temp:
    RCTIME 1,46,W0 ' 46 is the scale factor.
    ' Remember that Stamp math is computed left to
    ' right--no parentheses, no precedence of
    ' operators.
    W1 = W0*W0/co2bt1*co2top/co2btm
    W0 = W0*co1top/co1btm+W0
    W0 = co0+W1-W0
    'DEBUG W0
    PAUSE 1000
    DEBUG DEC W0
    PAUSE 1000 ' Wait 1 second for next
    GOTO Check_temp ' temperature reading.
    
  • Shawn LoweShawn Lowe Posts: 635
    edited 2012-04-05 12:04
    are you sure you have your thermistor hooked to pin 1?
  • Jeff MJeff M Posts: 6
    edited 2012-04-06 19:41
    yea i found it was wired wrong.. yet i have seen several different ways to connect it.
    I'm a bit confused on what wiring to use, and then there is the math to convert the output to temp....
    I could use a good example that someone knows works on the BS2.
Sign In or Register to comment.