; Aquamate, gestion d'un aquarium marin ; Copyright (C) Julien Schmitt ; julien@jls-info.com ; This program is free software; you can redistribute it and/or ; modify it under the terms of the GNU General Public License ; as published by the Free Software Foundation; either version 2 ; of the License, or (at your option) any later version. ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; You should have received a copy of the GNU General Public License ; along with this program; if not, write to the Free Software ; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. LIST p=16F877 ERRORLEVEL -305, -306, -302 #include "P16F877.INC" #define E PORTB,0 #define RW PORTB,1 #define RS PORTB,2 #define CLK PORTE,0 #define IO PORTE,1 #define RST PORTE,2 ;Sorties I2C : ;composant 0 : BLANCHE,BLEUE,1,2,3,4,TERMO,LIBRE ;composant 1 : REAC,NIV,OSMO ;Entrees I2C BAC_BAS equ 03h BAC_HAUT equ 04h RES_BAS equ 05h RES_HAUT equ 06h ;RAM CBLOCK 20h TEMP1 TEMP2 TEMP3 TEMP4 TEMP5 DONNEE MENUPOS PB ADRESSE MAX FLAGS EXDONNEE HEURES MINUTES SECONDES SORTIES SORTIES1 FINRETRO REMPREAC M_REAC H_REAC M_REMP EXSECONDES CMDMANU CPT CPT2 CPT_MIN CMDMANU1 EXDONNEE2 CPT_TIMER TEMPERATURE_ENTIER TEMPERATURE_DECIMALE FIN_X ENDC CBLOCK 70H ; 70H - 7FH : accessible depuis toutes les banks W_TEMP STATUS_TEMP ENDC ;EEPROM L_BLANCHE equ 00h ;heures debut - minutes debut - L_BLEUE equ 04h ;heures fin - minutes fin REACTEUR equ 08h ;toutes les X heures - pendant X min REMPLISSAGE equ 0Ah ;toutes les X minutes - pendant X sec POMPE1 equ 0Ch ; POMPE2 equ 0Fh ;24 bits par pompe pour avoir les POMPE3 equ 12h ;24 heures POMPE4 equ 15h ; REACTEUR2 equ 18h ;toutes les X minutes - pendant X min H_REMPLISS equ 20h ;comme L_BLANCHE TEMP_VISEE equ 24h ;seuil bas - seuil haut (4 octets) TEMPS_REBOND equ 18h ;X fois 6 ms HYSTERESIS equ d'1' ORG 0003h goto MAIN ;**************************************************************************** ; interruption ;**************************************************************************** ORG 0004h goto INT ;**************************************************************************** ; TEMPO == attente : 1 dans W = 0,25 ms ;**************************************************************************** TEMPO movwf TEMP1 tempo2 movlw 0ACh movwf TEMP2 tempo1 clrwdt decfsz TEMP2 goto tempo1 decfsz TEMP1 goto tempo2 retlw 0 ;**************************************************************************** ; Pilotage LCD ; LCDCMD envoie la commande W au LCD ; LCDCHAR envoie le caractere W au LCD ;**************************************************************************** LCDCMD bcf INTCON,GIE movwf TEMP1 call LCDBUSY bcf RS goto lcdwr LCDCHAR bcf INTCON,GIE movwf TEMP1 call LCDBUSY bsf RS lcdwr clrwdt bcf RW bsf E movf TEMP1,W movwf PORTD bcf E bsf INTCON,GIE retlw 0 ;**************************************************************************** ; LCDSTR == envoie la chaine W au LCD ;**************************************************************************** LCDSTR movwf TEMP3 movlw HIGH(MSG) movwf PCLATH movf TEMP3,W call MSG clrf PCLATH andlw 0FFH btfsc STATUS,Z retlw 0 call LCDCHAR incf TEMP3,W goto LCDSTR ;**************************************************************************** ; LCDSTR2 == envoie la chaine W au LCD ;**************************************************************************** LCDSTR2 movwf TEMP3 movlw HIGH(MSG2) movwf PCLATH movf TEMP3,W call MSG2 clrf PCLATH andlw 0FFH btfsc STATUS,Z retlw 0 call LCDCHAR incf TEMP3,W goto LCDSTR2 ;**************************************************************************** ; LCDBUSY == attend que le LCD soit libre ;**************************************************************************** LCDBUSY bcf INTCON,GIE bsf STATUS,RP0 movlw 0xFF movwf TRISD bcf STATUS,RP0 bcf RS bsf RW bsf E movf PORTD,W bcf E andlw 0x80 btfss STATUS,Z goto LCDBUSY bcf RW bsf STATUS,RP0 clrf TRISD bcf STATUS,RP0 bsf INTCON,GIE return ;**************************************************************************** ; LCDDEC == ecrit W en decimal ;**************************************************************************** LCDDEC clrf TEMP2 movwf TEMP3 lcddec10 movlw 0Ah subwf TEMP3,W btfss STATUS,C goto decend movwf TEMP3 incf TEMP2 goto lcddec10 decend movf TEMP2,W addlw 30h call LCDCHAR movf TEMP3,W addlw 30h goto LCDCHAR ;**************************************************************************** ; LCDHEX == ecrit W en Hexadecimal ;**************************************************************************** LCDHEX movwf TEMP3 swapf TEMP3,W call WRITEDIG movf TEMP3,W WRITEDIG andlw 0Fh addlw 0F6h btfsc STATUS,C addlw 07h addlw 3Ah goto LCDCHAR ;**************************************************************************** ; LCDSETADR == chargement de l'adresse ;**************************************************************************** LCDSETADR iorlw 80h call LCDCMD retlw 0 ;**************************************************************************** ; LCDINIT ;**************************************************************************** LCDINIT bcf RW bcf E bcf RS movlw 80h call TEMPO movlw 38h ;interface 8 bits, 2 lignes call LCDCMD movlw 08h ;disp.off, curs.off, no-blink call LCDCMD movlw 01h ;clear display call LCDCMD movlw 0Ch ;disp.on, curs.off call LCDCMD movlw 06h ;auto-inc (shift-cursor) call LCDCMD return ;**************************************************************************** ; DS1302 == lecture/ecriture … l'adresse W du DS1302 ; donnee dans DONNEE ;**************************************************************************** DS1302 bsf RST movwf TEMP1 movwf TEMP2 movlw 08h movwf TEMP4 movf TEMP1,W bcf STATUS,C adresse bcf IO btfsc TEMP1,0 bsf IO bsf CLK clrwdt clrwdt bcf CLK rrf TEMP1 decfsz TEMP4 goto adresse btfss TEMP2,0 ;test du bit R/W goto ecriture bsf STATUS,RP0 movlw 02h ;IO = entree movwf TRISE bcf STATUS,RP0 movlw 08h movwf TEMP4 bcf STATUS,C clrf DONNEE lecture rrf DONNEE bsf CLK clrwdt btfsc IO bsf DONNEE,7 bcf CLK decfsz TEMP4 goto lecture bsf STATUS,RP0 clrf TRISE bcf STATUS,RP0 bcf RST return ecriture movlw 08h movwf TEMP4 ecrit bcf IO btfsc DONNEE,0 bsf IO bsf CLK clrwdt clrwdt bcf CLK rrf DONNEE decfsz TEMP4 goto ecrit bcf RST return ;**************************************************************************** ; LISEEPROM == adresse W, donnee dans DONNEE ;**************************************************************************** LISEEPROM bsf STATUS,RP1 bcf STATUS,RP0 movwf EEADR bsf STATUS,RP0 bcf EECON1,EEPGD bsf EECON1,RD bcf STATUS,RP0 movf EEDATA,W bcf STATUS,RP1 movwf DONNEE return ;**************************************************************************** ; ECRISEEPROM == adresse W, donnee dans DONNEE ;**************************************************************************** ECRISEEPROM bcf INTCON,GIE bcf PIR2,EEIF bsf STATUS,RP1 movwf EEADR bcf STATUS,RP1 movf DONNEE,W bsf STATUS,RP1 movwf EEDATA bsf STATUS,RP0 bcf EECON1,EEPGD bsf EECON1,WREN movlw 55h movwf EECON2 movlw 0AAh movwf EECON2 bsf EECON1,WR bcf STATUS,RP0 bcf STATUS,RP1 boucle_eeprom clrwdt btfss PIR2,EEIF goto boucle_eeprom bsf STATUS,RP1 bsf STATUS,RP0 bcf EECON1,WREN bcf STATUS,RP0 bcf STATUS,RP1 bsf INTCON,GIE return ;**************************************************************************** ; PCF8574 == adresse W, donnee dans DONNEE ;**************************************************************************** PCF8574 movwf TEMP1 bsf STATUS,RP0 ;bank 1 bsf SSPCON2,SEN ;start bcf STATUS,RP0 ;bank 0 start btfss PIR1,SSPIF goto start movwf SSPBUF bcf PIR1,SSPIF adr btfss PIR1,SSPIF goto adr btfsc TEMP1,0 goto lect_I2C movf DONNEE,W movwf SSPBUF ;ecriture I2C bcf PIR1,SSPIF goto stop lect_I2C bsf STATUS,RP0 bsf SSPCON2,RCEN ;reception bcf STATUS,RP0 bcf PIR1,SSPIF ack btfss PIR1,SSPIF goto ack movf SSPBUF,W ;lecture movwf DONNEE bsf STATUS,RP0 bsf SSPCON2,ACKDT bsf SSPCON2,ACKEN ;ack bcf STATUS,RP0 bcf PIR1,SSPIF stop btfss PIR1,SSPIF goto stop bsf STATUS,RP0 ;bank 1 bsf SSPCON2,PEN ;stop bcf STATUS,RP0 ;bank 0 bcf PIR1,SSPIF fin_I2C btfss PIR1,SSPIF goto fin_I2C bcf PIR1,SSPIF return ;**************************************************************************** ; RELACHE == attend que la touche pressee soit relachee ;**************************************************************************** RELACHE clrwdt movlw 0FFh andwf PB,W btfss STATUS,Z goto RELACHE return ;**************************************************************************** ; MENU == premiere position dans W, retour dans DONNEE ;**************************************************************************** MENU movwf MENUPOS movwf TEMP2 ecrit_menu call RELACHE movlw 01h ;clear display call LCDCMD ; movlw 7Eh call LCDCHAR movlw HIGH(MENUTABLE) movwf PCLATH movf MENUPOS,W movwf DONNEE call MENUTABLE clrf PCLATH call LCDSTR movlw 41h call LCDSETADR incf MENUPOS movlw HIGH(MENUTABLE) movwf PCLATH movf MENUPOS,W call MENUTABLE clrf PCLATH andlw 0FFh btfss STATUS,Z ;test si fin de menu goto fin_menu movf TEMP2,W movwf MENUPOS movlw HIGH(MENUTABLE) movwf PCLATH movf MENUPOS,W call MENUTABLE clrf PCLATH fin_menu call LCDSTR attente_menu clrwdt btfsc PB,1 ;suivant goto ecrit_menu btfss PB,2 ;enter goto attente_menu call RELACHE return ;**************************************************************************** ; REGLHEURE == reglage de l'heure ;**************************************************************************** REGLHEURE clrw ;WP movwf DONNEE movlw b'10001110' call DS1302 ;************** jour ****************** movlw 32h movwf MAX movlw b'10000110' movwf ADRESSE movlw 42h call BOUCLEREGL ;************** mois ****************** movlw 13h movwf MAX movlw b'10001000' movwf ADRESSE movlw 47h call BOUCLEREGL ;************** annee ***************** movlw 99h movwf MAX movlw b'10001100' movwf ADRESSE movlw 4Ch call BOUCLEREGL ;************** heures **************** movlw 24h movwf MAX movlw b'10000100' movwf ADRESSE movlw 52h call BOUCLEREGL ;************** minutes *************** movlw 60h movwf MAX movlw b'10000010' movwf ADRESSE movlw 58h call BOUCLEREGL clrf DONNEE movlw b'10000000' ;secondes … 0 + clock enable call DS1302 return ;**************************************************************************** ; BOUCLEREGL == boucle de reglage de l'heure ; adresse DS1302 dans ADRESSE, valeur max dans MAX ; texte dans W (table MSG2) ;**************************************************************************** BOUCLEREGL movwf TEMP3 movlw 40h call LCDSETADR movf TEMP3,W call LCDSTR2 movf ADRESSE,W iorlw 01h call DS1302 movlw 48h call LCDSETADR movlw ":" call LCDCHAR movlw " " call LCDCHAR movf DONNEE,W call LCDHEX boucle_regl clrwdt btfsc PB,2 goto fin_regl btfss PB,1 goto boucle_regl movlw 4Ah call LCDSETADR movf MAX,W call INCREMENTE movf DONNEE,W call LCDHEX call RELACHE goto boucle_regl fin_regl call RELACHE movf ADRESSE,W ;ecriture call DS1302 return ;**************************************************************************** ; INCREMENTE == incremente DONNEE (en BCD), valeur max + 1 dans W ;**************************************************************************** INCREMENTE movwf TEMP2 movf DONNEE,W movwf TEMP1 incf TEMP1 movlw 0Fh andwf TEMP1,W sublw 0Ah btfss STATUS,Z goto fin_inc movlw 0Ah subwf TEMP1 movlw 10h addwf TEMP1 fin_inc movf TEMP1,W movwf DONNEE movf TEMP2,W subwf DONNEE,W btfsc STATUS,Z clrf DONNEE return ;**************************************************************************** ; OUINON == menu OUI / NON, emplacement dans W, resultat dans DONNEE ; FF : OUI, 00 : NON ;**************************************************************************** OUINON movwf TEMP2 non movf TEMP2,W call LCDSETADR movlw 7Dh call LCDSTR2 clrf DONNEE non_att clrwdt btfsc PB,2 goto fin_ouinon btfss PB,1 goto non_att call RELACHE oui movf TEMP2,W call LCDSETADR movlw 79h call LCDSTR2 movlw 0FFh movwf DONNEE oui_att clrwdt btfsc PB,2 goto fin_ouinon btfss PB,1 goto oui_att call RELACHE goto non fin_ouinon call RELACHE return ;**************************************************************************** ; MENU_UTIL == menu utilisateur ;**************************************************************************** MENU_UTIL movlw 01h ;clear display call LCDCMD ; movlw 20h call LCDSTR2 movlw 40h call LCDSETADR movlw 31h call LCDSTR2 menu_suite clrwdt btfss PB,2 goto menu_suite clrw call MENU movf DONNEE,W andlw 0FFh ;Commandes Manu ? btfsc STATUS,Z goto manu movlw 01h ;reglages ? subwf DONNEE,W btfsc STATUS,Z goto reglages movlw 03h ;… propos ? subwf DONNEE,W btfsc STATUS,Z goto apropos return manu call MENU_MANU return reglages movlw 06h call MENU call RELACHE movlw 06h ;date / heure ? subwf DONNEE,W btfsc STATUS,Z goto dateheure movlw 07h ;eclairage blanc ? subwf DONNEE,W btfsc STATUS,Z goto eclairage_blanc movlw 08h ;eclairage bleu ? subwf DONNEE,W btfsc STATUS,Z goto eclairage_bleu movlw 09h ;reacteur ? subwf DONNEE,W btfsc STATUS,Z goto reacteur movlw 0Ah ;reacteur 2 ? subwf DONNEE,W btfsc STATUS,Z goto reacteur2 movlw 0Bh ;remplissage ? subwf DONNEE,W btfsc STATUS,Z goto remplissage movlw 0Ch ;brassage ? subwf DONNEE,W btfsc STATUS,Z goto brassage movlw 0Dh ;heure remplissage subwf DONNEE,W btfsc STATUS,Z goto heure_rempliss movlw 0Eh ;temperature subwf DONNEE,W btfsc STATUS,Z goto regle_temperature movlw 0Fh ;reset ? subwf DONNEE,W btfsc STATUS,Z goto reset return apropos movlw 01h ;clear display call LCDCMD ; clrw call LCDSTR2 movlw 40h call LCDSETADR movlw 0Fh call LCDSTR2 apropos_att clrwdt btfss PB,2 goto apropos_att call RELACHE return dateheure movlw 01h ;clear display call LCDCMD ; movlw 02h call LCDSETADR movlw 58h call LCDSTR call REGLHEURE return eclairage_blanc movlw 01h ;clear display call LCDCMD ; movlw 48h call LCDSTR movlw 40h call LCDSETADR movlw 81h ;debut call LCDSTR2 movlw L_BLANCHE call REGLE movlw 01h ;clear display call LCDCMD ; movlw 48h call LCDSTR movlw 40h call LCDSETADR movlw 87h ;fin call LCDSTR2 movlw L_BLANCHE + 2 call REGLE return eclairage_bleu movlw 01h ;clear display call LCDCMD ; movlw 58h call LCDSTR movlw 40h call LCDSETADR movlw 81h ;debut call LCDSTR2 movlw L_BLEUE call REGLE movlw 01h ;clear display call LCDCMD ; movlw 58h call LCDSTR movlw 40h call LCDSETADR movlw 87h ;fin call LCDSTR2 movlw L_BLEUE + 2 call REGLE return reacteur movlw REACTEUR call REGLE2 return reacteur2 movlw REACTEUR2 call REGLE2 return remplissage movlw REMPLISSAGE call REGLE2 return brassage movlw 12h call MENU movlw 12h ;Pompe1 subwf DONNEE,W btfss STATUS,Z goto t_pompe2 movlw POMPE1 goto reglage_pompe t_pompe2 movlw 13h ;Pompe2 subwf DONNEE,W btfss STATUS,Z goto t_pompe3 movlw POMPE2 goto reglage_pompe t_pompe3 movlw 14h ;Pompe3 subwf DONNEE,W btfss STATUS,Z goto t_pompe4 movlw POMPE3 goto reglage_pompe t_pompe4 movlw 15h ;Pompe4 subwf DONNEE,W btfss STATUS,Z return movlw POMPE4 reglage_pompe call REGLE_POMPE goto brassage heure_rempliss movlw 01h ;clear display call LCDCMD ; movlw 0E6h call LCDSTR movlw 40h call LCDSETADR movlw 81h ;debut call LCDSTR2 movlw H_REMPLISS call REGLE movlw 01h ;clear display call LCDCMD ; movlw 48h call LCDSTR movlw 40h call LCDSETADR movlw 87h ;fin call LCDSTR2 movlw H_REMPLISS + 2 call REGLE return regle_temperature movlw 01h ;clear display call LCDCMD ; movlw 0B1h call LCDSTR movlw " " call LCDCHAR movlw ":" call LCDCHAR movlw TEMP_VISEE + 2 call LIS_EEPROM2 movlw 4Ch call LCDSETADR movlw 0DFh ;"ø" call LCDCHAR movlw "C" call LCDCHAR att_regle_temp clrwdt movlw 4Ah call LCDSETADR movf DONNEE,W call LCDDEC btfsc PB,2 goto fin_regle_temp btfss PB,1 goto att_regle_temp call RELACHE incf DONNEE movlw d'30' subwf DONNEE,W btfss STATUS,Z goto att_regle_temp movlw d'15' movwf DONNEE goto att_regle_temp fin_regle_temp movlw TEMP_VISEE + 2 call ECRISEEPROM decf DONNEE movlw TEMP_VISEE call ECRISEEPROM movlw HYSTERESIS movwf DONNEE movlw TEMP_VISEE + 3 call ECRISEEPROM movlw HYSTERESIS sublw d'10' movwf DONNEE movlw TEMP_VISEE + 1 call ECRISEEPROM return reset movlw 01h ;clear display call LCDCMD ; movlw 69h call LCDSTR2 movlw 4Dh call OUINON btfss DONNEE,0 return movlw 01h ;clear display call LCDCMD ; reset_fin goto reset_fin ;**************************************************************************** ; REGLE == reglage adresse EEPROM dans W ;**************************************************************************** REGLE movwf TEMP4 movlw 4Bh call LCDSETADR movf TEMP4,W call LISEEPROM movf DONNEE,W call LCDHEX movlw ":" call LCDCHAR incf TEMP4,W call LISEEPROM movf DONNEE,W call LCDHEX movf TEMP4,W call LISEEPROM attente_regle clrwdt btfsc PB,1 goto incremente_heure btfsc PB,2 goto fin_heure goto attente_regle incremente_heure call RELACHE movlw 24h call INCREMENTE movlw 4Bh call LCDSETADR movf DONNEE,W call LCDHEX goto attente_regle fin_heure call RELACHE movf TEMP4,W call ECRISEEPROM incf TEMP4,W call LISEEPROM attente_regle2 clrwdt btfsc PB,1 goto incremente_min btfsc PB,2 goto fin_regle goto attente_regle2 incremente_min call RELACHE movlw 60h call INCREMENTE movlw 4Eh call LCDSETADR movf DONNEE,W call LCDHEX goto attente_regle2 fin_regle call RELACHE incf TEMP4,W call ECRISEEPROM return ;**************************************************************************** ; interruption ;**************************************************************************** INT ;****************** sauvegarde de W, STATUS ********************************** movwf W_TEMP swapf STATUS,W clrf STATUS movwf STATUS_TEMP ;****************** sauvegarde de W, STATUS ********************************** btfsc INTCON,T0IF goto Timer0 goto fin_int Timer0 bcf STATUS,RP0 bcf STATUS,RP1 movf PB,F btfsc STATUS,Z ;Aucun bouton appuy‚ goto test_boutons decfsz CPT_TIMER goto fin_timer0 test_boutons ;non : on teste swapf PORTB,W andlw 07h xorlw 07h movwf PB btfsc STATUS,Z ;un changement ? goto fin_timer0 movlw TEMPS_REBOND movwf CPT_TIMER fin_timer0 bcf INTCON,T0IF fin_int ;****************** restauration de W, STATUS ******************************* swapf STATUS_TEMP,W movwf STATUS swapf W_TEMP swapf W_TEMP,W ;****************** restauration de W, STATUS ******************************* bsf INTCON,GIE retfie ;**************************************************************************** ; LIS_I2C == lecture des entrees sur le bus I2C et mise en marche des ; appareils en fonction ;**************************************************************************** LIS_I2C movlw H_REMPLISS call TEST_HEURE movwf TEMP4 movlw b'01000011' call PCF8574 movf TEMP4,F btfsc STATUS,Z goto pas_remplissage ;non btfss DONNEE,BAC_HAUT goto arret_remplissage btfsc FLAGS,2 ;on est deja en train de remplir ? goto test_osmo ;oui clrf M_REAC clrf H_REAC clrf M_REMP ;init bsf REMPREAC,0 ;de cycle bcf REMPREAC,2 bsf FLAGS,2 ;remplissage bsf SORTIES1,1 call ECRIS_I2C1 goto test_osmo arret_remplissage bcf FLAGS,2 ;stop remplissage bcf SORTIES1,1 test_osmo btfsc DONNEE,RES_BAS bsf SORTIES1,2 ;osmoseur btfss DONNEE,RES_HAUT bcf SORTIES1,2 ;stop osmoseur call ECRIS_I2C1 return pas_remplissage bcf FLAGS,2 goto test_osmo ;**************************************************************************** ; LIS_HEURE : lis l'heure sans l'afficher (pour init) ;**************************************************************************** LIS_HEURE movlw b'10000101' ;heures call DS1302 movf DONNEE,W movwf HEURES movlw b'10000011' ;minutes call DS1302 movf DONNEE,W movwf MINUTES return ;**************************************************************************** ; AFF_HEURE : affiche l'heure ;**************************************************************************** AFF_HEURE movlw 06h ;6 essais... movwf TEMP5 movlw 0Bh call LCDSETADR essai_heure decf TEMP5 btfsc STATUS,Z return ;trop d'erreurs, on quitte movlw b'10000101' ;heures call DS1302 movf HEURES,W subwf DONNEE,W btfss STATUS,C goto heure_erreur ;erreur si DONNEE < HEURES affichage_heure movf DONNEE,W movwf HEURES call LCDHEX movlw ":" call LCDCHAR essai_minute decf TEMP5 btfsc STATUS,Z return ;trop d'erreurs, on quitte movlw b'10000011' ;minutes call DS1302 movf MINUTES,W subwf DONNEE,W btfss STATUS,C goto minute_erreur ;erreur si DONNEE < MINUTES affichage_minute movf DONNEE,W movwf MINUTES call LCDHEX return heure_erreur movf HEURES,W btfsc STATUS,Z ;test si HEURES = 0 goto affichage_heure ;oui : pas de pb, on est pass‚ de 23 … 0 goto essai_heure ;non, il y a un pb, on recommence minute_erreur movf MINUTES,W btfsc STATUS,Z ;test si MINUTES = 0 goto affichage_minute ;oui : pas de pb, on est pass‚ de 59 … 0 goto essai_minute ;non, il y a un pb, on recommence ;**************************************************************************** ; ECRIS_I2C0 == ecriture sur le bus I2C (mise en marche des appareils) ;**************************************************************************** ECRIS_I2C0 movlw d'05' ;essaye 5 ecritures movwf CPT ecris_I2C0 comf SORTIES, W movwf DONNEE movlw b'01000000' ;ecriture call PCF8574 movlw b'01000001' ;lecture call PCF8574 comf SORTIES, W subwf DONNEE, W btfsc STATUS, Z ;ecriture OK ? goto ecriture_OK ;oui decfsz CPT goto ecris_I2C0 bcf FLAGS,7 retlw 0FFh ;on a essay‚ X fois : erreur ecriture_OK bcf FLAGS,7 retlw 0 ;**************************************************************************** ; TEST_HEURE == teste s'il faut mettre l'appareils du composant 0 ; en / hors fonction ; adresse EEPROM dans W ; retour dans W : 0 hors fction : FF en fonction ;**************************************************************************** TEST_HEURE movwf TEMP1 call LIS_EEPROM2 movf HEURES,W bcf STATUS,Z bcf STATUS,C subwf DONNEE,W btfsc STATUS,Z goto test_minutes btfsc STATUS,C retlw 0 test_heures incf TEMP1 incf TEMP1 movf TEMP1,W call LIS_EEPROM2 movf HEURES,W bcf STATUS,Z bcf STATUS,C subwf DONNEE,W btfsc STATUS,Z goto test_minutes2 btfss STATUS,C retlw 0 retlw 0FFh test_minutes incf TEMP1,W call LIS_EEPROM2 movf MINUTES,W bcf STATUS,Z bcf STATUS,C subwf DONNEE,W btfsc STATUS,Z goto test_heures btfsc STATUS,C retlw 0 goto test_heures test_minutes2 incf TEMP1,W call LIS_EEPROM2 movf MINUTES,W bcf STATUS,C subwf DONNEE,W btfsc STATUS,Z retlw 0 btfss STATUS,C retlw 0 retlw 0FFh ;**************************************************************************** ; REGLE2 == reglage pour niveau et reacteur adresse EEPROM dans W ;**************************************************************************** REGLE2 movwf TEMP4 movlw 01h ;clear display call LCDCMD ; movlw 8Bh ;chaque call LCDSTR2 movlw 0Ah call LCDSETADR movf TEMP4,W sublw REACTEUR movlw 9Ah ;min. btfsc STATUS,Z movlw 52h ;heure call LCDSTR2 movf TEMP4,W call LISEEPROM att_regle clrwdt movlw 07h call LCDSETADR movf DONNEE,W call LCDHEX movlw 0A0h btfsc PB,2 goto fin_regle1 btfss PB,1 goto att_regle call RELACHE movlw 0A0h call INCREMENTE goto att_regle fin_regle1 call RELACHE movf TEMP4,W call ECRISEEPROM movlw 40h call LCDSETADR movlw 92h ;pendant call LCDSTR2 movlw 4Bh call LCDSETADR movf TEMP4,W sublw REMPLISSAGE movlw 9Fh ;sec. btfss STATUS,Z movlw 9Ah ;min. call LCDSTR2 incf TEMP4,W call LISEEPROM att_regle2 clrwdt movlw 48h call LCDSETADR movf DONNEE,W call LCDHEX movlw 0A0h btfsc PB,2 goto fin_regle2 btfss PB,1 goto att_regle2 call RELACHE movlw 0A0h call INCREMENTE goto att_regle2 fin_regle2 call RELACHE incf TEMP4,W call ECRISEEPROM return ;**************************************************************************** ; LIS_EEPROM == lecture de l'EEPROM, recopie dans bank3 … partir de 20h ;**************************************************************************** LIS_EEPROM movlw 20h movwf FSR bsf STATUS,IRP ;page 3 pour adressage indirect movlw 40h movwf TEMP4 clrf ADRESSE boucle_lecture movf ADRESSE,W call LISEEPROM movf DONNEE,W movwf INDF incf ADRESSE incf FSR decfsz TEMP4 goto boucle_lecture return ;**************************************************************************** ; LIS_EEPROM2 == lecture de la copie de l'EEPROM ;**************************************************************************** LIS_EEPROM2 addlw 20h movwf FSR bsf STATUS,IRP movf INDF,W movwf DONNEE return ;**************************************************************************** ; REGLE_POMPE == reglage des pompes de brassage (tableau de 24 bits) ;**************************************************************************** REGLE_POMPE movwf ADRESSE call LISEEPROM movlw 01h ;clear display call LCDCMD ; movlw 04h call LCDSETADR movlw 08h call BOUCLE_POMPE incf ADRESSE,W call LISEEPROM movlw 04h call BOUCLE_POMPE movlw 44h call LCDSETADR movlw 04h call BOUCLE_POMPE incf ADRESSE incf ADRESSE,W decf ADRESSE call LISEEPROM movlw 08h call BOUCLE_POMPE movf ADRESSE,W call LISEEPROM clrf TEMP4 movlw 04h movwf TEMP5 clrf MENUPOS clrf FINRETRO attente_pompe clrwdt clrw call LCDSETADR movf FINRETRO,W call LCDDEC btfsc PB,0 return btfsc PB,2 goto suivant btfss PB,1 goto attente_pompe call RELACHE movlw 01h xorwf DONNEE movf TEMP5,W call LCDSETADR movlw "1" btfss DONNEE,0 movlw "0" call LCDCHAR goto attente_pompe suivant call RELACHE incf FINRETRO incf TEMP5 ;teste s'il faut passer sur la ligne movlw 10h ;suivante subwf TEMP5,W btfss STATUS,Z goto pompe_suivant movlw 44h movwf TEMP5 pompe_suivant bcf STATUS,C rrf DONNEE btfsc STATUS,C bsf DONNEE,7 incf TEMP4 movlw 08h subwf TEMP4,W btfss STATUS,Z goto attente_pompe movf ADRESSE,W call ECRISEEPROM incf MENUPOS movlw 03h subwf MENUPOS,W btfsc STATUS,Z return clrf TEMP4 incf ADRESSE movf ADRESSE,W call LISEEPROM goto attente_pompe ;**************************************************************************** ; BOUCLE_POMPE ;**************************************************************************** BOUCLE_POMPE movwf TEMP4 boucle_pompe movlw "1" btfss DONNEE,0 movlw "0" call LCDCHAR rrf DONNEE decfsz TEMP4 goto boucle_pompe return ;**************************************************************************** ; ECRIS_I2C1 == ecriture sur le bus I2C (mise en marche des appareils ; osmoseur et niveau) ;**************************************************************************** ECRIS_I2C1 movlw d'05' ;essaye 5 ecritures movwf CPT ecris_I2C1 comf SORTIES1, W iorlw 0F8h ;1 sur les entrees movwf DONNEE movlw b'01000010' ;ecriture call PCF8574 movlw b'01000011' ;lecture call PCF8574 movlw 07h ;teste que les 3 bits poids faible andwf DONNEE comf SORTIES1, W andlw 07h subwf DONNEE, W btfsc STATUS, Z ;ecriture OK ? retlw 0 ;oui decfsz CPT goto ecris_I2C1 retlw 0FFh ;on a essay‚ X fois : erreur ;**************************************************************************** ; REMPLISS_S = gestion de la pompe de remplissage (secondes) ;**************************************************************************** REMPLISS_S btfss REMPREAC,0 ;doit on encore attendre ? return ;oui movlw REMPLISSAGE + 1 call LIS_EEPROM2 movf DONNEE,W subwf SECONDES,W btfss STATUS,Z ;doit on arreter ? return ;non bcf REMPREAC,0 bcf SORTIES1,1 call ECRIS_I2C1 return ;**************************************************************************** ; REMPLISS_M = gestion de la pompe de remplissage (minutes) ;**************************************************************************** REMPLISS_M movlw 0A0h movwf MAX movf M_REMP,W movwf DONNEE call INCREMENTE movf DONNEE,W movwf M_REMP movlw REMPLISSAGE call LIS_EEPROM2 movf DONNEE,W subwf M_REMP,W btfss STATUS,Z ;doit on remettre en marche ? return ;non clrf M_REMP bsf REMPREAC,0 bsf SORTIES1,1 call ECRIS_I2C1 return ;**************************************************************************** ; REACT_REMP = gestion du reacteur a calcium (minutes) pendant rempliss ;**************************************************************************** REACT_REMP movlw 0A0h ;incremente M_REAC movwf MAX movf M_REAC,W movwf DONNEE call INCREMENTE movf DONNEE,W movwf M_REAC ;fin incremente M_REAC btfsc REMPREAC,2 ;doit on encore attendre ? goto reac_arret_remp ;oui movlw REACTEUR2 + 1 call LIS_EEPROM2 call INCREMENTE movf M_REAC,W subwf DONNEE,W btfss STATUS,Z ;doit on arreter ? goto marche_reac_remp ;non bcf SORTIES1,0 call ECRIS_I2C1 bsf REMPREAC,2 return marche_reac_remp bsf SORTIES1,0 call ECRIS_I2C1 return reac_arret_remp movlw REACTEUR2 call LIS_EEPROM2 call INCREMENTE movf DONNEE,W subwf M_REAC,W btfss STATUS,Z ;doit on remettre en marche ? return ;non bcf REMPREAC,2 clrf M_REAC return ;**************************************************************************** ; REACT = gestion du reacteur a calcium (minutes) ;**************************************************************************** REACT incf CPT_MIN movlw 0A0h ;incremente M_REAC movwf MAX movf M_REAC,W movwf DONNEE call INCREMENTE movf DONNEE,W movwf M_REAC ;fin incremente M_REAC btfsc REMPREAC,2 ;doit on encore attendre ? goto reac_arret ;oui movlw REACTEUR + 1 call LIS_EEPROM2 call INCREMENTE movf M_REAC,W subwf DONNEE,W btfss STATUS,Z ;doit on arreter ? goto marche_reac ;non bcf SORTIES1,0 call ECRIS_I2C1 bsf REMPREAC,2 return marche_reac bsf SORTIES1,0 call ECRIS_I2C1 return reac_arret movf CPT_MIN,W sublw d'60' ;1 heure ecoulee ? btfss STATUS,Z return ;non movf H_REAC,W ;oui movwf DONNEE call INCREMENTE movf DONNEE,W movwf H_REAC movlw REACTEUR call LIS_EEPROM2 movf DONNEE,W subwf H_REAC,W btfss STATUS,Z ;doit on remettre en marche ? return ;non bcf REMPREAC,2 clrf H_REAC clrf M_REAC return ;**************************************************************************** ; TEST_BRASSAGE = bit a tester a 1 dans TEMP4, adresse dans W ;**************************************************************************** TEST_BRASSAGE addwf TEMP5,W call LIS_EEPROM2 movf DONNEE,W andwf TEMP4,W btfss STATUS,Z goto marche_pompe movlw " " call LCDCHAR retlw 00h marche_pompe movf MENUPOS,W call LCDCHAR retlw 0FFh ;**************************************************************************** ; BRASSAGE = gestion des pompes de brassage ;**************************************************************************** BRASSAGE movf HEURES,W call BCD2DEC clrf TEMP5 movf DONNEE,W movwf TEMP3 movlw 08h subwf TEMP3,W btfss STATUS,C goto suite_bra movwf TEMP3 ;jusqu'… suite_bra : incf TEMP5 ;le bit … tester est le nø TEMP3 movlw 08h ;l'octet … lire est … POMPE + TEMP5 subwf TEMP3,W btfss STATUS,C goto suite_bra movwf TEMP3 incf TEMP5 suite_bra bsf TEMP4,0 movf TEMP3,W andlw 0FFh btfsc STATUS,Z goto suite_bra2 boucle_bras bcf STATUS,C rlf TEMP4 decfsz TEMP3 goto boucle_bras suite_bra2 movlw 44h ;position du premier affichage pompe call LCDSETADR movlw "1" movwf MENUPOS movlw POMPE1 call TEST_BRASSAGE bcf SORTIES,2 andlw 0FFh btfss STATUS,Z bsf SORTIES,2 incf MENUPOS movlw POMPE2 call TEST_BRASSAGE bcf SORTIES,3 andlw 0FFh btfss STATUS,Z bsf SORTIES,3 incf MENUPOS movlw POMPE3 call TEST_BRASSAGE bcf SORTIES,4 andlw 0FFh btfss STATUS,Z bsf SORTIES,4 incf MENUPOS movlw POMPE4 call TEST_BRASSAGE bcf SORTIES,5 andlw 0FFh btfss STATUS,Z bsf SORTIES,5 bsf FLAGS,7 ;signaler qu'il faut ecrire l'I2C return ;**************************************************************************** ; BCD2DEC = conversion de BCD (W) vers decimal (DONNEE) ;**************************************************************************** BCD2DEC movwf TEMP1 movlw 0 btfsc TEMP1,0 addlw d'1' btfsc TEMP1,1 addlw d'2' btfsc TEMP1,2 addlw d'4' btfsc TEMP1,3 addlw d'8' btfsc TEMP1,4 addlw d'10' btfsc TEMP1,5 addlw d'20' btfsc TEMP1,6 addlw d'40' btfsc TEMP1,7 addlw d'80' movwf DONNEE return ;**************************************************************************** ; MENU_MANU = gestion du menu : "Commandes Manu" ;**************************************************************************** MENU_MANU movlw 18h movwf MENUPOS movwf TEMP2 clrf TEMP5 clrf CPT bsf CPT,0 clrf CPT2 bsf CPT2,0 ecrit_menu_manu call RELACHE movlw 01h ;clear display call LCDCMD ; movlw 7Eh call LCDCHAR movlw HIGH(MENUTABLE) movwf PCLATH movf MENUPOS,W movwf DONNEE call MENUTABLE clrf PCLATH call LCDSTR movlw 0Eh ;ecriture de A - X - 0 call LCDSETADR movlw ' ' call LCDCHAR movf CPT,W andwf CMDMANU,W movlw 'A' btfsc STATUS,Z goto fin_test_auto1 movf CPT,W andwf SORTIES,W movlw 'X' btfsc STATUS,Z movlw '0' fin_test_auto1 call LCDCHAR movlw 41h call LCDSETADR movlw HIGH(MENUTABLE) movwf PCLATH incf MENUPOS,W call MENUTABLE clrf PCLATH andlw 0FFh btfss STATUS,Z ;test si fin de menu goto fin_menu_manu movlw HIGH(MENUTABLE) movwf PCLATH movf TEMP2,W call MENUTABLE clrf PCLATH fin_menu_manu call LCDSTR movlw 4Eh ;ecriture de A - X - 0 call LCDSETADR movlw ' ' call LCDCHAR rlf CPT,W andwf CMDMANU,W movlw 'A' btfsc STATUS,Z goto fin_test_auto2 rlf CPT,W andwf SORTIES,W movlw 'X' btfsc STATUS,Z movlw '0' fin_test_auto2 call LCDCHAR attente_menu_manu clrwdt btfsc PB,1 ;suivant goto menu_manu_suivant btfss PB,2 ;enter goto attente_menu_manu call RELACHE movlw 23h ;Sortie ? subwf MENUPOS,W btfsc STATUS,Z return movf CPT,W xorwf CMDMANU goto ecrit_menu_manu menu_manu_suivant rlf CPT btfss STATUS,C goto test_fin_manu bsf FLAGS,1 ;on passe sur le composant 1 test_fin_manu incf MENUPOS movlw HIGH(MENUTABLE) movwf PCLATH movf MENUPOS,W call MENUTABLE clrf PCLATH andlw 0FFh btfss STATUS,Z ;test si fin de menu goto ecrit_menu_manu movf TEMP2,W movwf MENUPOS goto ecrit_menu_manu ;**************************************************************************** ; DEC2BCD = conversion de decimal (W) vers BCD (DONNEE) ;**************************************************************************** DEC2BCD movwf TEMP1 clrf TEMP2 clrf DONNEE movlw d'10' continue_compt subwf TEMP1 btfss STATUS,C goto stop_compt incf TEMP2 goto continue_compt stop_compt swapf TEMP2,W movwf DONNEE movf TEMP1,W addlw d'10' iorwf DONNEE return ;**************************************************************************** ; TEMPERATURE = lecture de la temperature ;**************************************************************************** TEMPERATURE bsf STATUS,RP0 ;bank 1 bsf SSPCON2,SEN ;start bcf STATUS,RP0 ;bank 0 temp_start btfss PIR1,SSPIF goto temp_start movlw b'10000001' ;adresse thermometre movwf SSPBUF bcf PIR1,SSPIF temp_adr btfss PIR1,SSPIF goto temp_adr btfsc SSPCON2,ACKSTAT ;si not ack return movlw 04h call TEMPO bsf STATUS,RP0 bsf SSPCON2,RCEN ;reception bcf STATUS,RP0 bcf PIR1,SSPIF temp_lecture btfss PIR1,SSPIF goto temp_lecture movf SSPBUF,W ;lecture movwf TEMPERATURE_ENTIER movlw 04h call TEMPO bsf STATUS,RP0 bcf SSPCON2,ACKDT ;ack bsf SSPCON2,ACKEN bcf STATUS,RP0 bcf PIR1,SSPIF temp_ack btfss PIR1,SSPIF goto temp_ack movlw 04h call TEMPO bsf STATUS,RP0 bsf SSPCON2,RCEN ;reception bcf STATUS,RP0 bcf PIR1,SSPIF temp_lecture2 btfss PIR1,SSPIF goto temp_lecture2 movf SSPBUF,W ;lecture movwf TEMPERATURE_DECIMALE movlw 04h call TEMPO bsf STATUS,RP0 bsf SSPCON2,ACKDT ;not ack bsf SSPCON2,ACKEN bcf STATUS,RP0 bcf PIR1,SSPIF temp_not_ack btfss PIR1,SSPIF goto temp_not_ack movlw 04h call TEMPO bsf STATUS,RP0 ;bank 1 bsf SSPCON2,PEN ;stop bcf STATUS,RP0 ;bank 0 bcf PIR1,SSPIF temp_stop btfss PIR1,SSPIF goto temp_stop bcf PIR1,SSPIF movf TEMPERATURE_DECIMALE,W call DEC2BCD movf DONNEE,W movwf TEMPERATURE_DECIMALE movf TEMPERATURE_DECIMALE,W andlw 0Fh sublw d'05' clrf TEMP1 btfss STATUS,C incf TEMP1 swapf TEMPERATURE_DECIMALE,W andlw 0Fh addwf TEMP1,W movwf TEMPERATURE_DECIMALE sublw d'10' btfss STATUS,Z return incf TEMPERATURE_ENTIER clrf TEMPERATURE_DECIMALE return ;**************************************************************************** ; AFF_TEMPERATURE = affichage de la temperature ;**************************************************************************** AFF_TEMPERATURE clrw call LCDSETADR movf TEMPERATURE_ENTIER,W call LCDDEC movlw "." call LCDCHAR movf TEMPERATURE_DECIMALE,W addlw d'48' ;passage en ascii call LCDCHAR movlw 0DFh ;"ø" call LCDCHAR movlw "C" call LCDCHAR return ;**************************************************************************** ; SORTIE_LIBRE = gestion de la sortie libre avec PB1 ; activation si appui, desactivation si relache ; si appui > 2s, interrupteur normal ;**************************************************************************** SORTIE_LIBRE btfsc FLAGS,6 ;l'appui a dur‚ plus de 2s ? goto interrupteur ;oui btfss PB,1 ;on appuie toujours goto arret_sortie btfsc FLAGS,5 ;premier appui ? goto pas_premier ;non bsf FLAGS,5 bsf SORTIES,7 call ECRIS_I2C0 movlw 49h call LCDSETADR movlw "X" call LCDCHAR movlw 60h movwf MAX movf SECONDES,W movwf DONNEE call INCREMENTE call INCREMENTE movf DONNEE,W movwf FIN_X return pas_premier movf SECONDES,W subwf FIN_X,W btfsc STATUS,Z bsf FLAGS,6 return interrupteur btfsc FLAGS,4 goto deja_relache btfsc PB,1 return bsf FLAGS,4 deja_relache btfss PB,1 return arret_sortie bcf FLAGS,5 ;arret bcf FLAGS,4 bcf FLAGS,6 btfss SORTIES,7 return bcf SORTIES,7 call ECRIS_I2C0 movlw 49h call LCDSETADR movlw " " call LCDCHAR return ;**************************************************************************** ; REGUL_TEMPERATURE = regulation de la temperature ;**************************************************************************** REGUL_TEMPERATURE movlw TEMP_VISEE + 2 call LIS_EEPROM2 movf TEMPERATURE_ENTIER,W subwf DONNEE,W btfsc STATUS,Z ;temp_entier = temp_visee_entier, on teste la decimale goto test_decimale btfsc STATUS,C ;temp_entier > temp_visee goto temp_faible btfss SORTIES,6 return bcf SORTIES,6 bsf FLAGS,7 return test_decimale temp_faible btfsc SORTIES,6 return bsf SORTIES,6 bsf FLAGS,7 return ;**************************************************************************** ; programme principal ;**************************************************************************** MAIN clrwdt bsf STATUS,RP0 ;bank 1 movlw b'11010101' ;timer 0 prescaler 64 movwf OPTION_REG movlw 0FFh ;desactivation des movwf ADCON1 ;entrees analogiques movlw 78h ;port B movwf TRISB clrf TRISD ;port D, outputs clrf TRISE ;port E, outputs movlw d'127' ;vitesse clock I2C movwf SSPADD ;20 kHz bcf STATUS,RP0 ;bank 0 bsf PORTB,7 bsf INTCON,T0IE bsf INTCON,GIE movlw b'00101000' ;I2C master mode movwf SSPCON ;configuration I2C clrf PB clrf PORTE clrf FLAGS clrf EXDONNEE clrf SORTIES clrf SORTIES1 clrf REMPREAC clrf M_REAC clrf H_REAC clrf CMDMANU clrf CPT_MIN bsf SORTIES,6 call LCDINIT call LIS_HEURE call AFF_HEURE debut bsf FLAGS,0 call LIS_EEPROM movlw 01h ;clear display call LCDCMD ; call BRASSAGE boucle clrwdt movf PB,W andlw 07h btfsc STATUS,Z ;doit on allumer le retroeclairage goto pas_retro ;non bcf PORTB,7 ;retroeclairage bcf STATUS,C movf SECONDES,W addlw 30h ;activer pendant 30s movwf FINRETRO movlw 60h subwf FINRETRO,W btfsc STATUS,C movwf FINRETRO pas_retro call SORTIE_LIBRE movf SECONDES,W movwf EXSECONDES movlw b'10000001' ;secondes call DS1302 movf DONNEE,W andlw 7Fh movwf SECONDES btfsc FLAGS,0 goto minute_ecoulee ;forcage minute ecoulee ? andlw 0FFh btfss STATUS,Z ;secondes = 0 ? goto pas_min_ecoulee movf EXSECONDES,W sublw 59h btfss STATUS,Z ;exsecondes = 59 ? goto pas_min_ecoulee minute_ecoulee bcf FLAGS,0 call AFF_HEURE call TEMPERATURE call AFF_TEMPERATURE call REGUL_TEMPERATURE movf SECONDES,F btfsc STATUS,Z call LIS_I2C btfss FLAGS,2 ;forcage reacteur ? goto react_normal ;non call REACT_REMP goto suite_test react_normal call REACT suite_test movlw L_BLANCHE call TEST_HEURE andlw 0FFh btfsc STATUS,Z ;marche L_BLANCHE ? goto arret_blanche ;non btfsc SORTIES,0 ;L_BLANCHE deja allumee ? goto test_bleue ;oui bsf SORTIES,0 ;non : l'allumer bsf FLAGS,7 goto test_bleue arret_blanche btfss SORTIES,0 ;L_BLANCHE deja eteinte ? goto test_bleue ;oui bcf SORTIES,0 ;non : l'eteindre bsf FLAGS,7 test_bleue movlw L_BLEUE call TEST_HEURE andlw 0FFh btfsc STATUS,Z ;marche L_BLEUE ? goto arret_bleue ;non btfsc SORTIES,1 ;L_BLEUE deja allumee ? goto fin_lumiere ;oui bsf SORTIES,1 ;non : l'allumer bsf FLAGS,7 goto fin_lumiere arret_bleue btfss SORTIES,1 ;L_BLEUE deja eteinte ? goto fin_lumiere ;oui bcf SORTIES,1 ;non : l'eteindre bsf FLAGS,7 fin_lumiere btfsc FLAGS,7 ;Changement sur le bus 0 ? call ECRIS_I2C0 movlw 42h call LCDSETADR movlw " " btfsc SORTIES,0 movlw "B" call LCDCHAR movlw " " btfsc SORTIES,1 movlw "b" call LCDCHAR movlw 48h call LCDSETADR movlw " " btfsc SORTIES,6 movlw "C" call LCDCHAR movlw " " btfsc SORTIES,7 movlw "X" call LCDCHAR movlw " " btfsc SORTIES1,0 movlw "R" call LCDCHAR movlw " " btfsc FLAGS,2 ;remplissage movlw "r" call LCDCHAR movlw " " btfsc SORTIES1,2 movlw "O" call LCDCHAR movf MINUTES,W andlw 0FFh ;une heure ecoulee ? btfsc STATUS,Z call BRASSAGE btfss FLAGS,2 ;pompe de remplissage ? goto pas_rempliss ;non call REMPLISS_M pas_min_ecoulee btfss FLAGS,2 ;pompe de remplissage ? goto pas_rempliss ;non call REMPLISS_S ;oui pas_rempliss movf SECONDES,W subwf FINRETRO,W btfsc STATUS,Z bsf PORTB,7 ;arret retroeclairage btfss PB,0 goto boucle call RELACHE bcf PORTB,7 ;retroeclairage call MENU_UTIL bsf PORTB,7 ;arret retroeclairage goto debut org 0800h ;**************************************************************************** ; MSG == messages utilises dans les Menus ;**************************************************************************** MSG addwf PCL DT "Commandes manu",0 ;00h DT "Reglages",0 ;0Fh DT "Mesure pH",0 ;18h DT "Sortie",0 ;22h DT "A propos...",0 ;29h DT "date / heure",0 ;35h DT "Reset",0 ;42h DT "Lumiere blanche",0 ;48h DT "Lumiere bleue",0 ;58h DT "Reacteur calc.",0 ;66h DT "Remplissage",0 ;75h DT "Pompes brassage",0 ;81h DT "Pompe 1",0 ;91h DT "Pompe 2",0 ;99h DT "Pompe 3",0 ;A1h DT "Pompe 4",0 ;A9h DT "Temperature",0 ;B1h DT "Libre",0 ;BDh DT "Osmoseur",0 ;C3h DT "Etalonage",0 ;CCh DT "Reacteur calc.2",0 ;D6h DT "Heures Rempliss",0 ;E6h org 0900h ;**************************************************************************** ; MSG2 == messages ;**************************************************************************** MSG2 addwf PCL DT "Julien Schmitt",0 ;00h DT "V1.0 19/06/2000",0 ;0Fh DT "Menu utilisateur",0 ;20h DT "****************",0 ;31h DT "jour",0 ;42h DT "mois",0 ;47h DT "annee",0 ;4Ch DT "heure",0 ;52h DT "minutes",0 ;58h DT "Aquamate",0 ;60h DT "Etes vous sur ?",0 ;69h DT "OUI",0 ;79h DT "NON",0 ;7Dh DT "debut",0 ;81h DT "fin",0 ;87h DT "chaque",0 ;8Bh DT "pendant",0 ;92h DT "min.",0 ;9Ah DT "sec.",0 ;9Fh org 0A00h ;**************************************************************************** ; MENUTABLE == gestion des messages du menu ;**************************************************************************** MENUTABLE addwf PCL DT 00h,0Fh,18h,29h,22h,0 ;menu principal : 00h DT 35h,48h,58h,66h,0D6h,75h,81h,0E6h,0B1h,42h,22h,0 ;menu reglages : 06h DT 91h,99h,0A1h,0A9h,22h,0 ;reglage des pompes : 12h DT 48h,58h,91h,99h,0A1h,0A9h,0B1h,0BDh,66h,75h,0C3h,22h,0 ;Menu Manu : 18h END