A controller for an electrosurgical generator, the controller comprising: a radio frequency inverter configured to generate an electrosurgical waveform; a signal processor configured to output a measured value of at least one of a voltage, a current, or power of the electrosurgical waveform; a software compensator configured to generate a desired value for at least one of the voltage, the current, or the power of the electrosurgical waveform; a hardware compensator configured to generate a phase shift based on the measured value and the desired value; and an RF inverter controller configured to generate a pulse-width modulation signal based on the phase shift to control the RF inverter, wherein the hardware compensator includes: a setpointer configured to select a target value for at least one of the voltage, the current, or the power of the electrosurgical waveform; and a compensator configured to compensate for a first phase based on the target value, characterized in that the hardware compensator further includes: an impedance gain scheduler configured to calculate an impedance gain; a voltage gain scheduler configured to calculate a voltage gain; and a phase gain scheduler configured to calculate a phase gain, and wherein the hardware compensator is further configured to multiply the first phase by the impedance gain and the voltage gain to obtain a second phase, wherein the hardware compensator is further configured to multiply the second phase by the phase gain to obtain a third phase as an input to the RF inverter controller. a radio frequency inverter configured to generate an electrosurgical waveform; a signal processor configured to output a measured value of at least one of a voltage, a current, or power of the electrosurgical waveform; a software compensator configured to generate a desired value for at least one of the voltage, the current, or the power of the electrosurgical waveform; a hardware compensator configured to generate a phase shift based on the measured value and the desired value; and an RF inverter controller configured to generate a pulse-width modulation signal based on the phase shift to control the RF inverter, wherein the hardware compensator includes: a setpointer configured to select a target value for at least one of the voltage, the current, or the power of the electrosurgical waveform; and a compensator configured to compensate for a first phase based on the target value, characterized in that the hardware compensator further includes: an impedance gain scheduler configured to calculate an impedance gain; a voltage gain scheduler configured to calculate a voltage gain; and a phase gain scheduler configured to calculate a phase gain, and wherein the hardware compensator is further configured to multiply the first phase by the impedance gain and the voltage gain to obtain a second phase, wherein the hardware compensator is further configured to multiply the second phase by the phase gain to obtain a third phase as an input to the RF inverter controller. a setpointer configured to select a target value for at least one of the voltage, the current, or the power of the electrosurgical waveform; and a compensator configured to compensate for a first phase based on the target value, characterized in that the hardware compensator further includes: an impedance gain scheduler configured to calculate an impedance gain; a voltage gain scheduler configured to calculate a voltage gain; and a phase gain scheduler configured to calculate a phase gain, and wherein the hardware compensator is further configured to multiply the first phase by the impedance gain and the voltage gain to obtain a second phase, wherein the hardware compensator is further configured to multiply the second phase by the phase gain to obtain a third phase as an input to the RF inverter controller.