Feedback loop for electrical circuit

David Gershon on 3 Aug 2021
Latest activity Reply by David Gershon on 4 Aug 2021

My simulink program require a feedback loop from an AC signal. How does one create a mean/ median value from a sinusoidal signal. Specifically, I want to average a power signal for last 0.1 sec and then adjust PWM signal.

Joel Van Sickel
Joel Van Sickel on 3 Aug 2021

Hello David,

if you have access to additional toolboxes, there is a moving average filter in simscape electrical as well as these filters: https://www.mathworks.com/help/dsp/mathematics-and-statistics.html?s_tid=CRUX_lftnav

alternatively, you can implement your own sliding window moving average filter using basic blocks from the simulink base components, specifically the discrete components. You will need to know your fixed step time in addition to how long you wan(0.1 seconds) so for instance, if you want a moving window average with 1 msec time steps, you will need to save the last 100 data points using a z transform and divide their sum by 100.

https://www.mathworks.com/help/simulink/discrete.html

Personally, I would use a z domain filter (called a "discrete filter" in the library) with numerator set to "[ones(1,N)/N]" and denominator set to "1". This will take N samples for a sliding window average.

David Gershon
David Gershon on 4 Aug 2021

Thanks for your quick response.