...[/ CODE][/QUOTE]
[QUOTE]'***** PILOTAGE DRY CELL avec PICAXE 20M2 *****
'C.0 = OUT : Afficheur LCD 2x20 caractères
'C.1 = OUT : Arrêt / marche DRY CELL
'C.2 = IN : Mesure du courant consommé
'C.3 = IN : Interruption : Arrêt d'urgence
'C.4 = IN : Mesure de température d'eau sur DS18B20
'C.5 = IN : Détection rotation moteur
'C.6 = IN : Détection niveau bas dans le réservoir
'C.7 = OUT: Buzzer
#picaxe 20M2
symbol temp = b0
symbol moteur = pinC.5
symbol niveau = pinC.6
symbol courant = C.2
symbol buzzer = C.7
symbol drycell = C.1
init_LCD:
symbol LCD = C.0
symbol BD = N4800
pause 500
serout LCD,BD, (254,1)
dirsC = %10000011 'pinC.0 et pinC.1 en sorties, les autres en entrées
init_demo:
' b15 = 148
' serout LCD,BD, (254,192," INITIALISATION ")
' pause 1500
' for b2 = 1 to 20 'ligne de 20 caractères
' serout LCD,BD, (254,b15,4)
' pause 50
' serout LCD,BD, (254,b15,5)
' pause 50
' serout LCD,BD, (254,b15,6)
' pause 50
' serout LCD,BD, (254,b15,7)
' pause 50
' serout LCD,BD, (254,b15,8)
' pause 50
' b15 = b15 + 1
' next b2
' pause 1500
' serout LCD,BD, (254,1)
' pause 1000
boucle_OFF:
call lecture_capteurs
pause 10
do
call niveau_eau
pause 10
call mesure_temp
pause 10
call rotation_moteur
pause 10
call mesure_courant
pause 10
loop while moteur=0 or temp<2 or temp>60 or b1>=128 'DRY CELL reste OFF tant que :
'moteur OFF ou
gosub drycell_ON 'temp <2°C ou >=70°C ou <=0°C
boucle_ON:
setint %00001000,%00001000 'interruption quand pinC.3=1 (appui sur BP ARR URG)
call lecture_capteurs
pause 10
do
call niveau_eau
pause 10
call mesure_temp
pause 10
call rotation_moteur
pause 10
call mesure_courant
pause 10
loop while moteur=1 and temp>1 and temp<=60 'DRY CELL reste ON tant que :
'moteur ON et
gosub drycell_OFF 'temp >1°C et <=60°C
'********** SOUS-PROGRAMMES **********
'--------------------------------------------------------------------------------------
lecture_capteurs:
serout LCD,BD, (254,1)
pause 10
serout LCD,BD, (254,128,1) 'Symbole niveau d'eau (1)
pause 10
serout LCD,BD, (254,142,3) 'Symbole température (3)
pause 10
serout LCD,BD, (254,148,"Moteur: Conso:")
pause 10
return
'--------------------------------------------------------------------------------------
niveau_eau: 'capteur à flotteur ILS
if niveau=0 then
serout LCD,BD, (254,130,"OK ")
endif
if niveau=1 then
serout LCD,BD, (254,130,"BAS")
pause 300
serout LCD,BD, (254,130," ")
endif
return
'--------------------------------------------------------------------------------------
mesure_temp: 'capteur température DS18B20
readtemp C.4,temp
b1=temp
if temp>=60 and temp<127 then 'temp >=60°C : afficher >60°C
serout LCD,BD, (254,144,">60",2)
pause 300
serout LCD,BD, (254,144," ")
pause 10
endif
if temp>=0 and temp<60 then 'temp >=0°C et <60°C
serout LCD,BD, (254,143," ",#temp,2," ")
endif
if temp>127 then 'temp <-1°C et >-9°C
temp=temp-128
serout LCD,BD, (254,143," -",#temp,2," ")
endif
return
'--------------------------------------------------------------------------------------
rotation_moteur: 'relais sur alternateur
if moteur=0 then
serout LCD,BD, (254,212,"STOP")
endif
pause 10
if moteur=1 then
serout LCD,BD, (254,212,"RUN ")
endif
pause 10
return
'--------------------------------------------------------------------------------------
mesure_courant: 'capteur ACS712 - 30A
readadc10 courant,w10
w10=w10-514
w11=w10*37/50
bintoascii w11,b11,b10,b9,b8,b7
serout LCD,BD, (254,227,b9,b8,",",b7,"A")
return
'--------------------------------------------------------------------------------------
drycell_ON:
pause 1000
serout LCD,BD, (254,1)
high buzzer 'Buzzer ON
pause 10
serout LCD,BD, (254,128,"********************")
pause 10
serout LCD,BD, (254,192," DRY CELL ")
pause 10
serout LCD,BD, (254,148," ON ")
pause 10
serout LCD,BD, (254,212,"********************")
pause 1000
low buzzer 'Buzzer OFF
high drycell 'DRY CELL ON
gosub boucle_ON
'--------------------------------------------------------------------------------------
drycell_OFF:
pause 1000
serout LCD,BD, (254,1)
high buzzer 'Buzzer ON
pause 10
serout LCD,BD, (254,128,"********************")
pause 10
serout LCD,BD, (254,192," DRY CELL ")
pause 10
serout LCD,BD, (254,148," OFF ")
pause 10
serout LCD,BD, (254,212,"********************")
pause 1000
low buzzer 'Buzzer OFF
low drycell 'DRY CELL OFF
gosub boucle_OFF
'--------------------------------------------------------------------------------------
interrupt:
low drycell 'DRY CELL OFF
serout LCD,BD, (254,1)
high buzzer 'Buzzer ON
pause 10
serout LCD,BD, (254,128,"********************")
pause 10
serout LCD,BD, (254,192,"* ARRET D'URGENCE *")
pause 10
serout LCD,BD, (254,148,"* DRY CELL OFF *")
pause 10
serout LCD,BD, (254,212,"********************")
pause 1000
low buzzer 'Buzzer OFF
stop[/QUOTE]
J'ai laissé les 2 blocs à leur place, plus simple pour moi...