Bar Logo Dual Active Bridge Development Board (Part-No. )
 
Content
     
Loading...
Searching...
No Matches
fault.c
Go to the documentation of this file.
1
9#include "xc.h"
10#include <stdbool.h>
11#include <stddef.h>
12
13#include "cmp/cmp1.h"
14#include "cmp/cmp3.h"
15#include "pwm_hs/pwm.h"
16#include "system/pins.h"
17
18#include "config/macros.h"
19#include "device/device.h"
20#include "pwrctrl/pwrctrl.h"
21#include "fault_common.h"
22#include "fault.h"
24
25// PRIVATE FUNCTIONS
27
28bool loadDisconnect = false;
29
30
41void Fault_Handler(void)
42{
43 // Drive the fault pin to Low when Fault trips
45
46 // Turn off PWM output
48
49 // set the fault active bit
50 dab.Status.bits.FaultActive = 1;
51
52 // clear the running bit
53 dab.Status.bits.Running = 0;
54
55}
56
57
66{
67 // Initialize Primary Over Current Protection
70
71 // Initialize Secondary Over Current Protection
74
75 // Initialize Primary Over Voltage Protection
78
79 // Initialize Primary Over Voltage Protection
82
83 // Initialize Secondary Over Voltage Protection
86
87 // Initialize Secondary Over Voltage Protection
90
91 // Initialize 5V Rail instability Protection
94
95 // Initialize Over Temperature Protection
98
99#if defined (FAULT_SHORT_CCT) && (FAULT_SHORT_CCT == true)
100 // Initialize short circuit fault protection with comparators
102#endif
103
104}
105
106
116{
117 uint16_t faultCheck = 0;
118 // secondary over current fault handler
119 #if defined(FAULT_ISEC_OC) && (FAULT_ISEC_OC == true)
121 #endif
122
123 // secondary over voltage fault handler
124 #if defined(FAULT_VSEC_OV) && (FAULT_VSEC_OV == true)
126 #endif
127
128 // primary over current fault handler
129 #if defined (FAULT_IPRI_OC) && (FAULT_IPRI_OC == true)
131 #endif
132
133 // primary over voltage fault handler
134 #if defined(FAULT_VPRI_OV) && (FAULT_VPRI_OV == true)
136 #endif
137
138 // primary over voltage fault handler
139 #if defined(FAULT_VPRI_UV) && (FAULT_VPRI_UV == true)
141 #endif
142
143 // primary over voltage fault handler
144 #if defined(FAULT_VRAIL_5V) && (FAULT_VRAIL_5V == true)
146 #endif
147
148 // Hardware short circuit
150
152
153 // Set fault bits
156
157 faultCheck &= dab.Fault.Object.ISenseSCP.FaultActive;
158 }
159
160 #if defined (LOAD_DISCONNECT) && (LOAD_DISCONNECT == true)
161 // Protection when Load is removed by accident.
162 //DAB does not sink power in this modulation. Voltage builds up on output.
164 {
167 (dab.Properties.IReference >= 1) )
168 {
169 loadDisconnect = true;
171 }
172 }
174 {
177 (dab.Properties.IReference >= 1) )
178 {
179 loadDisconnect = true;
181 }
182 }
183 #endif
184
185 dab.Status.bits.FaultActive = faultCheck;
186
187 // Identify the fault that trips
189}
190
191
192
200void Fault_Reset(void)
201{
202 // Drive the fault pin to high to allow PWM signal drive
204
205 // Clear fault Objects FaultActive bit
213
214 // Clear fault Objects FaultLatch bit
222
223 loadDisconnect = false;
224
225 dab.Status.bits.FaultActive = 0;
226}
227
228
238{
239 // on dsPIC33CK DP-PIM:
240 // CMP1B used for short circuit protection on the secondary side
241 // CMP3B used for short circuit protection on the primary side
242
243 // initialize thresholds of comparators used for short circuit protection
246
247 // turn on comparator DACs
250
251}
252
253
264{
265 #if defined (FAULT_PS_OTP) && (FAULT_PS_OTP == true)
267 {
268 devTempData.OverTemperatureFlag = 1; //for over temperature
269 dab.Status.bits.FaultActive = 1;
270 }
271 else
272 {
273 devTempData.OverTemperatureFlag = 0; //for over temperature
274 dab.Status.bits.FaultActive = 0;
275 }
276 #endif
277}
This is the generated driver header file for the CMP1 driver.
This is the generated driver header file for the CMP3 driver.
This is the generated driver header file for the PWM driver.
Contains h files that are part of device layer.
bool loadDisconnect
Definition fault.c:28
Contains public fault functions.
Contains fault generic public functions.
uint16_t Fault_GetFlags(void)
Contains API functions for fault protection.
#define VPRI_OV_T_BLANK_TRIG
Definition macros.h:125
#define VPRI_OV_THRES_TRIG
Definition macros.h:123
#define VPRI_OV_T_BLANK_CLEAR
Definition macros.h:126
#define VPRI_OV_THRES_CLEAR
Definition macros.h:124
#define VSEC_OV_THRES_TRIG
Definition macros.h:105
#define VPRIM_LOAD_STEP_CLAMP
Definition macros.h:116
#define VSEC_OV_T_BLANK_TRIG
Definition macros.h:107
#define VSEC_OV_THRES_CLEAR
Definition macros.h:106
#define VSEC_LOAD_STEP_CLAMP
Definition macros.h:115
#define VSEC_OV_T_BLANK_CLEAR
Definition macros.h:108
#define IPRI_OC_THRES_CLEAR
Definition macros.h:93
#define IPRI_SC_THRES_TRIG
Definition macros.h:97
#define IPRI_OC_T_BLANK_CLEAR
Definition macros.h:95
#define IPRI_OC_THRES_TRIG
Definition macros.h:92
#define IPRI_OC_T_BLANK_TRIG
Definition macros.h:94
#define ISEC_OC_THRES_CLEAR
Definition macros.h:72
#define ISEC_SC_THRES_TRIG
Definition macros.h:76
#define ISEC_OC_T_BLANK_CLEAR
Definition macros.h:74
#define ISEC_LOAD_STEP_CLAMP
Definition macros.h:77
#define ISEC_OC_THRES_TRIG
Definition macros.h:71
#define ISEC_OC_T_BLANK_TRIG
Definition macros.h:73
#define VRAIL_5V_UV_T_BLANK_CLEAR
Definition macros.h:146
#define VRAIL_5V_UV_T_BLANK_TRIG
Definition macros.h:145
#define VRAIL_5V_UV_THRES_TRIG
Definition macros.h:143
#define VRAIL_5V_UV_THRES_CLEAR
Definition macros.h:144
#define FAULT_PERSISTENCE_COUNT_TEMP
Definition config.h:169
#define OTP_THRES_TRIG_CELCIUS
Degrees Celcius.
Definition config.h:167
#define OTP_THRES_CLEAR_CELCIUS
Degrees Celcius.
Definition config.h:168
TEMP_SETTINGS_t devTempData
Data Object of temperature settings.
Definition dev_temp.c:30
int8_t Dev_Temp_Get_Temperature_Celcius(void)
This converts the raw values to temperature celcius as per device lookup table.
Definition dev_temp.c:87
POWER_CONTROL_t dab
Global data object for a DAB Converter.
Definition pwrctrl.c:28
AVERAGING_t iSecAveraging
Data Object of secondary current averaging.
AVERAGING_t vPrimAveraging
Data Object of primary voltage averaging.
AVERAGING_t vSecAveraging
Data Object of secondary voltage averaging.
void PwrCtrl_PWM_Disable(void)
Disable the PWM output.
@ PWR_CTRL_CHARGING
power converter is in charging mode
@ PWR_CTRL_DISCHARGING
power converter is in discharging mode
void Fault_Execute_100ms(void)
Fault evaluation for Temperature and other slow fault detection executed every 100ms.
Definition fault.c:263
void Fault_Reset(void)
Clears the fault object flag bits.
Definition fault.c:200
static void Fault_EnableShortCircuitProtection(void)
Enable Short circuit hardware protection.
Definition fault.c:237
void Fault_Initialize(void)
Initialize the fault objects.
Definition fault.c:65
void Fault_Execute(void)
Executes the fault handlers.
Definition fault.c:115
void Fault_Handler(void)
Handles the fault trip by turning off the power control switching.
Definition fault.c:41
bool FAULT_CheckMax(FAULT_OBJ_T *faultInput, int16_t faultSource, FAULT_CALLBACK callback)
This function compares the fault source value with the threshold limits and sets (or) resets the faul...
bool FAULT_CheckMin(FAULT_OBJ_T *faultInput, int16_t faultSource, FAULT_CALLBACK callback)
This function compares the fault source value with the threshold limits and sets (or) resets the faul...
void FAULT_Init(FAULT_OBJ_T *faultInput, int16_t threshold, int16_t hysLimit, uint16_t thresholdCnt, uint32_t hysCnt)
This function initializes the fault object data structure with the values that required to detect a f...
bool CMP3_StatusGet(void)
Returns the comparator output status.
Definition cmp3.c:111
#define CMP_IPRI_SC_DACDataWrite
This macro defines the Custom Name for CMP3_DACDataWrite API.
Definition cmp3.h:100
bool CMP1_StatusGet(void)
Returns the comparator output status.
Definition cmp1.c:111
#define CMP_IPRI_SC_DACEnable
This macro defines the Custom Name for CMP3_DACEnable API.
Definition cmp3.h:90
#define CMP_ISEC_SC_DACDataWrite
This macro defines the Custom Name for CMP1_DACDataWrite API.
Definition cmp1.h:100
#define CMP_ISEC_SC_DACEnable
This macro defines the Custom Name for CMP1_DACEnable API.
Definition cmp1.h:90
#define FAULT_SetLow()
Sets the RD9 GPIO Pin which has a custom name of FAULT to Low.
Definition pins.h:368
#define FAULT_SetHigh()
Sets the RD9 GPIO Pin which has a custom name of FAULT to High.
Definition pins.h:359
uint8_t OverTemperatureFlag
Over temperature flag.
Definition dev_temp.h:44
uint8_t FaultActive
Set/Cleared inside flt check loop
uint8_t FaultLatch
Flag indicating if FAULT has been tripped.
FAULT_OBJ_T VRail_5V
Fault object for 5V rail.
FAULT_OBJ_T VSecondaryUVP
Fault object for Secondary under voltage protection.
FAULT_OBJ_T PowerSupplyOTP
Fault object for Power Supply Temperature.
FAULT_OBJ_T VSecondaryOVP
Fault object for Secondary over voltage protection.
FAULT_OBJ_T ISecondaryOCP
Fault object for Secondary over current protection.
FAULT_OBJ_T VPrimaryOVP
Fault object for Primary over voltage protection.
FAULT_OBJ_T VPrimaryUVP
Fault object for Primary under voltage protection.
FAULT_OBJ_T IPrimaryOCP
Fault object for Primary over current protection.
FAULT_OBJ_T ISenseSCP
Fault object for Short circuit protection.
uint16_t FaultDetected
Fault indication for fault occurrence.
FAULT_t Object
Fault Objects.
uint16_t AverageValue
uint16_t VPriVoltage
Data value for input voltage.
uint16_t ISensePrimary
Data value for primary current as measured with CT.
uint16_t VSecVoltage
Data value for output voltage.
uint16_t ISenseSecondary
Data value for secondary current as measured with CT.
uint16_t VRail_5V
Data value for 5V auxiliary rail.
unsigned Running
Bit 0: Power converter is running.
unsigned FaultActive
Bit 1: Power converter fault is active.
int16_t Reference
actual reference
int16_t IReference
User current reference setting used to control the converter controller.
PWR_CTRL_PROPERTIES_t Properties
Power Control properties
CONTROLLER_t VLoop
structure for voltage controller data
FEEDBACK_SETTINGS_t Data
Feedback channel settings.
PWR_CTRL_CHARGE_STATE_t PowerDirection
defines if the power converter is in charging or discharging mode
STATUS_FLAGS_t Status
Power Supply status flags.
FAULT_SETTINGS_t Fault
Fault flags and settings.