This note is about troubleshooting a simple Arduino-controlled high-side P-channel buck converter and explaining why it fails even though the basic buck formula and component values look correct. It focuses on the real problem: the IRF4905 MOSFET gate is not being charged fully during the PWM off-time because the gate drive is too weak, so the MOSFET never turns off properly and the output voltage rises toward the input instead of dropping to the expected 6 V at 50% duty. The post walks through the PWM timing, gate charge/discharge concept, the gate time-constant estimate, the measured waveforms, and the practical solution of using a much stronger gate drive or a proper push-pull driver stage.
For the complete Buck Converter design with feedback, protection features see Arduino PI Synchronous Buck Converter | DIY DC DC Converter Design
Below is circuit diagram of simple Arduino P-MOSFET High side buck converter circuit diagram. It uses IRF4905 P-channel MOSFET at the high side. The 2N2222 BJT is used as inverter/level shifter.
The inductor and capacitor value can be calculated using the Buck Converter Calculator: Calculate L, C, and Duty Cycle. Here I have used L1=220uH and C1=37uF for 31.2KHz PWM switching frequency using Arduino. That is, the Arduino is configured to produce 31.2Khz PWM signal using Timer 1. That is 8-bit Phase Correct PWM mode with no prescaling (CS10) to establish a 31.2 kHz switching frequency on Pin 9 (OC1A). The duty cycle is set to approximately 50%, so the output is 50% of the input voltage. Here 12V battery source has been used and so the output is 6V.
const int pwmPin = 9;
void setup() {
pinMode(pwmPin, OUTPUT);
// Set Timer 1 to Phase Correct PWM mode, frequency ~31.3 kHz (prescaler = 1)
TCCR1A = _BV(COM1A1) | _BV(WGM10);
TCCR1B = _BV(CS10);
}
void loop() {
// Set duty cycle (0 to 255)
// e.g., 128 ≈ 50% duty cycle
analogWrite(pwmPin, 128);
}
From the last graph you can see that the gate voltage Vg only reaches around 2V when the Q1 switch is off. With Q1 switched off, the gate voltage should rise to 12V but it rises only upto 2V.
How I got the time constant
I treated the gate as a capacitor charged through R1 when Q1 turns off.
- Gate capacitance. The IRF4905 datasheet gives Ciss ≈ 3.4 nF.
- Time constant. Ï„ = R1 × Ciss = 10 kΩ × 3.4 nF ≈ 34 µs.
- Time available. The Arduino code sets Timer 1 to phase-correct PWM with no prescaler, so f = 16 MHz / 510 ≈ 31.4 kHz and T ≈ 31.9 µs. At 50% duty the gate has about 16 µs to charge during each off period.
- How far it gets. Vg(t) = 12 V × (1 - e^(-t/Ï„)). At t = 16 µs that is 12 × (1 - e^(-0.47)) ≈ 4.5 V.
- How far it needs to go. To turn off a P-MOSFET, the gate must come within |Vth| (2-4 V) of the source, so about 8-10 V. Reaching 10 V takes t = Ï„ × ln(12/2) ≈ 1.8Ï„ ≈ 61 µs, nearly four times the 16 µs available.
As a cross-check using charge: the gate needs about 120-180 nC to switch. R1 can supply at most 12 V / 10 kΩ = 1.2 mA, and 1.2 mA × 16 µs ≈ 19 nC, only about 10% of what’s needed.
The 4.5 V estimate is higher than the roughly 2 V in the simulation graph. This is because the simple RC calculation ignores the Miller effect: while Vds changes, Cgd is effectively multiplied, so the real capacitance seen is larger than Ciss. The conclusion is the same either way, and the gate also gets discharged hard by Q1 (a fast path through R3, Ï„ ≈ 0.2 µs) at the start of every on period, which is why the red trace looks like a sawtooth.
Design rule
The gate must be able to fully charge or discharge within the shortest phase of your duty range:
- R × Ciss ≲ t_min / 5, where t_min is the shortest on or off time. For 16 µs this gives R ≲ 940 Ω, so my 330-470 Ω suggestion gives Ï„ ≈ 1-1.6 µs.
- For clean edges, the drive current should be about Qg / t_switch. Switching 180 nC in 100 ns needs about 1.8 A peak, which is why real designs use drivers.
- Average gate current is Qg × f = 180 nC × 31.4 kHz ≈ 5.6 mA, and gate drive power is Qg × Vg × f ≈ 68 mW.
- The worst case is at the extremes of duty. At 90% duty the off-time shrinks to about 3 µs, so a weak pull-up fails even sooner.
Solutions
- Make the pull-up much stronger: change R1 from 10 kΩ to about 330-470 Ω. Q1 can easily sink 12 V / 470 Ω ≈ 25 mA, and the gate time constant drops to a few µs, so Vg should swing close to 0-12 V. This is the quick fix for the simulation, though it wastes a bit of power in R1 while Q1 is on.
- Use a proper gate driver: a push-pull (totem-pole) NPN/PNP stage, or a driver IC, so the gate is actively driven both ways. This is the better approach for real hardware.
- Use a P-MOSFET with lower gate charge, since the IRF4905 is overkill for a small load.
- Use a P-MOSFET with Bootstrap circuit:How to Add a Bootstrap Circuit to a High-Side N-Channel MOSFET Buck Converter





