
Originally Posted by
Charlie
You did not post enough code that we can answer your question. Post all of your code.
Code:
define osc 4
adcon1.7=1
ANSEL = 0001 'Disable Inputs Tranne AN0
ADCON1 = 001110
OSCCON = 100000 'Internal RC set to 4MHZ
TRISA = 000001 ' impostazioni INP/OUT
TRISB = 000000 ' delle porte
'----------------------------------------------------
DEFINE LCD_DREG PORTB 'Porta B DATA OUT
DEFINE LCD_DBIT 4 '0 --> Bit 0-3 : 4 --> Bit 4-7
DEFINE LCD_RSREG PORTB 'LCD register select port - Porta B --> RS
DEFINE LCD_RSBIT 2 'LCD register select bit - Pin RS B2
DEFINE LCD_EREG PORTB 'LCD enable port - Porta B --> EN
DEFINE LCD_EBIT 3 'LCD enable bit - Pin EN B3DEFINE LCD_BITS 4 'LCD bus size 4 or 8
DEFINE LCD_LINES 2 'Number lines on LCD DEFINE LCD_COMMANDUS 2000 'Command delay time in us
DEFINE LCD_DATAUS 50 'Data delay time in us
Rele VAR PORTA.6 ' Pin 15
'--------------------------------------------------------------
'---------Define ADCin Parameters
DEFINE ADC_BITS 10 'set number of bits in result
DEFINE ADC_CLOCK 3 'set clock source (3=rc)
DEFINE ADC_SAMPLEUS 50 'Set sampling time in uS
' RAM Assignments and Variables
'===========================================================================
temp var word
temperature var word
samples var word
sample VAR BYTE
quanta con 1250
Tmax VAR byte
Tmin VAR byte
'===========================================================================
Tmin=16
Tmax=30
START:
Lcdout $FE, 1
low rele
main:
sample = 1
samples= 0
FOR sample = 1 TO 20 'Take 20 samples
ADCIN 0, temp 'Read AN0 into temp variable
samples = samples + temp
PAUSE 50 ' Wait 1/4 seconds per reading
NEXT sample
temp = samples/20 'Average over 20 samples (Every 5 seconds)
temperature= temp */ quanta
if temp > 675 then high rele 'Instead 675 write the correct RAW number for 30degC
if temp < 675 then low rele 'Instead 675 write the correct RAW number for 30degC
LCDOUT $FE, 2 ' ritorna al primo carattere
lcdout $FE, 2, "Temp ",dec2 (temperature/10),".", dec1 (temperature/10),"C"
'lcdout $FE, $C0, "Tmin ",#Tmin, " Tmax ",#Tmax FOR NORMAL OPERATION UNCOMMENT LINE
lcdout $FE, $C0, "RAW:",dec temp 'this show the ADC value FOR NORMAL OPERATION COMMENT OR DELETE THIS LINE
'lcdout $FE, $C0, "RAW:",dec temperature
'When the display show 30,0 degC look at the RAW number on LCD and rewrite it in lines: if temp > 675 then high rele
'and if temp < 675 then low rele .
goto main
Bookmarks