// rev 23-09-2023 void Equalisation_3_DS18B20(void) { CPrint(" Demande AUTO_etalonnage des 3 sondes DS18B20\r\n"); CPrint(" elles doivent etre reliees mecaniquement ensembles (meme temperature ambiante)\r\n"); sprintf(CRam1," Attente relache SW6 ..puis appui sur SW6 \r\n"); Print (CRam1); LCD_Cmd(LCD_CLEAR);__delay_ms(100); LCD_Write_CText_At(1,1,"Relacher SW6 "); while(BP_Egalisation==1); // attente relache SW6 //gabarit 12345678901234567890 LCD_Cmd(LCD_CLEAR); __delay_ms(100); LCD_Write_CText_At(1,1,"Demande EGALISATION "); LCD_Write_CText_At(2,1,"Les sondes doivent "); LCD_Write_CText_At(3,1,"etre liees ensemble "); LCD_Write_CText_At(4,1,"Valider par SW6>2sec"); // Attente validation par SW6 appyué > sec // les 2 leds clignotes en alternance LED_vert=1; LED_rouge=0; while (BP_Egalisation==1) { __asm("btg LATA,6"); // LED_verte __asm("btg LATA,4"); // LED_rouge __delay_ms(20); } i=0; while (BP_Egalisation==0) // duree BP appuye { __delay_ms(100); i++; __asm("btg LATA,6"); // LED_verte __asm("btg LATA,4"); // LED_rouge if (i>20) break; } if (i<20) { Erase_Line(1); Erase_Line(2); // 12345678901234567890 LCD_Write_CText_At(3,1,"Delay SW6 trop court"); LCD_Write_CText_At(4,1,"Demande abortee !.. "); __delay_xSec(4); Demande_Equalisation=0; __asm("reset"); } LCD_Write_CText_At(4,1,"Demande Acceptee .."); __delay_xSec(3); // Affiche_3_mesures_DS18B20_sur_LCD;(0); // 12345678901234567890 CPrint("Mesures brutes \r\n"); LCD_Cmd(LCD_CLEAR); F1= getTemperature1(); // 12345678901234567890 sprintf(txt," T1.INTER.= %5.3f%cC",F1,176); Print(txt);CRLF1(); *(txt+17)=7; // degre C LCD_Write_Text_At(2,1,txt); F2= getTemperature2(); sprintf(txt," T2.EXTER.= %5.3f%cC",F2,176); Print(txt);CRLF1(); *(txt+17)=7; // degre C LCD_Write_Text_At(3,1,txt); F3= getTemperature3(); sprintf(txt," T3.EAU .= %5.3f%cC",F3,176); Print(txt);CRLF1(); *(txt+17)=7; // degre C LCD_Write_Text_At(4,1,txt); __delay_xSec(2); F0=(F1+F2+F3)/3.0; // 12345678901234567890 sprintf(txt," MOYENNE .= %5.3f%cC",F0,176); Print(txt);CRLF1(); *(txt+17)=7; // degre C LCD_Write_Text_At(1,1,txt); __delay_xSec(3); CPrint("Calcul des corrections :\r\n"); Txcor[0]=F0-F1; Txcor[1]=F0-F2; Txcor[2]=F0-F3; CPrint(" Mesures issues de l' Egalisation :\r\n"); // resultats sur LCD LCD_Cmd(LCD_CLEAR);__delay_ms(100); // Erase_Line(1); LCD_Write_CText_At(1,1," Results Egalisation"); Erase_Line(2); //gabarit 12345678901234567890 sprintf(CRam1,"T1 %3.2f%c corr=%2.2f%c",F1,7,Txcor[0],7); LCD_Write_Text_At(2,1,CRam1); // Erase_Line(3); sprintf(CRam1,"T2 %3.2f%c corr=%2.2f%c",F2,7,Txcor[1],7); LCD_Write_Text_At(3,1,CRam1); // Erase_Line(4); sprintf(CRam1,"T3 %3.2f%c corr=%2.2f%c",F3,7,Txcor[2],7); LCD_Write_Text_At(4,1,CRam1); sprintf(txt," T1.INTER = %5.3f%c C T1cor=%2.3f",F1,176,Txcor[0]); Print(txt);CRLF1(); sprintf(txt," T2.EXT = %5.3f%c C T2cor=%2.3f",F2,176,Txcor[1]); Print(txt);CRLF1(); sprintf(txt," T3.EAU = %5.3f%c C T3cor=%2.3f",F3,176,Txcor[2]); Print(txt);CRLF1(); __delay_xSec(4); LCD_Cmd(LCD_CLEAR); __delay_ms(100); // 123456787901234567890 LCD_Write_CText_At(1,1," Appuyer sur SW6 "); LCD_Write_CText_At(2,1," pendant > 2 Sec "); LCD_Write_CText_At(3,1," pour valider "); CPrint(" Appuyer sur SW6 pendant >2sec pour valider\r\n"); i=0; // les 2 leds clignotes en alternance LED_vert=1; LED_rouge=0; while (BP_Egalisation==1) { __asm("btg LATA,6"); // LED_verte __asm("btg LATA,4"); // LED_rouge __delay_ms(20); } i=0; while (BP_Egalisation==0) // duree BP appuye { __delay_ms(100); i++; __asm("btg LATA,6"); // LED_verte __asm("btg LATA,4"); // LED_rouge if (i>20) break; } if ( (BP_Egalisation==0) && (i>19) ) // appui>=2sec { LED_vert=1; LED_rouge=0; CPrint(" Sauvegardes corrections en Eeprom en 0x0050, 0x0054, 0x0058\r\n"); // Sauve_Float_To_Eeprom(Org_Txcor,Txcor[0]); // Sauve_Float_To_Eeprom(Org_Txcor+4,Txcor[1]); // Sauve_Float_To_Eeprom(Org_Txcor+8,Txcor[2]); Sauve_Corrections_Temper(); CPrint(" Fin Auto etalonnage 3 sondes DS18B20\r\n"); LCD_Cmd(LCD_CLEAR); LCD_Write_CText_At(1,1," FIN...OK.......... "); // 12345678901234567890 LCD_Write_CText_At(2,1,"Sauve corrections "); LCD_Write_CText_At(3,1,"dans Eeprom PIC "); __delay_xSec(3); } CPrint(" Rechargement corrections capteurs DS18B20 depuis Eeprom\r\n"); Restitue__Corrections_Temper(); // Txcor[0]= Read_Float_from_Eeprom(Org_Txcor); sprintf(CRam1," Temp 1 corrigee= %5.3f \r\n",F1+Txcor[0] ); Print(CRam1); // Txcor[1]= Read_Float_from_Eeprom(Org_Txcor+4); sprintf(CRam1," Temp 2 corrigee= %5.3f \r\n",F2+Txcor[1] ); Print(CRam1); // Txcor[2]= Read_Float_from_Eeprom(Org_Txcor+8); sprintf(CRam1," Temp 3 corrigee= %5.3f \r\n",F3+Txcor[2] ); Print(CRam1); __delay_xSec(3); CRLF1(); CPrint ("\r\n Attente remise en place des 3 capteurs,et RESET pour sortir \r\n"); LED_vert=0; LCD_Cmd(LCD_CLEAR); LCD_Write_CText_At(1,1,"EGALISATION terminee"); LCD_Write_CText_At(2,1,"Remettre en place "); LCD_Write_CText_At(3,1,"Les 3 sondes DS18B20"); LCD_Write_CText_At(4,1,"puis BP RESET ... "); // attente Reset while(1) // boucle infinie ! { __asm("btg LATA,4"); // LED_rouge __delay_ms(100); } } */