Bar Logo 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
28void PwrCtrl_DeadTimeAdjust(void);
33
34
47{
49
50 // Update the ADC data member
52
53 // Execute the fault detection
55
56 // Performs data averaging necessary for control loop
57 // also Enabling interleaved the Vloop (10KHz execution)
58 // and Ploop (10KHz execution) enable bit
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
66// }
67
68 // Measure Primary to Secondary phase in degrees
70
71 // Adjust DeadTime based on Primary to Secondary phase in degrees
73
74 #if defined (PERIOD_MODULATION_DEMO) && (PERIOD_MODULATION_DEMO == true)
76 #endif
77
78 #endif
79
80 #if defined (DAC_DEBUG) && (DAC_DEBUG == true)
81 // This is for DAC debugging purposes
82// CMP2_DACDataWrite(variable_to_test_here);
83 #endif
84
85 #if defined (OPEN_LOOP_POTI) && (OPEN_LOOP_POTI == true)
86
87 // Connect TP11 -> Pot1 & TP12 -> Pot2 in digital Power Development Board
88 uint16_t Pot1 = dab.Data.ISecAverage;
89 uint16_t Pot2 = dab.Data.ISenseSecondary;
90
91 // Calculate the Frequency based on the Potentiometer 1 voltage
92 dab.Pwm.ControlPeriod = (uint16_t)(MIN_PWM_PERIOD + (Pot1 * ADC_PERIOD_RANGE));
93
94 // Change the control Phase with Potentiometer 2
95 dab.Pwm.ControlPhase = (uint16_t)(Pot2 * ADC_SCALER * (dab.Pwm.ControlPeriod >> 1));
96
97 #endif
98
99 if(dab.Status.bits.Running == 0)
100 {
101 // Suppress Power Converter Control Loop values
102 dab.Pwm.ControlPhase = 0;
103 }
104 // Update PWM Properties
106
107 // Enable the ADC sampling
109
111}
This is the generated driver header file for the ADC1 driver.
This is the generated driver header file for the SCCP1-TIMER driver.
Contains public fault functions.
void PwrCtrl_ControlLoopExecute(void)
void PwrCtrl_PeriodModulator(void)
#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
#define MIN_PWM_PERIOD
This sets the switching period of the converter.
Definition macros.h:41
POWER_CONTROL_t dab
Global data object for a DAB Converter.
Definition pwrctrl.c:28
void PwrCtrl_DeadTimeAdjust(void)
This function updates the DAB data members dead time based on load.
void PwrCtrl_UpdateADConverterData(void)
This function updates the DAB data members with ADC raw values.
void PwrCtrl_10KHzVPLoopPrepareData(void)
This function prepares the data for control loop and selects which control loop will be executed.
void PwrCtrl_PrimToSecPHDegree(void)
This function updates the DAB data members with phase values normalized in degree.
void ControlLoop_Interrupt_CallBack(void)
Executes the power converter control loop.
Definition pwrctrl_isr.c:46
void PwrCtrl_PWM_Update(POWER_CONTROL_t *pcInstance)
PWM distribution for DAB converter.
Definition pwrctrl_pwm.c:25
void Fault_Execute(void)
Executes the fault handlers.
Definition fault.c:116
static void ADC1_SoftwareTriggerEnable(void)
This inline function sets software common trigger.
Definition adc1.h:134
#define GPIO_1_SetHigh()
Sets the RC10 GPIO Pin which has a custom name of GPIO_1 to High.
Definition pins.h:53
#define GPIO_1_SetLow()
Sets the RC10 GPIO Pin which has a custom name of GPIO_1 to Low.
Definition pins.h:62
uint16_t ControlPeriod
Control period value from control loop.
uint16_t ControlPhase
Control phase value from control loop.
uint16_t ISecAverage
Data value for average secondary current as measured with isolated current sensor.
uint16_t ISenseSecondary
Data value for secondary current as measured with CT.
unsigned Running
Bit 0: Power converter is running.
SWITCH_NODE_t Pwm
Switch node settings.
FEEDBACK_SETTINGS_t Data
Feedback channel settings.
STATUS_FLAGS_t Status
Power Supply status flags, running or fault.