Simulink - unsolvable algebraic loop when using discrete shift register

1 view (last 30 days)
Hi.
I am trying to design a controller in Simulink that makes sure the moving average (mean value of the last 10 minutes) stays below a given limit. The error is fed into a PID controller and its output is used as the input for the next loop. When using an integrator and dividing the output with the output of a clock, I get the average of the entire time series, and the simulation runs just fin.. However, I need to limit the moving average to the last 10 minutes. To do this, I chose to replace the integrator/clock combo with a discrete shift register with the number of samples to save set equivalent to 10 minutes, followed by a mean block, which finds the mean value over the entire input.
When running the simulation with this combination, I get the error "Simulink cannot solve the algebraic loop containing 'Model/*Block following moving average*' at time 20695.5 [this is the around the time the disturbance values are non-zero]. using LineSearch-based algorithm due to one of the following reasons: the model is ill-defined i.e., the system equations do not have a solution; or the nonlinear equation solver failed to converge due to numerical issues.
Both solutions suggested (changing to TrustRegion-based algorithm) and reducing the fixed step size do not work. Reducing the number of samples in the discrete shift register by half seems to get rid of the error, but I need the moving average of 10 minutes.
If anyone has an idea how I could solve this problem, please let me know!
Update: Using the windowed integrator followed by a gain of 1/(time sample) causes the same error. Without the gain it runs fine, but gives me incorrect results.
Thanks!
Marc
UPDATE 2: I have found the cause for the error. It occurs when the error comes close to zero. I think this will be possible to solve...

Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!