H4-PFC Infineon 1600W Server PSU
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
control_interrupts.h File Reference

Interrupts code. More...

#include <DAVE.h>

Go to the source code of this file.

Data Structures

struct  PFC_coefs
 

Macros

#define VOLT_LOOP_SHIFT_Q12   4
 
#define VOLT_LOOP_SHIFT_Q13   3
 
#define BOP_DCBUS_RATIO   13
 
#define SOFT_START_MAX   2317
 
#define MAX_DUTY   953
 
#define PFC_RUNNING   (0x04|0x08)
 
Shifting for ADC related variables
#define ADC_FIR_TO_Q15   1
 
#define ADC_TO_Q15   3
 
#define IIR_QFORMAT   14
 
#define ADC_TO_IIR   (IIR_QFORMAT+ADC_TO_Q15)
 
#define LPF_TO_2ADC   (ADC_TO_IIR-1)
 
#define LPF_TO_Q15   15
 
#define NOTCH_TO_Q15   14
 
#define OFFSET_SAMPLES_2   8
 
#define OFFSET_SAMPLES   256
 
#define OFFSET_END   0xFFFF
 
#define OFFSET_VAC   432
 
DCM detection
#define K_DCM_SHIFT   10
 
#define K_DCM_FACTOR   22749
 
#define AVG_DCM_SHIFT   15
 
#define IL_AVG_GAIN   1
 
#define T_DCM_MAX   1253
 
#define T_DCM_MIN   147
 
DC voltage filter definitions
#define MULT_FACTOR_DC_FILTER   9
 
#define DC_FILTER_SHIFT   3
 
Input frequency range
#define PWM_FREQ   65
 
#define FREQ_COUNT_MAX   780
 
#define FREQ_COUNT_MIN   420
 
Current loop coefficients calculation, CCM
#define COEFF_OFFSETC_9k_Q14   15113
 
#define COEFF_SLOPEC_9k_Q14   12605
 
#define COEFF_OFFSET1_9k_Q14   16383
 
#define COEFF_SLOPE1_9k_Q14   39463
 
#define ZERO_LOC_9k_Q14   11468
 
#define COEFF_OFFSET1_4k_Q14   12393
 
#define COEFF_SLOPE1_4k_Q14   29852
 
#define COEFF_OFFSET2_4k_Q14   4228
 
#define COEFF_SLOPE2_4k_Q14   5265
 
#define ZERO_LOC_4k_Q14   11468
 
#define CONSTL_ILIMIT   1550
 
#define COEFF_ILIMIT_Q14   11482
 
#define I_4kHzBW   4650
 
#define I_9kHzBW   3100
 
#define Q28_TO_Q14   14
 
#define Q29_TO_Q14   15
 
#define Q28_TO_Q13   15
 
#define CURRENT_REF_TO_Q15   19
 
#define Q30_TO_Q15   15
 
#define ACCOMP_TO_Q15   21
 
Output voltage related macros
#define VOUT_OFFSET   0
 
#define VOUT_OFFSET_LCDO   174
 
#define VOUT_OVP_STOP   25171+VOUT_OFFSET
 
#define VOUT_STEADY_MIN   23015+VOUT_OFFSET
 
#define VOUT_STEADY_MAX   24122+VOUT_OFFSET
 
#define VOUT_ORIGIN1   20790+VOUT_OFFSET
 
#define VOUT_SLOPE1   19423
 
#define VREF_TO_Q15   14
 
#define VOUT_UVP_MIN   18063
 
#define VOUT_START_MIN   14338
 
#define VOLTAGE_OFFSET_NL_ON   21845
 
#define VOLTAGE_OFFSET_NL_OFF   22719
 
Soft start related macros
#define SOFT_START_STEP_VOLTAGE   1022
 
#define ST_STB_BOP_CHECK_BULK   80
 
#define ST_STB_BOP_SFTSTRT_WAIT   (10+ST_STB_BOP_CHECK_BULK)
 

Typedefs

typedef enum state state_t
 
typedef enum fault fault_t
 
typedef struct PFC_coefs PFC_coefs_t
 
typedef enum grid_voltage grid_voltage_t
 

Enumerations

enum  state {
  ST_INIT = 0x00, ST_STB = 0x01, ST_STB_BOP = 0x02, ST_SOFT_START = 0x04,
  ST_RUNNING = 0x08, ST_LATCH = 0x10, ST_I_OFFSET = 0x20
}
 
enum  fault {
  F_INIT = 0x0, F_OVP = 0x1, F_BOP = 0x2, F_UVP = 0x4,
  F_PEAK = 0x8, F_OTP = 0x10
}
 
