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

AC Voltage Sampling and True RMS Value Calculation

Sample rate is set to 20kHz, an addition counter operating at 120Mhz is utilized to trigger the sampling process. The sample is updated when the counter reaches 600. An array is used to save the sample voltage and calculate the RMS value of the output voltage, as Figure 3-7 shows. Code declaration and initialization were accomplished previously. The length of the array number is a trade-off between accuracy and update speed. A larger array number indicates better accuracy and lower speed. Figure 3-8 shows the simulation results for this module. To determine the exact length of the array, assume the window width is four periods of 50Hz sinusoidal wave and the sample rate is 20kHz, then an array length of 1600 is obtained.

GUID-20240319-SS0I-F7XH-WRC9-FT9NNJJQCTXC-low.pngFigure 3-7 AC Voltage Sampling and RMS Value Calculation Code