📄 aqua ok.asm
字号:
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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -