Shop OBEX P1 Docs P2 Docs Learn Events
Tracy, math question — Parallax Forums

Tracy, math question

ArchiverArchiver Posts: 46,084
edited 2002-11-23 18:46 in General Discussion
Hi Tracy, All,

I am making a hot tub controller, using an LM34 sensor, a LTC1298 ADC and a
B2sx. I need help (as usual!) with the math. I want to be able to display
the temp on an LCD, so I need to convert the ADC output to degrees. How do I
do this using "stamp math"?

Let's say my tub is at 78 degrees, input is 0.788mV. So the ADC yields
.788/5.0*4095= 645. How can I convert this?

Thanks!

Jonathan

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-11-21 17:10
    >Hi Tracy, All,
    >
    >I am making a hot tub controller, using an LM34 sensor, a LTC1298 ADC and a
    >B2sx. I need help (as usual!) with the math. I want to be able to display
    >the temp on an LCD, so I need to convert the ADC output to degrees. How do I
    >do this using "stamp math"?
    >
    >Let's say my tub is at 78 degrees, input is 0.788mV. So the ADC yields
    >.788/5.0*4095= 645. How can I convert this?
    >
    >Thanks!
    >
    >Jonathan

    ADCresult=645
    degF = ADCresult */ 313
    debug "degrees F = ", dec degF/10,".".dec1 degF
    ' displays 78.8

    OR, for a little better precision in the 1/10ths digit:

    ADCresult=645
    degF = ADCresult */ 3125 + 5 / 10 ' with roundoff
    debug "degrees F = ", dec degF/10,".".dec1 degF
    ' displays 78.7

    OR, another way, using ** instead of */

    ADCresult=645
    degF = ADCresult ** 14464 +ADCresult
    debug "degrees F = ", dec degF/10,".".dec1 degF
    ' displays 78.7

    The factors to use in */ come from the ratio, 5000/4096=1.2207.
    You multiply that times 256 to get, 1.2207*256 = 312.5. That is the
    factor. Notice that 3125/2560 = 5000/4096, they are the same ratio.
    The Stamp */ command automatically does the division by 256.

    -- Tracy
  • ArchiverArchiver Posts: 46,084
    edited 2002-11-21 17:16
    for tracy

    I found your web site, - very nice!

    I want to put together a soil moisture sensor, and I was wondering if
    you sell your ac - dc conditioner/ amplifier, or whatever it is exactly?

    I could not find this on your web page. Thanks.



    Original Message
    From: "Tracy Allen" <tracy@e...>
    To: <basicstamps@yahoogroups.com>
    Sent: Thursday, November 21, 2002 11:10 AM
    Subject: Re: [noparse][[/noparse]basicstamps] Tracy, math question


    > >Hi Tracy, All,
    > >
    > >I am making a hot tub controller, using an LM34 sensor, a LTC1298 ADC and
    a
    > >B2sx. I need help (as usual!) with the math. I want to be able to display
    > >the temp on an LCD, so I need to convert the ADC output to degrees. How
    do I
    > >do this using "stamp math"?
    > >
    > >Let's say my tub is at 78 degrees, input is 0.788mV. So the ADC yields
    > >.788/5.0*4095= 645. How can I convert this?
    > >
    > >Thanks!
    > >
    > >Jonathan
    >
    > ADCresult=645
    > degF = ADCresult */ 313
    > debug "degrees F = ", dec degF/10,".".dec1 degF
    > ' displays 78.8
    >
    > OR, for a little better precision in the 1/10ths digit:
    >
    > ADCresult=645
    > degF = ADCresult */ 3125 + 5 / 10 ' with roundoff
    > debug "degrees F = ", dec degF/10,".".dec1 degF
    > ' displays 78.7
    >
    > OR, another way, using ** instead of */
    >
    > ADCresult=645
    > degF = ADCresult ** 14464 +ADCresult
    > debug "degrees F = ", dec degF/10,".".dec1 degF
    > ' displays 78.7
    >
    > The factors to use in */ come from the ratio, 5000/4096=1.2207.
    > You multiply that times 256 to get, 1.2207*256 = 312.5. That is the
    > factor. Notice that 3125/2560 = 5000/4096, they are the same ratio.
    > The Stamp */ command automatically does the division by 256.
    >
    > -- Tracy
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2002-11-21 20:41
    Tracy,

    Sure wish I wasn't so math impaired. Thanks a ton for the help. I have more
    questions though.

    I just changed the supply voltage to the LM34, which changed my output. The
    ADC now reads 715 at 104 degrees. Still using a 5.0 supply to the ADC. Since
    I may have to change power supplies again, and I expect that the added wire
    length to the sensor when it is actually installed is also going to change
    the output, how does someone as math challenged as I am recalibrate this
    system? Aside from bothering you ;-)

    Also, I find the LM34 doesn't really do 10mV/degree as advertised. I am
    going to test it to establish what it really does.

    Thanks again,

    Jonathan


    Original Message
    From: "Tracy Allen" <tracy@e...>
    To: <basicstamps@yahoogroups.com>
    Sent: Thursday, November 21, 2002 9:10 AM
    Subject: Re: [noparse][[/noparse]basicstamps] Tracy, math question


    > >Hi Tracy, All,
    > >
    > >I am making a hot tub controller, using an LM34 sensor, a LTC1298 ADC and
    a
    > >B2sx. I need help (as usual!) with the math. I want to be able to display
    > >the temp on an LCD, so I need to convert the ADC output to degrees. How
    do I
    > >do this using "stamp math"?
    > >
    > >Let's say my tub is at 78 degrees, input is 0.788mV. So the ADC yields
    > >.788/5.0*4095= 645. How can I convert this?
    > >
    > >Thanks!
    > >
    > >Jonathan
    >
    > ADCresult=645
    > degF = ADCresult */ 313
    > debug "degrees F = ", dec degF/10,".".dec1 degF
    > ' displays 78.8
    >
    > OR, for a little better precision in the 1/10ths digit:
    >
    > ADCresult=645
    > degF = ADCresult */ 3125 + 5 / 10 ' with roundoff
    > debug "degrees F = ", dec degF/10,".".dec1 degF
    > ' displays 78.7
    >
    > OR, another way, using ** instead of */
    >
    > ADCresult=645
    > degF = ADCresult ** 14464 +ADCresult
    > debug "degrees F = ", dec degF/10,".".dec1 degF
    > ' displays 78.7
    >
    > The factors to use in */ come from the ratio, 5000/4096=1.2207.
    > You multiply that times 256 to get, 1.2207*256 = 312.5. That is the
    > factor. Notice that 3125/2560 = 5000/4096, they are the same ratio.
    > The Stamp */ command automatically does the division by 256.
    >
    > -- Tracy
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2002-11-22 04:36
    >I just changed the supply voltage to the LM34, which changed my output. The
    >ADC now reads 715 at 104 degrees. Still using a 5.0 supply to the ADC. Since
    >I may have to change power supplies again, and I expect that the added wire
    >length to the sensor when it is actually installed is also going to change
    >the output, how does someone as math challenged as I am recalibrate this
    >system? Aside from bothering you ;-)
    >
    >Also, I find the LM34 doesn't really do 10mV/degree as advertised. I am
    >going to test it to establish what it really does.

    Hi Jonathan,

    Changing the power supply should _not_ affect the signal voltage.
    LM34 output should be 10 millivolts per deg. F,, so long as the power
    supply is anywhere within the allowed range. If not, something is
    wrong with the wiring.

    I have been using LM34 for years, and have always found them to be
    very close to spec. Even on a 100 foot cable, the error due to
    ground loop current is less than 0.1 degree F, because the supply
    current is only 70 microamps. Are you checking it with a voltmeter?
    Look for a bad ground connection. Also, the output signal can
    oscillate wildly if the chip has to drive a cable in the range of
    inches to feet. That will make the readings appear whacko. You can
    isolate the chip from the cable with a 3kohm resistor or with an RC
    snubber.

    regards,
    -- Tracy


    >
    >Thanks again,
    >
    >Jonathan
    >
    >
    >
    Original Message
    >From: "Tracy Allen" <tracy@e...>
    >To: <basicstamps@yahoogroups.com>
    >Sent: Thursday, November 21, 2002 9:10 AM
    >Subject: Re: [noparse][[/noparse]basicstamps] Tracy, math question
    >
    >
    > > >Hi Tracy, All,
    > > >
    > > >I am making a hot tub controller, using an LM34 sensor, a LTC1298 ADC and
    >a
    > > >B2sx. I need help (as usual!) with the math. I want to be able to display
    > > >the temp on an LCD, so I need to convert the ADC output to degrees. How
    >do I
    > > >do this using "stamp math"?
    > > >
    > > >Let's say my tub is at 78 degrees, input is 0.788mV. So the ADC yields
    > > >.788/5.0*4095= 645. How can I convert this?
    > > >
    > > >Thanks!
    > > >
    > > >Jonathan
    > >
    > > ADCresult=645
    > > degF = ADCresult */ 313
    > > debug "degrees F = ", dec degF/10,".".dec1 degF
    > > ' displays 78.8
    > >
    > > OR, for a little better precision in the 1/10ths digit:
    > >
    > > ADCresult=645
    > > degF = ADCresult */ 3125 + 5 / 10 ' with roundoff
    > > debug "degrees F = ", dec degF/10,".".dec1 degF
    > > ' displays 78.7
    > >
    > > OR, another way, using ** instead of */
    > >
    > > ADCresult=645
    > > degF = ADCresult ** 14464 +ADCresult
    > > debug "degrees F = ", dec degF/10,".".dec1 degF
    > > ' displays 78.7
    > >
    > > The factors to use in */ come from the ratio, 5000/4096=1.2207.
    > > You multiply that times 256 to get, 1.2207*256 = 312.5. That is the
    > > factor. Notice that 3125/2560 = 5000/4096, they are the same ratio.
    > > The Stamp */ command automatically does the division by 256.
    > >
    > > -- Tracy
    > >
    > >
    > > To UNSUBSCRIBE, just send mail to:
    > > basicstamps-unsubscribe@yahoogroups.com
    > > from the same email address that you subscribed. Text in the Subject and
    >Body of the message will be ignored.
    > >
    > >
    > > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    > >
    > >
    > >
    > >
    >
    >
    >To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    >from the same email address that you subscribed. Text in the
    >Subject and Body of the message will be ignored.
    >
    >
    >Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
  • ArchiverArchiver Posts: 46,084
    edited 2002-11-22 17:49
    Tracy,

    Could you elaborate on the 3k isolation resistor and the RC snubber
    for the LM34.

    Thanks,
    Marylou
    ___________________________
    >
    > Hi Jonathan,
    >
    > Changing the power supply should _not_ affect the signal voltage.
    > LM34 output should be 10 millivolts per deg. F,, so long as the
    power
    > supply is anywhere within the allowed range. If not, something is
    > wrong with the wiring.
    >
    > I have been using LM34 for years, and have always found them to be
    > very close to spec. Even on a 100 foot cable, the error due to
    > ground loop current is less than 0.1 degree F, because the supply
    > current is only 70 microamps. Are you checking it with a
    voltmeter?
    > Look for a bad ground connection. Also, the output signal can
    > oscillate wildly if the chip has to drive a cable in the range of
    > inches to feet. That will make the readings appear whacko. You
    can
    > isolate the chip from the cable with a 3kohm resistor or with an RC
    > snubber.
    >
    > regards,
    > -- Tracy

    > >
    > >
    > >To UNSUBSCRIBE, just send mail to:
    > > basicstamps-unsubscribe@y...
    > >from the same email address that you subscribed. Text in the
    > >Subject and Body of the message will be ignored.
    > >
    > >
    > >Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/
  • ArchiverArchiver Posts: 46,084
    edited 2002-11-22 20:29
    >Tracy,
    >
    >Could you elaborate on the 3k isolation resistor and the RC snubber
    >for the LM34.
    >
    >Thanks,
    >Marylou
    >___________________________

    view with monospace font

    --- isolation resistor ---
    ;---
    +6 volts
    |
    cable 3 kohm |
    signal ---/\/\
    | LM34
    common
    |
    `---

    The resistor has to go right next to the LM34, not at the far end of
    the cable! There is more on construction of cables at
    <http://www.emesystems.com/BS2index.htm>

    --- snubber ---


    +6 volts
    |
    signal
    o--| LM34
    ;--||--/\/\--' |
    | 1uf 100 |
    common -o
    |
    X7R

    OR (this is the one I usually use)

    +6 volts
    |
    signal ----;
    /\/\---| LM34
    === 390 |
    | 1uf |
    common -o--'
    |

    I usually put a resistor (~390 ohm) in series with the +5 volt lead
    also when it is cable mounted, because sooner or later someone is
    going to hook it up backwards.
  • ArchiverArchiver Posts: 46,084
    edited 2002-11-22 23:00
    Take a look at Tracy's site, he has a nice description there (with pictures)
    showing how to make the LM34/35 cable - or you can even purchase pre-made
    ones from there. The site may be plain looking but its a veritable treasure
    trove of information! Wolf in sheep's clothing so to speak [noparse]:D[/noparse]

    Original Message
    From: "astumpf999" <astumpf999@y...>
    To: <basicstamps@yahoogroups.com>
    Sent: Friday, November 22, 2002 9:49 AM
    Subject: [noparse][[/noparse]basicstamps] Re: Tracy, math question


    > Tracy,
    >
    > Could you elaborate on the 3k isolation resistor and the RC snubber
    > for the LM34.
    >
    > Thanks,
    > Marylou
    > ___________________________
    > >
    > > Hi Jonathan,
    > >
    > > Changing the power supply should _not_ affect the signal voltage.
    > > LM34 output should be 10 millivolts per deg. F,, so long as the
    > power
    > > supply is anywhere within the allowed range. If not, something is
    > > wrong with the wiring.
    > >
    > > I have been using LM34 for years, and have always found them to be
    > > very close to spec. Even on a 100 foot cable, the error due to
    > > ground loop current is less than 0.1 degree F, because the supply
    > > current is only 70 microamps. Are you checking it with a
    > voltmeter?
    > > Look for a bad ground connection. Also, the output signal can
    > > oscillate wildly if the chip has to drive a cable in the range of
    > > inches to feet. That will make the readings appear whacko. You
    > can
    > > isolate the chip from the cable with a 3kohm resistor or with an RC
    > > snubber.
    > >
    > > regards,
    > > -- Tracy
    >
    > > >
    > > >
    > > >To UNSUBSCRIBE, just send mail to:
    > > > basicstamps-unsubscribe@y...
    > > >from the same email address that you subscribed. Text in the
    > > >Subject and Body of the message will be ignored.
    > > >
    > > >
    > > >Your use of Yahoo! Groups is subject to
    > http://docs.yahoo.com/info/terms/
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2002-11-23 04:08
    I hear lots of good things about Tracy's sight in this forum.

    What is the address?


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-11-23 18:46
    > I hear lots of good things about Tracy's sight in this forum.
    >
    >What is the address?

    As to my sight, not everything you hear is true! I definitely need
    Dr. Dean reading glasses!

    but as to the web site URL:
    http://www.emesystems.com
    enjoy!

    - Tracy
Sign In or Register to comment.