Please take a minute to review and accept our Terms of Use.
Welcome to the PLECS User Forum, where you can ask questions and receive answers from other members of the community.

Many technical questions regarding PLECS are answered on the Technical Solutions page of our website. Tutorial videos, specific application examples, and pre-recorded webinars are available on our YouTube page. Please follow us on LinkedIn for the latest Plexim news.

Integrator with anti-windup

0 votes
Hi everyone!

I would like to build a continuos integrator block in C-script with an anti-windup protection.

I need a C-script because I have time-varying saturation limits and I don't know which library block to use.

I attached the Plecs file so you can see my work.

What I would like is to block the integration when I exceed the saturation and get out as soon as the input " discharge " the integral. (solve the wind-up problem)

Can someone help me please? Thank you so much.
asked Nov 13, 2018 by nikilito (113 points)
retagged Nov 14, 2018 by nikilito

1 Answer

+1 vote


The main problem: you are assigning your derivative only if the integrator isn't locked, but you don't set the derivative to zero if it is locked, so the derivative remains at the last value set before being locked.

To further improve the implementation:

  • Use two separate lock states inLowerLimit and inUpperLimit
  • Leave the lock states if the input is negative (for inUpperLimit) or positive (for inLowerLimit)
  • Limit the continuous state instead of just the output, otherwise you'll end up with numeric errors

Kind regards,

Oliver Schwartz


answered Nov 15, 2018 by Oliver Schwartz (622 points)
edited Nov 15, 2018 by Oliver Schwartz