Moscow, Azovskaya 14
+7 (495) 310-97-15
Mo-Fr: 9.00 - 18.00 (Moscow time)
Order a call
Your name *
Enter phone *
Your Email *
Call me back
Linearly increasing function for heating process control

Software implementation of a ramp function

To smoothly change the control variable (SP setting), which sets the process value, according to the law of a linearly increasing function, the Ramp function block is used. This task is often in demand during heating or cooling processes for various inert processes (large furnaces, scientific implementations, food industry).

Processes process inputs and generates an analog output that is the setting for a specific controller to operate. The ramp function is intended for the technological process to reach the setpoint extended in time. The bit depth of the growth or deceleration process depends on the speed of the processor (duty cycle), the higher the bit depth, the more accurate (smoother the line) the process will be.

The block supports the ability to pause/decrease the ramp function depending on the needs of the process (for example, when there is no need for regulation). Allows for flexible customization.

The logic of the function block allows you to reach the floating setpoint (FSP) to the static setpoint (SP) in a given (RAMP_TIME) time. This deceleration by process control is required for inertial processes.

Ramp processes are most often used where there are tasks of temperature control (control of the heating process). When the temperature of the furnace or any other device cannot be quickly heated or cooled by technology. I used such functions in the operation of greenhouse complexes, when drying and firing bricks, when hardening metal products, and in fruit ripening systems. We do not manage the variable of the object itself, but work with the value of the controller, which regulates the temperature of the object using heat, gas or other control methods.

Линейно-нарастающая функция

Below is the program code for programming the RAMP function for linear incremental technological processes. When it is necessary to increase or decrease the set value from the initial value to the final value for a specified time interval or at a specified rate, for example, 2C per hour.

It is important to note here that for this function to work correctly, we need a variable associated with the controller's system time. The variable is constantly changing in the code of this block. The launch process itself is based on remembering the start time and calculating the time until which the function will follow.
This program code is taken from a program written for Codesys 2.3, but with minor modifications it will work in other systems where the ST (Structured Text) language is implemented in accordance with the standard.

The block starts with an announcement.

Be sure to comment your code. This will reduce the security of your solution, but increase clarity and readability.

Линейно-временная функция RAMP

    TE_SP_1:REAL;(* The value from which we started *)
    TE_SP_2:REAL;(* The meaning to which we are going *)
    SPEED:REAL;(* The speed with which we must reach the set value *)
    OUT:REAL; (*Output variable that is tied to the setpoint *)
    State:INT; (*Step number we are on *)
    Complite:BOOL;(* We set the flag that the ramp has finished *)
    START_TIME:TIME;(* The time when the count is expected to complete *)
    FINISH_TIME:TIME;(* The time when the count is expected to complete *)

TIME_MAIN:TIME;(* Total ramp time *)
First:REAL;(* Interval start value *)
Second:REAL;(* Interval end value *)
GRADUS:REAL;(* Calculate the difference in degrees *)
TON2:TON;(* Таймер от зависания в стадии перехода через 0*)
Cur_Timei:DWORD;(* To calculate the transition through 00:00:00*)
AM:REAL;(* Difference Between Set and Process Variable *)
OS:REAL;(* The value of the process variable at the beginning of the function *)
Err:REAL;(* Decreasing error *)
tx:TIME;(* PLC current time *)
tx1:TIME;(* Remembering the PLC time at the beginning of the count *)
txr_diff:REAL;(* Rising time in REAL format *)
fr:REAL;(* Calculated gain factor, angle of inclination *)
R_TRIG:R_TRIG;(* We catch the transition, the end of RAMP *)


Now a little about the code of this function block. The code is executed on the CASE statement, which is convenient for the implementation of the state machine. This is when at any particular moment in time some part of the program code is being executed, while the rest of the program code is in a waiting state. It is possible to make various flexible combinations similar to the SFC language. The transition from step to step is controlled using the integer variable State

0:(* At this step, we stand and wait, initialize the variables *)
OUT:=TE_SP_1; (*Assigning an initial value to the output *)
START_TIME:=T#0m; (*Reset start time *)
FINISH_TIME:=T#0m; (*Reset end time *)
IF START THEN  State:=1; END_IF; (*If the start button is pressed, then go to the next level *)

1:(* Determine the start time of the function, calculate the time and move on *)
Complite:=FALSE;(* Resetting the end sign *)
GRADUS:=ABS(TE_SP_2 - TE_SP_1);(* Calculate the degree difference *)
First:=TE_SP_1;(* remember the first number *)
Second:=TE_SP_2;(* remember the second number *)
txr_diff:=1;(* We assign 1 variable, which is responsible for the angle of inclination of the function *)
TIME_MAIN:=(REAL_TO_TIME(GRADUS/SPEED)*1000*60*60);(* Calculate how long to increment the function *)
fr:=txr_diff/DINT_TO_REAL(TIME_TO_DINT(TIME_MAIN));(* The time over which the function should increase or decrease. Calculates the increment/decrement factor *)
tx:=T#0s;(* Zeroed the time increment *)
Err:=0.0;(* Zeroed the mismatch increment *)
AM:=Second - First;(* Calculate the distance in degrees between two points *)
OS:=First; (*Remember where we're coming from *)
tx1:=PLC_TIME; (*Remembering the time before the start of the ramp *)

2:(*Делаем RAMP from first to second point*)
tx:=PLC_TIME;(* Time cyclically accumulates*)
txr_diff:=DINT_TO_REAL(TIME_TO_DINT(tx)) - DINT_TO_REAL(TIME_TO_DINT(tx1));(* Difference between memorized time and current time *)
fr:=txr_diff/DINT_TO_REAL(TIME_TO_DINT(TIME_MAIN));(* The time over which the function should increase or decrease. Calculates the increment/decrement factor *)
IF First<Second THEN Err:=Second - OUT; END_IF;(*0- rise*)
IF First>Second THEN Err:=OUT - Second; END_IF;(*1- fall*)
OUT:=AM * fr + OS;(* General linear dependence*)
R_TRIG(CLK:=Err< 0);(* We are waiting for the transition through zero*)

3:(* The ramp worked*)
OUT:=TE_SP_2;(* We leave the second value on the output*)
START_TIME:=T#0m;(* Делаем визуализацию переменных времени Making the visualization of time variables*)
FINISH_TIME:=TIME_MAIN;(* Making the visualization of time variables*)
Complite:=TRUE;(* We set a sign that it has ended*)

IF NOT START THEN State:=0; END_IF;(* We return, if the START button has ceased to operate, to step 0*)

Линейно-нарастающая функция RAMP

Линейно-нарастающая функция RAMP

Application Features

The angle of inclination of the linear-increasing function at the initial impact (START) occurs in time (RAMP_TIME), all subsequent jumps of the static setpoint (SP) occur at a rate of one degree per minute.

Recommendations for use

Линейно-нарастающая функция Step7

The output from the function block serves as a setpoint for the controller. The variables FSP_SP SP_PV, provide visualization of the values assigned to the output in the body of the block. FSP_SP is assigned if the measuring part of the process has crossed the SP boundary, and SP_PV if FALSE is assigned to the input of the START block. If the variable INDIRECT is activated (TRUE), then the geometric location of the angle of inclination of the FSP is reversed and the function is changed. The choice of the value of this input depends on the nature of the operation of the linear-increasing or linear-decreasing function block

I post another code of this FB RAMP


#RAMP, #Linearincrementing function, #Controloftheheatingprocess

Be the first to comment

You comment add