3.3kW Totem-pole PFC with CoolMOS and XMC1402
init_bckgnd_funct.h File Reference

Header of the functions for SW initialization and running in the background during operation. More...

#include <DAVE.h>
#include "xmc_flash.h"

Go to the source code of this file.

Data Structures

struct  IIR_lowpass_int
 
struct  controller_PI
 
struct  controller_int
 

Macros

#define CLK_CORE_HZ   48000000UL
 
CORDIC configuration
#define DIV_AUTO_START   0
 
#define UNSIGNED_DIVISION   4
 
#define SIGNED_DIVISION   0
 
#define DIV_32BIT_BY_32BIT   0
 
Duty cycle limitation
#define MAX_DUTY   1453
 
#define MIN_DUTY   11
 
#define MAX_DELTA_DUTY   (MAX_DUTY >> 1)
 
#define MAX_DUTY_LCDO   1387
 
Input voltage range for BOP
#define VIN_MIN_START_INIT   2530
 
#define VIN_MIN_START   2530
 
#define VIN_MIN_PLD_130V   2133
 
#define VIN_MIN_PLD_150V   2500
 
#define VRMS_MIN_LIMIT   1176
 
Current limit
#define I_IN_AVG_MAX   17882
 
Temperature and fan control

Maximum current representation Multiplication factor during bulk undershoot (applied shift) Multiplication factor applied if reference under certain limit

#define T_MIN_ADC   1945
 
#define T_CORNER_ADC   301
 
#define T_UC_ZERO_ADC   2225
 
#define T_UC_SLOPE_ADC   1170
 
#define T_OC_ZERO_ADC   589
 
#define T_OC_SLOPE_ADC   7959
 
#define T_MIN_PWM   40
 
#define T_MAX_PWM   65
 
#define PR_FAN_PWM   (fan_pwm.config_ptr->period_value)
 
#define T_SLOPE_PWM   (PR_FAN_PWM/(T_MAX_PWM-T_MIN_PWM))
 
#define FAN_MS   (80)
 
Timing definition
#define LIMIT_1_MILI_S   5
 
#define LIMIT_100_MILI_S   100
 

Typedefs

typedef struct IIR_lowpass_int IIR_lowpass_int_t
 
typedef struct controller_PI controller_PI_t
 
typedef struct controller_int controller_int_t
 

Functions

void IIR_param_init (void)
 IIR coefficients initialization.
IIR cascaded low-pass filter of the AC voltage to obtain the RMS value.
IIR notch filter of the DC voltage to remove 100/120Hz ripple.
Sampling frequency of both filters is 2500Hz, every 2 cycles of CCU40.CC41 @ 5kHz. More...
 
void MATH_DIV_config (void)
 DIV kernel of the MATH co-processor initialization.
Used in the input RMS feedforward. More...
 
void control_loop_init (void)
 Assign value to the coefficients of voltage and current loops.
Reset the state and output of both controllers.
Reset current offset calculation variables.
Set initial power for inverter operation. More...
 
void time_counter (void)
 Time counter is a background process to count "real-time" in the application. More...
 
void delay_100us (uint32_t time)
 Delay function. More...
 
void PFC_INV_mode (void)
 Operation mode (PFC - AC/DC or inverter - DC/AC) selection function.
Decision taken only once when starting the application.
OPERATION MODE FIXED TO PFC!!! More...
 
void input_voltage_observer (void)
 BOP protection, checking AVG input voltage.
The function modifies the control status register. More...
 
void fan_control_temp_protection (void)
 Temperature monitoring: protection and fan control. More...
 
void flash_sleep_ctr ()
 Flash memory sleep state control. More...
 

Variables

volatile IIR_lowpass_int_t ACfilter
 
volatile IIR_lowpass_int_t DCfilter
 
volatile int32_t auxAC
 
volatile int32_t auxDC
 
volatile uint16_t time_count_5kHz
 
uint8_t _1ms_count
 
uint8_t _100ms_count
 
uint8_t time_BOP
 
uint8_t time_ACOK
 
uint8_t time_PLD_130V
 
uint8_t time_PLD_150V
 
uint8_t time_V_step
 
uint16_t time_INIT
 
uint8_t time_extra_bulk
 
volatile bool power_stage_ON
 
