Shop OBEX P1 Docs P2 Docs Learn Events
LCD/Temperature — Parallax Forums

LCD/Temperature

ArchiverArchiver Posts: 46,084
edited 2002-07-22 18:18 in General Discussion
'm new to the Basic Stamp. I have a BS2P24 and a NX1000 board that I
am trying to display the temperature to the 2x16 LCD offered by
Parallax.(4 bit mode)
I started with the DS1620bsp code. My modified code is at the bottom
of this Page. I know there is some excess code, But I will eliminate
it when I have it operating corectly


I am using LCDOUT LCDpin,NoCmd,[noparse][[/noparse](tempIn)] to display the temp on the
LCD. I get a display that changes with the temp but it is a single
letter. K is about 73 degrees F. If I warm the chip then it will
display L,N,P,R,T.... and so forth depending on the temp. Any help
would be appreciated. I would like to end up diplaying degrees in F.

Thank you,

Chris Haley


Main:
GOSUB GetTemperature ' read the DS1620
DEBUG Home
DEBUG "DS1620",CR
DEBUG SDEC tempC," C ",CR
DEBUG SDEC tempF," F ",CR
PAUSE 500 ' pause between
readings


LCDCMD LCDpin,ClrLCD ' clear display
PAUSE 500

LCDOUT LCDpin,NoCmd,[noparse][[/noparse]tempIn]

pause 1000
GOTO Main ' do it all over
END

'

DS1620init:
HIGH Reset ' alert the DS1620
'SHIFTOUT DQ,Clock,LSBFirst,[noparse][[/noparse]WrCfg,%10] ' use with CPU; free-
run
LOW Reset
PAUSE 10
HIGH Reset
SHIFTOUT DQ,Clock,LSBFirst,[noparse][[/noparse]StartC] ' start conversions
LOW Reset
RETURN
GetTemperature:
HIGH Reset ' alert the DS1620
SHIFTOUT DQ,Clock,LSBFIRST,[noparse][[/noparse]RdTmp] ' give command to
read temp
SHIFTIN DQ,Clock,LSBPRE,[noparse][[/noparse]tempIn\9] ' read it in
LOW Reset ' release the DS1620
tSign = sign ' save sign bit
tempIn = tempIn/2 ' round to whole
degrees
IF tSign = 0 THEN NoNeg1
tempIn = tempIn | $FF00 ' extend sign bits
for negative
NoNeg1:
tempC = tempIn ' save Celsius value
tempIn = tempIn */ $01CC ' multiply by 1.8
IF tSign = 0 THEN NoNeg2 ' if negative, extend
sign bits
tempIn = tempIn | $FF00
NoNeg2:
tempIn = tempIn + 32 ' finish C -> F
conversion
tempF = tempIn ' save Fahrenheit
value
RETURN

