Logic Machine Forum
Outside compensation curve - 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: Outside compensation curve (/showthread.php?tid=1770)



Outside compensation curve - oyvindnordbo - 04.12.2018

I have tried to make an outside compensation curve for a heating system in the FB editor, but do not find out completely of unwanted blocks that are most powerful to use.
I need to write from four groups
-10 ° C = 45 ° C
-5 ° C = 40 ° C
0 ° C = 35 ° C
5 ° C = 30 ° C
In order to get a set point out of what outdoor temperature it is, is this possible?


RE: Outside compensation curve - admin - 04.12.2018

Do you really need a curve here? From your data it looks like simple linear compensation, for each 5 degrees of temperature the setpoint is lowered by 5 degrees:
Code:
setpoint = 35 - temperature



RE: Outside compensation curve - oyvindnordbo - 04.12.2018

Yes wee need a curve besause all values is going to be able to change in the visualizatione


RE: Outside compensation curve - admin - 04.12.2018

This might be helpful: http://lua-users.org/wiki/SimpleFit


RE: Outside compensation curve - Daniel - 04.12.2018

There is block in match advance curve function with 2 points, it might be good starting point.


RE: Outside compensation curve - merel - 04.12.2018

Hello.

You can try this:

Code:
function linear_by_table(input,curve,offset)
local FDY = offset or 0
    fk1= (curve["y"][1] - curve["y"][2]) / (curve["x"][1] - curve["x"][2])
    fk2= (curve["y"][2] - curve["y"][3]) / (curve["x"][2] - curve["x"][3])
    fk3= (curve["y"][3] - curve["y"][4]) / (curve["x"][3] - curve["x"][4])

    if input < curve["x"][1] then
        out = curve["y"][1] + FDY;
    elseif input >= curve["x"][1] and input < curve["x"][2] then    
        out = fk1 * (input - curve["x"][1]) + curve["y"][1] + FDY
    elseif input >= curve["x"][2] and input < curve["x"][3] then
        out = fk2 * (input - curve["x"][2]) + curve["y"][2] + FDY
    elseif input >= curve["x"][3] and input < curve["x"][4] then    
        out = fk3 * (input - curve["x"][3]) + curve["y"][3] + FDY
    else
        out = curve["y"][4] + FDY
    end
 return out
end

curve = {}
curve["x"] = {-20,-10,0,20}
curve["y"] = {80,70,65,18}

--offset=2
--log(linear_by_table(20,curve,offset))
log(linear_by_table(-15,curve))