Bar Logo Dual Active Bridge Development Board (Part-No. )
 
Content
     
Loading...
Searching...
No Matches
pwrctrl.c
Go to the documentation of this file.
1
9#include <xc.h>
10
11//MCC header files
12#include "pwm_hs/pwm_hs_types.h"
13#include "pwm_hs/pwm.h"
14
15//DAB header files
16#include "config/macros.h"
17#include "pwrctrl.h"
18#include "fault/fault.h"
19#include "dcdt/pwrctrl_dcdt.h"
20
21
28POWER_CONTROL_t dab; // Declare DAB converter data structure, global, only one instance
29
30// PRIVATE FUNCTIONS
31static void PwrCtrl_StartUpInitialize(void);
32static void PwrCtrl_ControlLoopInitialize(void);
33
34// PUBLIC FUNCTIONS
35extern void PwrCtrl_StateMachine(POWER_CONTROL_t* pcInstance);
36
37
46{
47 // Clear dab references
52
53 // Initialize the Control Period and Control Phase during start-up
58
59 // Initialize the DAB to charging state
61
62 // Initialize Start-Up ramp settings
64
65 // Initialize Power Control Loop
67
68 // Disable PWM output by setting the PWM override bits to High
70
71 // Enable PWM peripheral
72 PWM_Enable();
73
74 // Update the Period, Duty Cycle and Phases of the PWMs based on
75 // the given Control period and Control Phase
77}
78
79
89{
90 // Execute the state machine
92}
93
94
103{
104 //set the period to maximum
109
110 // Reset the power control references
115
116 // Initialize current loop reference to 0, to be controlled externally
117 dab.ILoop.Reference = 0;
118 // Initialize power loop reference to 0, to be controlled externally
119 dab.PLoop.Reference = 0;
120 // Initialize voltage loop reference to current secondary voltage
121 dab.VLoop.Reference = 0;
122
123 // Set the AGC to 1
124 dab.VLoop.AgcFactor = 0x7FFF;
125 dab.ILoop.AgcFactor = 0x7FFF;
126 dab.PLoop.AgcFactor = 0x7FFF;
127
128 // Reset Control Loop Histories
130}
131
132
133
142{
143 // Initialize voltage loop compensator
145
146 // Initialize current loop compensator
148
149 // Initialize power loop compensator
151
152 // Voltage loop properties initialize
153 dab.VLoop.Enable = false;
154 dab.VLoop.AgcFactor = 0x7FFF;
155 dab.VLoop.Feedback = 0;
156 dab.VLoop.Output = 0;
157 dab.VLoop.Reference = 0;
158
159 // Current loop properties initialize
160 dab.ILoop.Enable = false;
161 dab.ILoop.AgcFactor = 0x7FFF;
162 dab.ILoop.Feedback = 0;
163 dab.ILoop.Output = 0;
164 dab.ILoop.Reference = 0;
165
166 // Power loop properties initialize
167 dab.PLoop.Enable = false;
168 dab.PLoop.AgcFactor = 0x7FFF;
169 dab.PLoop.Feedback = 0;
170 dab.PLoop.Output = 0;
171 dab.PLoop.Reference = 0;
172
173}
174
175
187{
188 // Initialize Voltage ramp-up settings
189 dab.VRamp.ptrReference = (uint16_t *)&dab.VLoop.Reference;
190
191
193 {
195 }
196 else
197 {
199 }
200
201 dab.VRamp.StepSize = 1;
202 dab.VRamp.Delay = 20;
203 dab.VRamp.Counter = 0;
205
206 //Initialize Current ramp-up settings
207 dab.IRamp.ptrReference = (uint16_t*)&dab.ILoop.Reference;
209 dab.IRamp.StepSize = 1;
210 dab.IRamp.Delay = 60;
211 dab.IRamp.Counter = 0;
213
214 //Initialize Power ramp-up settings
215 dab.PRamp.ptrReference = (uint16_t*)&dab.PLoop.Reference;
217 dab.PRamp.StepSize = 1;
218 dab.PRamp.Delay = 4;
219 dab.PRamp.Counter = 0;
221
222 #if defined (OPEN_LOOP_PBV) && (OPEN_LOOP_PBV == true)
223 // The PWM Period bits [2:0] needs to be mask when using cascaded PWM setup
224 // (please refer to Section 4.1.3.3 in High Resolution PWM FRM)
225 uint16_t PeriodMask = 0x7;
226
227 // Initialize Voltage ramp-up settings for Period control
228 dab.Pwm.ControlPeriod = dab.Pwm.ControlPeriod & ~(PeriodMask);
229 dab.Pwm.PBVPeriodTarget = dab.Pwm.PBVPeriodTarget & ~(PeriodMask);
230
233 dab.VRamp.StepSize = 0xE;
234 dab.VRamp.Delay = 0;
235
236 //Initialize Current ramp-up settings for Phase control
237 dab.Pwm.ControlPhase = dab.Pwm.ControlPhase & ~(PeriodMask);
239
242 dab.IRamp.StepSize = 0xE;
243 dab.IRamp.Delay = 0;
244
245#endif
246}
247
This is the generated driver header file for the PWM driver.
This is the generated driver types header file for the PWM driver.
Contains public fault functions.
Contains public functions and data types relevant for DCDT file interface.
#define MINIMUM_DEADTIME
Minimum Deadtime in seconds [sec].
Definition config.h:27
#define MAX_PWM_PERIOD
This sets the switching period of the converter.
Definition macros.h:40
void PwrCtrl_Initialize(void)
Initialize the power control parameters.
Definition pwrctrl.c:45
static void PwrCtrl_StartUpInitialize(void)
Initialize the StartUp Ramp configuration.
Definition pwrctrl.c:186
void PwrCtrl_Execute(void)
Executes the power control state machine.
Definition pwrctrl.c:88
POWER_CONTROL_t dab
Global data object for a DAB Converter.
Definition pwrctrl.c:28
void PwrCtrl_Reset(void)
Resets the power control properties.
Definition pwrctrl.c:102
static void PwrCtrl_ControlLoopInitialize(void)
Initializes the control loop.
Definition pwrctrl.c:141
void PwrCtrl_PWM_Update(POWER_CONTROL_t *pcInstance)
PWM distribution for DAB converter.
Definition pwrctrl_pwm.c:25
void PwrCtrl_PWM_Disable(void)
Disable the PWM output.
void PwrCtrl_StateMachine(POWER_CONTROL_t *pcInstance)
Manages the power control state machine.
Definition pwrctrl_sm.c:72
void PwrCtrl_IComp_Initialize(void)
Initialize the Current Loop Control.
void PwrCtrl_PComp_Initialize(void)
Initialize the Power Loop Control.
void PwrCtrl_VComp_Initialize(void)
Initialize the Voltage Loop Control.
void PwrCtrl_ResetControlLoopHistories(void)
Clear the control and error histories of the control loops.
@ PWR_CTRL_DISCHARGING
power converter is in discharging mode
@ PWR_CTRL_STOP
static void PWM_Enable(void)
This inline function will enable all the generators of PWM module.
Definition pwm.h:412
uint16_t ControlPeriod
Control period value from control loop.
uint16_t DeadTimeHigh
Deadtime High settings for PWM.
uint16_t DeadTimeLow
Deadtime High settings for PWM.
uint16_t PBVPeriodTarget
Power Board Visualizer Set Control target.
uint16_t ControlPhase
Control phase value from control loop.
uint16_t PBVControlPhaseTarget
Power Board Visualizer Set Control phase.
bool RampComplete
indicates when ramp-up is complete
uint16_t Delay
Soft-Start Period (POD, RAMP PERIOD, PGD, etc.)
uint16_t * ptrReferenceTarget
pointer to the ramp-up reference target
uint16_t * ptrReference
pointer the reference variable
uint16_t Counter
Soft-Start Execution Counter. This setting is set/cleared by the device driver and is 'read only'.
uint16_t StepSize
Size/value of one reference increment/decrement or this period.
uint16_t Output
controller output
bool Enable
Enable control loop.
int16_t Reference
actual reference
uint16_t Feedback
coming
int16_t AgcFactor
Adaptive gain control.
uint16_t PwrReference
User power reference setting used to control the converter controller.
int16_t IReference
User current reference setting used to control the converter controller.
uint16_t VPriReference
User primary-voltage port reference setting used to control the power converter output voltage in boo...
uint16_t VSecReference
User secondary-voltage port reference setting used to control the power converter output voltage in b...
Power control API structure.
CONTROLLER_t ILoop
structure for current controller data
SWITCH_NODE_t Pwm
Switch node settings.
CONTROLLER_t PLoop
structure for power controller data
PWR_CTRL_PROPERTIES_t Properties
Power Control properties
CONTROLLER_t VLoop
structure for voltage controller data
START_UP_RAMP_t PRamp
Power ramp-up settings.
PWR_CTRL_CHARGE_STATE_t PowerDirection
defines if the power converter is in charging or discharging mode
START_UP_RAMP_t VRamp
Voltage ramp-up settings.
START_UP_RAMP_t IRamp
Current ramp-up settings.