;gestion chauffage solaire ; MM 24/03/25
;modif 12/05/25 : MAX 31855 , liaison Tpanneau par RS232
#picaxe 20M2
setfreq M16
symbol pano=C.7 ;Entrée T panneau
symbol selec=pinC.6 ;poussoir de sélection
symbol DSbalon=C.5 ;T balon
symbol DSjac=C.4 ;T jaccuzi
symbol DSpisc=C.3 ;T piscine
symbol DSser=C.2 ;T serre
symbol valid=pinC.0 ;poussoir de validation
symbol potar=B.5 ;pot de réglages consignes
symbol LCD=B.0 ;LCD 2004
symbol circBal=outpinB.1 ;circulateur balon
symbol circJac=outpinB.2 ;circulateur jaccuzi
symbol circPisc=outpinB.3 ;circulateur piscinne
symbol circSer=outpinB.4 ;circulateuur serre
symbol def =bit0 ;défaut thermocouple
symbol Tpano =b1 ;valeur T° panneaux
symbol Tbalon =b2 ;ballon
symbol Tpisc =b3 ;piscine
symbol Tjac =b4 ;jacuzzi
symbol Tser =b5 ;serre
symbol Cbalon =b6 ;valeur consigne ballon
symbol Cjac =b7 ;jacuzzi
symbol Cpisc =b8 ;piscine
symbol Cser =b9 ;serre
symbol varb =b10 ;variable byte
symbol delt =b11 ;delte pan-balon
symbol Ident =b12 ;Identification RS232
symbol baud =N2400_16
symbol baudT =T2400_16 ;modifié T2400 au lieu de N2400
dirsC=%0
dirsB=%00011111
pullup %1111111100000000
;****************************************
pause 500 ;temps iitialisation LCD
serout LCD, baud,(254,1)
serout LCD, baud,(254,130,"Pa Ba Ja Pi Se")
serout LCD, baud,(254,148,"C",254,192,"T",254,212,"P")
read 0,Cjac,Cpisc,Cser ;lecture consignes enEEPROM
if Cjac=0 then
gosub consigne ; si EEPROM vide
else
serout LCD,baud,(254,158,#Cjac,254,162,#Cpisc,254,166,#Cser)
endif
do
serin pano,baudT,(Ident,def,Tpano) ;sur C.7 : readadc à remplacer par readtemp
if Ident <> 123 or def=1 then gosub erreur
readtemp DSbalon,Tbalon ;sur C.5
readtemp DSjac,Tjac ;sur C.4
readtemp DSpisc,Tpisc ;sur C.3
readtemp DSser,Tser ;sur C.2
;Tpano=85:Tbalon=75:Tjac=35:Tpisc=32:Tser=22 ;valeurs test
serout LCD, baud,(254,194,#Tpano," ",254,198,#Tbalon," ",254,202,#Tjac," ",254,206,#Tpisc," ",254,210,#Tser)
pause 200
if valid=0 then gosub consigne ;passage par consigne à la MST
gosub gescirc
loop
;*********************************************
consigne:
serout LCD,baud, (254,150," ",254,153,">",#delt," ") ;affichage chevron
do loop while valid=0 ;attente relachement valid
do
if selec=0 then jac ;si pous selection => étiquette pisc
loop while valid=1 ;si valid relaché, on tourve
do loop while valid=0 ;valid a été appuyé, on attend le relachement
do ;réglage Cjac
readadc potar, delt
delt= 15 *delt/255
serout LCD, baud,(254,153,"=",#delt," ") ;affichage = devant la valeur de Cjac
loop while valid=1 ;on tourne tant que valid est relaché
write 3,delt ;valid appuyé consigne en mémoire EEPROM
do loop while valid=0 ;attente relachement
jac:
do loop while selec=0 ;si selec appuyé, on attend le relachement
serout LCD,baud, (254,153," ",254,157,">",#Cjac," ") ;effacement "=" et chevron suivant
do
if selec=0 then pisc ;si pous selection => étiquette pisc
loop while valid=1 ;si valid relaché, on tourve
do loop while valid=0 ;valid a été appuyé, on attend le relachement
do ;réglage Cjac
readadc potar, Cjac
Cjac= 50 *Cjac/255
serout LCD, baud,(254,157,"=",#Cjac," ") ;affichage = devant la valeur de Cjac
loop while valid=1 ;on tourne tant que valid est relaché
write 0,Cjac ;valid appuyé consigne en mémoire EEPROM
do loop while valid=0 ;attente relachement
pisc:
do loop while selec=0 ;si selec appuyé, on attend le relachement
serout LCD,baud, (254,157," ",254,161,">",#Cpisc," ") ;effacement "=" et chevron suivant
do
if selec=0 then Ser
loop while valid=1
do loop while valid=0
do
readadc potar, Cpisc
Cpisc= 40 *Cpisc/255
serout LCD, baud,(254,161,"=",#Cpisc," ")
loop while valid=1
write 1, Cpisc
do loop while valid=0
Ser:
do loop while selec=0
serout LCD,baud, (254,161," ",254,165,">",#Cser)
do
if selec=0 then fin
loop while valid=1
do loop while valid=0
do
readadc potar, Cser
Cser= 20 *Cser/255 +10
serout LCD, baud,(254,165,"=",#Cser)
loop while valid=1
write 2, Cser
do loop while valid=0
fin:
serout LCD, baud,(254,165," ")
return
gescirc:
if Tbalon >=90 or Tbalon>= Tpano then
circBal=0
endif
varb=Tbalon+delt ;Temp ballon +5°C
if Tpano>varb then
circBal=1
else circBal=0
endif
serout LCD,baud,(254,218,#circBal) ;affichage val de circbal
if Tbalon>Tjac and Cjac> Tjac then
circJac= 1
endif
If Tjac>=Cjac or Tjac>=Tbalon then
circJac=0
endif
serout LCD,baud,(254,222,#circJac)
if Tser>=Cser or Tbalon<Tser or circJac=1 then
circSer=0
endif
if Tbalon>Tser and circJac=0 and Tser<Cser then
circser=1
endif
serout LCD,baud,(254,230,#circSer)
if Tbalon>Tpisc and circJac=0 and Tpisc< Cpisc then
circpisc=1
endif
if Tpisc>=Tbalon or Tpisc>=Cpisc or circJac=1 then
circpisc=0
endif
serout LCD,baud,(254,226,#circpisc)
return
erreur:
if Ident <>123 then
Tpano=999 ;erreur identification
else Tpano=888 ;erreur thermocouple
do loop while valid=1 ;attente appui
do loop while valid=0 ;attente relachement
endif
return