LCD Temperature display (#27976 & DS1620)
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!
·
I also need the circuit design to build it for my HomeWork Board.
·
I’m new and just trying to get started.· Thanks!

Comments
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
http://forums.parallax.com/showthread.php?p=552892
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
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 Williams
Applications Engineer, Parallax
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?
Can someone help me get the correct information to·write this program?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
' Purpose... Temperature
Post Edited (superpro) : 3/23/2006 2:20:22 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
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 DisplayAll 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
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 Tech Support
csavage@parallax.com
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 Savage
Parallax Tech Support
csavage@parallax.com
IF tempF < tempMax THEN tempMax = tempF to
IF tempF·> tempMax THEN tempMax = tempF
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
If I change it back to" >", or keep it the same, the result will be unchanged.
Thanks.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
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
How can I reset the Max temp by using·pushbutton?
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