Skip to content

Problem with Step Tunning at line 244 "calculate the standard deviation" #1

@succZS

Description

@succZS

I really like this PID Controller, but I have one issue.

When I try to use the Step Tuning feature, I always get 0 or close to 0 as the calculated ioKp. I have a really stable input at the start.

I think it's because of these lines of code:

―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
REGION Step tuning
CASE #statStepTuning.state OF
0:
REGION Initialize tuning
// Init tuning variables
#statStepTuning.find_u_max := #temp_uF; // Let's say I have a 20.0°C input, so #statStepTuning.find_u_max = 20.0
#statStepTuning.find_u_min := #temp_uF; // Let's say I have a 20.0°C input, so #statStepTuning.find_u_min = 20.0
#statStepTuning.calc_u_dev := 0.0;
#statStepTuning.calc_u_start := 0.0;
#statStepTuning.find_k_inflection := 0.0;
#statStepTuning.find_u_inflection := 0.0;
#statStepTuning.find_t_inflection := 0.0;
#statStepTuning.calc_m := 0.0;
#statStepTuning.calc_L := 0.0;
#statStepTuning.calc_Kc := 0.0;
#statStepTuning.calc_Ti := 0.0;
#statStepTuning.calc_Td := 0.0;
#statStepTuning.t := 5.0;

            // Transition
            #statStepTuning.state := 1;
        END_REGION
        
    1:
        REGION Calculate the standard deviation
            // Find min and max input
            IF #temp_uF > #statStepTuning.find_u_max THEN   // This condition becomes (IF 20.0 > 20.0 THEN...), which is false.
                #statStepTuning.find_u_max := #temp_uF;
            END_IF;
            IF #temp_uF < #statStepTuning.find_u_min THEN   // This condition becomes (IF 20.0 < 20.0 THEN...), which is also false.
                #statStepTuning.find_u_min := #temp_uF;
            END_IF;
            
            // Calculate the standard deviation
            #statStepTuning.calc_u_dev := #statStepTuning.find_u_max - #statStepTuning.find_u_min; // This calculation is (20.0 - 20.0), resulting in 0.0.
            
            // Transition
            // Timer runs out / calculate starting point
            IF #statStepTuning.t <= 0.0 THEN
                #statStepTuning.t := 0.0;
                
                // Adjust derivative filter to corresponding deviation
                #statAdvanced.derivateFilter := #statStepTuning.calc_u_dev * 40.0; // This becomes (0.0 * 40.0), which basically disables the derivative filter.
                #statAdvanced.derivateFilter := #statStepTuning.calc_u_dev * 40.0; // This becomes (0.0 * 40.0), which basically disables the derivative filter.
                // Save starting point
                #statStepTuning.calc_u_start := #statStepTuning.find_u_min + #statStepTuning.calc_u_dev / 2; //This becomes (20.0 + 0.0) /2 
                #statStepTuning.find_k_inflection := #"temp_du/dt"; // Save slope
                
                // Save start output
                #statStepTuning.find_y_start := #statOut;
                
                // Increase output to make a step
                #statOut := #statAdvanced.outMax;
                
                // Change state
                #statStepTuning.state := 2;
            ELSE
                // Decrease step timer
                #statStepTuning.t := #statStepTuning.t - #temp_dt;
            END_IF;

―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
If I am wrong, feel free to correct me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions