Bar Logo 4kW dsPIC33C PSFB DC-DC DA (Part-No. )
 
Content
     
Loading...
Searching...
No Matches
pwrctrl.c
Go to the documentation of this file.
1
8#include <xc.h>
9
10//MCC header files
11#include "pwm_hs/pwm_hs_types.h"
12#include "pwm_hs/pwm.h"
13
14//PSFB header files
15//#include "config/macros.h"
16#include "pwrctrl.h"
17//#include "fault/fault.h"
18
19
20
27POWER_CONTROL_t psfb; // Declare psfb converter data structure
29
30// PRIVATE FUNCTIONS
31static void PwrCtrl_StartUpInitialize(void);
32static void PwrCtrl_ControlLoopInitialize(void);
33
34
36extern void PwrCtrl_StateMachine(POWER_CONTROL_t* pcInstance);
37
38
47
48 // Clear references
53
54
55 // Initialize Start-Up ramp settings
56 PwrCtrl_StartUpInitialize(); // ramp initialize
57
58 // Initialize Power Control Loop
59 PwrCtrl_ControlLoopInitialize(); //coefficents and SMPS_Controller2P2ZInitialize
60
61 //TODO: ??
62
63}
64
73void PwrCtrl_Execute(void) {
74 // Execute the state machine
76}
77
78
85void PwrCtrl_Reset(void){
86 //set the period to maximum
87
88/* psfb.Pwm.ControlPeriod = MAX_PWM_PERIOD;
89 psfb.Pwm.ControlPhase = psfb.Pwm.DeadTimeLow;
90 psfb.Pwm.PBVPeriodTarget = MAX_PWM_PERIOD;
91 psfb.Pwm.PBVControlPhaseTarget = psfb.Pwm.DeadTimeLow; */
92
93 // Reset the power control references
98
99 // Initialize current loop reference to 0, to be controlled externally
100 psfb.ILoop.Reference = 0;
101 // Initialize power loop reference to 0, to be controlled externally
102 psfb.PLoop.Reference = 0;
103 // Initialize voltage loop reference to current secondary voltage
104 psfb.VLoop.Reference = 0;
105
106 // Set the AGC to 1
107 psfb.VLoop.AgcFactor = 0x7FFF;
108 psfb.ILoop.AgcFactor = 0x7FFF;
109 psfb.PLoop.AgcFactor = 0x7FFF;
110
111 // Reset Control Loop Histories
113}
114
115
116
128{
129 // Initialize Voltage ramp-up settings
132 psfb.VRamp.StepSize = 1;
133 psfb.VRamp.Delay = 4;
134 psfb.VRamp.Counter = 0;
136
137 //Initialize Current ramp-up settings
140 psfb.IRamp.StepSize = 1;
141 psfb.IRamp.Delay = 60;
142 psfb.IRamp.Counter = 0;
144
145}
146
147
148
157{
158 //VCOMP_ControlObject_Initialize();
159
160 // Initialize current loop compensator
161 //PwrCtrl_IComp_Initialize();
162
163 // Initialize voltage loop compensator
165
166 //Initialize the current loop 3p3z
168
169 // Current loop properties initialize
170 psfb.ILoop.Enable = false;
171 psfb.ILoop.AgcFactor = 0x7FFF;
172 psfb.ILoop.Feedback = 0;
173 psfb.ILoop.Output = 0;
174 psfb.ILoop.Reference = 0;
175
176 // Voltage loop properties initialize
177 psfb.VLoop.Enable = false;
178 psfb.VLoop.AgcFactor = 0x7FFF;
179 psfb.VLoop.Feedback = 0;
180 psfb.VLoop.Output = 0;
181 psfb.VLoop.Reference = 0;
182}
183
184
193 // 10 volts
194 // for 10 volts
195 // divided by 8 to keep it within 16bits
196 psfb.Precharge.scaler = 10 * 2 * 17 * 54;
198 // divided by 8 as scaler is also divided by 8
200
202
203 if (psfb.Precharge.maxDutyCycle > 80)
204 psfb.Precharge.maxDutyCycle = 80; // limit precharge to 80 percent dutycycle
205}
206
207
This is the generated driver header file for the PWM driver.
This is the generated driver types header file for the PWM driver.
POWER_CONTROL_t * psfb_ptr
Definition pwrctrl.c:28
void PwrCtrl_Initialize(void)
Initialize the power control parameters.
Definition pwrctrl.c:46
static void PwrCtrl_StartUpInitialize(void)
Initialize the StartUp Ramp configuration.
Definition pwrctrl.c:127
void PwrCtrl_Execute(void)
Executes the power control state machine.
Definition pwrctrl.c:73
POWER_CONTROL_t psfb
Global data object for a PSFB Converter.
Definition pwrctrl.c:27
void PwrCtrl_OffsetDatatypesInitalize(void)
reset offset data types
Definition pwrctrl.c:214
void PwrCtrl_Reset(void)
Resets the power control properties.
Definition pwrctrl.c:85
void PwrCtrl_MaxDutyCycle(void)
Calculates the max duty cycle for precharge.
Definition pwrctrl.c:192
static void PwrCtrl_ControlLoopInitialize(void)
Initializes the control loop.
Definition pwrctrl.c:156
void PwrCtrl_StateMachine(POWER_CONTROL_t *pcInstance)
Manages the power control state machine.
Definition pwrctrl_sm.c:48
void PwrCtrl_IComp_3p3z_Initialize(void)
Initialize the Current 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.
uint16_t Dev_PwrCtrl_GetAdc_Vpri(void)
API function to get the value of the sampled ADC for input Voltage.
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...
uint16_t primaryVoltage
uint16_t maxDutyCycle
uint16_t AveragingCount
uint16_t AverageValue
Power control API structure.
CONTROLLER_t ILoop
structure for current controller data
CONTROLLER_t PLoop
structure for power controller data
PWR_CTRL_PROPERTIES_t Properties
Power Control properties
PRECHARGE_t Precharge
structure for precharge data
AVERAGING_t VoutCalibratingAveraging
structure for averaging Vout during Droop
CONTROLLER_t VLoop
structure for voltage controller data
AVERAGING_t SecondarySh_Offset
structure for averaging secondary sensor offset
AVERAGING_t PrimaryCT_Offset
structure for averaging primary CT offset
START_UP_RAMP_t VRamp
Voltage ramp-up settings.
START_UP_RAMP_t IRamp
Current ramp-up settings.