LCDinit:
PAUSE 500 ' let the LCD settle
LCDCMD LCDpin,%00110000 ' 8-bit mode
PAUSE 5
LCDCMD LCDpin,%00110000
PAUSE 0
LCDCMD LCDpin,%00110000
PAUSE 0
LCDCMD LCDpin,%00100000 ' 4-bit mode
PAUSE 0
LCDCMD LCDpin,%00101000 ' 2-line mode
PAUSE 0
LCDCMD LCDpin,%00001100 ' no crsr, no blink
PAUSE 0
LCDCMD LCDpin,%00000110 ' inc crsr, no disp
shift
RETURN

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-07-21 06:36
    The LCD displays characters and you're sending it a number. It is simply
    interpreting the value as a character. Use the SDEC modifier (as you did
    with DEBUG) to change the temperature value to a string of characters.

    -- Jon Williams
    -- Applications Engineer, Parallax

    In a message dated 7/21/02 12:06:55 AM Central Daylight Time,
    chaley63@y... writes:


    > I am using LCDOUT LCDpin,NoCmd,[noparse][[/noparse](tempIn)] to display the temp on the
    > LCD. I get a display that changes with the temp but it is a single
    > letter. K is about 73 degrees F. If I warm the chip then it will
    > display L,N,P,R,T.... and so forth depending on the temp. Any help
    >




    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-07-21 06:37
    So what is the ASCII value of an upper-case K?

    http://www.mindspring.com/~jc1/serial/Resources/ASCII.html

    Looks like a value of 75 decimal -- so the LCD is displaying what you told
    it to, but not what you want it to. You need to convert this value to
    characters in order to display it properly.

    Original Message

    > 'm new to the Basic Stamp. I have a BS2P24 and a NX1000 board that I
    > am trying to display the temperature to the 2x16 LCD offered by
    > Parallax.(4 bit mode)
    > I started with the DS1620bsp code. My modified code is at the bottom
    > of this Page. I know there is some excess code, But I will eliminate
    > it when I have it operating corectly
    >
    >
    > I am using LCDOUT LCDpin,NoCmd,[noparse][[/noparse](tempIn)] to display the temp on the
    > LCD. I get a display that changes with the temp but it is a single
    > letter. K is about 73 degrees F. If I warm the chip then it will
    > display L,N,P,R,T.... and so forth depending on the temp. Any help
    > would be appreciated. I would like to end up diplaying degrees in F.
  • ArchiverArchiver Posts: 46,084
    edited 2002-07-21 07:47
    Thank you Jon and Rodent. That makes sense

    Chris


    --- In basicstamps@y..., Rodent <daweasel@s...> wrote:
    > So what is the ASCII value of an upper-case K?
    >
    > http://www.mindspring.com/~jc1/serial/Resources/ASCII.html
    >
    > Looks like a value of 75 decimal -- so the LCD is displaying what
    you told
    > it to, but not what you want it to. You need to convert this value
    to
    > characters in order to display it properly.
    >
    >
    Original Message
    >
    > > 'm new to the Basic Stamp. I have a BS2P24 and a NX1000 board
    that I
    > > am trying to display the temperature to the 2x16 LCD offered by
    > > Parallax.(4 bit mode)
    > > I started with the DS1620bsp code. My modified code is at the
    bottom
    > > of this Page. I know there is some excess code, But I will
    eliminate
    > > it when I have it operating corectly
    > >
    > >
    > > I am using LCDOUT LCDpin,NoCmd,[noparse][[/noparse](tempIn)] to display the temp on
    the
    > > LCD. I get a display that changes with the temp but it is a single
    > > letter. K is about 73 degrees F. If I warm the chip then it will
    > > display L,N,P,R,T.... and so forth depending on the temp. Any help
    > > would be appreciated. I would like to end up diplaying degrees in
    F.
  • ArchiverArchiver Posts: 46,084
    edited 2002-07-21 07:53
    Jon,

    The SDEC modifier worked. Thanks All


    --- In basicstamps@y..., jonwms@a... wrote:
    > The LCD displays characters and you're sending it a number. It is
    simply
    > interpreting the value as a character. Use the SDEC modifier (as
    you did
    > with DEBUG) to change the temperature value to a string of
    characters.
    >
    > -- Jon Williams
    > -- Applications Engineer, Parallax
    >
    > In a message dated 7/21/02 12:06:55 AM Central Daylight Time,
    > chaley63@y... writes:
    >
    >
    > > I am using LCDOUT LCDpin,NoCmd,[noparse][[/noparse](tempIn)] to display the temp on
    the
    > > LCD. I get a display that changes with the temp but it is a
    single
    > > letter. K is about 73 degrees F. If I warm the chip then it will
    > > display L,N,P,R,T.... and so forth depending on the temp. Any
    help
    > >
    >
    >
    >
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-07-22 16:14
    chaley63 <chaley63@y...> wrote: 'm new to the Basic Stamp. I have a
    BS2P24 and a NX1000 board that I
    am trying to display the temperature to the 2x16 LCD offered by
    Parallax.(4 bit mode)
    I started with the DS1620bsp code. My modified code is at the bottom
    of this Page. I know there is some excess code, But I will eliminate
    it when I have it operating corectly


    I am using LCDOUT LCDpin,NoCmd,[noparse][[/noparse](tempIn)] to display the temp on the
    LCD. I get a display that changes with the temp but it is a single
    letter. K is about 73 degrees F. If I warm the chip then it will
    display L,N,P,R,T.... and so forth depending on the temp. Any help
    would be appreciated. I would like to end up diplaying degrees in F.

    Thank you,

    Chris Haley


    Main:
    GOSUB GetTemperature ' read the DS1620
    DEBUG Home
    DEBUG "DS1620",CR
    DEBUG SDEC tempC," C ",CR
    DEBUG SDEC tempF," F ",CR
    PAUSE 500 ' pause between
    readings


    LCDCMD LCDpin,ClrLCD ' clear display
    PAUSE 500

    LCDOUT LCDpin,NoCmd,[noparse][[/noparse]tempIn]

    pause 1000
    GOTO Main ' do it all over
    END

    '

    DS1620init:
    HIGH Reset ' alert the DS1620
    'SHIFTOUT DQ,Clock,LSBFirst,[noparse][[/noparse]WrCfg,%10] ' use with CPU; free-
    run
    LOW Reset
    PAUSE 10
    HIGH Reset
    SHIFTOUT DQ,Clock,LSBFirst,[noparse][[/noparse]StartC] ' start conversions
    LOW Reset
    RETURN
    GetTemperature:
    HIGH Reset ' alert the DS1620
    SHIFTOUT DQ,Clock,LSBFIRST,[noparse][[/noparse]RdTmp] ' give command to
    read temp
    SHIFTIN DQ,Clock,LSBPRE,[noparse][[/noparse]tempIn\9] ' read it in
    LOW Reset ' release the DS1620
    tSign = sign ' save sign bit
    tempIn = tempIn/2 ' round to whole
    degrees
    IF tSign = 0 THEN NoNeg1
    tempIn = tempIn | $FF00 ' extend sign bits
    for negative
    NoNeg1:
    tempC = tempIn ' save Celsius value
    tempIn = tempIn */ $01CC ' multiply by 1.8
    IF tSign = 0 THEN NoNeg2 ' if negative, extend
    sign bits
    tempIn = tempIn | $FF00
    NoNeg2:
    tempIn = tempIn + 32 ' finish C -> F
    conversion
    tempF = tempIn ' save Fahrenheit
    value
    RETURN

    LCDinit:
    PAUSE 500 ' let the LCD settle
    LCDCMD LCDpin,%00110000 ' 8-bit mode
    PAUSE 5
    LCDCMD LCDpin,%00110000
    PAUSE 0
    LCDCMD LCDpin,%00110000
    PAUSE 0
    LCDCMD LCDpin,%00100000 ' 4-bit mode
    PAUSE 0
    LCDCMD LCDpin,%00101000 ' 2-line mode
    PAUSE 0
    LCDCMD LCDpin,%00001100 ' no crsr, no blink
    PAUSE 0
    LCDCMD LCDpin,%00000110 ' inc crsr, no disp
    shift
    RETURN



    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/




    Do You Yahoo!?
    Yahoo! Health - Feel better, live better

    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-07-22 18:18
    Use the SDEC modifier with LCDOUT just as you did with DEBUG. You're sending
    the value directly which is causing the LCD to think your sending an ASCII
    character; that's why the character changes as the temperature changes. The
    DEC, SDEC, HEX and BIN modifiers (used with DEBUG, SEROUT, LCDOUT, I2COUT,
    OWOUT) are actually numeric-to-text convertors.

    -- Jon Williams
    -- Applications Engineer, Parallax

    In a message dated 7/22/02 10:15:25 AM Central Daylight Time,
    donaldscott_18@y... writes:


    > I am using LCDOUT LCDpin,NoCmd,[noparse][[/noparse](tempIn)] to display the temp on the
    > LCD. I get a display that changes with the temp but it is a single
    > letter. K is about 73 degrees F. If I warm the chip then it will
    > display L,N,P,R,T.... and so forth depending on the temp. Any help
    >




    [noparse][[/noparse]Non-text portions of this message have been removed]
Sign In or Register to comment.