Bar Logo 3.8/7.6 kw Totem pole Demonstration Application (Part-No. (not specified))
 
Content
     
Loading...
Searching...
No Matches
dev_TPBLPFC_typedef.h
Go to the documentation of this file.
1
13/*
14� [2024] Microchip Technology Inc. and its subsidiaries.
15
16 Subject to your compliance with these terms, you may use Microchip
17 software and any derivatives exclusively with Microchip products.
18 You are responsible for complying with 3rd party license terms
19 applicable to your use of 3rd party software (including open source
20 software) that may accompany Microchip software. SOFTWARE IS ?AS IS.?
21 NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS
22 SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT,
23 MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
24 WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
25 INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY
26 KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF
27 MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE
28 FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S
29 TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT
30 EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR
31 THIS SOFTWARE.
32*/
33
34#ifndef _DEV_TPBLPFC_TYPEDEF_H
35#define _DEV_TPBLPFC_TYPEDEF_H
36
37#include <xc.h>
38#include <stdint.h>
39
40//------------------------------------------------------------------------------
41// @brief power controller states
42//------------------------------------------------------------------------------
43
44typedef enum
45{
46 PCS_INIT = 1, // Init peripherals that are involved
47 PCS_WAIT_IF_FAULT_ACTIVE = 2, // goes on if no fault is active
49 PCS_VACOK = 4, //
51 PCS_RELAYON = 6, //
56 PCS_STALL_DEBUG = 11 // for debug purposes
58
60
61//------------------------------------------------------------------------------
62// @brief Analog values
63//------------------------------------------------------------------------------
64
66{
67 volatile int16_t Raw;
68 volatile int16_t Rectified;
69 volatile uint16_t Rectified_Shift;
70 volatile int16_t RectifiedSum;
71 volatile uint16_t Filtered;
72 volatile int16_t Vin_div_Averaged2;
73 volatile int16_t Vin_div_Averaged2_Freezed;
74 volatile uint16_t FilterCounter;
75 volatile int16_t Offset;
76 volatile uint16_t PreviousValue;
77 volatile uint16_t Max_Peak;
78};
80
81//------------------------------------------------------------------------------
82// @brief Reference set points for Vout
83//------------------------------------------------------------------------------
84
86{
87 volatile uint16_t Reference_Internal;
88 volatile uint16_t Reference_Set;
89 volatile uint16_t Voltage_Loop_Output;
90 volatile uint16_t VOUT_dV_dt_Hystresis_High;
91 volatile uint16_t VOUT_dV_dt_Hystresis_Low;
92 volatile uint16_t VOUT_Hystresis_High;
93 volatile uint16_t VOUT_Hystresis_Low;
94
95 volatile unsigned VOUT_dV_dt_Up : 1;
96 volatile unsigned VOUT_dV_dt_Active : 1;
97};
99
100//------------------------------------------------------------------------------
101// @brief Values for current control loop
102//------------------------------------------------------------------------------
103
105{
106 volatile uint16_t PWM_Counter;
107 volatile uint16_t Duty_Cycle_Set_Value;
108 volatile uint16_t CCM_Counter;
109 volatile uint16_t DFF_Value;
110 volatile uint32_t IAC_Reference_l;
111 volatile uint16_t IAC_Reference;
112 volatile uint16_t BurstModeCycleCounter;
113 volatile uint16_t BurstModeCyclesOff;
114 volatile uint16_t BurstModeCyclesOn;
115 volatile uint16_t ZeroCrossCounter;
116 volatile uint16_t VariableGainCounter;
117
118 volatile unsigned Control_Freeze : 1;
119};
121
122//------------------------------------------------------------------------------
123// @brief Power controller status flags
124//------------------------------------------------------------------------------
125
127{
128 union{
129 struct{
130 volatile unsigned Soft_Start_Zero_Cross : 1; // Bit 0:
131 volatile unsigned VAC_Polarity_last : 1; // Bit 1:
132 volatile unsigned Relay : 1; // Bit 2:
133 volatile unsigned Stop : 1; // Bit 3:
134 volatile unsigned Fault : 1; // Bit 4:
135 volatile unsigned VAC_Polarity_Changed : 1; // Bit 5:
136 volatile unsigned VAC_Polarity_Changed_last : 1; // Bit 6:
137 volatile unsigned CCM : 1; // Bit 7:
138 volatile unsigned BurstModeDetected : 1; // Bit 8:
139 volatile unsigned BurstModeLatched : 1; // Bit 9:
140 volatile unsigned Reference_Changed : 1; // needed to decide if ref change after startup or during run
141 volatile unsigned VariableGain : 1; // Gain changes around ZC
142
143 } __attribute__((packed)) bits;
144 volatile uint16_t value;
145
146 };
147};
149
150//------------------------------------------------------------------------------
151// @brief Values AC Acquisition bits coming direct from AC Acquisition board via SPI and MSIB
152//------------------------------------------------------------------------------
153
155{
156 union{
157 struct{
158 volatile unsigned VACdrop : 1; // Bit 0:
159 volatile unsigned VDC_Input_Voltage : 1; // Bit 1:
160 volatile unsigned VAC_OK : 1; // Bit 2:
161 volatile unsigned Zero_Cross_Range : 1; // Bit 3:
162 volatile unsigned VAC_Polarity : 1; // Bit 4:
163 volatile unsigned nu5 : 1; // Bit 5:
164 volatile unsigned nu6 : 1; // Bit 6:
165 volatile unsigned nu7 : 1; // Bit 7:
166 } __attribute__((packed)) bits;
167 volatile uint16_t value;
168
169 };
170};
172
173//------------------------------------------------------------------------------
174// @brief Values for the individual 3 phase
175//------------------------------------------------------------------------------
176
187
188//------------------------------------------------------------------------------
189// @brief Values for the outer voltage loop
190//------------------------------------------------------------------------------
191
201
202//------------------------------------------------------------------------------
203// @brief common PFC mode bits
204//------------------------------------------------------------------------------
205
207{
208 union{
209 struct{
210 volatile unsigned Run : 1; // Bit 0
211 volatile unsigned Stop : 1; // Bit 1
212 volatile unsigned Fault : 1; // Bit 2
213 volatile unsigned OC_PH1 : 1; // Bit 3
214 volatile unsigned OC_PH2 : 1; // Bit 4
215 volatile unsigned OC_PH3 : 1; // Bit 5
216 volatile unsigned OV_Vout : 1; // Bit 6
217 //Run Modes
218 volatile unsigned AC_PFC_1_PH : 1; // Bit 7
219 volatile unsigned AC_AVGCM_no_VMC_1_PH : 1; // Bit 8
220 volatile unsigned DC_AVGCM_no_VMC_1_PH : 1; // Bit 9
221 volatile unsigned AC_AVGCM_no_VMC_1_PH_reverse : 1; // Bit 10
222 volatile unsigned AC_PFC_2PH_1_PH : 1; // Bit 11
223 volatile unsigned AGOn : 1; // Bit 12
224 volatile unsigned : 1; // Bit 13
225 volatile unsigned : 1; // Bit 14
226 volatile unsigned : 1; // Bit 15
227
228 } __attribute__((packed)) bits;
229 volatile uint16_t value; // buffer for 16-bit word read/write operations
230 };
231};
234
235//==============================================================================
236// @brief extern declarations
237//==============================================================================
238
239typedef struct
240{
241 uint16_t Data[10];
242 volatile unsigned DataReceivedOK : 1;
245
246//==============================================================================
247// @brief function prototypes
248//==============================================================================
249extern uint16_t OpenLoopStartupDuration;
250extern uint16_t Adaptive_Gain_Factor;
251
252void Init_pwr_ctrl (void);
253
254//------------------------------------------------------------------------------
255// END
256//------------------------------------------------------------------------------
257#endif /* XC_HEADER_TEMPLATE_H */
PHASE_VALUES_t AC_N
uint16_t OpenLoopStartupDuration
PHASE_VALUES_t Phase_Values_PH2
Primary_Data_Handling primary_vac_values
PWR_CTRL_STATE_e pwr_ctrl_state
uint16_t Adaptive_Gain_Factor
VMC_VALUES_t Vout_Control
PWR_CTRL_STATE_e
@ PCS_VACOK
@ PCS_STANDBY
@ PCS_RELAYON
@ PCS_SOFT_START
@ PCS_WAIT_IF_FAULT_ACTIVE
@ PCS_START_CONTROL
@ PCS_VOUT_PRELOAD
@ PCS_DELAY_AFTER_RELAYON
@ PCS_UP_AND_RUNNING
@ PCS_STALL_DEBUG
PHASE_VALUES_t Phase_Values_PH1
void Init_pwr_ctrl(void)
PFC_FLAGS_t PFC_Flags
volatile int16_t Rectified
volatile int16_t Vin_div_Averaged2_Freezed
volatile uint16_t Filtered
volatile int16_t Offset
volatile uint16_t PreviousValue
volatile uint16_t FilterCounter
volatile int16_t Raw
volatile int16_t RectifiedSum
volatile int16_t Vin_div_Averaged2
volatile uint16_t Rectified_Shift
volatile uint16_t Max_Peak
volatile uint16_t VOUT_Hystresis_High
volatile unsigned VOUT_dV_dt_Active
volatile uint16_t VOUT_Hystresis_Low
volatile uint16_t Voltage_Loop_Output
volatile uint16_t VOUT_dV_dt_Hystresis_High
volatile uint16_t VOUT_dV_dt_Hystresis_Low
volatile uint16_t Reference_Internal
volatile uint16_t BurstModeCycleCounter
volatile uint16_t PWM_Counter
volatile uint16_t ZeroCrossCounter
volatile uint32_t IAC_Reference_l
volatile uint16_t BurstModeCyclesOff
volatile uint16_t IAC_Reference
volatile uint16_t Duty_Cycle_Set_Value
volatile uint16_t CCM_Counter
volatile uint16_t BurstModeCyclesOn
volatile unsigned Control_Freeze
volatile uint16_t VariableGainCounter
volatile uint16_t DFF_Value
struct CONTROL_STATUS_FLAGS_s::@24::@26 bits
volatile unsigned Reference_Changed
volatile unsigned VAC_Polarity_last
volatile unsigned VariableGain
volatile unsigned VAC_Polarity_Changed
volatile uint16_t value
buffer for 16-bit word read/write operations
volatile unsigned BurstModeDetected
volatile unsigned BurstModeLatched
volatile unsigned Soft_Start_Zero_Cross
volatile unsigned VAC_Polarity_Changed_last
struct ACCONTROL_PHASE_STATUS_FLAGS_s::@27::@29 bits
ACCONTROL_PHASE_STATUS_FLAGS_t ACcontrol_Status_Flags_perPhase
ANALOG_VALUES_t Phase_Voltage
CONTROLLER_VALUES_t Controller_Values
ANALOG_VALUES_t Phase_Current
CONTROL_STATUS_FLAGS_t Control_Status_Flags
CONTROL_REFERENCE_VALUES_t Reference
ANALOG_VALUES_t Vout_MidPoint
ANALOG_VALUES_t Vout
volatile unsigned OC_PH3
volatile unsigned AC_AVGCM_no_VMC_1_PH
volatile unsigned AC_AVGCM_no_VMC_1_PH_reverse
volatile uint16_t value
struct PFC_FLAGS_s::@30::@32 bits
volatile unsigned AGOn
volatile unsigned DC_AVGCM_no_VMC_1_PH
volatile unsigned AC_PFC_1_PH
volatile unsigned AC_PFC_2PH_1_PH
volatile unsigned Fault
volatile unsigned OC_PH2
volatile unsigned OV_Vout
volatile unsigned Stop
volatile unsigned OC_PH1
volatile unsigned Run
volatile unsigned DataReceivedOK