Logic Machine Forum
PID thermostat with LogicMachine - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: PID thermostat with LogicMachine (/showthread.php?tid=386)



PID thermostat with LogicMachine - Domoticatorino - 12.09.2016

Hi,
as you know on example section there is script to realise 30 PID Thermostats. As you can see PID is 1 byte but I should manage the histeresy in 1 bit. 2 point valve on/off.

Have you idea to modify the PID script?

Thank you very much.

Claudio


RE: PID thermostat with LogicMachine - Erwin van der Zwart - 12.09.2016

Hi Claudio,

You can put a event based script on the 1 byte output and write a bit output to another object

Code:
output = event.getvalue()
if output > 0 then
   -- Get value of object to avoid write true on each 1-100 value
   bitvalue = grp.getvalue('yourbitobject')
   if bitvalue == false then
      grp.write('yourbitobject', true)
   end
else
   -- Get value of object to avoid write false on each 0 value
   bitvalue = grp.getvalue('yourbitobject')
   if bitvalue == true then
      grp.write('yourbitobject', false)
   end
end

BR,

Erwin van der Zwart


RE: PID thermostat with LogicMachine - buuuudzik - 12.09.2016

Maybe the solution is the PWM controller? For example when your value is 50% and time T is e.g. 1hour your valve will be switched on for 30minutes and switched off for 30minutes. It will be better for the relay because you will have less switching.


RE: PID thermostat with LogicMachine - admin - 13.09.2016

Or you can just modify setoutput function to send boolean true when value >= 10, false otherwise:

Code:
function PID:setoutput()
  local t, value

  self.output = math.max(self.output, self.params.min)
  self.output = math.min(self.output, self.params.max)

  value = math.floor(self.output) >= 10
  t = type(self.params.output)

  if t == 'string' then
    grp.write(self.params.output, value, dt.bool)
  elseif t == 'table' then
    for _, output in ipairs(self.params.output) do
      grp.write(output, value, dt.bool)
    end
  end
end



RE: PID thermostat with LogicMachine - Domoticatorino - 22.11.2016

Thank you very much for your effort.


RE: PID thermostat with LogicMachine - buuuudzik - 25.11.2016

How can I use this script for individually controlling a few zones? Could somebody prepare some little example?


RE: PID thermostat with LogicMachine - admin - 25.11.2016

You can either create a new script for each zone, or several instances per script.
Code:
if not p1 then
  p1 = PID:init({ ... })
end

if not p2 then
  p2 = PID:init({ ... })
end

p1:run()
p2:run()



RE: PID thermostat with LogicMachine - leonidas - 11.07.2017

How can I stop this thermostat?
http://openrb.com/example-pid-thermostat-with-lm2/


RE: PID thermostat with LogicMachine - admin - 11.07.2017

You can set manual parameter to a group address. Setting this group to true will disable the PID algorithm.


RE: PID thermostat with LogicMachine - Bobby - 07.10.2018

I have an on/off output, and this works ok. But is it possible to get the output to work like, with 10% gain, it will have 1 min on, and 9 min off. with 60% gain, 6 min on, and 4 min off?
i hope you understand what im meaning..

Today its like attached picture. 
But the water haeating system will then have a warm floor when on, and cold when off. is it possible to have the thermostat work in cycles?


RE: PID thermostat with LogicMachine - admin - 08.10.2018

Use this script (resident, sleep time = 5 seconds) to convert 0..100% value to slow PWM (proportional on/off). Change input/output objects and period time as needed.

Code:
input = '1/1/1' -- proportional value input (0..100%) object
output = '1/1/2' -- on/off output object
period = 10 * 60 -- 10 minutes in seconds

date = os.date('*t')
seconds = date.hour * 3600 + date.min * 60 + date.sec

curr = seconds % period
perc = math.floor(curr / period * 100)

state = grp.getvalue(input) > perc
grp.checkwrite(output, state)



RE: PID thermostat with LogicMachine - Bobby - 08.10.2018

Hi again!

then i changed my residential script back to basic, as shown here: http://openrb.com/example-pid-thermostat-with-lm2/
add another residential script, as described above.

I cannot get any output for 1 byte scaled object. it shows 0% even if the setpoint is 5 degrees higher than current value.
if i change the scaled object to 50%, the output will change from '0' to '1'. so the last script should be ok.
please take a look at the attached pictures, and tell me where i went wrong...


RE: PID thermostat with LogicMachine - admin - 09.10.2018

You need to change the PID user library back to the original version and do full resident script restart via disable/enable, otherwise new library code won't load.


RE: PID thermostat with LogicMachine - Bobby - 09.10.2018

Yeay. did a backup, rebooted. When started up, 16 of my OV - PID adresses was gone. run the backup, still missing. what happened? is this a fault in LM? all the values was 0%. do they need to be changed for remembering?

Actually, several group addresses, who i have changed name on, is missing???


RE: PID thermostat with LogicMachine - admin - 09.10.2018

Looks like microSD card in your LM became read-only. You need to replace it with a new one an run recovery procedure. See more info here: http://openrb.com/reflash-logicmachine3-and-streaming-player-software/


RE: PID thermostat with LogicMachine - Bobby - 09.10.2018

(09.10.2018, 11:23)admin Wrote: Looks like microSD card in your LM became read-only. You need to replace it with a new one an run recovery procedure. See more info here: http://openrb.com/reflash-logicmachine3-and-streaming-player-software/

What is recommended size?


RE: PID thermostat with LogicMachine - Daniel - 09.10.2018

(09.10.2018, 12:30)Bobby Wrote:
(09.10.2018, 11:23)admin Wrote: Looks like microSD card in your LM became read-only. You need to replace it with a new one an run recovery procedure. See more info here: http://openrb.com/reflash-logicmachine3-and-streaming-player-software/

What is recommended size?

It is up to you, we use from 4GB and up.


RE: PID thermostat with LogicMachine - Bobby - 09.10.2018

Changed the SD card, everything is ok again. thanx!