Hi slimpeng,
Here! Already written, and links to where to get it. You will be here 2 years from now trying to accomplish your goal with that thermistor. Oh, and please do try to use Google, it really does work to bring you good things, like data sheets, vendors, etc. . .
http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2815/t/al
Code:@MyConfig = _HS_OSC & _WDT_ON & _PWRTE_ON & _LVP_OFF @MyConfig = MyConfig & _BODEN_OFF @ __config MyConfig ' One-wire temperature for LAB-X1 and DS1820 Define PIC16F877A @ errorlevel -230 temperature Var Word ' Temperature storage count_remain Var Byte ' Count remaining count_per_c Var Byte ' Count per degree C DQ Var PORTC.0 ' One-wire data pin define OSC 20 TrisA = %00000000 TrisB = %11111111 ' Define LCD registers and bits DEFINE LCD_DREG PORTA DEFINE LCD_DBIT 0 DEFINE LCD_RSREG PORTA DEFINE LCD_RSBIT 5 DEFINE LCD_EREG PORTA DEFINE LCD_EBIT 4 DEFINE LCD_BITS 4 DEFINE LCD_LINES 4 DEFINE LCD_COMMANDUS 2000 'Define delay time between sending LCD commands DEFINE LCD_DATAUS 50 'Define delay time between data sent. CMCON = 7 ADCON1 = 7 ' Set PORTA and PORTE to digital Low PORTE.2 ' LCD R/W line low (W) pause 500 LCDOUT 254,1,"initializing" mainloop: OWOut DQ, 1, [$CC, $44] ' Start temperature conversion waitloop: OWIn DQ, 4, [count_remain] ' Check for still busy converting If count_remain = 0 Then waitloop OWOut DQ, 1, [$CC, $BE] ' Read the temperature OWIn DQ, 0, [temperature.LOWBYTE, temperature.HIGHBYTE, Skip 4, count_remain, count_per_c] ' Calculate temperature in degrees C to 2 decimal places (not valid for negative temperature) temperature = (((temperature >> 1) * 100) - 25) + (((count_per_c - count_remain) * 100) / count_per_c) Lcdout $fe, 1, DEC (temperature / 100), ".", DEC2 temperature, " C" ' Calculate temperature in degrees F to 2 decimal places (not valid for negative temperature) temperature = (temperature */ 461) + 3200 Lcdout $fe, $c0, DEC (temperature / 100), ".", DEC2 temperature, " F" Pause 1000 ' Display about once a second Goto mainloop ' Do it forever




Bookmarks