Shop OBEX P1 Docs P2 Docs Learn Events
LCD Temperature display (#27976 & DS1620) — Parallax Forums

LCD Temperature display (#27976 & DS1620)

superprosuperpro Posts: 17
edited 2006-03-24 05:29 in BASIC Stamp
I’m looking for a program that will have my LCD (2 row x 16 char non-backlit #27976) display temperature from a DS1620 chip.
·
I also need the circuit design to build it for my HomeWork Board.
·
I’m new and just trying to get started.· Thanks!

Comments

  • RDL2004RDL2004 Posts: 2,554
    edited 2006-03-16 15:31
    http://www.parallax.com/dl/docs/books/sw/exp/sw28.pdf



    I believe the documentation that comes with the LCD explains how to convert the·DEBUG statements to SEROUT to drive the display. If not, it shouldn't be too hard to track down the info.



    ·- Rick
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-03-16 15:50
    The following project is actually a Binary Digital Clock with both a Binary Display (10mm LEDs) and a 7-Segment Digital Display (1" Digits), however it also has a Parallax LCD and displays the Temperature as well as the day and date on the LCD.

    http://forums.parallax.com/showthread.php?p=552892

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • superprosuperpro Posts: 17
    edited 2006-03-17 23:45
    Thanks for the help. This site ROCKS!
  • superprosuperpro Posts: 17
    edited 2006-03-19 04:56
    I'm not finding the right information to get this working.

    I'm willing to pay $$ for this program if anybody can·write it.


    Post Edited (superpro) : 3/19/2006 5:15:12 AM GMT
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-03-19 05:22
    Download StampWorks 2.0 -- there are LCD experiments and DS1620 experiments; it will be up to you to put the two together, but it shouldn't be too hard.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • superprosuperpro Posts: 17
    edited 2006-03-19 16:15
    Thanks JON!!!!· That gave the solution to my program.

    Now I need to display a MAX temp (F) along with the current temp (F) read by the DS1629.

    Can someone help me with creating a MAX code that will read on line 2 of the lcd?
  • superprosuperpro Posts: 17
    edited 2006-03-20 19:47
    I want to display the current temp on line one, and to display the·maxium temp on line two.

    Can someone help me get the correct information to·write this program?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-03-20 20:13
    Post what you have so far and we'll see what we can do with it.· Without knowing how you're handling your data it would be difficult to guide you.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • superprosuperpro Posts: 17
    edited 2006-03-21 03:30
    ' LCD Temperature Display
    ' Purpose... Temperature

    Post Edited (superpro) : 3/23/2006 2:20:22 AM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-03-21 14:55
    Whoops, I probably should've worded it "attach" since pasting it has messed up the formatting.· In any event I wanted you to post it because I thought you were using Jon's code as per above.· But in fact this is code from my Binary/Digital Clock Project.· I already have routines for storing max temperature for this project at home and I will post those later (when I get home).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • superprosuperpro Posts: 17
    edited 2006-03-21 17:55
    Thanks!
    Chris Savage (Parallax) said...
    Whoops, I probably should've worded it "attach" since pasting it has messed up the formatting.· In any event I wanted you to post it because I thought you were using Jon's code as per above.· But in fact this is code from my Binary/Digital Clock Project.· I already have routines for storing max temperature for this project at home and I will post those later (when I get home).

  • superprosuperpro Posts: 17
    edited 2006-03-22 03:11
    ttt
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-03-22 05:15
    ttt???· Anyway, I found my updated code, and the only thing I forgot about was that since I never expect to have negative temperatures it really is designed to store positive values only.· It's only one additional line I added as shown below...
    Get_Temp:
      HIGH DS1620                           ' Select DS1620
      SHIFTOUT DataIO, Clock, LSBFIRST,
        [noparse][[/noparse]RdTemp]                            ' Send Read Temp Command
      SHIFTIN DataIO, Clock, LSBPRE,
        [noparse][[/noparse]tempIn\9]                          ' Read Temp Data
      LOW DS1620                            ' Deselect DS1620
      tempIn.BYTE1 = -tempIn.BIT8           ' Extend Sign To 16 Bits
      tempC = tempIn * 5                    ' Convert To C * 5 (Res. 0.5 C)
      tempF = tempC + 2732 * 9 / 50 - 459   ' C * 10 to F (First To K * 10)
      IF tempF > tempMax THEN tempMax = tempF   '<---This line added holds tempMax
      RETURN
     
    Show_Temp:
      SEROUT LCD, Baud, [noparse][[/noparse]LcdLine1, "Temp = ", DEC2 tempF, 0, "F ",
        LcdLine2, "Max  = ", DEC2 tempF, 0, "F "]
      RETURN                                ' Display Temp On LCD Display
    
    

    All you have to do is display it in the routine as shown.· If you need support for negative numbers that's not difficult but since they're not being used in this code I wouldn't worry about it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • superprosuperpro Posts: 17
    edited 2006-03-22 10:43
    "ttt"··Is just an acronym·for To The Top.··When a·thread has a new post---it will be To The Top of the Forum.
    Thanks for your help in this matter, and for your code in the Binary/Digital Clock Project.

    Which Basic Stamp module should I use to make this a stand alone component?
    Chris Savage (Parallax) said...
    ttt???· Anyway, I found my updated code, and the only thing I forgot about was that since I never expect to have negative temperatures it really is designed to store positive values only.· It's only one additional line I added as shown below..

    All you have to do is display it in the routine as shown.· If you need support for negative numbers that's not difficult but since they're not being used in this code I wouldn't worry about it.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-03-22 15:46
    Interesting...All of my new posts appear at the bottom of the current thread.· In any event as far as a BASIC Stamp Module for stand alone operation you could either use a BS2 Module on a Super Carrier Board or you could use the BS2-OEM.· Not really sure of everything connected to this system.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • superprosuperpro Posts: 17
    edited 2006-03-23 01:01
    Everything is working except the "Max Line" is not holding the Max temp.· The "Max Line" changes (up & down) with the Temp.

    I think it needs to write and read the Max temp, right?

    Any clues how to fix this?

    Post Edited (superpro) : 3/23/2006 1:05:09 AM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-03-23 01:18
    I will have to re-run the code later.· I don't have the circuit setup right now.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • superprosuperpro Posts: 17
    edited 2006-03-23 02:18
    I have attached my file for you to view/use.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-03-23 02:40
    In GetTemp:, change

    IF tempF < tempMax THEN tempMax = tempF to

    IF tempF·> tempMax THEN tempMax = tempF
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-03-23 05:14
    You changed the code...If you back up a few messages you will see that I had the greater than sign there, not the less than sign.·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • superprosuperpro Posts: 17
    edited 2006-03-23 10:45
    I did that to see if it made any difference to the reading of the Max temp.

    If I change it back to" >", or keep it the same, the result will be unchanged.

    Thanks.
    PJ Allen said...

    In GetTemp:, change

    IF tempF < tempMax THEN tempMax = tempF to

    IF tempF·> tempMax THEN tempMax = tempF

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-03-23 15:18
    The code works perfectly...I just tested it.· Your code does not.· The reason is you're not displaying the tempMax in the second line as I am.· You are displaying tempF in both lines, so of course they will follow each other.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • SSteveSSteve Posts: 808
    edited 2006-03-23 23:56
    I'm a little late to the party, but I just happened to write a program that does what the original poster asked for. The pin connections should be obvious from the constants, but ask if you aren't sure.

    I welcome comments on programming style. I'm new to the BASIC Stamp (but not to programming in general).

    (I tried to attach the file, but I get a message saying I can't upload files with MIME type www/unknown.)

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    ' ------------------------------------------------------------
    ' I/O Definitions
    
    ' LCD connections (block X2 on prof devel board)
    E            PIN        1
    RW            PIN        2
    RS            PIN        3
    LcdBus        VAR        OUTB
    LcdDir        VAR        DIRL
    
    ' Connections to DS1620 (other connections are the same as in StampWorks2.0  book)
    DQ            PIN        8
    Clock            PIN        9
    Reset            PIN        10
    
    ' ------------------------------------------------------------
    ' DS1620 Constants
    RdTmp            CON        $AA        ' read temperature
    WrHI            CON        $01        ' write TH (high temp)
    WrLo            CON        $02        ' write TL (low temp)
    RdHi            CON        $A1        ' read TH
    RdLo            CON        $A2        ' read TL
    RdCntr        CON        $A0        ' read counter
    RdSlope        CON        $A9        ' read slope
    StartC        CON        $EE        ' start conversion
    STOPC            CON        $22        ' stop conversion
    WrCfg            CON        $0C        ' write config register
    RdCfg            CON        $AC        ' read config register
    
    ' ------------------------------------------------------------
    ' LCD Constants
    ' LCD Commands - These are sent with RS set to LOW
    
    LcdCls        CON        %00000001    ' Clear the display
    LcdHome        CON        %00000010    ' Move cursor home
    
    ' Entry Mode commands
    LcdIncNoShift    CON        %00000110 ' Inc cursor after writing a
                                ' character, don't shift display
    LcdIncAndShift    CON        %00000111 ' Inc cursor after writing a
                                ' character, shift display
    LcdDecNoShift    CON        %00000100    ' Dec cursorafter writing a
                                ' character, don't shift display
    LcdDecAndShift    CON        %00000101 ' Dec cursor after writing a
                                ' character, shift display
    ' Display on/off control
    ' "cursor" sets whether or not cursor is visible
    ' "blink" sets whether or not the character at the cursor position blinks
    LcdDisplayOff        CON        %00001000    ' display off
    LcdCrsOffBlnkOff    CON        %00001100    ' display on, cursor off, Blink off
    LcdCrsOffBlnkOn        CON        %00001101    ' display on, cursor off, Blink on
    LcdCrsOnBlnkOff        CON        %00001110    ' display on, cursor on, Blink off
    LcdCrsOnBlnkOn        CON        %00001111    ' display on, cursor on, Blink on
    
    ' Cursor/display shift
    LcdCrsrL        CON        %00010000        ' Move cursor left
    LcdCrsrR        CON        %00010100        ' Move cursor right
    LcdDispL        CON        %00011000        ' Shift chars left
    LcdDispR        CON        %00011100        ' Shift chars right
    
    ' Function Set
    Lcd8bit        CON        %0011            ' set to 8-bit mode
    Lcd4bit        CON        %0010            ' set to 4-bit mode
    ' Function Set (these are all for 4-bit mode)
    Lcd1Line        CON        %00100000        ' one line of 5x8 chars
    Lcd2Line        CON        %00101000        ' two lines of 5x8 chars
    Lcd1LineBig    CON        %00100100        ' one line of 5x10 chars
    
    ' RAM addresses
    LcdGCRam        CON        $40    ' Character Generator RAM
    LcdDDRam        CON        $80    ' Display Data RAM control
    LcdLine1        CON        $80    ' DDRAM address of line 1
    LcdLine2        CON        $C0    ' DDRAM address of line 2
    
    ' Special character codes
    DegSym        CON        $DF        ' degree symbol
    
    
    ' #DEFINE _LcdReady = ($STAMP >= BS2P)
    
    ' ------------------------------------------------------------
    ' Variables
    
    char            VAR        BYTE        ' Character sent to LCD
    idx            VAR        BYTE        ' Loop index
    
    tempIn        VAR        WORD        ' raw temperature
    sign            VAR        tempIn.BIT8    ' 1 = negative termperature
    
    tC            VAR        WORD        ' Celcius temp
    tF            VAR        WORD        ' Farenheit temp
    
    displayTemp    VAR        WORD        ' The temp to display
    displayPos        VAR        BYTE        ' Where to display the temp
    
    LowestTemp        VAR        WORD        ' Lowest recorded temp (in F)
    HighestTemp    VAR        WORD        ' Highest recorded temp (in F)
    
    #DEFINE __debugDisplay = 0
    
    ' ------------------------------------------------------------
    ' EEPROM data
    
    MsgF            DATA        ". ", DegSym, "F", 0
    MsgC            DATA        ". ", DegSym, "C", 0
    MsgHi            DATA        "Hi:   ", 0
    MsgLo            DATA        "Lo:   ", 0
    
    ' ------------------------------------------------------------
    ' Initialization
    
    Setup:
    #IF (__debugDisplay) #THEN
        DEBUG CLS
    #ENDIF
    
        GOSUB Lcd_2Line_Init
    
        LowestTemp = 2000
        HighestTemp = 0
    
        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
    
        char = LcdCls                ' clear the LCD
        GOSUB LCD_Cmd
        PAUSE 500
    
        ' Write the constant part of message
        char = LcdLine1 + 3            ' set address to begin writing
        GOSUB LCD_Cmd
        idx = MsgF                    ' display degrees F message
        GOSUB LCD_Message
        char = LcdLine2 + 3            ' set address to begin writing
        GOSUB LCD_Cmd
        idx = MsgC                    ' display degrees C message
        GOSUB LCD_Message
        char = LcdLine1 + 8            ' display "Hi:   "
        GOSUB LCD_Cmd
        idx = MsgHi
        GOSUB LCD_Message
        idx = MsgF                    ' display degrees F message
        GOSUB LCD_Message
        char = LcdLine2 + 8            ' display "Lo:   "
        GOSUB LCD_Cmd
        idx = MsgLo
        GOSUB LCD_Message
        idx = MsgF                    ' display degrees F message
        GOSUB LCD_Message
    
    
    ' ------------------------------------------------------------
    ' Program Code
    
    Main:
        DO    
            GOSUB READ_DS1620            ' get the temperature
    
    Display_C:    
    #IF __debugDisplay #THEN
        DEBUG (tC.BIT15 * 13 + " "),
            DEC (ABS tF / 10), ".", DEC1 (ABS tF), "° F  ",
            DEC (ABS tC / 10), ".", DEC1 (ABS tC), "° C", CR
    #ENDIF
        ' Write degrees Farenheit
        displayPos = LcdLine1
        displayTemp = tF
        GOSUB LCD_Display_Temp
    
        ' Write degrees Celsius
        displayPos = LcdLine2
        displayTemp = tC
        GOSUB LCD_Display_Temp
    
        IF (tF > HighestTemp) THEN
            HighestTemp = tF
            displayTemp = tF
            displayPos = LcdLine1 + 11
            GOSUB LCD_Display_Temp
        ENDIF
    
        IF (tF < LowestTemp) THEN
            LowestTemp = tF
            displayTemp = tF
            displayPos = LcdLine2 + 11
            GOSUB LCD_Display_Temp
        ENDIF
    
        PAUSE 5000            ' Change this value to change the sample interval
        LOOP
    
    END
    
    ' ------------------------------------------------------------
    ' Subroutines
    
    READ_DS1620:
        HIGH Reset
        SHIFTOUT DQ, Clock, LSBFIRST, [noparse][[/noparse]RdTmp]    ' give command to read temp
        SHIFTIN DQ, Clock, LSBPRE, [noparse][[/noparse]tempIn\9]    ' read the temp
        LOW Reset
    
        tempIn.BYTE1 = -sign                    ' extend sign bit
        tC = tempIn * 5                        ' convert to tenths
        
        IF (tC.BIT15 = 0) THEN                ' temp c is positive
            tF = tC */ $01CC + 320
        ELSE
            tF = 320 - ((ABS tC) */ $01CC)
        ENDIF
    RETURN
    
    ' ------------------------------------------------------------
    ' LCD Subroutines
    
    LCD_4bitInit:
    ' The program shouldn't call this directly. It is called by "LCD_1Line_Init
    ' and LCD_2Line_Init
        LCDDir = %11111110
        PAUSE 100
        LcdBus = Lcd8bit            ' 8-bit mode
        PULSOUT E, 3
        PAUSE 5
        PULSOUT E, 3
        PULSOUT E, 3
        LcdBus = Lcd4bit            ' 4-bit mode
        PULSOUT E, 1
    RETURN
    
    '** LCD_1Line_Init:
    '**     GOSUB LCD_4bitInit
    '**     char = Lcd1Line                ' single-line mode
    '**     GOSUB LCD_Cmd
    '**     char = LcdCrsOffBlnkOff        ' disp on, no crsr or blink
    '**     GOSUB LCD_Cmd
    '**     char = LCDIncNoShift            ' inc crsr, no disp shift
    '**     GOSUB LCD_Cmd
    '** RETURN
    
    LCD_2Line_Init:
        GOSUB LCD_4bitInit
        char = Lcd2Line                ' multi-line mode
        GOSUB LCD_Cmd
        char = LcdCrsOffBlnkOff        ' disp on, no crsr or blink
        GOSUB LCD_Cmd
        char = LCDIncNoShift            ' inc crsr, no disp shift
        GOSUB LCD_Cmd
    RETURN
    
    LCD_Cmd:
        LOW RS                    ' enter command mode
        ' fall through to LCD_Out
    LCD_Out:
        LcdBus = char.HIGHNIB        ' output high nibble
        PULSOUT E, 3                ' strobe the enable line
        LcdBus = char.LOWNIB            ' output low nibble
        PULSOUT E, 3                ' strobe the enable line
        HIGH RS                    ' return to character mode
    RETURN    
    
    LCD_Message:                    ' Display the message pointed to by idx
        READ idx, char
        DO WHILE (char <> 0)
            GOSUB LCD_Out            ' write the character
            idx = idx + 1
            READ idx, char
        LOOP
    RETURN
    
    LCD_Display_Temp:
        char = displayPos
        GOSUB LCD_Cmd
        char = displayTemp.BIT15 * 13 + " "
        GOSUB LCD_Out
        char = (displayTemp DIG 2) + "0"
        GOSUB LCD_Out
        char = (displayTemp DIG 1) + "0"
        GOSUB LCD_Out
        char = displayPos + 4
        GOSUB LCD_Cmd
        char = (displayTemp DIG 0) + "0"
        GOSUB LCD_Out
    RETURN
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    OS-X: because making Unix user-friendly was easier than debugging Windows
  • superprosuperpro Posts: 17
    edited 2006-03-24 03:18
    Thanks Chris!!! You're right.....again!!! [noparse];)[/noparse]

    How can I reset the Max temp by using·pushbutton?
    Chris Savage (Parallax) said...
    The code works perfectly...I just tested it.· Your code does not.· The reason is you're not displaying the tempMax in the second line as I am.· You are displaying tempF in both lines, so of course they will follow each other.

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-03-24 05:29
    In your main loop do something like:

    IF IN0 = 1 THEN tempMax = tempF

    ...assuming you have an active HIGH pushbutton connected to P0.· You get the idea.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
Sign In or Register to comment.