Hey guys. I was wondering if it’s possible to calculate the integral in a logic? I wanna build a pi regulator for my underfloor heating
If you know the math and how to program it there is nothing stopping you. The Rules Domain Specific Language (DSL) is Turning Complete so if it can be calculated you can write a Rule(s) to calculate it.
However, there won’t be a whole lot of direct support. I don’t think OH includes any third party math libraries so you will need to write the code to do it yourself (maybe the Trapezoidal method). I’m not sure if there is away to add and make available third party libraries to Rules.
Normally a P regulator is enough due to the heat capacity in your system.
Yes I know, but I need a functionn or formula to calculate the integrale… May do some research to see how to calc it on my calculator I just press “integrate”
I don’t think a P regulator is enough, this will create a static offset all ways…
I did a piece of python code for the PI regulator
with publish and subscriptions to/from mqtt is it easy to control from openhab.
With a Raspberry, I2C D/A and some opamp “glue” it is easy to control a 0-10V propotional valve.
If you use waterbased underfloor heating, take a look at getting the temperature in the FUTURE for your shunt valve.
I use yr.no to get the temperature 6 hours in the future, to control the temperature of the underfloor heating.
I use wireless Roth Touchline for room control - also controlled from openhab.
Awesome, I’ll take a look in to it… Actually as I understand it, the python code could be implemented into openhab…
Indeed a good idea to get the temperature 6 hours in front, should make the regulation much better… Are you controlling the temperature on the floor from this? Or the heating source?
Can you publish that code? Have you been able to use yr instead of yahoo weather?
Regarding using PI regulator: [quote=“Rasmus7700, post:4, topic:8600”]
I don’t think a P regulator is enough, this will create a static offse
Well not even P regulator is needed since the temperature inside your flat changes so slowly:
If temp>22 heating off
if temp<20 heating on
Is more than enough, I went down the same path as you in the beginning but after listening to expert on the forum such as @rlkoshak I went for a much simpler regulator.
I can’t show the PI regulator, it is not working satisfactory for public viewing
but the P regulator is extremely simple
I have organised the python file to do several things every 60 seconds
read the data from yr.no, poll all onewire sensors, poll dht11 sensors, poll roth controller, write log, look at received mqtt data, etc.
with the right knowledge of the ‘future’ you don’t need the integral with windup and all associated problems. a simple P regulator will do the job.
Especially coupled with a heat requirement-curve ( i got it from https://de.wikipedia.org/wiki/Heizkurve )
Yes, the yr.no was not really that hard (i googled your name )
I save the html file to /tmp and parse down to the line i want, and into the line for the temperature i want.
#run at 45 second in the minute cycle sys.stdout.write("get_yr"); yr_data=read_yr() print("yr_data : "+str(yr_data)) yr_num=float(yr_data) mqttc.publish("/python/yr/6h/",yr_num); ######################## vejrkompensering ############################## Tforward = (0.55)*tilt*((goaltemp)**(yr_num/(320-yr_num*4)))*((-yr_num+20)*2)+goaltemp+comfort_compensation sys.stdout.write (" fremlob : "+str(Tforward)) sys.stdout.write (" yr_num : "+str(yr_num)) sys.stdout.write (" goal : "+str(goaltemp)) sys.stdout.write (" tilt : "+str(tilt)) print (" comp : "+str(comfort_compensation)) ######################## vejrkompensering ############################## mqttc.publish("/python/comp/tforward/",Tforward); mqttc.publish("/python/comp/soll/",solltemp); mqttc.publish("/python/comp/tilt/",tilt); mqttc.publish("/python/comp/comp/",comfort_compensation); get_yr_flag=True
@skatun - a underfloor heating system shows a typical behaviour of a badly compensated PI regulator.
when the temperature is too low, (P too low) the room will never reach desired temperature
when the temperature is too high (P too high) it will oscillate between hot and cold
It is all in the nature of the on/off valve on the distribution block.
I have RRD graphs to prove my point.
I have set up my heatcurve to ‘just under enough’ temperature, to avoid oscillations.
the goal is to have the on/off valve never (or almost) never to shut off.
Any home needs a slightly higher water temperature when the weather is cold.
if the water temperature is too high the valve for that room, will shut down the circuit.
and then the floors will cool down for some hours to come - usually they are too cold in the evening, exactly at the time when you need the heating the most, because outdoors is cooling down.
do not mistake on/off control with a true PI loop. I can write a whole book about this but I will try to make it simple. I write a lot of these routines for PLCs so I will approach it as such.
For on/off control you simply use comparators and the switch point for this is a little lower than your setpoint.
A PI loop has an analog output (this includes an motor controlled valve the difference there is that you use 2 digital outputs)
Proportional is the easiest you subtract the actual from the setpoint this will give you the loop error, multiply this error with a number large enough to drive your output, this is your true proportional.
Integrator, so the idea is that you charge a capacitor, in logic you build a clock you have to make sure that it is 3 times slower than the scan time of your program.
from the clock you trigger at one of the edges, when this happens you multiply the loop error and add this to the previous value eg I+newI=I
all you have left now is to add the prop with the I.
A quick note make sure you have an as high resolution actual as you can it will improve the loop response.
@polarit er du dansker? Kan se du har skrevet vejrkompensering i dit script
The on/off regulation is what I do now, but as @polarit says this leads to cold floors sometimes on the day… That was why I was thinking on the PI loop, then simply open the valves a bit to keep the floors at a comfort temperature…
Currently now I can’t control the set point on my heat pump, it is running “it’s own life” but maybe I need to do something to can control it… Then I can set the setpoint according to the yr.no data - Ian that what you mean @polarit
@Carel I also do this kind of regulation on Plc for living, but here you simply use function block - I don’t write the code for the PID regulator my self… That why I don’t know how to calc the integrale here in OH
@Rasmus7700 Jep, det er præcis hvad jeg er
Vi kan kommunikere off-line ?
One of the places i started was “PID without a PHD” http://cms.edn.com/contenteetimes/documents/embedded.com/2000/f-wescot.pdf
SInce i ‘know’ the future, i don’t need integrator and derivate part of the PID.
just enough P gain to not overshoot during the rise and fall of temperatures.
and a static additon - this is where the heatcurve comes in to the picture.
When all room circuits are closed, and the pump is stopped, i have to freze the output at last calculated temperature, otherwise it will open the shunt valve fully to try to keep the temperature - takes too much pressure from the other (non-underfloor) circuits.
oh - and build in a function to cycle the proportional valve once a month, from fully open to fully closed - that way the valve will never get stuck.
What kind of heatpump - maybe something can be hacked into the circuits, or a signal ‘liftet’ out of the controller. and another put in to fool it.
Some (many) heatpumps and furnaces uses EBUS, check it out : http://ebus-wiki.org/doku.php
@polarit - har sent dig en PM
I thought it was electrical heating, my mistake. Sorry folks.
Sorry for bringing up an old topic.
Kenneth I’m just curious about how you communicate with the Roth system.
I have just installed the Touchline controller, and would like to get the temperature readings from the thermostats into Openhab, but I’m nut sure how to do this. I’m definitely not an expert in programming, and still new to linux systems.