Shop OBEX P1 Docs P2 Docs Learn Events
pulsin and temperatur sensor SMT 160-30 — Parallax Forums

pulsin and temperatur sensor SMT 160-30

ArchiverArchiver Posts: 46,084
edited 2002-02-21 18:09 in General Discussion
hi :-)

I use stamp2p
and try to ad an temp-sensor
the SMT 160 is an Pulse-width modulated temp-sensor
frequency is between 1 and 4 kHz
The duty cycl is direct proportional to the temperature.
So I thought it is very easy to use with the pulsin command

td var word
tp var word

pulsin 1,1,td
pulsin 1,0,tp

and some calculations and finish..............
but..
when I use debug "td= ",dec td," tp= ",dec tp,cr
I get : td= 146 tp= 223 (about 18°C)
The problem now is:
W i t h o u t changing the temperature I get sometimes
"td" and "tp" changed from 146 to 151
= 5* 0,75µSec ... it is too much
after my calculations I got a different of 1-2°C
W i t h o u t changing the temperature !!

it should be 0.2°C max (datasheet)

I added 100nF directly on the sensors supply leg
No change
Is the pulsin command counting very exactly?

I also used a loop and a counter to read the pulse
But the pulse is to short I arrived only about 10 loops

Has somebody an idea what else I could check or think about?
Or what could be wrong?

A nice day to every body Heinz

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-02-21 17:16
    The spec sheet says this:

    "So to achieve the wished accuracy it is necessary to sample over more than
    one sensor period. This way of working has also the advantage to filter
    noise."

    Here's a subroutine that takes five samples and returns the temperature:

    Get_SMT160_Temp:
    tHigh = 0
    tLow = 0

    FOR x = 1 TO 5
    PULSIN Tpin, 1, pWidth
    tHigh = tHigh + (pWidth / 5)
    PULSIN Tpin, 0, pWidth
    tHigh = tLow + (pWidth / 5)
    NEXT

    ' temperature = (duty - 32) / 0.47

    tempC = (tHigh * 100) / tLow ' calc duty cycle
    tempC = (tempC - 32)
    tempC = (tempC * 2) + (tempC ** $20AE) ' = tempC * 2.12765
    RETURN

    The PULSIN accuracy of the BS2p is 0.75 uS -- way beyond what you need to
    read this sensor accurately. According the spec, an accuracy of 50 mS will
    give a temperature accuracty of 0.1C.

    Please not that I don't have a sensor to test with, I wrote this code against
    the spec sheet. HTH.

    -- Jon Williams
    -- Parallax


    In a message dated 2/21/02 9:14:13 AM Central Standard Time, hschwenk@g...
    writes:


    > I use stamp2p
    > and try to ad an temp-sensor
    > the SMT 160 is an Pulse-width modulated temp-sensor
    > frequency is between 1 and 4 kHz
    > The duty cycl is direct proportional to the temperature.
    > So I thought it is very easy to use with the pulsin command
    >
    > td var word
    > tp var word
    >
    > pulsin 1,1,td
    > pulsin 1,0,tp
    >
    > and some calculations and finish..............
    > but..
    > when I use debug "td= ",dec td," tp= ",dec tp,cr
    > I get : td= 146 tp= 223 (about 18°C)
    > The problem now is:
    > W i t h o u t changing the temperature I get sometimes
    > "td" and "tp" changed from 146 to 151
    > = 5* 0,75µSec ... it is too much
    > after my calculations I got a different of 1-2°C
    > W i t h o u t changing the temperature !!
    >




    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-02-21 18:09
    ***************************
    hi Jon,
    t h a n k s! for Your quick response Heinz

    ***************************
    Original Message
    *
    From: <jonwms@a...>
    To: <basicstamps@yahoogroups.com>
    Sent: Thursday, February 21, 2002 6:16 PM
    Subject: Re: [noparse][[/noparse]basicstamps] pulsin and temperatur sensor SMT 160-30


    The spec sheet says this:

    "So to achieve the wished accuracy it is necessary to sample over more than
    one sensor period. This way of working has also the advantage to filter
    noise."

    Here's a subroutine that takes five samples and returns the temperature:

    Get_SMT160_Temp:
    tHigh = 0
    tLow = 0

    FOR x = 1 TO 5
    PULSIN Tpin, 1, pWidth
    tHigh = tHigh + (pWidth / 5)
    PULSIN Tpin, 0, pWidth
    tHigh = tLow + (pWidth / 5)
    NEXT

    ' temperature = (duty - 32) / 0.47

    tempC = (tHigh * 100) / tLow ' calc duty cycle
    tempC = (tempC - 32)
    tempC = (tempC * 2) + (tempC ** $20AE) ' = tempC * 2.12765
    RETURN

    The PULSIN accuracy of the BS2p is 0.75 uS -- way beyond what you need to
    read this sensor accurately. According the spec, an accuracy of 50 mS will
    give a temperature accuracty of 0.1C.

    Please not that I don't have a sensor to test with, I wrote this code
    against
    the spec sheet. HTH.

    -- Jon Williams
    -- Parallax


    In a message dated 2/21/02 9:14:13 AM Central Standard Time,
    hschwenk@g...
    writes:


    > I use stamp2p
    > and try to ad an temp-sensor
    > the SMT 160 is an Pulse-width modulated temp-sensor
    > frequency is between 1 and 4 kHz
    > The duty cycl is direct proportional to the temperature.
    > So I thought it is very easy to use with the pulsin command
    >
    > td var word
    > tp var word
    >
    > pulsin 1,1,td
    > pulsin 1,0,tp
    >
    > and some calculations and finish..............
    > but..
    > when I use debug "td= ",dec td," tp= ",dec tp,cr
    > I get : td= 146 tp= 223 (about 18°C)
    > The problem now is:
    > W i t h o u t changing the temperature I get sometimes
    > "td" and "tp" changed from 146 to 151
    > = 5* 0,75µSec ... it is too much
    > after my calculations I got a different of 1-2°C
    > W i t h o u t changing the temperature !!
    >




    [noparse][[/noparse]Non-text portions of this message have been removed]


    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/
Sign In or Register to comment.