SBOA444 November 2020 TMCS1100
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.
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 VRMS reading is specifically used for updating the sag, swell, and interruption state variables. The 1-cycle VRMS 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.