HPWM switching between half bridge and single mode on the fly

Adiman

Member
Hi all,

I read that running a new HPWM command resets the internal timer and may cause glitches if already running a HPWM output. I am running a Picaxe 20x2.

I am running a synchronous buck DC converter, and would like it to change between Buck and Synchronous Buck modes on the fly. The output is charging a battery.

A high side mosfet is connected to pin C.5 and a low side Mosfet to pin C.4 via a half bridge gate driver IC.

I am using:
SETFREQ M64
HPWM 1, pwmHHHH, 1, 249, DutyCycle
which runs the converter in Half bridge synchronous conversion mode @ 64khz.

My application benefits from running the converter in non-synchronous mode now and then (may need to change every few seconds). Which means I need to issue a new HPWM 0 or 1* command. Now I know from experience that if the low side Mosfet stays on for any amount of time greater than say a millisecond the Mosfet will short the battery and destroy the converter. So at the moment I am being cautious and disabling pwm (HPWM off) for (300 / 8) milliseconds with a Pause 300 command before issuing this command to run in single mode (Buck) conversion:
HPWM 0, pwmHHHH, %0001, 249, DutyCycle

My Question is, do you think it is actually necessary to use the HPWM OFF command and Pauses in this scenario, or do you think the momentary reset of the timer that happens with another HPWM command shouldn't cause enough of an output PWM waveform corruption that would keep the low side signal on for any appreciable time (>1mS) to warrant it and I should just run the "HPWM 0, pwmHHHH, %0001, 249, DutyCycle" command while it is already switching.

I will test this personally if no one else has experience with this but i'm not keen on blowing up expensive Mosfets when someone else may have experience in this area :)

Cheers,

Adrian
 

hippy

Technical Support
Staff member
I will test this personally if no one else has experience with this but i'm not keen on blowing up expensive Mosfets when someone else may have experience in this area :)
Not sure anyone will have much experience with the intricacies of exactly what will happen. The best approach would be to disconnect the MOSFET's, connect up a scope or logic analyser and see what happens, tweak the code until it works.

If the PICAXE provided HPWM commands do not give you what you need you might be able to achieve that through directly poking the appropriate SFR registers.
 

Adiman

Member
I've had a few more random failures of the MOSFET's in my half bridge synchronous DC converter. They have usually failed at first launch of the HPWM 1 command (98% duty cycle). Once the thing is switching it runs fine and tested for hours switching hugely varying levels of current without issue.

I'm starting to suspect the Picaxe doesn't instantly form a nice PWM waveform when first launching the HPWM command. I read in the Picaxe manual that HPWMDuty doesn't affect the timers, but running HPWM commands do, so maybe there is a briefest moment of poor waveform while the timer(s) are starting/configuring. Potentially causing my MOSFET's to stay on together (shoot-through) or the low side mosfet to stay on just too long (causing a battery short via the inductor)..

Of course this issue could be hardware related, for example the charged input capacitors would push a lot of current when the HPWM command is first lauched, however the circuit has been designed to quell all kinds of spikes, with a RC snubber, TVS diodes, thick short traces, etc and I have checked for spikes on the gate to source and Drain to Source on an oscilloscope while HPWM switching starts and haven't detected anything of note.

I'll try to capture the PWM waveform when HPWM first starts using trigger on my oscilloscope, with both probes connected to the output PWM pins on the Picaxe. I'll post back here with my findings if any. If I can't capture this, I will attempt to start half bridge HPWM with a duty cycle of 100% for say 100 milliseconds which should ensure said timers are stable, before then lowering the duty cycle which will start switching the bottom MOSFET.
 

hippy

Technical Support
Staff member
I'll try to capture the PWM waveform when HPWM first starts using trigger on my oscilloscope, with both probes connected to the output PWM pins on the Picaxe.
The easiest way to do that is to put out a pulse on another PICAXE pin just before the code you wish to sample and trigger on that.
 

Adiman

Member
I set it up so that HPWM turns on for a few seconds, then turns off for a few seconds, then loops... so I could set up a trigger to capture the first signal that comes out when HPWM starts.

Running the following code (64khz, approx 98% duty cycle half bridge PWM signal):
SETFREQ M64
HPWM 1, pwmHHHH, 1, 249, 980

Tested from the C.4 and C.5 pins of the Picaxe 20x2 with a probe on each:

The Oscilloscope shows the Low side (pin c.4) comes on *first* for a lengthy 13uS before it switches low, the high side (pin c.5) switches on and then everything starts switching as expected with the expected period. This test is repeatable, and tested triggering on either input to make sure i'm not missing something.

13uS is almost a full cycle at 64khz and means the low side is on for an awfully long time. and worst still, it comes on first. This is most definitely the source of my issues. The Duty Cycle would have to be something like 16% to normally have the low side on this long. Also, it turning on first it's shorting the battery across the Inductor while the Inductor has no magnetic field stored which equals a lot of amps burst of current (12 volt lead acid battery) into the inductor and mosfet, if the current doesn't cause the MOSFET to blow, the secondary spike from the inductor might do it.

