Help with low pass filter for PWM to drive Analog meter

Discussion in 'The Projects Forum' started by spinnaker, Dec 17, 2015.

  1. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009
    4,883
    999
    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
     
  2. AnalogKid

    Distinguished Member

    Aug 1, 2013
    4,531
    1,248
    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
     
  3. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009
    4,883
    999
    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.
     
  4. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009
    4,883
    999
    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
     
  5. AnalogKid

    Distinguished Member

    Aug 1, 2013
    4,531
    1,248
    For a single-pole lowpass or highpass R-C filter, the cutoff frequency f = 1/(2 x pi x R x C).

    ak
     
  6. Sensacell

    Well-Known Member

    Jun 19, 2012
    1,128
    266
    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: Dec 17, 2015
  7. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009
    4,883
    999
    I think I will pick up some LM324s just in case.
    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".
     
  8. OBW0549

    Well-Known Member

    Mar 2, 2015
    1,308
    884
    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.
     
    spinnaker likes this.
  9. crutschow

    Expert

    Mar 14, 2008
    13,001
    3,229
    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: Dec 18, 2015
    spinnaker likes this.
Loading...