enum  comp_BW_t { BW_L = 0, BW_H = 1 }
 
enum  grid_voltage { NEGATIVE, POSITIVE }
 

Functions

__STATIC_INLINE void PWM_OFF ()
 
__STATIC_INLINE void PWM_ON ()
 
__STATIC_INLINE void relay_ON ()
 
__STATIC_INLINE void relay_OFF ()
 
__STATIC_INLINE void set_duty (uint16_t duty)
 
__STATIC_INLINE void Iref (uint16_t level)
 
__STATIC_INLINE void ENABLE_PRIM_ON ()
 
__STATIC_INLINE void ENABLE_PRIM_OFF ()
 

Variables

__IO uint32_t * ADCResult_iL
 
__IO uint32_t * ADCResult_DCBus
 
__IO uint32_t * ADCResult_VAC
 
__IO uint32_t * ADCResult_Temp
 
__IO uint32_t * ADCResult_BOP
 
volatile PFC_coefs_t PFC
 
__I uint32_t * DCM_capture_p
 
__I uint32_t * DCM_capture_n
 
volatile state_t status_reg
 
volatile fault_t fault_reg
 
volatile uint16_t freq_in_count
 

Detailed Description

Interrupts code.

Author
Meneses Herrera, David
Date
09.01.2018

Macro Definition Documentation

#define ACCOMP_TO_Q15   21

Shifting for AC sensing compensation in current reference calculation: Qx to Q15

#define ADC_FIR_TO_Q15   1

ADC with FIR [2 2 0] normalization shift (Q15)

#define ADC_TO_IIR   (IIR_QFORMAT+ADC_TO_Q15)

Shift for RMS filter input

#define ADC_TO_Q15   3

ADC normalization shift (Q15)

#define AVG_DCM_SHIFT   15

Shift fort DCM current correction factor multiplication

#define BOP_DCBUS_RATIO   13

Ratio between DC and average input voltage before start-up sequence.

#define COEFF_ILIMIT_Q14   11482

Current limit between regions, considering linear variation of the inductance

#define COEFF_OFFSET1_4k_Q14   12393

Current coefficient offset of first region (coefficient for 0A operation)

#define COEFF_OFFSET1_9k_Q14   16383

Current coefficient offset of first region (coefficient for 0A operation)

#define COEFF_OFFSET2_4k_Q14   4228

Current coefficient offset of second region (coefficient for I_Limit operation)

#define COEFF_OFFSETC_9k_Q14   15113

Current coefficient offset of first region (coefficient for 0A operation)

#define COEFF_SLOPE1_4k_Q14   29852

Current coefficient slope of first region, considering linear variation of the inductance

#define COEFF_SLOPE1_9k_Q14   39463

Current coefficient slope of first region, considering linear variation of the inductance

#define COEFF_SLOPE2_4k_Q14   5265

Current coefficient slope of second region, considering linear variation of the inductance

#define COEFF_SLOPEC_9k_Q14   12605

Current coefficient slope of first region, considering linear variation of the inductance

#define CONSTL_ILIMIT   1550

At AVG current close to zero, constant inductance considered

#define CURRENT_REF_TO_Q15   19

Current reference adaptation to Q15 representation

#define DC_FILTER_SHIFT   3

Shifting in moving average filter

#define FREQ_COUNT_MAX   780

Experimental (PWMFREQ * 1000 / (2 * 45)) // 45Hz @ PWMFREQ

#define FREQ_COUNT_MIN   420

Experimental (PWMFREQ * 1000 / (2 * 70)) // 70Hz @ PWMFREQ

#define I_4kHzBW   4650

Upper level for BW change in the current loop

#define I_9kHzBW   3100

Lower level for BW change in the current loop

#define IIR_QFORMAT   14

RMS filter coefficient format

#define IL_AVG_GAIN   1

SW current gain. Power of 2 (2^IL_AVG_GAIN).

#define K_DCM_FACTOR   22749

Factor applied for DCM current correction

#define K_DCM_SHIFT   10

Shift for DCM current correction factor calculation

#define LPF_TO_2ADC   (ADC_TO_IIR-1)

Shift of RMS filter for proper Iref calculation

#define LPF_TO_Q15   15

Shift of DC filter for proper voltage loop

#define MAX_DUTY   953

Maximum allowed duty cycle

#define MULT_FACTOR_DC_FILTER   9

Scaling factor for filter calculation

#define NOTCH_TO_Q15   14

Shift of DC filter for proper voltage loop

#define OFFSET_END   0xFFFF

Count value when the offset calculation is done

#define OFFSET_SAMPLES   256

Number of samples to be acquire for zero current offset calculation

#define OFFSET_SAMPLES_2   8

