AN296094 Method For Converting A PWM Output To An Analog Output When Using Hall Effect Sensor ICs
AN296094 Method For Converting A PWM Output To An Analog Output When Using Hall Effect Sensor ICs
AN296094 Method For Converting A PWM Output To An Analog Output When Using Hall Effect Sensor ICs
D = tON / TPWM
A current sensor with PWM output is a very useful type
of device. Traditionally, the device can serve in a digital tON 1 / fPWM
application where the host microcontroller can determine
VPWM
the ratio of the on-time to the off-time of the sensor output
signal. Another useful way to use a PWM sensor is to
convert the PWM output signal into an analog output signal.
The goal of this article is to briefly introduce a simple way
to convert the PWM signal into an analog signal, along with time
some examples and important design constraints.
Figure 1. Basic PWM Definitions
296094-AN
Passive Filters using known filters, it is most useful to compute this attenuation
factor in dB:
Now we come to the interesting part of the process, where we
create an analog DC voltage from the PWM output signal. The VRIPPLE
AdB = 20 × log (1)
simplest method for this is with a passive low pass filter. For the VPWM
purposes of this guide, and for simplicity, the focus will be on where AdB is attenuation, and must be a negative number!
passive, first and second order, low pass filters. Passive filters
Remember that VPWM is simply the output voltage swing of the
can be realized very simply with resistors and capacitors. The
PWM sensor.
concepts presented here can be applied to more advanced filters.
For the purposes of this document, we will be focusing on ana- Once the attenuation factor is known we can apply our
lyzing and designing circuits that use passive low pass filters with knowledge, that the slope of a first order low pass filter is
attenuation roll-off factors of –20 dB / decade for first order filters –20 dB / decade and the slope of a second order low pass filter is
and –40 dB / decade for second order filters. In some cases, a –40 dB / decade, to determine the required 3-dB frequency (f3dB )
first order filter will work fine. However, some applications may for the filter:
require a faster response time. In these cases, a second order filter fPWM
may be necessary. It is up to the end user to evaluate the tradeoff AdB = Slope × log (2)
f3dB
between cost of the filter and the filter performance. The order
of the filter can be increased by simply cascading more and more What this equation is telling us is that the attenuation, AdB , is
stages. For each additional order of the filter, the roll-off rate equal to the slope (dB / decade) of the low pass filter, times how
becomes steeper, by an additional –20 dB / decade. many decades are between the 3-dB frequency (f3dB) and the
There are a couple of ways to compute the filter response to PWM frequency (fPWM). Since we already know AdB , we will
an input signal: time analysis and frequency analysis. I prefer solve the following equation for what we want to know, f3dB :
back-of-an-envelope frequency analysis, and will be focusing on A3dB
–
using frequency analysis techniques to design first and second f3dB = fPWM × 10 Slope (3)
order low pass filters. In general, most folks without an electron-
ics background understand frequency methods better than time Now we have everything we need to design a passive low pass
domain methods when designing simple filters. filter. While this may seem a little complicated, trust me, it is
easier than solving second order time domain equations.
Back of the Envelope Filter Design
Another interesting exercise is to set equation 1 equal to equa-
While there are many detailed ways to compute filter require-
ments and filter output ripple voltage, I prefer to keep things tion 2 and solve for VRIPPLE . This will give us an equation that
simple in such a way that I can easily draw up and design a sim- expresses voltage ripple as a function of f3dB :
ple filter on the back of a small envelope and make calculations Slope × log
fPWM
with a cheap scientific calculator (or smart phone app). The first VRIPPLE = VPWM × 10 20
f3dB
(4)
term you have to define is how much ripple voltage, VRIPPLE ,
is acceptable in the analog output. The second necessary term is While this equation is a little more complicated than the previous
the PWM frequency, fPWM , of the sensor. Once the acceptable three equations, it has pretty simple mathematics that allow us to
VRIPPLE and fPWM are defined, the required attenuation can be plot ripple voltage versus 3-dB frequency for determining known
computed. Because we are working in the frequency domain and slope, PWM voltage, and PWM frequency.
1000
100
1st Order Filter
10
VRIPPLE (mV)
0.1
2nd Order Filter
0.01
0.001
CF = 10 μF R L ≈ 50 kΩ
CF = 1 μF CF = 1 μF RL ≈ 50 kΩ
3.58 mV
Lab Data
A filter design and simulation exercise would not be complete
until the filter has been constructed and tested in the lab. The last
two figures (11 and 12) are oscilloscope images of the output
ripple for each of the two filters. The filters were constructed with
the original design components earlier in a solderless breadboard.
The input PWM and the output analog voltage were measured Figure 10. Detail of output ripple for second order filter simulation,
using an oscilloscope. The two figures illustrate that our filters ripple = 2.86 mV
performed very close to the original design targets.
The information contained in this document does not constitute any representation, warranty, assurance, guaranty, or inducement by Allegro to the
customer with respect to the subject matter of this document. The information being provided does not guarantee that a process based on this infor-
mation will be reliable, or that Allegro has explored all of the possible failure modes. It is the customer’s responsibility to do sufficient qualification
testing of the final product to insure that it is reliable and meets all design requirements.