Bar Logo Dual Active Bridge Development Board (Part-No. )
 
Content
     
Loading...
Searching...
No Matches
pwrctrl_dcdt.c
Go to the documentation of this file.
1
30#include <xc.h>
31
32#include "pwrctrl_dcdt.h"
33
34
42
50
58
59//==============================================================================
60
61
68int16_t VMC_2p2zACoefficients[2]__attribute__((space(xmemory)));
69
76int16_t VMC_2p2zBCoefficients[3] __attribute__((space(xmemory)));
77
83int16_t VMC_2p2zControlHistory[2] __attribute__((space(ymemory), far));
84
90int16_t VMC_2p2zErrorHistory[3] __attribute__((space(ymemory), far));
91
92//==============================================================================
93
100int16_t IMC_2p2zACoefficients[2]__attribute__((space(xmemory)));
101
108int16_t IMC_2p2zBCoefficients[3] __attribute__((space(xmemory)));
109
115int16_t IMC_2p2zControlHistory[2] __attribute__((space(ymemory), far));
116
122int16_t IMC_2p2zErrorHistory[3] __attribute__((space(ymemory), far));
123
124//==============================================================================
125
132int16_t PMC_2p2zACoefficients[2]__attribute__((space(xmemory)));
133
140int16_t PMC_2p2zBCoefficients[3] __attribute__((space(xmemory)));
141
147int16_t PMC_2p2zControlHistory[2] __attribute__((space(ymemory), far));
148
154int16_t PMC_2p2zErrorHistory[3] __attribute__((space(ymemory), far));
155
156
166{
167 //charger direction
168 VMC_2p2z.aCoefficients = &VMC_2p2zACoefficients[0]; // Set up pointer to derived coefficients
169 VMC_2p2z.bCoefficients = &VMC_2p2zBCoefficients[0]; // Set up pointer to derived coefficients
170 VMC_2p2z.controlHistory = &VMC_2p2zControlHistory[0]; // Set up pointer to controller history
171 VMC_2p2z.errorHistory = &VMC_2p2zErrorHistory[0]; // Set up pointer to error history
172
178
179 VMC_2p2zACoefficients[0] = DAB_SPVO_COMP_2P2Z_COEFF_A1;
180 VMC_2p2zACoefficients[1] = DAB_SPVO_COMP_2P2Z_COEFF_A2;
181 VMC_2p2zBCoefficients[0] = DAB_SPVO_COMP_2P2Z_COEFF_B0;
182 VMC_2p2zBCoefficients[1] = DAB_SPVO_COMP_2P2Z_COEFF_B1;
183 VMC_2p2zBCoefficients[2] = DAB_SPVO_COMP_2P2Z_COEFF_B2;
184
185 //explicit clear to 0
186 VMC_2p2zControlHistory[0] = 0;
187 VMC_2p2zControlHistory[1] = 0;
188 VMC_2p2zErrorHistory[0] = 0;
189 VMC_2p2zErrorHistory[1] = 0;
190 VMC_2p2zErrorHistory[2] = 0;
191
193}
194
195
205{
206 //charger
207 IMC_2p2z.aCoefficients = &IMC_2p2zACoefficients[0]; // Set up pointer to derived coefficients
208 IMC_2p2z.bCoefficients = &IMC_2p2zBCoefficients[0]; // Set up pointer to derived coefficients
209 IMC_2p2z.controlHistory = &IMC_2p2zControlHistory[0]; // Set up pointer to controller history
210 IMC_2p2z.errorHistory = &IMC_2p2zErrorHistory[0]; // Set up pointer to error history
211
217
218
219 IMC_2p2zACoefficients[0] = DAB_PSIO_COMP_2P2Z_COEFF_A1;
220 IMC_2p2zACoefficients[1] = DAB_PSIO_COMP_2P2Z_COEFF_A2;
221 IMC_2p2zBCoefficients[0] = DAB_PSIO_COMP_2P2Z_COEFF_B0;
222 IMC_2p2zBCoefficients[1] = DAB_PSIO_COMP_2P2Z_COEFF_B1;
223 IMC_2p2zBCoefficients[2] = DAB_PSIO_COMP_2P2Z_COEFF_B2;
224
225 //explicit clear to 0
226 IMC_2p2zControlHistory[0] =0;
227 IMC_2p2zControlHistory[1] =0;
228 IMC_2p2zErrorHistory[0] =0;
229 IMC_2p2zErrorHistory[1] =0;
230 IMC_2p2zErrorHistory[2] =0;
231
233}
234
235
244void PwrCtrl_PComp_Initialize(void) //only battery has power sense option. should be bidirectional
245{
246 //charger
247 PMC_2p2z.aCoefficients = &PMC_2p2zACoefficients[0]; // Set up pointer to derived coefficients
248 PMC_2p2z.bCoefficients = &PMC_2p2zBCoefficients[0]; // Set up pointer to derived coefficients
249 PMC_2p2z.controlHistory = &PMC_2p2zControlHistory[0]; // Set up pointer to controller history
250 PMC_2p2z.errorHistory = &PMC_2p2zErrorHistory[0]; // Set up pointer to error history
251
257
258 PMC_2p2zACoefficients[0] = DAB_PSPO_COMP_2P2Z_COEFF_A1;
259 PMC_2p2zACoefficients[1] = DAB_PSPO_COMP_2P2Z_COEFF_A2;
260 PMC_2p2zBCoefficients[0] = DAB_PSPO_COMP_2P2Z_COEFF_B0;
261 PMC_2p2zBCoefficients[1] = DAB_PSPO_COMP_2P2Z_COEFF_B1;
262 PMC_2p2zBCoefficients[2] = DAB_PSPO_COMP_2P2Z_COEFF_B2;
263
264 //explicit clear to 0
265 PMC_2p2zControlHistory[0] =0;
266 PMC_2p2zControlHistory[1] =0;
267 PMC_2p2zErrorHistory[0] =0;
268 PMC_2p2zErrorHistory[1] =0;
269 PMC_2p2zErrorHistory[2] =0;
270
272}
273
274
283{
284 //explicit clear to 0
285 VMC_2p2zControlHistory[0] = 0;
286 VMC_2p2zControlHistory[1] = 0;
287 VMC_2p2zErrorHistory[0] = 0;
288 VMC_2p2zErrorHistory[1] = 0;
289 VMC_2p2zErrorHistory[2] = 0;
290
291 //explicit clear to 0
292 IMC_2p2zControlHistory[0] = 0;
293 IMC_2p2zControlHistory[1] = 0;
294 IMC_2p2zErrorHistory[0] = 0;
295 IMC_2p2zErrorHistory[1] = 0;
296 IMC_2p2zErrorHistory[2] = 0;
297
298 //explicit clear to 0
299 PMC_2p2zControlHistory[0] = 0;
300 PMC_2p2zControlHistory[1] = 0;
301 PMC_2p2zErrorHistory[0] = 0;
302 PMC_2p2zErrorHistory[1] = 0;
303 PMC_2p2zErrorHistory[2] = 0;
304}
305
#define DAB_PSIO_COMP_2P2Z_MAX_CLAMP
#define DAB_PSIO_COMP_2P2Z_COEFF_B0
#define DAB_PSIO_COMP_2P2Z_COEFF_B2
#define DAB_PSIO_COMP_2P2Z_PRESHIFT
#define DAB_PSIO_COMP_2P2Z_MIN_CLAMP
#define DAB_PSIO_COMP_2P2Z_POSTSHIFT
#define DAB_PSIO_COMP_2P2Z_COEFF_B1
#define DAB_PSIO_COMP_2P2Z_COEFF_A2
#define DAB_PSIO_COMP_2P2Z_COEFF_A1
#define DAB_PSIO_COMP_2P2Z_POSTSCALER
#define DAB_PSPO_COMP_2P2Z_COEFF_A1
#define DAB_PSPO_COMP_2P2Z_PRESHIFT
#define DAB_PSPO_COMP_2P2Z_COEFF_A2
#define DAB_PSPO_COMP_2P2Z_COEFF_B1
#define DAB_PSPO_COMP_2P2Z_MAX_CLAMP
#define DAB_PSPO_COMP_2P2Z_COEFF_B0
#define DAB_PSPO_COMP_2P2Z_COEFF_B2
#define DAB_PSPO_COMP_2P2Z_POSTSHIFT
#define DAB_PSPO_COMP_2P2Z_POSTSCALER
#define DAB_PSPO_COMP_2P2Z_MIN_CLAMP
#define DAB_SPVO_COMP_2P2Z_POSTSHIFT
#define DAB_SPVO_COMP_2P2Z_COEFF_A2
#define DAB_SPVO_COMP_2P2Z_COEFF_B0
#define DAB_SPVO_COMP_2P2Z_MAX_CLAMP
#define DAB_SPVO_COMP_2P2Z_MIN_CLAMP
#define DAB_SPVO_COMP_2P2Z_PRESHIFT
#define DAB_SPVO_COMP_2P2Z_COEFF_A1
#define DAB_SPVO_COMP_2P2Z_POSTSCALER
#define DAB_SPVO_COMP_2P2Z_COEFF_B1
#define DAB_SPVO_COMP_2P2Z_COEFF_B2
Contains public functions and data types relevant for DCDT file interface.
void SMPS_Controller2P2ZInitialize(SMPS_2P2Z_T *controllerData)
int16_t VMC_2p2zACoefficients[2] __attribute__((space(xmemory)))
Voltage Loop A-coefficient array.
void PwrCtrl_IComp_Initialize(void)
Initialize the Current Loop Control.
SMPS_2P2Z_T PMC_2p2z
Data Object of power mode control.
void PwrCtrl_PComp_Initialize(void)
Initialize the Power Loop Control.
SMPS_2P2Z_T VMC_2p2z
Data Object of voltage mode control generated by DCDT.
void PwrCtrl_VComp_Initialize(void)
Initialize the Voltage Loop Control.
void PwrCtrl_ResetControlLoopHistories(void)
Clear the control and error histories of the control loops.
SMPS_2P2Z_T IMC_2p2z
Data Object of current mode control.
int16_t * controlHistory
uint16_t minOutput
int16_t postShift
int16_t * errorHistory
uint16_t maxOutput
int16_t postScaler
int16_t * aCoefficients
uint16_t preShift
int16_t * bCoefficients