Re: Regul chauffage PID
Publié : 17 mai 2016, 23:53
Re bonjour ou plutôt bonsoir, je pense avoir un petit peu progressé comme débutant mais maintenant je suis devant un mur d'interrogation!
j'ai implanté les scripts de la régul PID et j'obtiens les erreurs suivantes:
2016-05-17 22:30:23.051 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_conschauf.lua: /home/pi/domoticz/scripts/lua/script_device_conschauf.lua:1: unexpected symbol near char(255)
2016-05-17 22:31:00.383 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_time_cmdchauffv2.lua: /home/pi/domoticz/scripts/lua/script_time_cmdchauffv2.lua:1: unexpected symbol near char(255)
Voici le script que j'ai entré script_device_conschauf.lua:
-- script_device_conschauf.lua ---------------------------------------
-- G PETREMENT -----------------------------------------------2015----
----------------------------------------------------------------------
-- Pilotage d'un Thermostat setpoint Consigne pour pilotage regul ----
-- en fonction d'une programation journaliere ------------------------
----------------------------------------------------------------------
-- Le programme est basé sur l'action de 2 switchs (virtuels ou non) -
-- Le Switch EcoConfort dispose d'une programation mais peut aussi ---
-- être actionné manuellement. ---------------------------------------
-- Le switch HorsGel est un mode vacance qui stope la programmation --
-- Les temperatures de consignes sont stockées en variable direct ----
-- dans domoticz pour être modifiées par l'interface web. ------------
----------------------------------------------------------------------
----------------------------------------------------------------------
-- VARIABLES UTILISATEUR : mettre les nom des dispositifs ici --------
----------------------------------------------------------------------
local VarConsJour = 'ConsigneJour' --Variable consigne jour
local VarConsNuit = 'ConsigneNuit' --Variable consigne nuit
local VarConsVac = 'ConsigneVacance' --Variable consigne vacances
local VarSomErr = 'SommeErreur' --Variable Somme des erreurs
local SondeCons = 'ConsigneChauffage' --Sonde de temperature
local InterEcoConfort = 'EcoConfort' --Interrupteur programmé Off:eco On:confort
local InterHorsGel = 'HorsGel' --Interrupteur On:mode hors gel>> plus de programmation, consigne vacance ou manuelle
local domoticz_url = '192.168.0.203:8080' --Adresse IP:port de Domoticz
local IDXcons = '54' --IDx de l'afficheur de consigne
----------------------------------------------------------------------
-- Fonction retourant la differrence de temps en secondes ------------
function timedifference(s)
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
t1 = os.time()
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = os.difftime (t1, t2)
return difference
end
commandArray = {}
-- Recuperation des variables ---------------------------------------
local ConsJour = uservariables[VarConsJour]
local ConsNuit = uservariables[VarConsNuit]
local ConsVac = uservariables[VarConsVac]
local Consigne = otherdevices_temperature[SondeCons]
local t1 = os.date("%H:%M")
-- Lorsqu'un interrupteur est manipulé on modifie la temperature de consigne.
-- La variable SommeErreur utilisée pour calculer le gain intégral est aussi remise à 0 >> Gain intégral=0
if (((devicechanged[InterEcoConfort] == 'On') and (otherdevices[InterHorsGel] == 'Off')) or ((devicechanged[InterHorsGel] == 'Off') and (otherdevices[InterEcoConfort] == 'On'))) then
print("-------------- Temperature modifiée vers Confort à "..t1)
-- Mise a jour de l'afficheur via JSON -----------------------------
local url = domoticz_url..'/json.htm?type=command¶m=udevice&idx='..IDXcons..'&nvalue=0&svalue='..ConsJour
commandArray[1]={['OpenURL']=url }
commandArray['Variable:'..VarSomErr]='0'
elseif (((devicechanged[InterEcoConfort] == 'Off') and (otherdevices[InterHorsGel] == 'Off')) or ((devicechanged[InterHorsGel] == 'Off') and (otherdevices[InterEcoConfort]=='Off' ))) then
print("-------------- Temperature modifiée vers Eco à "..t1)
-- Mise a jour de l'afficheur via JSON -----------------------------
local url = domoticz_url..'/json.htm?type=command¶m=udevice&idx='..IDXcons..'&nvalue=0&svalue='..ConsNuit
commandArray[1]={['OpenURL']=url }
commandArray['Variable:'..VarSomErr]='0'
elseif (devicechanged[InterHorsGel] == 'On') then
print("-------------- Temperature modifiée vers HorsGel à "..t1)
-- Mise a jour de l'afficheur via JSON -----------------------------
local url = domoticz_url..'/json.htm?type=command¶m=udevice&idx='..IDXcons..'&nvalue=0&svalue='..ConsVac
commandArray[1]={['OpenURL']=url }
commandArray['Variable:'..VarSomErr]='0'
end
return commandArray
et le suivant script_time_cmdchauffv2.lua:
-- script_time_cmdchauffv2.lua ---------------------------------------
-- G PETREMENT -------------------------------------------------------
----------------------------------------------------------------------
-- Permet de commander relais de pilotage de chaudiere à gaz ---------
-- Le cycle fait 900s / 15min ---------------------------------------
-- La commande est un nombre de 0 à 100 ------------------------------
-- Le cycle minimum de la chaudière est de 3min pour réduire l'usure -
----------------------------------------------------------------------
local InterOnOff = 'Chauffage On/Off' --Interrupteur général de mise en route du chauffage
local VarCmdChauff = 'CmdChauff' --Variable de commande de chauffage définie par script_device_thermostat
local CycleMini = 180 --Durée de chauffe minimum en secondes (fonction de la chaudière)
local InterRelais = 'Piface RelayChaud' --Sortie vers relais chaudière
local domoticz_url = '192.168.0.203:8080' --Adresse IP:port de Domoticz
-- Fonction retourant la differrence de temps en secondes
function timedifference(s)
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
t1 = os.time()
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = os.difftime (t1, t2)
return difference
end
commandArray = {}
-- Recuperation des variables
local CmdChauff = uservariables[VarCmdChauff]
local OnOff = otherdevices[InterOnOff]
-- Recuperation des minutes
time=os.time()
minutes=tonumber(os.date('%M',time))
hours=tonumber(os.date('%H',time))
-- Execution de cette partie du script toutes les 15 minutes
-- Contacte la chaudière et modifie la variable domoticz Cycle
if( (minutes==15) or (minutes==0) or (minutes==30) or (minutes==45) ) then
print('-- Lancement du script à '..hours..'h'..minutes)
print('-- OnOff ='..OnOff..' / CmdChauff ='..CmdChauff)
if OnOff == 'On' then --Si l'inter général est ON
local Cycle = CmdChauff * 9 --Calcul du temps de cycle en seconde
if Cycle < CycleMini then --Si le cycle est trop court on coupe
commandArray[InterRelais]='Off'
-- commandArray['Variable:'..VarCycle]= tostring('0')
print('Cycle :'..Cycle..'s >> Chaudière Off')
elseif Cycle > 870 then --Si le cycle est trop long (> 14min30) on allume sans coupure
commandArray[InterRelais]='On'
-- commandArray['Variable:'..VarCycle]= tostring(Cycle)
print('Cycle :'..Cycle..'s >> Chaudière On')
else --Enfin on lance pour X seconde
print('Cycle lancé pour : '..Cycle..'secondes')
commandArray[1]={[InterRelais]='On'}
commandArray[2]={[InterRelais]='Off AFTER '..tostring(Cycle)}
end
else
commandArray[InterRelais]='Off'
-- commandArray['Variable:'..VarCycle]= tostring('0')
print('Chaudière Off')
end
end
return commandArray
et voici une capture de ma page Domoticz:
Autres questions:
1) je ne sais pas comment entrer les valeurs des Constantes Kp Ki Kd dans ma régulation! elles sont déclarées comme des variables mais à aucun moment je n'ai vu une entrée de ces constantes.
2) Comment obtenir dans domoticz le tableau des variables:
3) Comment debuger un programme en script lua?
Merci d'avance à celui qui voudra bien me répondre.
Raspberry Pi model B+,Dongle WIFI, RFXComm,6 modules volet roulant BLYSS, sonde Oregon
j'ai implanté les scripts de la régul PID et j'obtiens les erreurs suivantes:
2016-05-17 22:30:23.051 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_conschauf.lua: /home/pi/domoticz/scripts/lua/script_device_conschauf.lua:1: unexpected symbol near char(255)
2016-05-17 22:31:00.383 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_time_cmdchauffv2.lua: /home/pi/domoticz/scripts/lua/script_time_cmdchauffv2.lua:1: unexpected symbol near char(255)
Voici le script que j'ai entré script_device_conschauf.lua:
-- script_device_conschauf.lua ---------------------------------------
-- G PETREMENT -----------------------------------------------2015----
----------------------------------------------------------------------
-- Pilotage d'un Thermostat setpoint Consigne pour pilotage regul ----
-- en fonction d'une programation journaliere ------------------------
----------------------------------------------------------------------
-- Le programme est basé sur l'action de 2 switchs (virtuels ou non) -
-- Le Switch EcoConfort dispose d'une programation mais peut aussi ---
-- être actionné manuellement. ---------------------------------------
-- Le switch HorsGel est un mode vacance qui stope la programmation --
-- Les temperatures de consignes sont stockées en variable direct ----
-- dans domoticz pour être modifiées par l'interface web. ------------
----------------------------------------------------------------------
----------------------------------------------------------------------
-- VARIABLES UTILISATEUR : mettre les nom des dispositifs ici --------
----------------------------------------------------------------------
local VarConsJour = 'ConsigneJour' --Variable consigne jour
local VarConsNuit = 'ConsigneNuit' --Variable consigne nuit
local VarConsVac = 'ConsigneVacance' --Variable consigne vacances
local VarSomErr = 'SommeErreur' --Variable Somme des erreurs
local SondeCons = 'ConsigneChauffage' --Sonde de temperature
local InterEcoConfort = 'EcoConfort' --Interrupteur programmé Off:eco On:confort
local InterHorsGel = 'HorsGel' --Interrupteur On:mode hors gel>> plus de programmation, consigne vacance ou manuelle
local domoticz_url = '192.168.0.203:8080' --Adresse IP:port de Domoticz
local IDXcons = '54' --IDx de l'afficheur de consigne
----------------------------------------------------------------------
-- Fonction retourant la differrence de temps en secondes ------------
function timedifference(s)
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
t1 = os.time()
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = os.difftime (t1, t2)
return difference
end
commandArray = {}
-- Recuperation des variables ---------------------------------------
local ConsJour = uservariables[VarConsJour]
local ConsNuit = uservariables[VarConsNuit]
local ConsVac = uservariables[VarConsVac]
local Consigne = otherdevices_temperature[SondeCons]
local t1 = os.date("%H:%M")
-- Lorsqu'un interrupteur est manipulé on modifie la temperature de consigne.
-- La variable SommeErreur utilisée pour calculer le gain intégral est aussi remise à 0 >> Gain intégral=0
if (((devicechanged[InterEcoConfort] == 'On') and (otherdevices[InterHorsGel] == 'Off')) or ((devicechanged[InterHorsGel] == 'Off') and (otherdevices[InterEcoConfort] == 'On'))) then
print("-------------- Temperature modifiée vers Confort à "..t1)
-- Mise a jour de l'afficheur via JSON -----------------------------
local url = domoticz_url..'/json.htm?type=command¶m=udevice&idx='..IDXcons..'&nvalue=0&svalue='..ConsJour
commandArray[1]={['OpenURL']=url }
commandArray['Variable:'..VarSomErr]='0'
elseif (((devicechanged[InterEcoConfort] == 'Off') and (otherdevices[InterHorsGel] == 'Off')) or ((devicechanged[InterHorsGel] == 'Off') and (otherdevices[InterEcoConfort]=='Off' ))) then
print("-------------- Temperature modifiée vers Eco à "..t1)
-- Mise a jour de l'afficheur via JSON -----------------------------
local url = domoticz_url..'/json.htm?type=command¶m=udevice&idx='..IDXcons..'&nvalue=0&svalue='..ConsNuit
commandArray[1]={['OpenURL']=url }
commandArray['Variable:'..VarSomErr]='0'
elseif (devicechanged[InterHorsGel] == 'On') then
print("-------------- Temperature modifiée vers HorsGel à "..t1)
-- Mise a jour de l'afficheur via JSON -----------------------------
local url = domoticz_url..'/json.htm?type=command¶m=udevice&idx='..IDXcons..'&nvalue=0&svalue='..ConsVac
commandArray[1]={['OpenURL']=url }
commandArray['Variable:'..VarSomErr]='0'
end
return commandArray
et le suivant script_time_cmdchauffv2.lua:
-- script_time_cmdchauffv2.lua ---------------------------------------
-- G PETREMENT -------------------------------------------------------
----------------------------------------------------------------------
-- Permet de commander relais de pilotage de chaudiere à gaz ---------
-- Le cycle fait 900s / 15min ---------------------------------------
-- La commande est un nombre de 0 à 100 ------------------------------
-- Le cycle minimum de la chaudière est de 3min pour réduire l'usure -
----------------------------------------------------------------------
local InterOnOff = 'Chauffage On/Off' --Interrupteur général de mise en route du chauffage
local VarCmdChauff = 'CmdChauff' --Variable de commande de chauffage définie par script_device_thermostat
local CycleMini = 180 --Durée de chauffe minimum en secondes (fonction de la chaudière)
local InterRelais = 'Piface RelayChaud' --Sortie vers relais chaudière
local domoticz_url = '192.168.0.203:8080' --Adresse IP:port de Domoticz
-- Fonction retourant la differrence de temps en secondes
function timedifference(s)
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
t1 = os.time()
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = os.difftime (t1, t2)
return difference
end
commandArray = {}
-- Recuperation des variables
local CmdChauff = uservariables[VarCmdChauff]
local OnOff = otherdevices[InterOnOff]
-- Recuperation des minutes
time=os.time()
minutes=tonumber(os.date('%M',time))
hours=tonumber(os.date('%H',time))
-- Execution de cette partie du script toutes les 15 minutes
-- Contacte la chaudière et modifie la variable domoticz Cycle
if( (minutes==15) or (minutes==0) or (minutes==30) or (minutes==45) ) then
print('-- Lancement du script à '..hours..'h'..minutes)
print('-- OnOff ='..OnOff..' / CmdChauff ='..CmdChauff)
if OnOff == 'On' then --Si l'inter général est ON
local Cycle = CmdChauff * 9 --Calcul du temps de cycle en seconde
if Cycle < CycleMini then --Si le cycle est trop court on coupe
commandArray[InterRelais]='Off'
-- commandArray['Variable:'..VarCycle]= tostring('0')
print('Cycle :'..Cycle..'s >> Chaudière Off')
elseif Cycle > 870 then --Si le cycle est trop long (> 14min30) on allume sans coupure
commandArray[InterRelais]='On'
-- commandArray['Variable:'..VarCycle]= tostring(Cycle)
print('Cycle :'..Cycle..'s >> Chaudière On')
else --Enfin on lance pour X seconde
print('Cycle lancé pour : '..Cycle..'secondes')
commandArray[1]={[InterRelais]='On'}
commandArray[2]={[InterRelais]='Off AFTER '..tostring(Cycle)}
end
else
commandArray[InterRelais]='Off'
-- commandArray['Variable:'..VarCycle]= tostring('0')
print('Chaudière Off')
end
end
return commandArray
et voici une capture de ma page Domoticz:
Autres questions:
1) je ne sais pas comment entrer les valeurs des Constantes Kp Ki Kd dans ma régulation! elles sont déclarées comme des variables mais à aucun moment je n'ai vu une entrée de ces constantes.
2) Comment obtenir dans domoticz le tableau des variables:
3) Comment debuger un programme en script lua?
Merci d'avance à celui qui voudra bien me répondre.
Raspberry Pi model B+,Dongle WIFI, RFXComm,6 modules volet roulant BLYSS, sonde Oregon