How to use op-amp and lc filter to get a constant voltage from a pwm signal?

Discussion in 'The Projects Forum' started by blackslide, Sep 3, 2015.

  1. blackslide

    Thread Starter New Member

    Jul 15, 2015
    16
    0
    So, I need a constant voltage/current around 1.5-2V, from a ~3V PWM signal @ 143Hz.

    I've tried all sorts of first order Low pass filters but no RC combo seems to work. Could an added op-amp fix this? How should I wire it up? As a voltage follower, as a Low-Pass filter, both?

    The logic:
    3.3V @143Hz PWM Dutycycle ~60% -> LED1 (actually an optomos relay) -> LED2 -> GND

    The PWM signal would be fine otherwise but since there's a relay involved, it doesn't switch on when it's active, but buzzes at 143Hz, that's a no go for my intended use.

    I'd like to wire the filter/op-amp at the gnd if it's possible. Since there's 8 pairs of leds/relays, but it's kind of irrelevant since only one is active at any one time.

    If it helps, the op-amp I've got at hand is a GL386.
     
  2. crutschow

    Expert

    Mar 14, 2008
    13,000
    3,229
    I don't understand. :confused:
    You want 1.5V-2V for a relay that drives LEDs, or is it to drive the LEDs directly?
    Please post a circuit diagram of what you want to do.
     
  3. AnalogKid

    Distinguished Member

    Aug 1, 2013
    4,523
    1,247
    What are you trying to achieve?
    Why are you driving a relay with a PWM signal?
    Do you want the relay to come on at 60%, but drop out at 30% (or something like that), or what?
    How much current is available to drive things?
    What kind of chip is the PWM signal coming from?

    ak
     
  4. Russmax

    Member

    Sep 3, 2015
    81
    12
    The piece I'm missing is how much current capability the circuit that puts out the PWM has. Is it power capable? Can it drive several tens of mA required to drive the LED, or are you going to need a buffer?

    If you're trying to drive the LED directly from the PWM, that's hard, because 143 Hz is a very low frequency for passive LC filtering of the PWM. You would need a great big coil. 143 kHz would be better, and an L value of 30 to 50 uH would suffice. Tiny at your current magnitudes. A bonus is it would be also be inaudible.

    So, it's likely no LC filter is practical at 143 Hz. You can't do a passive RC filter because the R and C would have to be large, and that's too much loss. If you can't raise to > 100 kHz, then you need a moderately powerful op amp wired in a 2nd order low-pass filter configuration. The op-amp has to be able to drive enough current to feed the LED at 2V. The GL386 should be powerful enough to drive the LED directly

    The AAC section on active filters is not done yet, so get Don Lancaster's Active Filter Cookbook. Or Walt Jung also has a really good filters book. Among others.

    Good luck.
     
  5. #12

    Expert

    Nov 30, 2010
    16,261
    6,770
    and keep the receipt. Mine started falling apart the day I bought it!
     
  6. blackslide

    Thread Starter New Member

    Jul 15, 2015
    16
    0
    Thanks for the info!

    I have only on/off control over the PWM, originally it drives one red led. I'm using it as an On/Off switch for the relay + LED. It has just enough current to drive the relay + the yellow LED, but dies out before a sufficient RC low-pass filter value is reached.

    I need a way to even out the PWM pulse to a stable voltage/current. I guess this is doable with the GL386. Ability to boost the current would be good, but not mandatory.

    To keep it simple I'd rather not, but a psu 5-12V is available if needed.

    The filter should be the last component before gnd. I'll draw something up on the ewb, so you get a better idea :)
     
  7. Russmax

    Member

    Sep 3, 2015
    81
    12
    Can you drive LED2 directly from the PWM? Seems like an optoMOS LED would be about as easy to drive as LED2, but maybe their operating currents are very different. Or maybe the peak LED current would be too high with LED2 driven directly from the PWM.

    If you cannot drive LED2 directly, throw out the optoMOS and drive the PWM signal into the GL386, which will be wired as an active filter. You will have to power the GL386 from the 5-12V psu, and it can drive LED2 directly. To safely get the LED brightness you want, you may need to design the filter with gain, and it may need a resistor in series with LED2 as a current limit.

    You want to design the active filter with a Butterworth response, so there's no peaking in the filter response. A cutoff of 50 Hz or less will be sufficient to smooth the PWM. Here's an excellent and comprehensive publication detailing how to design active filters:
    http://www.ti.com/lit/ml/sloa088/sloa088.pdf

    Regards
     
  8. blackslide

    Thread Starter New Member

    Jul 15, 2015
    16
    0
    Here's my current setup:
    [​IMG]
     
  9. ScottWang

    Moderator

    Aug 23, 2012
    4,853
    767
    You just need a diode and a capacitor, the capacitor should be related with the frequency of the PWM, the problem is that does the current enough to supply the relay?
     
  10. ScottWang

    Moderator

    Aug 23, 2012
    4,853
    767
    Please upload your image to the forum, I can't see the image, and it will also loss the image when the link is disconnection.
     
  11. blackslide

    Thread Starter New Member

    Jul 15, 2015
    16
    0
  12. Wendy

    Moderator

    Mar 24, 2008
    20,765
    2,536
    Actually, it is better if you upload it to this thread so we can locally host it. Folk are not really interested in clicking a link when it is to help someone out.
     
  13. blackslide

    Thread Starter New Member

    Jul 15, 2015
    16
    0
    Duh, I didn't even realize you could do that :/ Here's the logic :)
    relay_GL386.JPG
     
  14. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,779
    1,103
    Your ADC EOC output is active-low. What are its current source and sink ratings?
    Why are you trying to filter the ground side of things?
     
  15. blackslide

    Thread Starter New Member

    Jul 15, 2015
    16
    0
    I have no idea. I had the IC number and I/O pins written down somewhere but didn't find them. I haven't got the actual device at hand. I put that ADC there just to demonstrate.

    The IC seems to output enough voltage and current since it drives a relay LED 1,044V + yellow led, but not much more. The PWM frequency is a constant 143Hz.

    I've got 8xPWM inputs, 8xxLANC I/O, 8xRelays and 8xLEDs and single gnd. So filtering there would be optimal. Why I only put one in the drawing is because It's a selector so a simple filter that works for one, works for the other 7 as well.
     
  16. blackslide

    Thread Starter New Member

    Jul 15, 2015
    16
    0
    Would a Sallen-Key Low-Pass filter work? At least on paper it seems ideal. Source=sim.okawa-denshi.jp

    Can I build one, using the GL386 and where do I terminate C2. On the same "gnd" as the Vout?

    The tool seems to favor non-polarized caps, can I still use a polarized variant? That's what I mostly have. Maybe a few microscopic n-p's somewhere...
     
  17. Russmax

    Member

    Sep 3, 2015
    81
    12
    Hey! A schematic! I like the one you posted, blackside, from 7:09 AM, Saturday.

    1st, try ScottWang's plan of a diode and a capacitor. Wire the diode between the EOC pin and the opto-relay, pointing at the relay, with the capacitor to gnd between the diode and the relay. If the voltage drop of the diode prevents it all from working, a germanium diode might do the trick, if you can get one.

    If it doesn't work, and you can't get, or don't want to use a germanium diode, try the the Sallen-Key filter with GL386 between the EOC pin and the relay, using your GL386. Non-polar caps don't work well if there is no DC voltage across them, and in your application, there would not be. You can try wiring 2 electrolytics in series in each position, - to -, to get around this problem. I realize the expected C values are going to be pretty big, so I expect you will need to do the series back-to-back wiring, or else buy non-polar electrolytics, where this has already been done in the package. In your filter, GND will be the GND connection between the controller and the relay box. Tie the negative supply pin of the GL386 to this GND. You will have to use the +5V supply for the positive supply pin of the GL386.

    Regards
     
  18. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,779
    1,103
    Here's how I'd do it :-
    PWM-smoother.PNG
     
  19. blackslide

    Thread Starter New Member

    Jul 15, 2015
    16
    0
    Thanks for the help! I'll source some np caps from old AC-adapters or motherboards, etc. and try these approaches out. Just a bit busy with a move/renovation and so forth :)

    The IC that supplies the original 16 leds their PWM, is an SN74LS145. The 16 leds are paired and the positive is wired to 8 pins on it. and all return to one pin that functions as negative/gnd. I've tapped straight into the led positives and cut the original negative/gnd.

    I wired these into rs-232/D9 connectors, so that I only need a "dummy" connector with a gnd loop to regain original operation.

    Cheers!
     
Loading...