Dear Plexim Technical Support Team,
I am conducting research on the impedance modeling and stability of a three-phase grid-connected inverter controlled by a Virtual Synchronous Generator (VSG) with cascaded proportional-resonant (PR) voltage and current control loops.
I am using PLECS 5.0.3 and RT-BOX 1 to investigate the inverter’s dynamic response to changes in grid inductance. However, I have encountered a significant discrepancy between high-accuracy offline simulations and real-time simulations.
1. System Configuration
The main system parameters are as follows:
-
Real-time platform: RT-BOX 1
-
Simulation software: PLECS 5.0.3
-
DC-link voltage: 500 V
-
Inverter-side filter inductance: 8 mH
-
Filter capacitance: 10 μF
-
Filter grid-side inductance: 2 mH
-
External grid inductance: changing from 2 mH to 5 mH
-
Grid frequency: 50 Hz
-
PWM switching frequency: 10 kHz
-
PWM signal delay: 100 μs
-
Control strategy: VSG with cascaded PR voltage and current control loops
The PR controllers are implemented using continuous-time transfer function blocks. The entire control system, PWM generation, inverter, LCL filter, and grid are executed within a single RT-BOX 1.
Four analog output channels are used to display the three-phase PCC voltages and the grid-inductance switching signal on an external oscilloscope.
2. Problem Description
In the offline simulation, a variable-step solver or a sufficiently small fixed step size (2 μs) produces the expected results:
-
With an external grid inductance of 2 mH, the three-phase voltages and currents are stable and nearly sinusoidal.
-
When the grid inductance increases to 5 mH, significant voltage and current oscillations occur, with a dominant oscillation frequency of approximately 800 Hz.
However, when the model is discretized using a 10 μs fixed step size and deployed to RT-BOX 1, noticeable periodic voltage and current ripple appears even before the inductance change.
FFT analysis indicates an additional frequency component around 1 kHz under the initial 2 mH grid condition.
This behavior can also be reproduced in the offline fixed-step simulation. Therefore, the problem appears to be related to the numerical implementation of the switching inverter rather than solely to the analog output hardware.
3. Troubleshooting Already Performed
I have carried out the following tests:
| Modification | Observed result |
|---|---|
| Variable-step offline simulation | Smooth voltage and current waveforms |
| Fixed-step, 10 μs | Significant periodic ripple |
| Fixed-step, 5 μs | Ripple noticeably reduced |
| Fixed-step, 2 μs | Ripple significantly reduced |
| Reduced PWM frequency from 10 kHz to 5 kHz | No substantial improvement |
| Replaced the original IGBT converter with three Half Bridge modules in Switched mode | Ripple remained |
| Changed floating-point format from double to float | No substantial improvement |
| Changed PWM delay from 100 μs to 50 μs | No substantial improvement |
| Added a 3 kHz low-pass filter to the voltage measurement path | Limited improvement |
| Used Half Bridge modules in Sub-cycle average mode | Smooth waveforms, but the post-disturbance oscillation characteristics changed |
I also replaced the variable grid-inductance implementation with a fixed physical 2 mH grid in a separate diagnostic model. The ripple remained at a 10 μs fixed step size and was significantly reduced at 2 μs.
This indicates that the variable-inductance implementation is not necessary for the ripple to occur.
4. Real-Time Computational Limitations
When the RT-BOX 1 base step size was reduced to 5 μs, the application encountered consecutive overruns and was terminated.
One reported execution time was approximately 7.16 μs, exceeding the permitted 5 μs interval.
At a 10 μs base step size, the model can run, but occasional overruns have also been recorded, with some execution times exceeding 14 μs.
Therefore, directly reducing the CPU base step size to 2 μs does not appear feasible with the current model implementation.
5. Technical Questions
I would greatly appreciate your guidance on the following questions:
-
Is there a recommended approach for accurately simulating a 10 kHz PWM-controlled three-phase LCL inverter on RT-BOX 1 when the CPU base step size is limited to approximately 10 μs?
-
Is it possible to improve the switching-event time resolution using RT-BOX 1 hardware resources without requiring additional external PWM loopback wiring?
-
Could the periodic ripple around 1 kHz be caused by switching-event quantization exciting the LCL resonance, and are there recommended methods to reduce such numerical excitation?
-
Is there an optimized real-time implementation that retains the relevant switching and control-delay dynamics while reducing the computational burden?
-
Would you recommend any specific discretization method, power module configuration, or code-generation optimization for this application?
-
If a Sub-cycle average model is recommended, how can the original PWM timing and 100 μs control delay be represented accurately so that the stability characteristics remain consistent with the high-accuracy switched model?
6. Experimental Constraints
For this research, it is essential to preserve the original PR controller parameters, PWM switching frequency, control delay, and electrical parameters because the results will be compared with another control strategy under identical operating conditions.
In addition, the experiment must be performed entirely within RT-BOX 1, without external PWM loopback wiring. Only four analog output channels are used for oscilloscope measurements.
The intended experimental outcome is a smooth and stable three-phase voltage waveform at 2 mH, followed by a clear oscillatory response when the external grid inductance increases to 5 mH.
I can provide the complete PLECS model, offline simulation results, oscilloscope screenshots, FFT results, and RT-BOX diagnostic logs for further investigation.
the complete PLECS model
offline simulation results
oscilloscope screenshots
FFT Spectrum Before the Step Change at a 10 μs Time Step
FFT Spectrum Before the Step Change at a 2 μs Time Step
RT-BOX diagnostic logs
Thank you very much for your time and assistance. I would greatly appreciate any recommendations regarding a suitable real-time implementation.





