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
35
43
51
59
60//==============================================================================
61//==============================================================================
62
63
71
79
87
88//==============================================================================
89//==============================================================================
90
91
92
99int16_t VMC_2p2zACoefficients[2]__attribute__((space(xmemory)));
100
107int16_t VMC_2p2zBCoefficients[3] __attribute__((space(xmemory)));
108
114int16_t VMC_2p2zControlHistory[2] __attribute__((space(ymemory), far));
115
121int16_t VMC_2p2zErrorHistory[3] __attribute__((space(ymemory), far));
122
123//==============================================================================
124
131int16_t IMC_2p2zACoefficients[2]__attribute__((space(xmemory)));
132
139int16_t IMC_2p2zBCoefficients[3] __attribute__((space(xmemory)));
140
146int16_t IMC_2p2zControlHistory[2] __attribute__((space(ymemory), far));
147
153int16_t IMC_2p2zErrorHistory[3] __attribute__((space(ymemory), far));
154
155//==============================================================================
156
163int16_t PMC_2p2zACoefficients[2]__attribute__((space(xmemory)));
164
171int16_t PMC_2p2zBCoefficients[3] __attribute__((space(xmemory)));
172
178int16_t PMC_2p2zControlHistory[2] __attribute__((space(ymemory), far));
179
185int16_t PMC_2p2zErrorHistory[3] __attribute__((space(ymemory), far));
186
187
188//==============================================================================
189//==============================================================================
190
191
198int16_t VMC_2p2zACoefficients_Rev[2]__attribute__((space(xmemory)));
199
206int16_t VMC_2p2zBCoefficients_Rev[3] __attribute__((space(xmemory)));
207
213int16_t VMC_2p2zControlHistory_Rev[2] __attribute__((space(ymemory), far));
214
220int16_t VMC_2p2zErrorHistory_Rev[3] __attribute__((space(ymemory), far));
221
222//==============================================================================
223
230int16_t IMC_2p2zACoefficients_Rev[2]__attribute__((space(xmemory)));
231
238int16_t IMC_2p2zBCoefficients_Rev[3] __attribute__((space(xmemory)));
239
245int16_t IMC_2p2zControlHistory_Rev[2] __attribute__((space(ymemory), far));
246
252int16_t IMC_2p2zErrorHistory_Rev[3] __attribute__((space(ymemory), far));
253
254//==============================================================================
255
262int16_t PMC_2p2zACoefficients_Rev[2]__attribute__((space(xmemory)));
263
270int16_t PMC_2p2zBCoefficients_Rev[3] __attribute__((space(xmemory)));
271
277int16_t PMC_2p2zControlHistory_Rev[2] __attribute__((space(ymemory), far));
278
284int16_t PMC_2p2zErrorHistory_Rev[3] __attribute__((space(ymemory), far));
285
286
287
300{
301 //charger direction, PSVO, Primary to Secondary V Out loop
302 VMC_2p2z.aCoefficients = &VMC_2p2zACoefficients[0]; // Set up pointer to derived coefficients
303 VMC_2p2z.bCoefficients = &VMC_2p2zBCoefficients[0]; // Set up pointer to derived coefficients
304 VMC_2p2z.controlHistory = &VMC_2p2zControlHistory[0]; // Set up pointer to controller history
305 VMC_2p2z.errorHistory = &VMC_2p2zErrorHistory[0]; // Set up pointer to error history
306
307 VMC_2p2z.preShift = DAB_PSVO_COMP_2P2Z_PRESHIFT;
308 VMC_2p2z.postScaler = DAB_PSVO_COMP_2P2Z_POSTSCALER;
309 VMC_2p2z.postShift = DAB_PSVO_COMP_2P2Z_POSTSHIFT;
310 VMC_2p2z.minOutput = DAB_PSVO_COMP_2P2Z_MIN_CLAMP;
311 VMC_2p2z.maxOutput = DAB_PSVO_COMP_2P2Z_MAX_CLAMP;
312
313 VMC_2p2zACoefficients[0] = DAB_PSVO_COMP_2P2Z_COEFF_A1;
314 VMC_2p2zACoefficients[1] = DAB_PSVO_COMP_2P2Z_COEFF_A2;
315 VMC_2p2zBCoefficients[0] = DAB_PSVO_COMP_2P2Z_COEFF_B0;
316 VMC_2p2zBCoefficients[1] = DAB_PSVO_COMP_2P2Z_COEFF_B1;
317 VMC_2p2zBCoefficients[2] = DAB_PSVO_COMP_2P2Z_COEFF_B2;
318
319 //explicit clear to 0
320 VMC_2p2zControlHistory[0] = 0;
321 VMC_2p2zControlHistory[1] = 0;
322 VMC_2p2zErrorHistory[0] = 0;
323 VMC_2p2zErrorHistory[1] = 0;
324 VMC_2p2zErrorHistory[2] = 0;
325
327
328 //discharger direction, SPVO, Secondary to Primary V Out loop
329 VMC_2p2z_Rev.aCoefficients = &VMC_2p2zACoefficients_Rev[0]; // Set up pointer to derived coefficients
330 VMC_2p2z_Rev.bCoefficients = &VMC_2p2zBCoefficients_Rev[0]; // Set up pointer to derived coefficients
331 VMC_2p2z_Rev.controlHistory = &VMC_2p2zControlHistory_Rev[0]; // Set up pointer to controller history
332 VMC_2p2z_Rev.errorHistory = &VMC_2p2zErrorHistory_Rev[0]; // Set up pointer to error history
333
339
340 VMC_2p2zACoefficients_Rev[0] = DAB_SPVO_COMP_2P2Z_COEFF_A1;
341 VMC_2p2zACoefficients_Rev[1] = DAB_SPVO_COMP_2P2Z_COEFF_A2;
342 VMC_2p2zBCoefficients_Rev[0] = DAB_SPVO_COMP_2P2Z_COEFF_B0;
343 VMC_2p2zBCoefficients_Rev[1] = DAB_SPVO_COMP_2P2Z_COEFF_B1;
344 VMC_2p2zBCoefficients_Rev[2] = DAB_SPVO_COMP_2P2Z_COEFF_B2;
345
346 //explicit clear to 0
347 VMC_2p2zControlHistory_Rev[0] = 0;
348 VMC_2p2zControlHistory_Rev[1] = 0;
349 VMC_2p2zErrorHistory_Rev[0] = 0;
350 VMC_2p2zErrorHistory_Rev[1] = 0;
351 VMC_2p2zErrorHistory_Rev[2] = 0;
352
354
355}
356
357
370{
371 //charger, PSIO, Primary to Secondary I Out loop
372 IMC_2p2z.aCoefficients = &IMC_2p2zACoefficients[0]; // Set up pointer to derived coefficients
373 IMC_2p2z.bCoefficients = &IMC_2p2zBCoefficients[0]; // Set up pointer to derived coefficients
374 IMC_2p2z.controlHistory = &IMC_2p2zControlHistory[0]; // Set up pointer to controller history
375 IMC_2p2z.errorHistory = &IMC_2p2zErrorHistory[0]; // Set up pointer to error history
376
382
383
384 IMC_2p2zACoefficients[0] = DAB_PSIO_COMP_2P2Z_COEFF_A1;
385 IMC_2p2zACoefficients[1] = DAB_PSIO_COMP_2P2Z_COEFF_A2;
386 IMC_2p2zBCoefficients[0] = DAB_PSIO_COMP_2P2Z_COEFF_B0;
387 IMC_2p2zBCoefficients[1] = DAB_PSIO_COMP_2P2Z_COEFF_B1;
388 IMC_2p2zBCoefficients[2] = DAB_PSIO_COMP_2P2Z_COEFF_B2;
389
390 //explicit clear to 0
391 IMC_2p2zControlHistory[0] =0;
392 IMC_2p2zControlHistory[1] =0;
393 IMC_2p2zErrorHistory[0] =0;
394 IMC_2p2zErrorHistory[1] =0;
395 IMC_2p2zErrorHistory[2] =0;
396
398
399 //discharger, SPIO, Secondary to Primary I Out loop
400 IMC_2p2z_Rev.aCoefficients = &IMC_2p2zACoefficients_Rev[0]; // Set up pointer to derived coefficients
401 IMC_2p2z_Rev.bCoefficients = &IMC_2p2zBCoefficients_Rev[0]; // Set up pointer to derived coefficients
402 IMC_2p2z_Rev.controlHistory = &IMC_2p2zControlHistory_Rev[0]; // Set up pointer to controller history
403 IMC_2p2z_Rev.errorHistory = &IMC_2p2zErrorHistory_Rev[0]; // Set up pointer to error history
404
405 IMC_2p2z_Rev.preShift = DAB_SPIO_COMP_2P2Z_PRESHIFT;//SPIO TBD
406 IMC_2p2z_Rev.postScaler = DAB_SPIO_COMP_2P2Z_POSTSCALER;
407 IMC_2p2z_Rev.postShift = DAB_SPIO_COMP_2P2Z_POSTSHIFT;
408 IMC_2p2z_Rev.minOutput = DAB_SPIO_COMP_2P2Z_MIN_CLAMP;
409 IMC_2p2z_Rev.maxOutput = DAB_SPIO_COMP_2P2Z_MAX_CLAMP;
410
411
412 IMC_2p2zACoefficients_Rev[0] = DAB_SPIO_COMP_2P2Z_COEFF_A1;
413 IMC_2p2zACoefficients_Rev[1] = DAB_SPIO_COMP_2P2Z_COEFF_A2;
414 IMC_2p2zBCoefficients_Rev[0] = DAB_SPIO_COMP_2P2Z_COEFF_B0;
415 IMC_2p2zBCoefficients_Rev[1] = DAB_SPIO_COMP_2P2Z_COEFF_B1;
416 IMC_2p2zBCoefficients_Rev[2] = DAB_SPIO_COMP_2P2Z_COEFF_B2;
417
418 //explicit clear to 0
419 IMC_2p2zControlHistory_Rev[0] =0;
420 IMC_2p2zControlHistory_Rev[1] =0;
421 IMC_2p2zErrorHistory_Rev[0] =0;
422 IMC_2p2zErrorHistory_Rev[1] =0;
423 IMC_2p2zErrorHistory_Rev[2] =0;
424
426}
427
428
440void PwrCtrl_PComp_Initialize(void) //only battery has power sense option. should be bidirectional
441{
442 //charger, PSPO, Primary to Secondary Power Out loop
443 PMC_2p2z.aCoefficients = &PMC_2p2zACoefficients[0]; // Set up pointer to derived coefficients
444 PMC_2p2z.bCoefficients = &PMC_2p2zBCoefficients[0]; // Set up pointer to derived coefficients
445 PMC_2p2z.controlHistory = &PMC_2p2zControlHistory[0]; // Set up pointer to controller history
446 PMC_2p2z.errorHistory = &PMC_2p2zErrorHistory[0]; // Set up pointer to error history
447
453
454 PMC_2p2zACoefficients[0] = DAB_PSPO_COMP_2P2Z_COEFF_A1;
455 PMC_2p2zACoefficients[1] = DAB_PSPO_COMP_2P2Z_COEFF_A2;
456 PMC_2p2zBCoefficients[0] = DAB_PSPO_COMP_2P2Z_COEFF_B0;
457 PMC_2p2zBCoefficients[1] = DAB_PSPO_COMP_2P2Z_COEFF_B1;
458 PMC_2p2zBCoefficients[2] = DAB_PSPO_COMP_2P2Z_COEFF_B2;
459
460 //explicit clear to 0
461 PMC_2p2zControlHistory[0] =0;
462 PMC_2p2zControlHistory[1] =0;
463 PMC_2p2zErrorHistory[0] =0;
464 PMC_2p2zErrorHistory[1] =0;
465 PMC_2p2zErrorHistory[2] =0;
466
468
469
470 //discharger, SPPO, Primary to Secondary Power Out loop
471 PMC_2p2z_Rev.aCoefficients = &PMC_2p2zACoefficients_Rev[0]; // Set up pointer to derived coefficients
472 PMC_2p2z_Rev.bCoefficients = &PMC_2p2zBCoefficients_Rev[0]; // Set up pointer to derived coefficients
473 PMC_2p2z_Rev.controlHistory = &PMC_2p2zControlHistory_Rev[0]; // Set up pointer to controller history
474 PMC_2p2z_Rev.errorHistory = &PMC_2p2zErrorHistory_Rev[0]; // Set up pointer to error history
475
476 PMC_2p2z_Rev.preShift = DAB_SPPO_COMP_2P2Z_PRESHIFT;
477 PMC_2p2z_Rev.postScaler = DAB_SPPO_COMP_2P2Z_POSTSCALER;
478 PMC_2p2z_Rev.postShift = DAB_SPPO_COMP_2P2Z_POSTSHIFT;
479 PMC_2p2z_Rev.minOutput = DAB_SPPO_COMP_2P2Z_MIN_CLAMP;
480 PMC_2p2z_Rev.maxOutput = DAB_SPPO_COMP_2P2Z_MAX_CLAMP;
481
482 PMC_2p2zACoefficients_Rev[0] = DAB_SPPO_COMP_2P2Z_COEFF_A1;
483 PMC_2p2zACoefficients_Rev[1] = DAB_SPPO_COMP_2P2Z_COEFF_A2;
484 PMC_2p2zBCoefficients_Rev[0] = DAB_SPPO_COMP_2P2Z_COEFF_B0;
485 PMC_2p2zBCoefficients_Rev[1] = DAB_SPPO_COMP_2P2Z_COEFF_B1;
486 PMC_2p2zBCoefficients_Rev[2] = DAB_SPPO_COMP_2P2Z_COEFF_B2;
487
488 //explicit clear to 0
489 PMC_2p2zControlHistory_Rev[0] =0;
490 PMC_2p2zControlHistory_Rev[1] =0;
491 PMC_2p2zErrorHistory_Rev[0] =0;
492 PMC_2p2zErrorHistory_Rev[1] =0;
493 PMC_2p2zErrorHistory_Rev[2] =0;
494
496
497}
498
499
508{
509 //explicit clear to 0
510 VMC_2p2zControlHistory[0] = 0;
511 VMC_2p2zControlHistory[1] = 0;
512 VMC_2p2zErrorHistory[0] = 0;
513 VMC_2p2zErrorHistory[1] = 0;
514 VMC_2p2zErrorHistory[2] = 0;
515
516 //explicit clear to 0
517 IMC_2p2zControlHistory[0] = 0;
518 IMC_2p2zControlHistory[1] = 0;
519 IMC_2p2zErrorHistory[0] = 0;
520 IMC_2p2zErrorHistory[1] = 0;
521 IMC_2p2zErrorHistory[2] = 0;
522
523 //explicit clear to 0
524 PMC_2p2zControlHistory[0] = 0;
525 PMC_2p2zControlHistory[1] = 0;
526 PMC_2p2zErrorHistory[0] = 0;
527 PMC_2p2zErrorHistory[1] = 0;
528 PMC_2p2zErrorHistory[2] = 0;
529
530 //explicit clear to 0
531 VMC_2p2zControlHistory_Rev[0] = 0;
532 VMC_2p2zControlHistory_Rev[1] = 0;
533 VMC_2p2zErrorHistory_Rev[0] = 0;
534 VMC_2p2zErrorHistory_Rev[1] = 0;
535 VMC_2p2zErrorHistory_Rev[2] = 0;
536
537 //explicit clear to 0
538 IMC_2p2zControlHistory_Rev[0] = 0;
539 IMC_2p2zControlHistory_Rev[1] = 0;
540 IMC_2p2zErrorHistory_Rev[0] = 0;
541 IMC_2p2zErrorHistory_Rev[1] = 0;
542 IMC_2p2zErrorHistory_Rev[2] = 0;
543
544 //explicit clear to 0
545 PMC_2p2zControlHistory_Rev[0] = 0;
546 PMC_2p2zControlHistory_Rev[1] = 0;
547 PMC_2p2zErrorHistory_Rev[0] = 0;
548 PMC_2p2zErrorHistory_Rev[1] = 0;
549 PMC_2p2zErrorHistory_Rev[2] = 0;
550
551}
552
#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.
SMPS_2P2Z_T VMC_2p2z_Rev
Data Object of voltage mode control generated by DCDT.
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.
SMPS_2P2Z_T PMC_2p2z_Rev
Data Object of power mode control.
SMPS_2P2Z_T IMC_2p2z_Rev
Data Object of current mode 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