I will run some more tests and report back.
 

Adiman

Member
Lots to report from my tests:

1. I note this first fixed period 'low' pulse discovered in my previous post correctly observes the dead time before the first high side pulse.

2. Changing the duty cycle makes no difference to the period of this first low pulse when HPWM 1 command is run.

3. Changing the Frequency to 100khz, make the low pulse change to approximately 7.5uS but the behaviour is the same.

4. If you go from say HPWM 0 to HPWM 1 without a 'HPWM OFF' between them, it is very ugly indeed. There are several pulses of both outputs mirroring each other before they get their act together and operate as expected. There is about 40us of overlapping switching before it's OK. In my application, this would be instantly fatal for two mosfets, and possibly the gate driver as well. I recommend anyone to use 'HPWM OFF' between running HPWM commands of different modes (half bridge, single, etc).

5. The following commands (*with the appropriate switches):

HPWM 0*
HPWM OFF
HPWM 1*

Results in a nice 100uS low time of both signals between the modes, so there should be no need for a Pause between different HPWM modes, just the 'HPWM OFF' alone will do nicely for most applications. Keep in mind the low side pulse coming on first for a fixed amount of time is still there when HPWM 1 is started.

6. HPWM OFF tested nicely, it will drop whatever it's doing and send both signals low instantly. no unusual errors. doesn't wait for a pulse to complete or anything like that.

7. Another big one to note... the 13us low side pulse still is captured when running a HPWM 1 command at 100% duty cycle, you would expect that only the high side turns on, but no this first pulse is the low side for 13us before normal 'always on' of the high side.

8. If you start HPWM at 100% duty cycle (you get the single low side pulse first) but after that when you have steady state high side on operation if you alter the duty cycle to say 98%, everything works as expected and the low side immediately starts up and pulses as expected.

9. Finally the PWMout wizard in the editor shows that 100% duty comes at DUTY of 999 when using 64mhz, 64khz signal, it does not, that results in a near 100% switching but there is still noticeable switching occurring on the oscilloscope. 1000 is perfect 100% in this case!

I'm not sure of a way forward from here, anyone have any ideas to prevent this low pulse from occurring?
 

edmunds

Senior Member
I don't have time to look into this fully, but I think you will find everything you need to know in microchip datasheet at around page 150. If that does not explain what is happening, I would try to poke SFRs to set up eccp instead of hpwm command and see if that gives the same result.

When you go through how the hardware works and what firmware has to do to give you the hpwm one-liner, it should be possible to isolate the problem and maybe even work around it. I'm interested, but cannot spend any time on this at least until the weekend and don't remember all the intricacies from my former study (some results and code documented in the thread linked above) of pwm functions by heart.


Good luck,

Edmunds
 

Adiman

Member
Thanks edmunds, I've had a look through the PIC18F14K22 20x2 datasheet, but I cannot really decipher what you need to do to recreate the HPWM command using PokeSfr. Based on your previous thread and some commands Rev-ED posted for a HPWM workaround in early firmware I can work out how to do some certain things, but in all cases you have used the HPWM or PWMOut commands in conjunction with these extra PokeSfr commands, so to recreate it totally from scratch without experience would be very difficult.
There is nothing in the datasheet that suggests there is a limitation with the low side coming on first for a set period.


One workaround for my application:

I can probably work with a starting 13us *high side* pulse. So I could swap the outputs from the Picaxe to the gate driver, so they are 'backwards'
Everywhere I have a HPWM or HPWMDuty command in my program, use 'DutyCycle = 1000 - DutyCycle' before it.
So a 980 98% dutycyle, would become a 20, 2% dutycycle, but with the outputs swapped it should achieve the same thing.

I'd still be interested to see if the HPWM command can be replaced with PokeSfr that would remove the bug/limitation of this low side pulse happening and I also wonder if this is just limited to the Picaxe 20x2.

Adrian
 

oracacle

Senior Member
just a quick question before we all get overly involved with issues that may exist with HPWM, how are you driving the MOSFETs?
quite often when they are driving large currents and voltages they need to be driven correctly. I have little project that I need to get back to that involves running a large voltage from a set of capacitors for a very short time period (aiming for around hopefully less than 2us). The MOSFET on that is driven through a dedicated driver, the close to ideal totem pole driver, you can buy them pre made - its a lot easier than making them.
 

Adiman

Member
I am driving 2 x FDP036N10A N Channel MOSFETs with a FAN7191_F085 driver chip. The high side is powered from an isolated dc converter @ 12v, low side powered from a seperate 12v regulator. It's a very nice driver chip:
http://www.mouser.com/ds/2/149/FAN7191_F085-1082609.pdf

With this chip the turn on/ turn off time of the upper mosfet is in the 30 nanosecond range. The low side has a 10 ohm gate resistor to come on a bit slower < 100 nanoseconds, with a paralleled diode to make the turn off time around 50 nanoseconds.

I am using HPWM with a deadtime of 1, which equals 60 nanoseconds at 64mhz which is about perfect for this application.

This creates a DC converter with exceptional efficiency.

