PFC:800WPSUC7-4pin
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
init_bckgnd_funct.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017, Infineon Technologies AG
3  * <br>All rights reserved.
4  * <br>Redistribution and use in source and binary forms, with or without
5  * modification,are permitted provided that the following conditions are met:
6  * - Redistributions of source code must retain the above copyright notice,
7  * this list of conditions and the following disclaimer.
8  * - Redistributions in binary form must reproduce the above copyright notice,
9  * this list of conditions and the following disclaimer in the documentation
10  * and/or other materials provided with the distribution.
11  * - Neither the name of the copyright holders nor the names of its contributors
12  * may be used to endorse or promote products derived from this software without
13  * specific prior written permission.
14  * .
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  * <br>To improve the quality of the software, users are encouraged to share
27  * modifications, enhancements or bug fixes with Infineon Technologies AG
28  * dave@infineon.com).
29  */
30 
43 #ifndef INIT_BCKGND_FUNCT_H_
44 #define INIT_BCKGND_FUNCT_H_
45 
46 /***********************************************************************************************************************
47  * HEADER FILES
48  **********************************************************************************************************************/
49 
50 #include <DAVE.h>
51 
52 /*********************************************************************************************************************
53  * MACROS
54  ********************************************************************************************************************/
62 #define DIV_AUTO_START 0
63 
66 #define UNSIGNED_DIVISION 4
67 
70 #define SIGNED_DIVISION 0
71 
74 #define DIV_32BIT_BY_32BIT 0
75 
78 #define CLK_CORE_HZ 48000000UL
79 
85 #define VIN_MIN_START_INIT 1330 // input voltage before starting the relay (experimental)
86 
87 #define VIN_MIN_START 1121 //1121 --> 86Vrms/3.3Vdd //1094 --> 84Vrms/3.3Vdd // input voltage after starting the relay
88 
89 #define VIN_MIN_STOP_HARD 808 //750 //808 // 847 --> 65Vrms/3.3Vdd; 810, considering filter response
90 
91 #define VIN_MIN_PLD_68V 938 // 938 --> 75Vrms/3.3Vdd
92 
93 #define VIN_MIN_PLD_75V 1068 // 1068 --> 82Vrms/3.3Vdd
94  // MAX AVG current must be Limited to a maximum of 30A for correct control coefficient calculation
101 #define I_IN_AVG_MAX 15887 //15887 --> 20A/3.3Vdd/470R-47R-1
102 
103 #define I_IN_MAX16b 0xFFFFU //0xFFFFU = 65535
104 
105 #define I_IN_FACTOR 2
106 
107 #define I_IN_MAX_FACTOR (I_IN_MAX16b >> I_IN_FACTOR)
108 
116 #define LIMIT_1_MILI_S 65
117 
118 #define LIMIT_100_MILI_S 100
119 
121 /*********************************************************************************************************************
122  * Type definition
123  ********************************************************************************************************************/
125 typedef struct FIR_lowpass_int
126 {
127  uint16_t n;
128  int16_t h[9];
129  int32_t x[17];
130  int32_t output_int;
131  int16_t output;
133 
135 typedef struct IIR_lowpass_int
136 {
137  int16_t k1;
138  int16_t a1[3];
139  int16_t b1[3];
140  int32_t u1[3];
141  int16_t k2;
142  int16_t a2[3];
143  int16_t b2[3];
144  int32_t u2[3];
145  int32_t output1;
146  int32_t output;
148  int32_t calc11;
149  int32_t calc21;
150  int32_t calc12;
151  int32_t calc22;
154 
156 typedef struct controller_PI
157 {
158  int32_t a0;
159  int32_t a1;
160  int32_t a2;
161  int32_t aux;
162  uint8_t qformat;
163  uint8_t shift_to_q13;
164  uint8_t shift_to_q29;
165  int32_t state_output[3];
166  int16_t *duty_iL;
167  uint16_t duty_ff;
168  int16_t duty;
169  int32_t state_error[3];
170  int16_t max_duty;
171  uint16_t PI_ref;
172  uint32_t PI_ref_int;
173  uint16_t PI_ref_max;
174 // int16_t duty_OL; /**< Duty cycle information use for open-loop testing */
175  int32_t interm_calc1;
176  int32_t interm_calc2;
177  bool double_freq;
179 
181 typedef struct controller_int
182 {
183  int16_t a[3];
184  int16_t b[3];
185  uint8_t qformat;
186  uint8_t shift_to_q15;
187  int16_t error[3];
188  int32_t state[3];
189  int32_t output_int;
190  int16_t *output_int_limit;
191  int16_t soft_start;
192  uint16_t output;
193  int16_t output_max;
194  uint16_t int_ref;
195  uint16_t int_ref_steady;
196  int32_t interm_calc1;
197  int32_t interm_calc2;
198  bool first_iter;
200 
201 /*********************************************************************************************************************
202 * External global variables
203  ********************************************************************************************************************/
204 // AC-RMS Filter instance
205 extern volatile IIR_lowpass_int_t ACfilter;
206 
207 // DC-bus Filter instance
208 //extern volatile FIR_lowpass_int_t DCfilter;
209 extern volatile IIR_lowpass_int_t DCfilter;
210 
211 // Scaled AC voltage for filter operation
212 extern volatile int32_t auxAC;
213 
214 // Scaled DC voltage for filter operation
215 extern volatile int32_t auxDC;
216 
217 extern volatile uint16_t time_count_65kHz;
218 
219 extern uint8_t _1ms_count;
220 extern uint8_t _100ms_count;
221 extern uint8_t time_BOP;
222 extern uint8_t time_ACOK;
223 extern uint8_t time_PLD_68V;
224 extern uint8_t time_PLD_75V;
225 extern uint8_t time_V_step;
226 extern uint8_t time_INIT;
227 
228 extern volatile bool power_stage_ON;
229 
230 extern volatile controller_int_t voltage_int_ctr;
231 extern volatile controller_PI_t current_PI_ctr;
232 
233 /***********************************************************************************************************************
234  * Function Prototypes
235  **********************************************************************************************************************/
236 void IIR_param_init(void);
237 
238 void MATH_DIV_config(void);
239 
240 void control_loop_init(void);
241 
242 void time_counter(void);
243 
244 void temperature_sense_enable(void);
245 
246 void delay_100us(uint32_t time);
247 
248 void input_voltage_observer(void);
249 
250 void fan_control_temp_protection(void);
251 
252 #endif /* INIT_BCKGND_FUNCT_H_ */
253