Help with low pass filter for PWM to drive Analog meter

Thread Starter

spinnaker

Joined Oct 29, 2009
7,830
I want to build an analog meter clock. The mcu will drive the meters using PWM. I will need a low pass filter, since I would like to have a seconds meter, my response time needs to be less than 1 second.

It has been a really long time since I have worked with RC filters and I don't ever recall using them in a DAC application so I am a bit lost and will need a bit of help.

I simed something up in LTSpice below. What I noticed in playing with the sim is my output voltage decreases dramatically as I reduce the load. Looks like I need around 200K or so to get a decent voltage out at 50% duty cycle.

Since I will be driving an analog meter, I imagine my impedance will be fairly low?

Will I need an active filter for this job?

Most of the active filters I have run across seem to use a 2 rail op amp. I like to use wallwarts for my projects since I have tons of them. Can I do an active filter on one rail?



upload_2015-12-17_21-13-35.png
upload_2015-12-17_21-12-33.png
 

AnalogKid

Joined Aug 1, 2013
11,038
Are you going to be running three PWM outputs (hours, minutes, seconds)?

An LM324 is an old and reliable part, one of the very first designed specifically for single-rail operation, has four opamps in one package, and would be good for this application. But since an analog meter has a relatively long mechanical time constant, its ballistics will be part of your overall filter scheme. My guess is that for any frequency above 10 KHz, a simple RC filter will be all you need.

The cutoff freq in your sim is 16 kHz, a bit high but it works because your PWM carrier freq is so much higher. If you decrease r1 that will lower the network output impedance so the output voltage is less dependent on the load. That increases the corner frequency even more, but you can correct for that with a larger C1. If you reduce R1 to 1 K and increase C1 to 0.1 uF, the corner frequency drops down to 1.6 kHz. This will filter the doors off of your PWM signal and still respond fast enough that you can see the seconds meter "tick".

ak
 

Thread Starter

spinnaker

Joined Oct 29, 2009
7,830
Cutoff frequency is where I need help. I looked up the definition but not sure how it is applied to PWM. How did you know it was 18K? perhaps if I could see it on the graph, I might understand.
 

Thread Starter

spinnaker

Joined Oct 29, 2009
7,830
Thanks for the tip. This is with the parameters that you suggested and a 5K load. And the good news, I have the .1mfds on hand. :)

upload_2015-12-17_22-11-22.png
 

Sensacell

Joined Jun 19, 2012
3,445
You don't need an analog filter- make the PWM frequency high enough so the analog meter movement doesn't respond. (100 Hz or more)
You can drive an analog meter direct from an IO pin, just include a series resistor to limit the current to full-scale deflection.

A trim pot is handy to tweak it exactly to full scale with 100 % duty cycle applied.
The only trick is having the Vcc stable so the full scale value is stable.
 
Last edited:

Thread Starter

spinnaker

Joined Oct 29, 2009
7,830
I think I will pick up some LM324s just in case.
You don't need an analog filter- make the PWM frequency high enough so the analog meter movement doesn't respond. (100 Hz or more)
You can drive an analog meter direct from an IO pin, just include a series resistor to limit the current to full-scale deflection.

A trim pot is handy to tweak it exactly to full scale with 100 % duty cycle applied.
The only trick is having the Vcc stable so the full scale value is stable.
Thanks! You know I have seen this bring done but I was not sure it is an acceptable way to go.

Can you clarify this statement please?

"make the PWM frequency high enough so the analog meter movement doesn't respond."

Are you saying my PWM out frequency needs to be high enough so the meter does not vary? Was not sure what you meant by "he analog meter movement doesn't respond".
 

OBW0549

Joined Mar 2, 2015
3,566
Set the PWM frequency high enough so that the meter needle doesn't vibrate in tune with the PWM waveform, and you should be good to go without any extra filtering. As Sensacell said, put a resistor in series with the meter so that at 100% PWM duty cycle you get full-scale deflection.
 

crutschow

Joined Mar 14, 2008
34,420
A mechanical meter has a low response frequency (typically perhaps a few Hz) so it acts, all by itself, as a low-pass filter.
So a OBW noted, you just need to have a PWM frequency high enough so that the meter doesn't visibly fluctuate at the PWM frequency.
It will still respond to the average value of the PWM waveform as you want.
 
Last edited:
Top