SBOA444 November   2020 TMCS1100

 

  1.   Trademarks
  2. 1Introduction
  3. 2Implementation Block Diagram
  4. 3Hardware Implemenation
    1. 3.1 Analog Inputs
      1. 3.1.1 Voltage Measurement Analog Front End
      2. 3.1.2 Current Measurement Analog Front End
    2. 3.2 MSP432 LaunchPad Connections
    3. 3.3 PCB Layout Recommendations
  5. 4How to Implement Software for Metrology Testing
    1. 4.1 Setup
      1. 4.1.1 Clock
      2. 4.1.2 UART Setup for GUI Communication
      3. 4.1.3 Real-Time Clock (RTC)
      4. 4.1.4 Direct Memory Access (DMA)
      5. 4.1.5 ADC Setup
    2. 4.2 Foreground Process
      1. 4.2.1 Formulas
        1. 4.2.1.1 Standard Metrology Parameters
        2. 4.2.1.2 Power Quality Formulas
    3. 4.3 Background Process
      1. 4.3.1 per_sample_dsp( )
        1. 4.3.1.1 Voltage and Current ADC Samples
        2. 4.3.1.2 Pure Waveform Samples
        3. 4.3.1.3 Frequency Measurement and Cycle Tracking
      2. 4.3.2 LED Pulse Generation
      3. 4.3.3 Phase Compensation
  6. 5Metrology Accuracy Testing
    1. 5.1 Test Setup
    2. 5.2 Results
  7. 6Schematics
  8. 7References

per_sample_dsp( )

The per_sample_dsp Function figure shows the flowchart for the per_sample_dsp() function. The per_sample_dsp() function is used to calculate intermediate dot product results that are fed into the foreground process for the calculation of metrology readings. Voltage samples, fundamental voltage samples, current samples, active power, reactive power, fundamental active power, and fundamental reactive power, are all accumulated in 64-bit registers.

GUID-20201005-CA0I-2HPL-ZS2K-NRZNWKTVDM3X-low.gif Figure 4-6 per_sample_dsp Function.
After CYCLES_PER_COMPUTATION number of cycles (10 cycles if fNOM = 50 and 12 cycles if fNom = 60) have been accumulated, the background process triggers the foreground function to calculate the final values of RMS voltage and current; active, reactive, and apparent powers; active, reactive, and apparent energy; frequency; power factor; fundamental voltage, fundamental current, fundamental active power, fundamental reactive power, and fundamental apparent power; voltage underdeviation and voltage overdeviation; and Voltage THD and Current THD. In the software, there are two sets of dot products: at any given time, one is used by the foreground for calculation and the other used as the working set by the background. After the background process has sufficient samples, it swaps the two dot products so that the foreground uses the newly acquired dot products that the background process just calculated and the background process uses a new empty set to calculate the next set of dot products.

Whenever there is a leading-edge zero-crossing (− to + voltage transition) on a voltage channel, the per_sample_dsp() function is also responsible for updating the frequency (in samples per cycle) of the corresponding phase and triggering the calculation of the foreground of the 1-cycle VRMS reading. This 1-cycle VRMS reading is a different calculation than the VRMS reading that is updated every CYCLES_PER_COMPUTATION number of cycles. The 1-cycle V­RMS reading is specifically used for updating the sag, swell, and interruption state variables. The 1-cycle V­RMS calculation uses the same dot-product swapping scheme as the scheme used for the CYCLES_PER_COMPUTATION dot products.

The per_sample_dsp function is also responsible for outputting a voltage zero crossing pin. Whenever there is a negative to positive zero crossing on a voltage channel and the corresponding 1-cycle VRMS reading of the voltage channel is greater than the interruption threshold, a falling edge is asserted on this pin. If there is a positive to negative zero crossing on a voltage channel and the 1-cycle VRMS reading of the voltage channel is greater than the interruption threshold, a rising edge is asserted on this pin. To reduce the impact of outputting the zero crossing pin on the accuracy of the design, the zero crossing output should not be selected to be on a GPIO pin connected to a LED.

The following sections describe the various elements of electricity measurement in the per_sample_dsp function.