Chapter 16. Analog
16.1 Filter Out High Frequencies (Quick and Dirty)
Problem
You want to filter out the high-frequency component of a signal, for instance, to convert a pulsed digital output into a smooth analog output using a low-pass filter.
Solution
In these circumstances, a simple RC filter (Figure 16-1) will suffice to remove most of the unwanted high-frequency PWM carrier.
Intuitively, all the resistor and capacitor do is make the output slow to respond to changes to the input. All that remains is to decide on suitable values for R and C. We can illustrate this with an example.
Figure 16-1. Low-pass Filtering of an Arduino-generated PWM Signal
The Arduino Mozzi library (Recipe 18.1) generates PWM (Recipe 10.13) audio output. The length of the pulses on the constant PWM frequency of 32.7kHz determine the amplitude of the lower frequency underlying the audio signal (440 Hz). Figure 16-2 illustrates this.
Figure 16-2. PWM of an Audio Signal
The average output voltage is shown ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access