PI Controller oscillating between limit values

madtorresga
Sun, 10 Aug 2025 11:55:24 +0000
Specific Domains

Hello,
I’m trying to implement a PI controller that turns on once the cell goes out of the voltage limits. My model looks something like this:

@mtkmodel Cell begin
...
    @components begin
...
        deadzone = DeadZone(u_max=4.1, u_min=2.6)
        feedback = Feedback()
        pi_controller = PI(k = 1, T = 0.01)
    end
    @equations begin
        deadzone.input.u ~ v
        feedback.input2.u ~ 0
        connect(deadzone.output, feedback.input1)
        connect(feedback.output, pi_controller.err_input)
        connect(output, pi_controller.ctr_output)
        #output.u ~ ifelse(feedback.output.u == 0, 0, pi_controller.ctr_output.u)
    end
end

@mtkmodel OneCell begin
    @components begin
...
        setpoint = RealOutput()
        limiter = Limiter(y_max=4.8)
    end
    @equations begin
...
        limiter.input.u ~ setpoint.u - cell.output.u
        setpoint.u ~ i_profile(t)
    end
end

The problem is the PI is still turned on even when the feedback signal reaches 0 again, and only changes once the opposite limit is reached, like bouncing all the time between those values. Any ideas on how to turn it off when it is back in a safe range? Thanks

5 posts - 2 participants