Close
0%
0%

2-Phase PWM with ATMEGA328P

Make 2-phase PWM to drive a transformer power supply circuit

Similar projects worth following
317 views
0 followers
Switch mode power supplies (SMPS) can be noisy. Push-pull transformer SMPS can be quiet, but there are only a few ICs available as controllers. Can a pro-mini with ATMEGA328P be a push-pull power supply controller?

So what am I trying to do here?  This project will investigate switch-mode power supplies (SMPS) with a transformer.  This isn't a single-ended topology like a flyback, it is push-pull.  Sort of like a class A-B audio amplifier.  Maybe class D.  A transformer SMPS has several advantages over a single-ended topology:  Smaller magnetics, low noise, no core gap, etc.  It does require a more complex PWM driver circuit.  Maybe when working, this will be a voltage booster to convert 6V to 90V for an antique radio project.  For now, it's just an experimental power supply project.

PWM output signals drive the switching transistors, BJT or MOSFET.  For a transformer based power supply, 2 phases are needed.  The drive phases can never overlap, because that would short the transformer primary.  PWM duty should vary from 0-49% for each phase.  The drive phases should be balanced and separated by 180 degrees.

There are some ICs available, but they are specialized and not what I want.  An arduino compatible pro-mini should be able to generate the PWM driver signals.  Since the PWM has to stay balanced, it would be best to generate the PWM using a timer peripheral on the chip.  A software timed solution might not work well.  Hopefully, ADC and software can be used for the feedback loop.

Reference info

https://www.analog.com/media/en/technical-documentation/application-notes/AN118fb.pdf   A classic Jim Williams app note.  Lots of info about Royer converters and low noise technique.  Some IC stuff, but nothing about microcontrollers.

https://www.ti.com/product/SN6505A  TI has an interesting driver chip with integrated MOSFETs.  It's open loop and requires a secondary regulator.  Max input voltage is only 5.5V.  Close, but I wanted 8V max.

https://www.analog.com/en/products/lt3999.html  Analog Devices has a monolithic chip that might work for this application.  It's in a 3x3mm lead-less package, so that's not DIY friendly.

Diagram1.png

Gate driver timing diagram for 4%, 25% and 98% duty. Stars mark possible cross conduction or risk of overlap.

Portable Network Graphics (PNG) - 43.56 kB - 09/11/2021 at 17:36

Preview
Download

p-p-xfmr.png

Generic schematic for push-pull transformer stage

Portable Network Graphics (PNG) - 11.14 kB - 09/11/2021 at 17:36

Preview
Download

Screenshot_2021-09-09_21-26-31.png

Screen snip from TI SN6505A data sheet. This shows open loop control and non-overlapping timing. PWM duty is maximum.

Portable Network Graphics (PNG) - 38.18 kB - 09/10/2021 at 01:28

Preview
Download

  • Timers and edges

    bobu09/11/2021 at 19:09 0 comments

    ATMEGA328P is the part that is found on inexpensive and generic Arduino-compatible boards.  ATMEGA328P is an older part but it is well supported in Arduino world.  It's what I've got.  If this was a commercial project, it would be better to use ATMEGA328PB or newer part in the ATmega family.  With '328P, there are 3 timers, 0, 1 and 2.  Each has unique features.  Timer1 is 16 bit and has most PWM features, so let's start with that one.  Timer0 is 8 bit and is used by Arduino code for delay() and millis().  Those functions are important, so don't use timer0.  Timer2 is also 8 bit and is also used by some functions.  Timer1 is used by servo libraries.  This project won't use servo PWM, so that should work.

    Looking at the PWM timing diagram, there are 4 edges to generate.  2 rising and 2 falling edges.  This is a challenge because timer1 has 2 output compare modules.  Most of the PWM modes change state when the timer reaches an output compare match.  The PWM output then resets at the TOP count.  So how can we generate 2 PWM pulses with 180 degree phase shift?

    • Software and interrupts:  This will work, but if the timing goes wrong, then the power stage might be damaged.  The interrupt service routine would have to be fast and reliable.
    • External logic:  Make some arrangement of gates and flip-flop to generate the timing sequence.  The timer output can clock the logic and control the duty.  Basically take 1-phase PWM and switch it back and forth between the 2 phases.  This would work well, but it requires 2 external ICs.  Switching frequency will be half of the timer PWM frequency.
    • Use 2 different timers, one for each PWM phase.  The timers need to be synchronized. Synchronizing 2 very different timers seems difficult.  This would be awful in ATTINY328P.  ATTINY328PB (and other ATMEGA parts) includes 2 extra 16-bit timers. These are copies of timer1 peripheral, so 2-phase or 3-phase PWM should be practical.  I'm not changing the chip for this project.
    • Use one of the "phase correct" PWM modes to generate 2 symmetrical outputs.  In this mode, the timer counts up and down to generate a symmetrical triangle of timer megnitude.  The output compare OCR1A/B can trigger PWM edges on the upward and downward counts.  This can make PWM pulses centered on the clock TOP and BOTTOM states.  Unfortunately, phase correct PWM is a bit slow.

    This project will focus on the phase correct method.  Maybe the other methods can be tried later.

  • Draw diagrams

    bobu09/11/2021 at 17:47 0 comments

    Schematic diagram for a generic push-pull transformer power stage.  Design of the power stage is outside the scope of the project.  This diagram explains the general concept and shows why the PWM waveform needs to be balanced.

    The timing diagrams show PWM timing for 4%, 50% and 98% duty.  98% duty is probably the maximum safe duty.  Anything higher will risk cross-conduction and short the transformer primary.  The ON pulses are spaced by 180 degrees phase and the ON times are same for each phase.

    If the PWM timing is not balanced, there will be net DC current in the transformer.  This will eventually increase and saturate the transformer core.  This won't hurt the transformer, but the primary inductance will decrease a large amount.  This increases current in the transistors and might destroy them.

    Next up:  ATMEGA328P timers and PWM modes.

View all 2 project logs

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates