;Chip Settings
#chip 16F887
;Include files (Libraries)
#include <maths.h>
;Defines (Constants)
#define LCD_IO 404
#define LCD_NO_RW
#define LCD_Speed slow
#define LCD_RS PORTE.0
#define LCD_Enable1 PORTE.1
#define LCD_Enable2 PORTE.2
#define LCD_DB4 PORTD.0
#define LCD_DB5 PORTD.1
#define LCD_DB6 PORTD.2
#define LCD_DB7 PORTD.3
#define SCROLL_DELAY 50 ms
;Variables
Dim Analog As integer
Dim Temp As integer
;Data tables
Table ADCtoTemp as integer
-10, -9, -8, -8, -7, -7, -6, -6, -5, -5, -4, -4, -4,-3, -3, -2, -2, -1, -1, 0, 0, 1, 1, 1, 2, 2,3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 7, 8,8, 9, 9, 9, 10, 10, 11, 11, 11, 12, 12, 13, 13,13, 14, 14, 15, 15, 15, 16, 16, 17, 17, 17, 18, 18,19, 19, 19, 20, 20, 21, 21, 21, 22, 22, 23, 23, 24,24, 24, 25, 25, 26, 26, 26, 27, 27, 28, 28, 28, 29,29, 30, 30, 31, 31, 31, 32, 32, 33, 33, 34, 34, 35,35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41,41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47,48, 49, 49, 50, 50, 51, 51, 52, 53, 53, 54, 55, 55,56, 56, 57, 58, 59, 59, 60, 61, 61, 62, 63, 64, 64,65, 66, 67, 68, 69, 69, 70, 71, 72, 73, 74, 75, 76,77, 78, 79, 81, 82, 83, 84, 86, 87, 88, 90, 91, 93,94, 96, 98, 100, 102, 104, 106, 108, 111, 113, 116, 119, 122,125, 129, 133, 138, 143, 148, 155, 162
End Table
'*******************************************************************
' Name: LCD Termometer 10K Thermistor PROGRAM
' Date: 2019 03 16
' Version: 1.0.0
' Programmer: Donald Great Cow Basic
'********************************************************************
' Device: Pic16f887
' Development bread board
' Description:Basic file to setup 10K Thermistor
' The LCD is a 4 - bit bus to a Topway 2 X 16
' Pin arrangement:
' RS on PORTE.0 - LCD pin 4
' Enable on PORTE.1 - LCD pin 6
' Data PORTC.0 to 3 - LCD pins 11 to 14
' 10K Thermistoe on AN0 with a 10K divider
' Beta factor 3380 used to develop the table
' Thermistor resistance at measured temperaure R = R0 * ( ( adcMax / adcVal ) - 1 )
' Temperature calculared from =1/298,15+1/3380*LN((ADCResolution/ADCInput)-1)
' First 46 digits in table ommited hence ReadAD(AN0)-46
'******************************************************************
'Boot message
Print "10K Thermistor:"
Locate 1, 2
Print "Thermometer"
Wait 500 ms
'Main loop
Do Forever
'Take a measurement and store in the Reading variable
Analog = ReadAD(AN0)-46
ReadTable ADCtoTemp, Analog, Temp
CLS
Print "Analog: "
Print Analog
Locate 1, 0
Print "Temp: "
Print Temp
'Delay to avoid flickering of screen (LCD is hard to read if changed often)
Wait 100 ms
Loop