Number of samples to be acquire for zero current offset calculation, in power of 2

#define OFFSET_VAC   432

Vac voltage under which the current offset measurement is allowed, to avoid capacitor charge current

#define PFC_RUNNING   (0x04|0x08)

PWM is on during PFC operation, e.g. soft-start and running operation

#define PWM_FREQ   65

[kHz]

#define Q28_TO_Q13   15

Shifting for duty feedforward: Q28 to Q13

#define Q28_TO_Q14   14

Shifting for coefficient calculation: Q28 to Q14

#define Q29_TO_Q14   15

Shifting for coefficient calculation: Q29 to Q14

#define Q30_TO_Q15   15

Shifting for AC measurement compensation of current reference: Q30 to Q15

#define SOFT_START_MAX   2317

Maximum value of the multiplier for current-loop operation. NOT used in this implementation

#define SOFT_START_STEP_VOLTAGE   1022

Reference step for the soft-start phase.

#define ST_STB_BOP_CHECK_BULK   80

Number of cycles before checking the bulk voltage after input voltage is in range and the decision of closing the relay is taken.

#define ST_STB_BOP_SFTSTRT_WAIT   (10+ST_STB_BOP_CHECK_BULK)

Number of cycles before starting the converter after closing the relay.

#define T_DCM_MAX   1253

Maximum captured time to be considered DCM operation

#define T_DCM_MIN   147

Minimum captured time to be considered DCM operation

#define VOLT_LOOP_SHIFT_Q12   4

Voltage loop shifting after addition with Q12 coefficients

#define VOLT_LOOP_SHIFT_Q13   3

Voltage loop shifting after addition with Q13 coefficients

#define VOLTAGE_OFFSET_NL_OFF   22719

Output voltage offset limit to stop applying non-linear loop error.

#define VOLTAGE_OFFSET_NL_ON   21845

Output voltage offset limit to apply non-linear loop error.

#define VOUT_OFFSET   0

Adjustable offset for output voltage measurements, Q15 representation

#define VOUT_OFFSET_LCDO   174

Adjustable offset for output voltage measurements, Q15 representation

#define VOUT_ORIGIN1   20790+VOUT_OFFSET

Linear variation of bulk voltage with output current/power

#define VOUT_OVP_STOP   25171+VOUT_OFFSET

420V, Q15 representation

#define VOUT_SLOPE1   19423

Linear variation of bulk voltage with output current/power

#define VOUT_START_MIN   14338

Output voltage before start-up must be higher than 168*sqrt(2) (Q15).

#define VOUT_STEADY_MAX   24122+VOUT_OFFSET

405V, Q15 representation. Used for the control loop reference and resume value after OVP

#define VOUT_STEADY_MIN   23015+VOUT_OFFSET

395V, Q15 representation. Used for the control loop reference and resume value after OVP

#define VOUT_UVP_MIN   18063

320V, Q15 representation

#define VREF_TO_Q15   14

Shifting for voltage target calculation: Qx to Q15

#define ZERO_LOC_4k_Q14   11468

Zero location of the current compensator (Q14 format)

#define ZERO_LOC_9k_Q14   11468

Zero location of the current compensator (Q14 format)

Typedef Documentation

typedef enum fault fault_t

Defined fault states used to manage the converter protections

Enum to hold the input voltage polarity

typedef struct PFC_coefs PFC_coefs_t

Structure for the PFC related variables

typedef enum state state_t

Defined states to be used in the starting sequence and state machine

Enumeration Type Documentation

enum comp_BW_t

Defined fault states used to manage the converter protections

enum fault

Defined fault states used to manage the converter protections

Enum to hold the input voltage polarity

enum state

Defined states to be used in the starting sequence and state machine

Function Documentation

__STATIC_INLINE void ENABLE_PRIM_OFF ( )

Turn P0.4 OFF, primary to secondary communication not allowed

__STATIC_INLINE void ENABLE_PRIM_ON ( )

Turn P0.4 ON, allow primary to secondary communication

__STATIC_INLINE void Iref ( uint16_t  level)

Iref is derived from CCU40.CC43 and a low-pass filter so level is set via duty cycle

__STATIC_INLINE void PWM_OFF ( )

Configure P0.0 as GPIO with output low

__STATIC_INLINE void PWM_ON ( )

Configure P0.0 as PWM output

__STATIC_INLINE void relay_OFF ( )

Relay off: P1.5 –> low

__STATIC_INLINE void relay_ON ( )

Relay on: P1.5 –> high

__STATIC_INLINE void set_duty ( uint16_t  duty)

Modify duty cycle of the PFC-PWM and the trigger of the ADC