SNOAAA7 April   2024 LMG3522R030

 

  1.   1
  2.   Abstract
  3.   Trademarks
  4. 1Introduction
  5. 2Overview of Inverter Model
    1. 2.1 Power Stage
    2. 2.2 Control and Modulation Method
  6. 3Realization of Digital Control Using C-Script Block
    1. 3.1 Overview of Project Structure
    2. 3.2 AC Voltage Sampling and True RMS Value Calculation
    3. 3.3 Multiple Loop Control
      1. 3.3.1 Voltage Loop With Notch Filter
      2. 3.3.2 Current Loop With PI Compensator Anti-Windup
      3. 3.3.3 Sinusoidal and Sawtooth Wave Generator
      4. 3.3.4 Totem-Pole Modulation and Dead-Time Control
  7. 4Simulation Results
  8. 5Summary
  9. 6References

Overview of Project Structure

For a better understanding of C-Script processing, Figure 3-1 provides an overall introduction of project structure and the C-Script function. Code declaration, start function, output function, and update function are used in block. For a detailed explanation of built-in functions and update logic, see the PLECS® C-Script user manual.

GUID-20240321-SS0I-PJPG-X1DL-NSHMQ9BPC25W-low.svg Figure 3-1 Project Structure Image

Some C-Script setups also need to be made in the C-Script block. Figure 3-2 shows an overview of the setup. The number of inputs represents the input signals from the power stage or other signals generated by other blocks, the number of outputs represents the number of output signals. An important parameter is the sample time, 83ns is set which means the frequency is 120MHz, same as 280039. This also means that the C-Script is simulated in continuous mode, similar to real MCU processing.

GUID-20240319-SS0I-CFR5-J3VS-GR70QCM61BCX-low.pngFigure 3-2 C-Script Setup

Next, a brief introduction of the code function is provided, in which global declarations and definitions are made. For example, in control loop, the inductor current and output voltage are sampled and need to be input to the C-Script block, so a built-in macro is used to define the input signal here. All parameters are initialized in the function.

GUID-20240319-SS0I-43J4-WNVL-P2FR8BBFMNXW-low.pngFigure 3-3 Input Signal Definitions

Global variables defined in code declarations are initialized in the start function.

GUID-20240319-SS0I-CJN1-1FVC-VQL3JGZKQTHP-low.pngFigure 3-4 Variables Initialized in Start Function Code

For example, the voltage loop and current loop reference is initialized as in Figure 3-4.

The update function is the main processing part of the C-Script. Control loop calculation, output voltage sampling, sawtooth, and sinusoidal wave generator, and dead-time control are all accomplished in the update function. For example, AC voltage is sampled at 20kHz.

GUID-20240319-SS0I-D3JP-GDN2-KFJQJMVRQ3MW-low.pngFigure 3-5 AC Voltage Sampling Code in Update Function

The desired signal and port outputs are set in the output function. Also, the PWM signal is defined. For example, Figure 3-6 shows how the twentieth port output is defined as the RMS value of sample AC voltage. OutputSignal is the built-in C-Script macro.

GUID-20240319-SS0I-NMVS-6Q7P-C66PSB2BVM7M-low.pngFigure 3-6 Declaration in Output Function

Section 3.2 discusses implementation of different blocks.