|  | 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
41 SMPS_2P2Z_T VMC_2p2z;
42
49 SMPS_2P2Z_T IMC_2p2z;
50
57 SMPS_2P2Z_T PMC_2p2z;
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
165 void PwrCtrl_VComp_Initialize(void)
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
173 VMC_2p2z.preShift = DAB_SPVO_COMP_2P2Z_PRESHIFT;
174 VMC_2p2z.postScaler = DAB_SPVO_COMP_2P2Z_POSTSCALER;
175 VMC_2p2z.postShift = DAB_SPVO_COMP_2P2Z_POSTSHIFT;
176 VMC_2p2z.minOutput = DAB_SPVO_COMP_2P2Z_MIN_CLAMP;
177 VMC_2p2z.maxOutput = DAB_SPVO_COMP_2P2Z_MAX_CLAMP;
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
192 SMPS_Controller2P2ZInitialize(&VMC_2p2z);
193}
194
195
204 void PwrCtrl_IComp_Initialize(void)
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
212 IMC_2p2z.preShift = DAB_PSIO_COMP_2P2Z_PRESHIFT;
213 IMC_2p2z.postScaler = DAB_PSIO_COMP_2P2Z_POSTSCALER;
214 IMC_2p2z.postShift = DAB_PSIO_COMP_2P2Z_POSTSHIFT;
215 IMC_2p2z.minOutput = DAB_PSIO_COMP_2P2Z_MIN_CLAMP;
216 IMC_2p2z.maxOutput = DAB_PSIO_COMP_2P2Z_MAX_CLAMP;
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
232 SMPS_Controller2P2ZInitialize(&IMC_2p2z);
233}
234
235
244 void 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
252 PMC_2p2z.preShift = DAB_PSPO_COMP_2P2Z_PRESHIFT;
253 PMC_2p2z.postScaler = DAB_PSPO_COMP_2P2Z_POSTSCALER;
254 PMC_2p2z.postShift = DAB_PSPO_COMP_2P2Z_POSTSHIFT;
255 PMC_2p2z.minOutput = DAB_PSPO_COMP_2P2Z_MIN_CLAMP;
256 PMC_2p2z.maxOutput = DAB_PSPO_COMP_2P2Z_MAX_CLAMP;
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
271 SMPS_Controller2P2ZInitialize(&PMC_2p2z);
272}
273
274
282 void PwrCtrl_ResetControlLoopHistories(void)
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
DAB_PSIO_COMP_2P2Z_MAX_CLAMP
#define DAB_PSIO_COMP_2P2Z_MAX_CLAMP
Definition dab_psio_dcdt.h:116
DAB_PSIO_COMP_2P2Z_COEFF_B0
#define DAB_PSIO_COMP_2P2Z_COEFF_B0
Definition dab_psio_dcdt.h:106
DAB_PSIO_COMP_2P2Z_COEFF_B2
#define DAB_PSIO_COMP_2P2Z_COEFF_B2
Definition dab_psio_dcdt.h:108
DAB_PSIO_COMP_2P2Z_PRESHIFT
#define DAB_PSIO_COMP_2P2Z_PRESHIFT
Definition dab_psio_dcdt.h:111
DAB_PSIO_COMP_2P2Z_MIN_CLAMP
#define DAB_PSIO_COMP_2P2Z_MIN_CLAMP
Definition dab_psio_dcdt.h:115
DAB_PSIO_COMP_2P2Z_POSTSHIFT
#define DAB_PSIO_COMP_2P2Z_POSTSHIFT
Definition dab_psio_dcdt.h:110
DAB_PSIO_COMP_2P2Z_COEFF_B1
#define DAB_PSIO_COMP_2P2Z_COEFF_B1
Definition dab_psio_dcdt.h:107
DAB_PSIO_COMP_2P2Z_COEFF_A2
#define DAB_PSIO_COMP_2P2Z_COEFF_A2
Definition dab_psio_dcdt.h:105
DAB_PSIO_COMP_2P2Z_COEFF_A1
#define DAB_PSIO_COMP_2P2Z_COEFF_A1
Definition dab_psio_dcdt.h:104
DAB_PSIO_COMP_2P2Z_POSTSCALER
#define DAB_PSIO_COMP_2P2Z_POSTSCALER
Definition dab_psio_dcdt.h:109
DAB_PSPO_COMP_2P2Z_COEFF_A1
#define DAB_PSPO_COMP_2P2Z_COEFF_A1
Definition dab_pspo_dcdt.h:104
DAB_PSPO_COMP_2P2Z_PRESHIFT
#define DAB_PSPO_COMP_2P2Z_PRESHIFT
Definition dab_pspo_dcdt.h:111
DAB_PSPO_COMP_2P2Z_COEFF_A2
#define DAB_PSPO_COMP_2P2Z_COEFF_A2
Definition dab_pspo_dcdt.h:105
DAB_PSPO_COMP_2P2Z_COEFF_B1
#define DAB_PSPO_COMP_2P2Z_COEFF_B1
Definition dab_pspo_dcdt.h:107
DAB_PSPO_COMP_2P2Z_MAX_CLAMP
#define DAB_PSPO_COMP_2P2Z_MAX_CLAMP
Definition dab_pspo_dcdt.h:116
DAB_PSPO_COMP_2P2Z_COEFF_B0
#define DAB_PSPO_COMP_2P2Z_COEFF_B0
Definition dab_pspo_dcdt.h:106
DAB_PSPO_COMP_2P2Z_COEFF_B2
#define DAB_PSPO_COMP_2P2Z_COEFF_B2
Definition dab_pspo_dcdt.h:108
DAB_PSPO_COMP_2P2Z_POSTSHIFT
#define DAB_PSPO_COMP_2P2Z_POSTSHIFT
Definition dab_pspo_dcdt.h:110
DAB_PSPO_COMP_2P2Z_POSTSCALER
#define DAB_PSPO_COMP_2P2Z_POSTSCALER
Definition dab_pspo_dcdt.h:109
DAB_PSPO_COMP_2P2Z_MIN_CLAMP
#define DAB_PSPO_COMP_2P2Z_MIN_CLAMP
Definition dab_pspo_dcdt.h:115
DAB_SPVO_COMP_2P2Z_POSTSHIFT
#define DAB_SPVO_COMP_2P2Z_POSTSHIFT
Definition dab_spvo_dcdt.h:109
DAB_SPVO_COMP_2P2Z_COEFF_A2
#define DAB_SPVO_COMP_2P2Z_COEFF_A2
Definition dab_spvo_dcdt.h:104
DAB_SPVO_COMP_2P2Z_COEFF_B0
#define DAB_SPVO_COMP_2P2Z_COEFF_B0
Definition dab_spvo_dcdt.h:105
DAB_SPVO_COMP_2P2Z_MAX_CLAMP
#define DAB_SPVO_COMP_2P2Z_MAX_CLAMP
Definition dab_spvo_dcdt.h:115
DAB_SPVO_COMP_2P2Z_MIN_CLAMP
#define DAB_SPVO_COMP_2P2Z_MIN_CLAMP
Definition dab_spvo_dcdt.h:114
DAB_SPVO_COMP_2P2Z_PRESHIFT
#define DAB_SPVO_COMP_2P2Z_PRESHIFT
Definition dab_spvo_dcdt.h:110
DAB_SPVO_COMP_2P2Z_COEFF_A1
#define DAB_SPVO_COMP_2P2Z_COEFF_A1
Definition dab_spvo_dcdt.h:103
DAB_SPVO_COMP_2P2Z_POSTSCALER
#define DAB_SPVO_COMP_2P2Z_POSTSCALER
Definition dab_spvo_dcdt.h:108
DAB_SPVO_COMP_2P2Z_COEFF_B1
#define DAB_SPVO_COMP_2P2Z_COEFF_B1
Definition dab_spvo_dcdt.h:106
DAB_SPVO_COMP_2P2Z_COEFF_B2
#define DAB_SPVO_COMP_2P2Z_COEFF_B2
Definition dab_spvo_dcdt.h:107
pwrctrl_dcdt.h
Contains public functions and data types relevant for DCDT file interface.
SMPS_Controller2P2ZInitialize
void SMPS_Controller2P2ZInitialize(SMPS_2P2Z_T *controllerData)
__attribute__
int16_t VMC_2p2zACoefficients[2] __attribute__((space(xmemory)))
Voltage Loop A-coefficient array.
PwrCtrl_IComp_Initialize
void PwrCtrl_IComp_Initialize(void)
Initialize the Current Loop Control.
Definition pwrctrl_dcdt.c:204
PMC_2p2z
SMPS_2P2Z_T PMC_2p2z
Data Object of power mode control.
Definition pwrctrl_dcdt.c:57
PwrCtrl_PComp_Initialize
void PwrCtrl_PComp_Initialize(void)
Initialize the Power Loop Control.
Definition pwrctrl_dcdt.c:244
VMC_2p2z
SMPS_2P2Z_T VMC_2p2z
Data Object of voltage mode control generated by DCDT.
Definition pwrctrl_dcdt.c:41
PwrCtrl_VComp_Initialize
void PwrCtrl_VComp_Initialize(void)
Initialize the Voltage Loop Control.
Definition pwrctrl_dcdt.c:165
PwrCtrl_ResetControlLoopHistories
void PwrCtrl_ResetControlLoopHistories(void)
Clear the control and error histories of the control loops.
Definition pwrctrl_dcdt.c:282
IMC_2p2z
SMPS_2P2Z_T IMC_2p2z
Data Object of current mode control.
Definition pwrctrl_dcdt.c:49
SMPS_2P2Z_T
Definition smps_control.h:163
SMPS_2P2Z_T::controlHistory
int16_t * controlHistory
Definition smps_control.h:166
SMPS_2P2Z_T::minOutput
uint16_t minOutput
Definition smps_control.h:173
SMPS_2P2Z_T::postShift
int16_t postShift
Definition smps_control.h:171
SMPS_2P2Z_T::errorHistory
int16_t * errorHistory
Definition smps_control.h:168
SMPS_2P2Z_T::maxOutput
uint16_t maxOutput
Definition smps_control.h:174
SMPS_2P2Z_T::postScaler
int16_t postScaler
Definition smps_control.h:172
SMPS_2P2Z_T::aCoefficients
int16_t * aCoefficients
Definition smps_control.h:164
SMPS_2P2Z_T::preShift
uint16_t preShift
Definition smps_control.h:170
SMPS_2P2Z_T::bCoefficients
int16_t * bCoefficients
Definition smps_control.h:165