How to plot MOSFET Gate capacitance vs gate drive voltage in Python

Using UliEngineering, you can easily plot the equivalent gate capacitance of a MOSFET vs the gate drive voltage. Note that the gate of a MOSFET is not a simple capacitor, but contains an (assumed to be constant) charge. The gate capacitance is the equivalent capacitance that would be required to store this charge at a given voltage.

In this example, we’ll plot the gate capacitance of a IRF540N MOSFET with a total gate charge of 94 nC.

from UliEngineering.Electronics.MOSFET import mosfet_gate_capacitance_from_gate_charge
from UliEngineering.EngineerIO import normalize_numeric
import matplotlib.pyplot as plt
import numpy as np

# Define the MOSFET parameters
Qg = normalize_numeric("94 nC")
# Plot starting from 2V min threshold voltage
Vg_th = normalize_numeric("2 V")
Vgs = np.linspace(Vg_th, 20, 1000) # V

# Calculate the gate capacitance
Cgs = mosfet_gate_capacitance_from_gate_charge(Qg, Vgs)

# Plot the gate capacitance
plt.style.use('ggplot')
plt.plot(Vgs, Cgs*1e9)
plt.xlabel("Gate drive voltage (V)")
plt.ylabel("Gate capacitance (nF)")
plt.title("MOSFET Gate capacitance vs gate drive voltage")

plt.savefig("MOSFET-Gate-Capacitance.svg")

MOSFET Gate capacitance by gate drive voltage