On your last program, you still have in the room temperature a 3 digit value, say 250 and compare it with the Tmax that is 30.
If temperature is 250 and TMax is 30 what is the result? Portb.6 always set as you requested.
Try this and see if relay makes 2 clicks at the start of the program and then rest of the program works as expected.
If it does not click, then your port has a problem. Search other things...
IoannisCode:'**************************************************************** '* Name : 16F88_LM235.BAS * '* Author : * '* Notice : Copyright (c) 2020 * '* : All Rights Reserved * '* Date : 04/04/2020 * '* Version : 1.0 * '* '**************************************************************** 'PIC 16F88 ' Hardware Assignments ' -------------------- ' LCD circuitery '01 - Vss (GND) '02 - Vdd (+5V) '08 RS - PORTB.2 '09 E - PORTB.3 '10 DB4 - PORTB.4 '11 DB5 - PORTB.5 '12 DB6 - PORTB.6 '13 DB7 - PORTB.7 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 B3 DEFINE 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 ' EEPROM Locations Codice ASCII es. a=97 b=98 c=99 ... '=========================================================================== DATA @0,16 ' 16 Tenp min. DATA @1,30 ' 30 Temp Max. '=========================================================================== '=========================================================================== '***** SETTAGGIO PORTE ' VAR PORTA.0 'LM235M Pin 17 IncButton VAR PORTA.1 'SW Pin 18 DecButton VAR PORTA.2 'SW Pin 1 SetButton VAR PORTA.3 'SW Pin 2 ' VAR PORTA.4 ' Pin 3 ' VAR PORTA.5 ' Pin 4 Rele VAR PORTA.6 ' Pin 15 ' VAR PORTA.7 ' Pin 16 '----------------------------------------------- ' Var PORTB.0 ' Pin 6 ' var PORTB.1 ' Pin 7 l_rs var PORTB.2 'LCD sig. RS Pin 8 l_en Var PORTB.3 'LCD sig. E Pin 9 l_d4 var PORTB.4 'LCD 4 Pin 10 l_d5 var PORTB.5 'LCD 5 Pin 11 l_d6 var PORTB.6 'LCD 6 Pin 12 l_d7 var PORTB.7 'LCD 7 Pin 13 '-------------------------------------------------------------- '---------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 '=========================================================================== CounterA var byte ' General purpose Variable CounterB var byte ' General purpose Variable CounterC var byte ' General purpose Variable temp var word temperature var word samples var word Dummy var word sample VAR BYTE quanta con 1250 DatoEE var byte Tmax VAR Byte Tmin VAR Byte Tcomp VAR word Grade var Byte TimeOut var word ' Variable for SetUp Menu Time-Out '=========================================================================== START: '*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~ '*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~ for sample =0 to 3 toggle portb.6 pause 250 next sample ' -------- bit a bit controllo 0=output 1=input INTCON = 0 ' NO INTERRUPT ADCON1 = 001110 ' ADCON0= 000101 'Disable Converter Module while !adcon0.0:wend ' Attende che il convertitore sia spento prima di fare il resto ANSEL = 000001 'Disable Inputs Tranne AN0 OSCCON = 100000 'Internal RC set to 4MHZ CMCON = 7 ' '76543210 TRISA = 111111 ' impostazioni INP/OUT TRISB = 000000 ' delle porte '---------------------------------------------------- ' Per utilizare i pin RA6 ed RA7 come I/O bisogna impostare lo switch in fase ' di programmazione Oscillotar come "INTRC_IO" PORTA.6=0 ' Leggi Dati dalla EEPROM '=========================================================================== Read 0,DatoEE Tmin=DatoEE Read 1,DatoEE Tmax=DatoEE '=========================================================================== Lcdout $FE, 1 'Clear screen MAIN: 'Subroutine to measure temp '---------------------------------------------------- TEMP_READ: temp = 0 'Clear temp register temperature = 0 'Clear temperature register sample = 0 'Clear sample register samples = 0 'Clear samples register do sample = 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*10) */ quanta Pause 200 ' Timeout for LCD to settle LCDOUT $FE, 1 ' cancella LCD LCDOUT $FE, 2 ' ritorna al primo carattere lcdout $FE, 2, "Temp. ",dec2 (temperature/100),".", dec1 (temperature//100),$DF,"C " lcdout $FE, $C0, "Tmin ",#Tmin DIG 1,#Tmin Dig 0," Tmax ",#Tmax DIG 1,#Tmax Dig 0 temperature=temperature/10 If temperature> TMax then PORTA.6=1 else PORTA.6=0 Endif 'lcdout $FE, $C0, "Tmax ",#Tmax DIG 1,#Tmax Dig 0," Tco ",dec2 (Tcomp/100),".", dec1 (Tcomp//100) loop goto MAIN '*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~ '*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~


 
			 
			 
			 
					
					

 Re: Compare value ...
 Re: Compare value ...
		 
				
				
				
				
			

Bookmarks