Algebraic loop: PID control DC motor in Simscape

I am trying to add a PID controller to the elec_motor_dc_pwm.slx DC motor Simscape example:
Original model:
My model:
However, Simscape complains about an algebraic loop in the feedback path.
This answer says models shouldn't contain both "physical signal to simulink" and "simulink to physical signal" converter blocks. (My picture does.) But then how do you design a feedback controller?
This Simscape help page suggests replacing the "PS-to-S" blocks with blocks like "PS Subtract" and "PS Gain". However, there is not a "PS Derivative" block, which would be needed for a PID controller.
Here is a link to these two models.
Thanks for your help.

 채택된 답변

Sebastian Castro
Sebastian Castro 2017년 10월 11일

1 개 추천

Check out this blog post -- I think it sums up pretty well how to address algebraic loops with continuous dynamics (like that PID block):
- Sebastian

댓글 수: 3

Thanks Sebastian. The article suggests inserting a transfer function into the feedback path with a time constant that's smaller than the system's dynamics. However, this seems like a hack to introduce additional dynamics to avoid an algebraic constraint, especially because Simscape is designed to solve algebraic constraints with its DAE solver.
I'd be happy to implement my controller in Simscape, but that's difficult because there's no derivative block. I could perhaps write the PID block as a monolithic Simscape component. Does this seem like a suitable solution -- to have everything written in Simscape?
You're right that this approach is a numerical "hack" IF the controller is an analog/continuous-time controller like in your model.
If you're implementing such a continuous-time derivative fully in Simscape, you should be able to do it using the Simscape Language. The equations have a "der" keyword so you can probably create a block that takes in the signal u and its integral uIntegral and then use a component equation like:
output == Kp*u + Ki*uIntegral + Kd*u.der;
The other option is to move the "hack" into the computation of the derivative, in that you can calculate a filtered derivative instead of a perfect one.
For practical applications, your PID controller will likely be discrete. At that point, you can break the loop with a Unit Delay block (at the same sample time of the controller) to mimic the delay in getting a sensor reading into the controller at the following time step.
- Sebastian
Thanks Sebastian. This seems promising.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Francisco J. Triveno Vargas
Francisco J. Triveno Vargas 2024년 7월 9일

1 개 추천

Only is necessary include the memory block to cancel the algebric loop.

커뮤니티

더 많은 답변 보기:  Power Electronics Community

카테고리

질문:

2017년 10월 11일

댓글:

2025년 3월 10일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by