New Twist Inverter Examples

I have created three new examples for the Twist to be used as a single phase inverter.
These examples leverage the single_phase_inverter library.

The examples were generated with A.I. I’ve validated that they compile, but nothing more.

The examples are here:

Structure

There are three examples:

  • Grid Following: Where the converter is in grid following mode. You can either generate a sine wave locally or measure it with V1 - V2.
  • Grid Forming: Where the converter is generating its own sine wave via a dq control.
  • Open-Loop: Where the converter generate a sine wave in open-loop.

To test them:

Here are the steps to test them:

  • follow the getting started
  • change the platformio.ini line to load the new examples:
    owntech_examples = https://github.com/luizvilla/examples.git#new_TWT_inverter_examples

Hello all.

I would love to give you some feedback on the single phase grid forming inverter example. I would appreciate it if you can validate it and tell me if any parameters I should change or anything that should be edited to make it work correctly.

I performed the experiment using a 30 V source, a 10 Ω resistor, and Vdref = 20. For reference, there is no wiring diagram provided for the single-phase grid-forming inverter, so I used the connection configuration attached which I believe is correct. Also I have attached the results.

The resluted voltage is zero. There is no waveform appearing across the load at all. both Vd and Id remain zero in the grid forming.Even after switching to power mode, the results remain the same: both Vd and Id are zero and nothing reached the load. Zero voltage.

Hello @LeqaaAwayssa

I have ran a few tests and found out the issue:

  • the rate limiter for the STARTUPMODE was stopping at around 0.4999 which was failing the test >0.5 necessary to tenter POWERMODE
  • the measurements used by the control were not real ones
  • there is a reasonable THD on the 3rd harmonic

I’ve updated the code and shipped an fft on the example now:

If you refresh your examples, you will be able to load what I have uploaded.
To do so you have to comment the example line on the platformio.ini, let platformio update and then un-comment it.

Another issue, which is interesting for your @LeqaaAwayssa :

You should find the following result with a 10 \Omega resistor.

As you can see, there is a high level of 3rd harmonics in the system.

I got the following explanation for it:

Single-phase SOGI-DQ 2\omega resonance and 3rd harmonic injection

The problem

In a single-phase system, the SOGI-DQ transform cannot fully eliminate the fundamental
ripple from the DQ quantities the way a three-phase transform can. For an input signal

v(t) = A\cos(\omega t)

the ideal SOGI produces \alpha = A\cos(\omega t) and \beta = A\sin(\omega t), so the
Park transform gives a clean DC value V_d = A. In practice however, any amplitude or
phase imperfection in the SOGI output leaves a residual 2\omega (100 Hz) ripple on
V_d and I_d after the DQ transform:

V_d(t) = A + \varepsilon\cos(2\omega t) \qquad \text{(DC amplitude + 100 Hz ripple)}

How the 3rd harmonic is injected

The voltage outer-loop PI reacts to this 100 Hz ripple and drives a 100 Hz variation into
the DQ output voltage:

V_{d,\text{out}}(t) \approx A_\text{dc} + B\cos(2\omega t)

When this is converted back to the time domain via the inverse Park transform:

\begin{aligned} V_\text{out}(t) &= V_{d,\text{out}}(t)\cdot\cos(\theta) \\ &= A_\text{dc}\cos(\omega t) + B\cos(2\omega t)\cos(\omega t) \\ &= A_\text{dc}\cos(\omega t) + \frac{B}{2}\cos(\omega t) + \frac{B}{2}\cos(3\omega t) \end{aligned}

The product of the 2\omega ripple with the fundamental creates a 3rd harmonic at 150 Hz.

Measured result

The FFT of V_\text{grid} from the recording 2026-05-22_15-35-15-record.csv
(V_{d,\text{ref}} = 10\ \text{V}, V_\text{dc} \approx 30\ \text{V}, 10 kHz switching,
100 µs control period) confirms the mechanism:

Harmonic Frequency V_\text{grid} amplitude THD contribution
h_1 50 Hz 11.89 V
h_3 150 Hz 0.71 V 5.95 %
h_5 250 Hz 0.15 V 1.26 %
h_2, h_4, \ldots even < 0.17\ \text{V} < 1.4\ \%
Total THD 6.32 %

The 3rd harmonic dominates, exactly matching the theoretical prediction.

FFT analysis showing 3rd harmonic dominance

For now there is no fix. I suspect that by changing the phase shift this can be modified. Maybe you can verify?
Remember that you can use the t key to trigger and the r key to retrieve data via the scope mimicry.