Adrian
 
Last edited:

edmunds

Senior Member
Yes, true, I never managed to start up eccp1 or eccp2 without hpwm command and got no response from RevEd on why (obviously, there is a reason for it, not complaining). I did notice hpwm function did strange things right after starting up, but as I thought at a time it was not critical to what I was trying to do (now I think otherwise) and because I ran out of time, I did not press it any further. With the sort of research you have done and documented, I think a bug report is in order and somebody from RevEd should investigate the cause and report back.


Cheers,

Edmunds
 
Last edited:

Adiman

Member
I think the HPWM issue is possibly a bug, however of course there may be a trade off in the Picaxe code or something around setting up the HPWM for all intended applications that necessitates the first fixed period low side pulse when starting HPWM mode 1 for some reason.
I also have no idea if it affects just the Picaxe 20x2 model. I only have 20x2's for testing.
I'd be interested to see if anyone else can test their 20x2, or any other model Picaxe with Hardware PWM to see if the same issue is present.
Then there's the fact I could be wrong. I'm going off what my oscilloscope is telling me....

I don't have a schematic. It's standard synchronous design i.e:
http://m.eet.com/media/1053918/IR_FETselect_Fig1.jpg

Using close to the standard application circuit: http://www.mouser.com/ds/2/149/FAN7191_F085-1082609.pdf
Except using a 1 watt 12v/12v isolated DC converter chip instead of the boot diode for powering the high side.
Picaxe and regulator power circuitry all powered from the battery side, with a common earth. (separate 5V & 12V regulators)
The Picaxe directly connects to the inputs on the gate controller. The gate controller has integrated 200k pull down resistors, so nothing else is needed.
 

tmfkam

Senior Member
In a PWM design I made, I found that all was well until the power was turned off - at which point the bridge sometimes went S/C. After a lot of blown IGBTs and drivers, I realised that as the power went down, the oscillator and PWM generation section supplies dipped before that of the 240V AC rectified supply did. As the oscillator and driver stalled, the drive to the 'H' bridge could be left in an ambiguous state momentarily, as there was still some significant charge in the reservoir capacitors for the output stage the output stage turned on both halves of the bridge together resulting in the damage to the IGBTs. My solution, once I realised what was happening, was to include two 'collision' detectors at the point where the drive left the oscillator and PWM stage - before being fed into the opto stage to drive the non-isolated HV section containing the 'H' bridge. The 'collision' detectors consisted of two transistors, with the base of transistor 'A' being connected to output 'A', the collector of transistor 'A' connected to output 'B' and the emitter to Gnd. The second transistor being connected with it's base to output 'B', it's collector to output 'A' and emitter again to Gnd. This ensured that if output 'A' was active, output 'B' was clamped to Gnd, and if output 'B' was active, output 'A' clamped to Gnd. As in an 'H' bridge, both outputs should NEVER be active together, in normal operation the 'collision' detectors should have no effect, just what I needed. After fitting this to my design, no more IGBTs or drivers blew up. I did fit another pair on the outputs of the optocoupler stage, just in case the optocouplers failed to work as expected.

I've had little success using the full bridge outputs fro the PicAxe, I've probably never got the syntax correct, but it's never worked successfully for me. The above design ended up being fully discrete with a whole load of AND gates being used to gate the master oscillator and PWM in order to provide the complimentary drive for the 'H' bridge. A second design for a high current PSU which I intended to use a PicAxe for the PWM drive ended up using a discrete PWM stage with three PicAxes used as the logic for selecting the operating modes and for giving an LCD display for each of the output voltages. Two PSUs could be operated in either individual mode, series mode or parallel mode. In parallel the designed output was 0-35V @ 16A but I never dared to try it at full current! It did give well over 5A @ 70V in series mode... The mode selection logic switched a bank of output relays that ensured that only certain output sockets were enabled in certain modes, so that if an output had been connected to what had been a 5V individual output was switched to full 70V series output, the sockets were isolated and the output leads would need to be swapped, saving any mistakes from damaging delicate circuits. As the mode was changed, the outputs automatically disconnected as well, meaning that the supply needed to be re-enabled too. Can't be too safe!
 

Adiman

Member
Thanks Technical, however the issue does not appear to be Deadband related (that part is working 100%)

Anyway, I have worked around the PWM bug/limitation for my application.

I have swapped the outputs from the Picaxe to the MOSFET driver chip.
Then anywhere in the program I have a 'HPWM 1' or 'HPWMDUTY' command I used code similar to this first:
TempD = 1000 - DutyCycle
Then used TempD as the duty cycle variable in my HPWM commands.

The makes the initial low side fixed period pulse a high side fixed period pulse instead. Not ideal, but I can work with it.

tmfkam - i can appreciate the work you have put in there. You do have to be ultra careful around your circuit design and Picaxe programming when you are using anything high power switching. A bit like a high powered turbo engine, it's often right on the edge of blowing up all the time.
The Picaxe is more than capable. It has the simplest most fully featured PIC hardware PWM control on the market.
 
Last edited:
Top