Bar Logo 4kW dsPIC33C PSFB DC-DC DA (Part-No. )
 
Content
     
Loading...
Searching...
No Matches
pwrctrl_isr_extension.c
Go to the documentation of this file.
1
9#include <xc.h>
10#include <math.h>
11#include <stdbool.h>
12#include <stdlib.h>
13
14// MCC header files
15#include "adc/adc_types.h"
16#include "adc/adc1.h"
17#include "system/pins.h"
18
19// PSFB header files
20//#include "config/macros.h"
21//#include "config/config.h"
22#include "pwrctrl.h"
23#include "fault/fault.h"
24#include "dcdt/pwrctrl_dcdt.h"
25
26
27
28
38{
39 // Enable the ADC sampling
40 // ADC1_SoftwareTriggerEnable();
41
42/* if(ADC1_IsConversionComplete(I_SEC_AVG_FILT))
43 psfb_ptr->Data.ISenseSecondary = ADC1_ConversionResultGet(I_SEC_AVG_FILT); */
44
45/* if(ADC1_IsConversionComplete(IPRI_CT))
46 psfb_ptr->Data.ISensePrimary = ADC1_ConversionResultGet(IPRI_CT); */
47
50 }
51
54
57
60 // vPrimAveraging.Accumulator += psfb_ptr->Data.VInVoltage;
61 // vPrimAveraging.Counter = vPrimAveraging.Counter + 1;
62 }
63
66 // vOutAveraging.Accumulator += psfb_ptr->Data.VOutVoltage;
67 // vOutAveraging.Counter = vOutAveraging.Counter + 1;
68 }
69
70// if(ADC1_IsConversionComplete(I_SEC_AVG_FILT)){
71// psfb_ptr->Data.ISenseSecondary = ADC1_ConversionResultGet(I_SEC_AVG_FILT);
72// psfb_ptr->Data.ISecAverageRectified = abs(psfb_ptr->Data.ISenseSecondary - psfb_ptr->Data.ISecSensorOffset);
73// iSecAveraging.Accumulator += psfb_ptr->Data.ISecAverageRectified;
74// iSecAveraging.Counter = iSecAveraging.Counter + 1;
75// }
76}
77
78
79
91{
92 // control loop execute
93 uint16_t IloopReference = 0;
94
95 if (psfb_ptr->VLoop.Enable == 1) {
96 // psfb_ptr->VLoop.Feedback = psfb_ptr->Data.VCapVoltage;
98
100 &VMC_2p2z, // SPMPS_2P2Z_T pointer type structure
101 &(psfb_ptr->VLoop.Feedback), // pointer to the input source register or variable being tracked by 2P2Z
102 psfb_ptr->VLoop.Reference, // VLoopReference from Vramp
103 &(psfb_ptr->VLoop.Output) // pointer to the control loop target register of the calculated result
104 );
105 }
106 // Vloop output
107 IloopReference = psfb_ptr->VLoop.Output;
108
109 if (psfb_ptr->ILoop.Enable == 1) {
110// psfb_ptr->ILoop.Feedback = psfb_ptr->Data.ISenseSecondary;
112
114 &IMC_3p3z, // SPMPS_2P2Z_T pointer type structure
115 &(psfb_ptr->ILoop.Feedback), // pointer to the input source register or variable being tracked by 2P2Z
116 //psfb_ptr->ILoop.Reference, // ILoopReference from Iramp
117 psfb_ptr->VLoop.Output, // IloopReference from Vloop
118 &(psfb_ptr->ILoop.Output) // pointer to the control loop target register of the calculated result
119 );
120
121 // temporary
122 // psfb_ptr->iloop_output = psfb_ptr->ILoop.Output;
123 // psfb_ptr->vloop_output = psfb_ptr->VLoop.Output;
124
125
128 }
129}
130
131
139 // average of last 100 values
140 if(psfb_ptr->ISecAveraging.Counter >= 99) {
144 }
145}
This is the generated driver header file for the ADC1 driver.
This is the generated driver types header file for the ADC driver.
@ FB_TEMP
Definition adc_types.h:60
@ FB_VOUT
Definition adc_types.h:57
@ FB_5V
Definition adc_types.h:62
@ VIN_INT_AN
Definition adc_types.h:59
@ FB_VCAP
Definition adc_types.h:58
Contains public fault functions.
Contains public functions and data types relevant for DCDT file interface.
void SMPS_Controller3P3ZUpdate(SMPS_3P3Z_T *controllerData, volatile uint16_t *controllerInputRegister, int16_t reference, volatile uint16_t *controllerOutputRegister)
void SMPS_Controller2P2ZUpdate(SMPS_2P2Z_T *controllerData, volatile uint16_t *controllerInputRegister, int16_t reference, volatile uint16_t *controllerOutputRegister)
POWER_CONTROL_t * psfb_ptr
Definition pwrctrl.c:28
void PwrCtrl_ControlLoopExecute(void)
Executes the power converter control loop.
void PwrCtrl_UpdateADConverterData(void)
This function updates the PSFB data members with ADC raw values.
void PwrCtrl_DroopAverage(void)
Averages secondary current for droop.
void PwrCtrl_PWM_Update()
PWM distribution for PSFB converter.
Definition pwrctrl_pwm.c:26
SMPS_2P2Z_T VMC_2p2z
Data Object of voltage mode control generated by DCDT.
SMPS_3P3Z_T IMC_3p3z
Data Object of current mode control.
void PwrCtrl_SetPhaseTarget(uint16_t reference)
API function to set the target PWM phase.
static bool ADC1_IsConversionComplete(enum ADC_CHANNEL channel)
This inline function returns the status of conversion.This function is used to determine if conversio...
Definition adc1.h:226
static uint16_t ADC1_ConversionResultGet(enum ADC_CHANNEL channel)
Returns the conversion value for the channel selected.
Definition adc1.h:178
uint16_t VCapVoltage
Data value for capacitor.
uint16_t VInVoltage
Data value for input voltage.
uint16_t VRail_5V
Data value for 5V auxiliary rail.
uint16_t Temperature
Data value for temperature.
uint16_t VOutVoltage
Data value for output voltage.
uint16_t Output
controller output
bool Enable
Enable control loop.
int16_t Reference
actual reference
uint16_t Feedback
coming
uint32_t Accumulator
uint16_t AverageValue
CONTROLLER_t ILoop
structure for current controller data
CONTROLLER_t VLoop
structure for voltage controller data
FEEDBACK_SETTINGS_t Data
Feedback channel settings.
AVERAGING_t ISecAveraging
secondary current average
uint16_t Secondary_Rolling_val
Secondary Current Rolling Average Value.