Picomite Phase Correct PWM


Author Message
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 6035
Posted: 01:30pm 24 Aug 2022      

Below text is meant to show what is possible with picomite. Things that are not directly implemented and documented in the user manual.

May come in handy if it comes onto your path....

The picomite is a versatile platform that can be used for all sorts of things.
In this case I use it as a pulse generator for driving a power convertor.
Power convertors (switch mode power supplies) switch power MOSFET's or IGBT's at a frequency of 20kHz...1MHz in order to convert 1 voltage into another.

There are literally zillions of power convertor designs but in my professions there is always need for one that does not exist yet. In that case you need to start from the basics (switching MOSFET's), design magnetics (transformer) and engineer the design to a product.

In stead of starting out with a off-the-shelf driver IC, I decided to use the picomite (dual) PWM to generate the signals to drive the MOSFET's. Typically there are 2 that are drive out-of-phase (in other words 1 MOSFET is ON, the other OFF .... and vice versa). But MOSFET's are never allowed to be ON at the same time (when both are ON, they create a short circuit with excessive dissipation).

So you need 2 signals that are out of phase, but need a "gap" between them to avoid MOSFET's being ON at the same time. In essence you can use a PWM and drive 2 outputs at different duty cycle. A PWM is essentialy a counter that starts at 0 and counts until it hit's the PWM comparator setting, and than toggles the pin.



As you can see, both signals PWM0B top, PWM0A bottom have a different duty cycle, and this shows as a time gap (at the falling edge). The leading edge of both signals happens simultaneous. If you use these 2 signals to drive 2 MOSFET's the falling edges will be fine, but the rising edge (depending the speed of individual MOSFET's) both could still be conducting (briefly) at the same time.

To create a symmetrical "gap" you need to change the PWM operating mode to "Phase Correct mode". The PMW counts from 0 upward until it hits the PWM compare value, toggles the pin, but at the end, it starts counting down again. Hitting the same value again, and toggles the pin again. It is easy to see that when counting up...and down... you need twice the time, so it is essential to double the PWM frequency when using phase correct mode.



In this image you can see that there is a symmetrical "gap" between the 2 PWM outputs.

You force the PWM into "Phase Correct" mode by setting bit 1 in the PWM control register. (see RP2040 manual). For PWM0 that is register &h40050000

Below code demonstrates the behaviour shown in above 2 graphs.

SetPin gp0,pwm0a
SetPin gp1,pwm0b

Print "PWM0A/B running at 100kHz 45%/55% duty cycles, press any key to continue
"
PWM 0,100000,45,55
Poke word &h40050000,1

Do :Loop While Inkey$=""

'phase correct PWM (halves PWM frequency)
Print "PWM0A/B running at 45%/55% duty cycle phase correct"
PWM 0,200000,45,55
Poke word &h40050000,3

End

Edited 2022-08-24 23:33 by Volhout
PicomiteVGA PETSCII ROBOTS