1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Convert 0-3.3v PWM signal to +/-12v Please Help

Discussion in 'General Electronics Chat' started by milolouis, Sep 21, 2017.

  1. milolouis

    milolouis New Member

    Joined:
    Sep 21, 2017
    Messages:
    12
    Likes:
    0
    I'm trying to convert a Microcontroller PWM signal at 0-3.3vpk to +/-12v. I'm sure it could be done with an optoisolator. Does anyone know the 'correct' way to do this. It must be able to reach -12v so a rail to rail op-amp isn't enough. Any help would be invaluable.
     
  2. alec_t

    alec_t Well-Known Member Most Helpful Member

    Joined:
    Jul 10, 2011
    Messages:
    9,320
    Likes:
    1,231
    Location:
    Cardiff, Wales
    Welcome to ETO!
    What is the PWM frequency?
    How much current does the ±12V have to supply?
     
    • Like Like x 1
  3. milolouis

    milolouis New Member

    Joined:
    Sep 21, 2017
    Messages:
    12
    Likes:
    0
    Wow quick reply, :cool:. 40-50KHz and maximum 1mA current for the output signal.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. alec_t

    alec_t Well-Known Member Most Helpful Member

    Joined:
    Jul 10, 2011
    Messages:
    9,320
    Likes:
    1,231
    Location:
    Cardiff, Wales

    Why won't a rail-to-rail opamp do? A CMOS opamp output would get very close to the supply rails. Or you could use almost any opamp with a ±13V supply :).
    What supplies do you have and how close to -12V does the output really need to be?
     
    • Like Like x 1
  6. milolouis

    milolouis New Member

    Joined:
    Sep 21, 2017
    Messages:
    12
    Likes:
    0
    I only have a clean +/-12v supply and it really does need to be able to reach -12v to within 0.1v. Other parts of my circuit use the ADA4610-4 rail to rail op-amp but I'm afraid I can't seem to find the figure for how close it gets to the rail. I know it will be one transistor drop away but I'd imagine that's more than 0.1v. Link to datasheet if it helps http://www.analog.com/media/en/technical-documentation/data-sheets/ADA4610-1_4610-2_4610-4.pdf.
    And thanks so much
     
  7. milolouis

    milolouis New Member

    Joined:
    Sep 21, 2017
    Messages:
    12
    Likes:
    0
    Ahh it seems they get within a couple of mV so I think I'll go with this circuit which give me reasonable noise of 17mV. I'm glad i can use an op-amp thanks for your help.
    Unless you can see a way of doing this to get a cleaner signal with the same number of stages.
     

    Attached Files:

    • fine.png
      fine.png
      File size:
      143.9 KB
      Views:
      32
  8. dknguyen

    dknguyen Well-Known Member

    Joined:
    May 6, 2006
    Messages:
    6,757
    Likes:
    72
    You could use the 3.3V signal to drive a half-bridge (that is connected between +/-12V with a floating gate driver circuit for the high-side FET ). It would have more components than just the op-amp though but has higher power capability should you need it.
     
  9. MikeMl

    MikeMl Well-Known Member Most Helpful Member

    Joined:
    Mar 17, 2009
    Messages:
    11,136
    Likes:
    565
    Location:
    AZ 86334
    Forget the LPF for a moment. The basic gain/offset stage has some problems. Where are you going to get a 1.8V reference? Second, the gain R2/R1 is too high, causing you to saturate the output of U2. See V(a). Is that what you intended?

    Note that to expose the saturation at U2, I temporarily made the supply voltages +-13V!

    3.png
     
    • Like Like x 1
  10. milolouis

    milolouis New Member

    Joined:
    Sep 21, 2017
    Messages:
    12
    Likes:
    0
    It's intended to control a voltage-controlled-filter. I made the gain a little too high to ensure I reach -12v. The reference was most likely going to be a trimpot divider between 3.3 and 0v.
    In an ideal world I'd like a circuit that could output -12v when the PWM duty cycle is 0% sitting at 0v and only go high when PWM is active. This would avoid having to have an accurate centrepoint.
     
  11. MikeMl

    MikeMl Well-Known Member Most Helpful Member

    Joined:
    Mar 17, 2009
    Messages:
    11,136
    Likes:
    565
    Location:
    AZ 86334
    Here is a version with the gain/offset stage with different values, and a different method of getting the offset. I tweaked your filter values a bit, too.

    This shows another problem. If the PWM duty cycle is small, the slew rate of the amplifier prevents it going from rail to rail, and the "filtered" average will not be what you think it should be...

    . 3a.png
     
    • Like Like x 1
  12. alec_t

    alec_t Well-Known Member Most Helpful Member

    Joined:
    Jul 10, 2011
    Messages:
    9,320
    Likes:
    1,231
    Location:
    Cardiff, Wales
    Have you identified an opamp which can accept a ±12V supply and give a clean ±12V output at 50kHz? I couldn't find a suitable opamp model in the LTspice library to simulate those conditions.
     
    • Like Like x 1
  13. milolouis

    milolouis New Member

    Joined:
    Sep 21, 2017
    Messages:
    12
    Likes:
    0
    Well I'm pretty new to circuit simulation. I was aiming for 100uS rise time so the output could oscillate at around 5KHz but this isn't entirely necessary as long as it can function above 500-1000Hz.
    The modifications Mike suggested work well on my primitive simulator but I'm struggling to find accurate models for my op-amp.
    The ADA4610 has a typical rise time of 21 V/us so can I assume this will be fine?
    On my original circuit I neglected to show there was a one-pole RC with a 7KHz cutoff prior to the op-amp.
    So with Mike's modification this is where I'm at.
    I'm using this basic circuit simulator just to get and understanding as it's quicker than Qucs for someone like me (all generic parts).
     

    Attached Files:

  14. MikeMl

    MikeMl Well-Known Member Most Helpful Member

    Joined:
    Mar 17, 2009
    Messages:
    11,136
    Likes:
    565
    Location:
    AZ 86334
    I cheat, and use the "idealized" universal opamp model that LTSpice has in-built. Note you can easily tweak its parameters (like GBP or SlewRate) to match those of some "real" opamp you can buy.
    3b.png
     
    • Thanks Thanks x 1
  15. alec_t

    alec_t Well-Known Member Most Helpful Member

    Joined:
    Jul 10, 2011
    Messages:
    9,320
    Likes:
    1,231
    Location:
    Cardiff, Wales
    That's a helluva way removed from the original 50kHz :D.
     
    • Like Like x 1
  16. alec_t

    alec_t Well-Known Member Most Helpful Member

    Joined:
    Jul 10, 2011
    Messages:
    9,320
    Likes:
    1,231
    Location:
    Cardiff, Wales
    Do you happen to know offhand of any RRO ones which can take 24V between the rails, Mike? Nearly all the LTspice models seem to be for either low voltage (5V or so, or unspecified) and fast, or higher voltage and sluggish. I think tweaking those models would lead to unrealistic sims.
     
  17. milolouis

    milolouis New Member

    Joined:
    Sep 21, 2017
    Messages:
    12
    Likes:
    0
    Oh sorry I meant the PWM, is at 50KHz to be above well above audio frequencies. I'd like to be able to get up to 20KHz out post filtering on the +/12v signal but I assume I'd need more filter poles to achieve this without it being audible in the signal path so I've set the cutoff to around 8KHz
     
  18. MikeMl

    MikeMl Well-Known Member Most Helpful Member

    Joined:
    Mar 17, 2009
    Messages:
    11,136
    Likes:
    565
    Location:
    AZ 86334
    I start out making the circuit work with the ideal model, then I see what I can buy, and modify the parameters as appropriate. For example, in this case an LT1499 would do ok. It's slew rate is a bit slower than 10MV/sec, but otherwise it is RRIO and capable of operating on +-18V.

    Here is another approach. It also distorts the PWM duty-cycle a bit, but at least it stops at +-12V, with good rise-fall times.

    4.png
     
    Last edited: Sep 21, 2017
    • Thanks Thanks x 1
  19. milolouis

    milolouis New Member

    Joined:
    Sep 21, 2017
    Messages:
    12
    Likes:
    0
    Oh fantastic Mike. I knew there'd be a way to do this using MOSFETs. This is exactly what I was looking for. There's 8 of these in the final application so I was aiming for the lowest part count whilst maintaining low-noise. Really appreciate yours and alecs help.
     
  20. ronsimpson

    ronsimpson Well-Known Member Most Helpful Member

    Joined:
    Apr 17, 2007
    Messages:
    7,365
    Likes:
    973
    Location:
    Loveland, CO USA
    I started out doing what Mike did in #17. (active pull down)

    Then I tried this.
    V4 should be set to 3.3V for DC analysis.
    For AC analysis it needs to be set to 0V.
    R7 & R8 = 20k to 3.3V/2.
    Gain is set by R4 & R5.
    Remove U1. Just for fum.
    upload_2017-9-21_15-30-9.png
    Frequency response with 17db gain. and compare to sample RC filter. Keep the ratio of C1/C2. Change value to get the frequency you want.
    upload_2017-9-21_15-33-9.png
    Wrong OP-Amp. Just pick one at random. The +/- 12V could be +/- 15V unregulated. If you don't want to use R-R amp.
     

    Attached Files:

    • Thanks Thanks x 1
  21. milolouis

    milolouis New Member

    Joined:
    Sep 21, 2017
    Messages:
    12
    Likes:
    0
    Hmm, i put this one into my sim and it seems to show periodic oscillation at anything other than %100 duty cycle
     

Share This Page