|  | Dual Active Bridge Development Board (Part-No. ) |
Content |  |  |  |  |  |

Loading...
Searching...
No Matches
pwrctrl_isr.c
Go to the documentation of this file.
1
10#include <xc.h>
11#include <math.h>
12#include <stdbool.h>
13#include <stdlib.h>
14
15// MCC header files
16#include "timer/sccp1.h"
17#include "adc/adc1.h"
18#include "system/pins.h"
19
20// DAB header files
21#include "config/macros.h"
22#include "config/config.h"
23#include "pwrctrl.h"
24#include "fault/fault.h"
25
26// PRIVATE FUNCTIONS
27void PwrCtrl_PrimToSecPHDegree(void);
28void PwrCtrl_DeadTimeAdjust(void);
29 void PwrCtrl_PeriodModulator(void);
30void PwrCtrl_UpdateADConverterData(void);
31void PwrCtrl_ControlLoopExecute(void);
32void PwrCtrl_10KHzVPLoopPrepareData(void);
33
34
46 void ControlLoop_Interrupt_CallBack(void)
47{
48 GPIO_1_SetHigh();
49
50 // Update the ADC data member
51 PwrCtrl_UpdateADConverterData();
52
53 // Execute the fault detection
54 Fault_Execute();
55
56 // Performs data averaging necessary for control loop
57 // also Enabling interleaved the Vloop (10KHz execution)
58 // and Ploop (10KHz execution) enable bit
59 PwrCtrl_10KHzVPLoopPrepareData();
60
61 #if defined (OPEN_LOOP_PBV) && (OPEN_LOOP_PBV == false)
62
63 if(dab.Status.bits.Running == 1){
64 // Execute Power Converter Control Loop
65 PwrCtrl_ControlLoopExecute(); }
66
67 // Measure Primary to Secondary phase in degrees
68 PwrCtrl_PrimToSecPHDegree();
69
70 // Adjust DeadTime based on Primary to Secondary phase in degrees
71 PwrCtrl_DeadTimeAdjust();
72
73 #if defined (PERIOD_MODULATION_DEMO) && (PERIOD_MODULATION_DEMO == true)
74 PwrCtrl_PeriodModulator();
75 #endif
76
77 #endif
78
79 #if defined (DAC_DEBUG) && (DAC_DEBUG == true)
80 // This is for DAC debugging purposes
81// CMP2_DACDataWrite(variable_to_test_here);
82 #endif
83
84 #if defined (OPEN_LOOP_POTI) && (OPEN_LOOP_POTI == true)
85
86 // Connect TP11 -> Pot1 & TP12 -> Pot2 in digital Power Development Board
87 uint16_t Pot1 = dab.Data.ISecAverage;
88 uint16_t Pot2 = dab.Data.ISenseSecondary;
89
90 // Calculate the Frequency based on the Potentiometer 1 voltage
91 dab.Pwm.ControlPeriod = (uint16_t)(MIN_PWM_PERIOD + (Pot1 * ADC_PERIOD_RANGE));
92
93 // Change the control Phase with Potentiometer 2
94 dab.Pwm.ControlPhase = (uint16_t)(Pot2 * ADC_SCALER * (dab.Pwm.ControlPeriod >> 1));
95
96 #endif
97
98 // Update PWM Properties
99 PwrCtrl_PWM_Update(&dab);
100
101 // Enable the ADC sampling
102 ADC1_SoftwareTriggerEnable();
103
104 GPIO_1_SetLow();
105}
adc1.h
This is the generated driver header file for the ADC1 driver.
sccp1.h
This is the generated driver header file for the SCCP1-TIMER driver.
fault.h
Contains public fault functions.
PwrCtrl_PeriodModulator
void PwrCtrl_PeriodModulator(void)
ADC_PERIOD_RANGE
#define ADC_PERIOD_RANGE
This is the calculation for ADC equivalent with Period range. NOTE: only use in Debugging moode using...
Definition macros.h:43
MIN_PWM_PERIOD
#define MIN_PWM_PERIOD
This sets the switching period of the converter.
Definition macros.h:41
dab
POWER_CONTROL_t dab
Global data object for a DAB Converter.
Definition pwrctrl.c:28
PwrCtrl_ControlLoopExecute
void PwrCtrl_ControlLoopExecute(void)
Executes the power converter control loop.
Definition pwrctrl_isr_extension.c:210
PwrCtrl_DeadTimeAdjust
void PwrCtrl_DeadTimeAdjust(void)
This function updates the DAB data members dead time based on load.
Definition pwrctrl_isr_extension.c:379
PwrCtrl_UpdateADConverterData
void PwrCtrl_UpdateADConverterData(void)
This function updates the DAB data members with ADC raw values.
Definition pwrctrl_isr_extension.c:65
PwrCtrl_10KHzVPLoopPrepareData
void PwrCtrl_10KHzVPLoopPrepareData(void)
This function prepares the data for control loop and selects which control loop will be executed.
Definition pwrctrl_isr_extension.c:112
PwrCtrl_PrimToSecPHDegree
void PwrCtrl_PrimToSecPHDegree(void)
This function updates the DAB data members with phase values normalized in degree.
Definition pwrctrl_isr_extension.c:351
ControlLoop_Interrupt_CallBack
void ControlLoop_Interrupt_CallBack(void)
Executes the power converter control loop.
Definition pwrctrl_isr.c:46
PwrCtrl_PWM_Update
void PwrCtrl_PWM_Update(POWER_CONTROL_t *pcInstance)
PWM distribution for DAB converter.
Definition pwrctrl_pwm.c:24
Fault_Execute
void Fault_Execute(void)
Executes the fault handlers.
Definition fault.c:115
ADC1_SoftwareTriggerEnable
static void ADC1_SoftwareTriggerEnable(void)
This inline function sets software common trigger.
Definition adc1.h:134
GPIO_1_SetHigh
#define GPIO_1_SetHigh()
Sets the RC10 GPIO Pin which has a custom name of GPIO_1 to High.
Definition pins.h:53
GPIO_1_SetLow
#define GPIO_1_SetLow()
Sets the RC10 GPIO Pin which has a custom name of GPIO_1 to Low.
Definition pins.h:62
SWITCH_NODE_s::ControlPeriod
uint16_t ControlPeriod
Control period value from control loop.
Definition pwrctrl_typedef.h:37
SWITCH_NODE_s::ControlPhase
uint16_t ControlPhase
Control phase value from control loop.
Definition pwrctrl_typedef.h:39
FEEDBACK_SETTINGS_s::ISecAverage
uint16_t ISecAverage
Data value for average secondary current as measured with isolated current sensor.
Definition pwrctrl_typedef.h:63
FEEDBACK_SETTINGS_s::ISenseSecondary
uint16_t ISenseSecondary
Data value for secondary current as measured with CT.
Definition pwrctrl_typedef.h:62
STATUS_FLAGS_s::Running
unsigned Running
Bit 0: Power converter is running.
Definition pwrctrl_typedef.h:82
POWER_CONTROL_s::Pwm
SWITCH_NODE_t Pwm
Switch node settings.
Definition pwrctrl_typedef.h:171
POWER_CONTROL_s::Data
FEEDBACK_SETTINGS_t Data
Feedback channel settings.
Definition pwrctrl_typedef.h:172
POWER_CONTROL_s::Status
STATUS_FLAGS_t Status
Power Supply status flags.
Definition pwrctrl_typedef.h:168