English
Language : 

UM1561 Datasheet, PDF (23/39 Pages) STMicroelectronics – This document describes how the firmware to manage the 250 W micro-inverter demo
UM1561
Implementation of digital phase locked loop
8
Implementation of digital phase locked loop
DQ_PhaseLockedLoop.c:
The .c file defines the DQ PLL implementation for a single-phase inverter. It is used for the
closed loop control in order to estimate the grid angle and to detect the grid voltage before
injecting current.
#include "stm32f10x_lib.h"
#include "Solar_Mul_Div.h"
#include "250WControl.h"
#define STEPS 512 /*number of entries of the sine look up table*/
#define OFFSET 64 /* Offset for cos(Theta)=sin_cos_Table[index_sin+offset]*/
#define INDUCTANCE_VALUE 65
//1117----- 34mH in q1.15= 34*10-3*2-15/
#define SAMPLES
256
#define SAMPLING_TIME
(s16)((4096)-1)
SystStatus_t Freq_Control= FREQ_OUT_OF_RANGE;
SystStatus_t GDVoltage = GRID_VOLTAGE_OUT_OF_RANGE;
where:
● 512: is (Number of entries of the sine look-up table).
The following code shows the look-up table with 512 elements in hexadecimal format.
//*********************** 512 elements *********************************
const s16 Sin_Cos_Table[STEPS] = {
//tabella USATA x IL VECTOR
0x0000, 0xFE6E, 0xFCDC, 0xFB4A, 0xF9B9, 0xF827, 0xF696, 0xF505, 0xF375,
0xF1E5, 0xF055, 0xEEC7, 0xED38, 0xEBAB, 0xEA1E, 0xE893,
0xE708, 0xE57E, 0xE3F5, 0xE26D, 0xE0E7, 0xDF61, 0xDDDD, 0xDC5A, 0xDAD8,
0xD958, 0xD7DA, 0xD65D, 0xD4E1, 0xD368, 0xD1EF, 0xD079,
0xCF05, 0xCD92, 0xCC22, 0xCAB3, 0xC946, 0xC7DC, 0xC674, 0xC50E, 0xC3AA,
0xC248, 0xC0E9, 0xBF8D, 0xBE32, 0xBCDB, 0xBB86, 0xBA33,
0xB8E4, 0xB797, 0xB64C, 0xB505, 0xB3C1, 0xB27F, 0xB141, 0xB005, 0xAECD,
0xAD97, 0xAC65, 0xAB36, 0xAA0B, 0xA8E3, 0xA7BE, 0xA69C,
0xA57E, 0xA463, 0xA34C, 0xA239, 0xA129, 0xA01D, 0x9F14, 0x9E0F, 0x9D0E,
0x9C11, 0x9B18, 0x9A23, 0x9931, 0x9843, 0x975A, 0x9674,
0x9593, 0x94B6, 0x93DC, 0x9307, 0x9236, 0x916A, 0x90A1, 0x8FDD, 0x8F1E,
0x8E62, 0x8DAB, 0x8CF9, 0x8C4B, 0x8BA1, 0x8AFC, 0x8A5B,
0x89BF, 0x8927, 0x8894, 0x8806, 0x877C, 0x86F7, 0x8676, 0x85FB, 0x8583,
0x8511, 0x84A3, 0x843B, 0x83D7, 0x8377, 0x831D, 0x82C7,
0x8276, 0x822A, 0x81E3, 0x81A1, 0x8163, 0x812B, 0x80F7, 0x80C8, 0x809E,
0x8079, 0x8059, 0x803E, 0x8028, 0x8017, 0x800A, 0x8003,
0x8000, 0x8003, 0x800A, 0x8017, 0x8028, 0x803E, 0x8059, 0x8079, 0x809E,
0x80C8, 0x80F7, 0x812B, 0x8163, 0x81A1, 0x81E3, 0x822A,
0x8276, 0x82C7, 0x831D, 0x8377, 0x83D7, 0x843B, 0x84A3, 0x8511, 0x8583,
0x85FB, 0x8676, 0x86F7, 0x877C, 0x8806, 0x8894, 0x8927,
0x89BF, 0x8A5B, 0x8AFC, 0x8BA1, 0x8C4B, 0x8CF9, 0x8DAB, 0x8E62, 0x8F1E,
0x8FDD, 0x90A1, 0x916A, 0x9236, 0x9307, 0x93DC, 0x94B6,
Doc ID 023556 Rev 1
23/39