The algebraic loop comes from the "P" branch of the PID controller. This input of the Simscape network is directly dependent on one of its outputs -- hence an algebraic loop.
If you're modeling a control algorithm using PID, there's two primary fixes:
- As you said, a Unit Delay block is good if it's acceptable for you to model a sensor delay with a discrete sample time. This is typically okay if your PID controller is running in Discrete mode.
- You can use a Transfer Fcn block to create a low-pass filter (for example 1/(0.01s + 1) ). This will break your loop and still keep the signal in continuous time if that's what you need.
Note that the cut-off frequency of the low-pass filter approach should be chosen carefully so you don't filter any meaningful system dynamics out of the Simscape model. You want something large enough to avoid that, but not something too small because a higher frequency controller can slow down your simulation. The best thing is to try with and without the filter and see if the results match up.
- Sebastian