This is the solution i came up with, in case someone else need this.

This function calculates the remaining kW wich are given by Heat7KwA with TRIAC.

**Code:**

FUNCTION_BLOCK HeatControl

VAR_INPUT

CmdSignal : INT := 0;

END_VAR

VAR_OUTPUT

Heat7KwA : BOOL := FALSE;

Heat7KwB : BOOL := FALSE;

Heat14Kw : BOOL := FALSE;

Heat27Kw : BOOL := FALSE;

Heat55Kw : BOOL := FALSE;

Triacscaled: INT := 0;

END_VAR

VAR

Triac : INT := 0;

END_VAR

**Code:**

Triacscaled := (CmdSignal - Triac) * 100 / 7;

IF CmdSignal >= 103 THEN

Heat7KwB := TRUE;

Heat14Kw := TRUE;

Heat27Kw := TRUE;

Heat55Kw := TRUE;

Triac := 103;

ELSIF CmdSignal >= 96 THEN

Heat14Kw := TRUE;

Heat27Kw := TRUE;

Heat55Kw := TRUE;

Triac := 96;

ELSIF CmdSignal >= 89 THEN

Heat7KwB := TRUE;

Heat27Kw := TRUE;

Heat55Kw := TRUE;

Triac := 89;

ELSIF CmdSignal >= 82 THEN

Heat27Kw := TRUE;

Heat55Kw := TRUE;

Triac := 82;

ELSIF CmdSignal >= 76 THEN

Heat7KwB := TRUE;

Heat14Kw := TRUE;

Heat55Kw := TRUE;

Triac := 76;

ELSIF CmdSignal >= 69 THEN

Heat14Kw := TRUE;

Heat55Kw := TRUE;

Triac := 69;

ELSIF CmdSignal >= 62 THEN

Heat7KwB := TRUE;

Heat55Kw := TRUE;

Triac := 62;

ELSIF CmdSignal >= 55 THEN

Heat55Kw := TRUE;

Triac := 55;

ELSIF CmdSignal >= 48 THEN

Heat7KwB := TRUE;

Heat14Kw := TRUE;

Heat27Kw := TRUE;

Triac := 48;

ELSIF CmdSignal >= 41 THEN

Heat14Kw := TRUE;

Heat27Kw := TRUE;

Triac := 41;

ELSIF CmdSignal >= 34 THEN

Heat7KwB := TRUE;

Heat27Kw := TRUE;

Triac := 34;

ELSIF CmdSignal >= 27 THEN

Heat27Kw := TRUE;

Triac := 27;

ELSIF CmdSignal >= 21 THEN

Heat7KwB := TRUE;

Heat14Kw := TRUE;

Triac := 21;

ELSIF CmdSignal >= 14 THEN

Heat14Kw := TRUE;

Triac := 14;

ELSIF CmdSignal >= 7 THEN

Heat7KwB := TRUE;

Triac := 7;

END_IF