volatile bool current_loop_ON
 
volatile controller_int_t voltage_int_ctr
 
volatile controller_PI_t current_PI_ctr
 

Detailed Description

Header of the functions for SW initialization and running in the background during operation.

Author
Meneses Herrera, David; Escudero Rodriguez, Manuel
Date
28.12.2020

Macro Definition Documentation

◆ CLK_CORE_HZ

#define CLK_CORE_HZ   48000000UL

CLK frequency (Hz)

◆ DIV_32BIT_BY_32BIT

#define DIV_32BIT_BY_32BIT   0

This sets 32-bit divide by 32-bit

◆ DIV_AUTO_START

#define DIV_AUTO_START   0

Calculation is automatically started with a write to DVS register

◆ FAN_MS

#define FAN_MS   (80)

Fan control clock timer. [_1ms_count]

◆ I_IN_AVG_MAX

#define I_IN_AVG_MAX   17882

Maximum current limitation

◆ LIMIT_100_MILI_S

#define LIMIT_100_MILI_S   100

100ms @ 1ms counter

◆ LIMIT_1_MILI_S

#define LIMIT_1_MILI_S   5

1ms @ 5kHz

◆ MAX_DELTA_DUTY

#define MAX_DELTA_DUTY   (MAX_DUTY >> 1)

Maximum allowed duty cycle variation of the control loop

◆ MAX_DUTY

#define MAX_DUTY   1453

Maximum allowed duty cycle during operation

◆ MAX_DUTY_LCDO

#define MAX_DUTY_LCDO   1387

Maximum allowed duty cycle after AC lost

◆ MIN_DUTY

#define MIN_DUTY   11

Minimum allowed duty cycle during operation

◆ PR_FAN_PWM

#define PR_FAN_PWM   (fan_pwm.config_ptr->period_value)

Fan PWM period

◆ SIGNED_DIVISION

#define SIGNED_DIVISION   0

Signed division is selected

◆ T_CORNER_ADC

#define T_CORNER_ADC   301

Corner temperature for linear approximation change

◆ T_MAX_PWM

#define T_MAX_PWM   65

Maximum temperature for fan PWM linear variation [Celsius]

◆ T_MIN_ADC

#define T_MIN_ADC   1945

Minimum temperature [ADC]

◆ T_MIN_PWM

#define T_MIN_PWM   40

Minimum temperature for fan PWM linear variation [Celsius]

◆ T_OC_SLOPE_ADC

#define T_OC_SLOPE_ADC   7959

Linear approx over corner temperature: slope

◆ T_OC_ZERO_ADC

#define T_OC_ZERO_ADC   589

Linear approx over corner temperature: value at 0°C

◆ T_SLOPE_PWM

#define T_SLOPE_PWM   (PR_FAN_PWM/(T_MAX_PWM-T_MIN_PWM))

Slope definition for fan PWM linear variation

◆ T_UC_SLOPE_ADC

#define T_UC_SLOPE_ADC   1170

Linear approx under corner temperature: slope

◆ T_UC_ZERO_ADC

#define T_UC_ZERO_ADC   2225

Linear approx under corner temperature: value at 0°C

◆ UNSIGNED_DIVISION

#define UNSIGNED_DIVISION   4

Unsigned division is selected

◆ VIN_MIN_PLD_130V

#define VIN_MIN_PLD_130V   2133

145Vrms; 0.5s if the voltage is between 127V and 150V (Power line disturbance)

◆ VIN_MIN_PLD_150V

#define VIN_MIN_PLD_150V   2500

170Vrms; 2s if the voltage is between 150V and 175V (Power line disturbance)

◆ VIN_MIN_START

#define VIN_MIN_START   2530

172Vrms, converter start threshold

◆ VIN_MIN_START_INIT

#define VIN_MIN_START_INIT   2530

172Vrms, converter start threshold

◆ VRMS_MIN_LIMIT

#define VRMS_MIN_LIMIT   1176

80Vrms; RMS voltage to limit the 1/RMS^2 calculation.

Typedef Documentation

◆ controller_int_t

Voltage controller structure

◆ controller_PI_t

Controller structure for current loop

◆ IIR_lowpass_int_t

IIR filter structure, used in AC-RMS and DC-Notch filtering