Digital thermometer with LM35 and PIC18F452


This can be a complete project on its own - a simple DIY digital thermometer with LCD display and only a handful of parts - the PIC18F452, LM35 and a small number of resistors and capacitors running off a regulated 5v supply.
Temperature range - 0 to 150'C
Display type - LCD (can be 16x1, 16x2 or anything larger)
Controller: PIC18F452
Programming Language: BASIC
Compiler: mikroBASIC PRO for PIC v3.20


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
program thermometer452

'Programmer: Syed Tahmid Mahbub
'Compiler: mikroBASIC PRO for PIC v3.20
'Target PIC: 18F452 - 40pin DIP
'Configuration: Check the project in the download link for the configuration bits

dim LCD_RS as sbit at RB4_bit
    LCD_EN as sbit at RB5_bit
    LCD_D4 as sbit at RB0_bit
    LCD_D5 as sbit at RB1_bit
    LCD_D6 as sbit at RB2_bit
    LCD_D7 as sbit at RB3_bit

    LCD_RS_Direction as sbit at TRISB4_bit
    LCD_EN_Direction as sbit at TRISB5_bit
    LCD_D4_Direction as sbit at TRISB0_bit
    LCD_D5_Direction as sbit at TRISB1_bit
    LCD_D6_Direction as sbit at TRISB2_bit
    LCD_D7_Direction as sbit at TRISB3_bit

dim ADCResult as longword
dim value as word[3]
dim vstring as string[3]

sub procedure GlobInit
    TRISB = 0
    PORTB = 0
    TRISA = 1
    ADCON1 = $4E
    LCD_Init
    LCD_Cmd(_LCD_CLEAR)
    LCD_Cmd(_LCD_CURSOR_OFF)
    LCD_Out(1, 1, "Temp:")
    LCD_Out(1, 15, "'C")
end sub

main:
     GlobInit
     while true
           ADCResult = (ADC_Read(0) * 500) >> 10
           value[0] = ADCResult div 100
           value[1] = (ADCResult div 10) mod 10
           value[2] = ADCResult mod 10
           vstring[0] = value[0] + 48
           vstring[1] = value[1] + 48
           vstring[2] = value[2] + 48
           LCD_Out(1, 10, vstring)
           delay_ms(50)
     wend
end.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Schematic:
 

Hex file + Schematic + Code freely available for download:
http://www.4shared.com/file/wrT3PgNJ/hex__schematic__code.html

The code can be freely used and there is no copyright restrictions or anything as such. Only credit the author where necessary.

Comments

Popular posts from this blog

Using the TLP250 Isolated MOSFET Driver - Explanation and Example Circuits

N-Channel MOSFET High-Side Drive: When, Why and How?

Using the high-low side driver IR2110 - explanation and plenty of example circuits