Feedback loop for electrical circuit
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.
2 Comments
Time DescendingHello 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.