Skip to content

owntech-foundation/single_phase_inverter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

single_phase_inverter

single_phase_inverter provides a C++ control block for single-phase inverters, including SOGI-based quadrature generation, a PLL, and dq current/voltage loops.

Main features

  • SOGI (Second-Order Generalized Integrator) to generate alpha/beta components.
  • PLL and dq transforms to estimate grid angle and frequency.
  • Forming and following modes with automatic sync logic.
  • Current and voltage PI loops and duty-cycle computation.
  • Accessors for measured dq quantities and power.

Public API (explained)

Calculations and lifecycle

  • singlePhaseInverter()
    Constructs the controller and initializes internal members to safe defaults.
  • int8_t init(inverter_mode mode, float32_t V_bus, float32_t grid_Vpk, float32_t grid_w0, float32_t Ts)
    Initializes all control parameters (SOGI, PLL, current/voltage PI loops) and sets operating mode, bus voltage, grid peak voltage, nominal grid frequency, and sampling period. Returns 0 on success.
  • void reset()
    Resets internal controller states (PI integrators, sync state, angles). Use this to restart the control after a fault or mode change.
  • float32_t calculateDuty(float32_t vgrid_meas, float32_t igrid_meas)
    Main control step. Updates PLL, dq transforms, current/voltage loops, and returns the duty cycle to apply.

Getters

  • dqo_t getVdq()
    Returns measured grid voltage in dq frame.
  • dqo_t getVdqOut()
    Returns the dq voltage command after control loops.
  • clarke_t getIab()
    Returns measured grid current in alpha/beta (Clarke) frame.
  • clarke_t getVab()
    Returns measured grid voltage in alpha/beta (Clarke) frame.
  • clarke_t getVabOutput()
    Returns output voltage in alpha/beta (Clarke) frame after control.
  • dqo_t getIdq()
    Returns measured grid current in dq frame.
  • dqo_t getIdqRefDelta()
    Returns the dq current reference delta generated by the voltage loop (forming mode).
  • dqo_t getPower()
    Returns computed active/reactive power in dq form.
  • float32_t getw()
    Returns estimated angular frequency (rad/s).
  • float32_t getTheta()
    Returns the estimated electrical angle (rad).
  • bool getSync()
    Returns true if the controller has synchronized in FOLLOWING mode.

Setters and configuration

  • void setVBus(float32_t V_bus)
    Updates the DC bus voltage used for duty-cycle scaling.
  • void setVdqRef(dqo_t Vdq_ref)
    Sets the voltage reference in dq frame (forming mode).
  • void setIdqRef(dqo_t Idq_ref)
    Sets the current reference in dq frame (following mode).
  • void setPowerOn(bool power_on)
    Enables or disables power injection in FOLLOWING mode.
  • void setSyncOff()
    Forces sync state to false and restarts the sync delay counter.
  • void setMode(inverter_mode mode)
    Switches operating mode and reinitializes controllers with stored parameters.
  • void setWRef(float32_t w_ref)
    Sets the reference angular frequency (rad/s).

Notes

About

The code for creating a dq controlled single phase inverter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages