First thing : the filter has normally NOT a very steep transition frequency from frequencies which pass to frequencies which are stopped, e. g. if you need that you should use two filters : one LPF from 0 to 20 KHz and one HSF from let's say 21 KHz to infinity. In this case the frequencies from 0 to let's say 18 KHz will pass, and frequencies above 22KHz will be stopped. It depends on how your filters are designed.
Second thing : You should study how to compute the parameters for filters with analog components( C, capacitors and L, inductances) and when you understand that , you should go to Matlab and Simulink, which let you design any kind of filter you want, but you have to know what you are doing
Yes, you can use a Triggered Subsystem in MATLAB Simulink to implement a low-pass filter on a PWM signal. The Triggered Subsystem allows you to execute a block of Simulink model when a specific condition is met, which in this case would be the PWM signal exceeding a certain frequency threshold.
A high-level overview of how you can design this technique in MATLAB Simulink is:
1 - Generate the PWM signal: Start by generating the PWM signal that you want to filter. You can use appropriate blocks or functions in Simulink to generate the PWM waveform based on your requirements.
2 - Measure the frequency: Use a frequency measurement block or algorithm to measure the frequency of the PWM signal. This could be achieved using techniques such as zero-crossing detection or FFT analysis.
3 - Compare with the threshold: Compare the measured frequency with the desired frequency threshold (20 kHz in your case). You can use a Comparison block or an if-else condition to make this comparison.
4 - Triggered Subsystem: Inside the Triggered Subsystem block, design the low-pass filter. You can use standard Simulink blocks, such as a Discrete-Time Integrator and a Discrete-Time Transfer Function block, to implement a simple low-pass filter. Adjust the filter parameters based on your desired cutoff frequency.
5 - Connect the subsystem: Connect the output of the Triggered Subsystem to the appropriate output in your Simulink model, so that the filtered PWM signal can be utilized for further processing or analysis.
6 - Configure the Trigger: Set up the trigger condition for the Triggered Subsystem. In this case, the trigger condition would be the comparison result from step 3.
7 - Simulate and analyze: Simulate the Simulink model and observe the filtered PWM output. Verify that the frequencies above 20 kHz are effectively attenuated while the frequencies below 20 kHz are passed through.
It's important to note that the specific details of your implementation may vary depending on your PWM signal source, sampling rate, desired filter characteristics, and any other additional requirements. Experimentation and fine-tuning may be necessary to achieve the desired filtering behavior.
By utilizing the Triggered Subsystem and appropriate filter blocks, you can implement a low-pass filter on a PWM signal in MATLAB Simulink, removing high frequencies above the specified threshold while allowing frequencies below it to pass through.