Bar Logo 3.8/7.6 kw Totem pole Demonstration Application (Part-No. (not specified))
 
Content
     
Loading...
Searching...
No Matches
smps_control.h
Go to the documentation of this file.
1
11
31// DOM-IGNORE-BEGIN
33// � 2015 Microchip Technology Inc.
34//
35// MICROCHIP SOFTWARE NOTICE AND DISCLAIMER: You may use this software, and any
36// derivatives created by any person or entity by or on your behalf, exclusively
37// with Microchip?s products. Microchip and its licensors retain all ownership
38// and intellectual property rights in the accompanying software and in all
39// derivatives here to.
40//
41// This software and any accompanying information is for suggestion only. It
42// does not modify Microchip?s standard warranty for its products. You agree
43// that you are solely responsible for testing the software and determining its
44// suitability. Microchip has no obligation to modify, test, certify, or
45// support the software.
46//
47// THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
48// EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED
49// WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR
50// PURPOSE APPLY TO THIS SOFTWARE, ITS INTERACTION WITH MICROCHIP?S PRODUCTS,
51// COMBINATION WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION.
52//
53// IN NO EVENT, WILL MICROCHIP BE LIABLE, WHETHER IN CONTRACT, WARRANTY, TORT
54// (INCLUDING NEGLIGENCE OR BREACH OF STATUTORY DUTY), STRICT LIABILITY,
55// INDEMNITY, CONTRIBUTION, OR OTHERWISE, FOR ANY INDIRECT, SPECIAL, PUNITIVE,
56// EXEMPLARY, INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, FOR COST OR EXPENSE OF
57// ANY KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWSOEVER CAUSED, EVEN IF
58// MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.
59// TO THE FULLEST EXTENT ALLOWABLE BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL
60// CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF
61// FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
62//
63// MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE
64// TERMS.
66// DOM-IGNORE-END
67
68#ifndef _SMPS_CONTROL_H // Guards against multiple inclusion
69#define _SMPS_CONTROL_H
70
71// *****************************************************************************
72// *****************************************************************************
73// Section: Included Files
74// *****************************************************************************
75// *****************************************************************************
76
77#include <xc.h>
78#include <stdint.h>
79
80#ifdef __cplusplus // Provide C++ Compatibility
81 extern "C" {
82#endif
83
84// *****************************************************************************
85// *****************************************************************************
86// Section: Data Types
87// *****************************************************************************
88// *****************************************************************************
89
90//**************************************************************************
91/* Data type for the 3-pole 3-zero (3P3Z) controller
92
93 Summary:
94 Data type for the 3-pole 3-zero (3P3Z) controller
95
96 Description:
97 The 3P3Z controller is the digital implementation of the analog type III
98 controller. This is a filter which generates a compensator characteristic
99 considering three poles and three zeros. This controller requires four
100 feedback errors multiplied by their associated coefficients plus the three
101 latest controller output values multiplied by their associated coefficients
102 along the delay line to provide proper compensation of the power converter.
103 The coefficients are determined externally using simulation tools.
104
105 The SMPS_3P3Z_T data structure contains a pointer to derived
106 coefficients in X-space and pointer to error/control history samples in
107 Y-space. User must declare variables for the derived coefficients and
108 the error history samples.
109
110 The abCoefficients referenced by the SMPS_3P3Z_T data structure are
111 derived from the coefficients B0-B3 plus A1-A3. These will be declared
112 in external arrays. The SMPS_3P3Z_T data structure just holds pointers
113 to these arrays.
114
115 The coefficients will be determined by simulation tools, their outputs are
116 given as floating point numbers. These numbers will be copied into the
117 declared arrays after they have been converted into 16-bit integer numbers.
118
119*/
120
121typedef struct
122{
123 int16_t* aCoefficients ; // Pointer to A coefficients located in X-space
124 int16_t* bCoefficients ; // Pointer to B coefficients located in X-space
125 int16_t* controlHistory ; // Pointer to 3 delay-line samples located in Y-space
126 // with the first sample being the most recent
127 int16_t* errorHistory ; // Pointer to 4 delay-line samples located in Y-space
128 // with the first sample being the most recent
129 uint16_t preShift ; // Normalization from ADC-resolution to Q15 (R/W)
130 int16_t postShift ; // Normalization bit-shift from Q15 to PWM register resolution (R/W)
131 int16_t postScaler ; // Controller output post-scaler (R/W)
132 uint16_t minOutput ; // Minimum output value used for clamping (R/W)
133 uint16_t maxOutput ; // Maximum output value used for clamping (R/W)
135
136// *****************************************************************************
137/* Data type for the 2-pole 2-zero (2P2Z) controller
138
139 Summary:
140 Data type for the 2-pole 2-zero (2P2Z) controller
141
142 Description:
143 The 2P2Z controller is the digital implementation of the analog type II
144 controller. This is a filter which generates a compensator characteristic
145 considering two poles and two zeros. This controller requires three feedback
146 error multiplied by their associated coefficients plus the two latest
147 controller output values multiplied by their associated coefficients along
148 the delay line to provide proper compensation of the power converter.
149 The coefficients are determined externally using simulation tools.
150
151 The SMPS_2P2Z_T data structure contains a pointer to derived
152 coefficients in X-space and pointer to error/control history samples in
153 Y-space. User must declare variables for the derived coefficients and
154 the error history samples.
155
156 The abCoefficients referenced by the SMPS_2P2Z_T data structure are
157 derived from the coefficients B0-B2 plus A1-A2. These will be declared
158 in external arrays. The SMPS_2P2Z_T data structure and just holds
159 pointers to these arrays.
160
161 The coefficients will be determined by simulation tools, which output
162 is given as floating point numbers. These numbers will be copied into
163 the declared arrays after they have been converted into 16-bit integer
164 numbers.
165*/
166typedef struct
167{
168 int16_t* aCoefficients ; // Pointer to A coefficients located in X-space
169 int16_t* bCoefficients ; // Pointer to B coefficients located in X-space
170 int16_t* controlHistory ; // Pointer to 2 delay-line samples located in Y-space
171 // with the first sample being the most recent
172 int16_t* errorHistory ; // Pointer to 3 delay-line samples located in Y-space
173 // with the first sample being the most recent
174 uint16_t preShift ; // Normalization from ADC-resolution to Q15 (R/W)
175 int16_t postShift ; // Normalization bit-shift from Q15 to PWM register resolution (R/W)
176 int16_t postScaler ; // Controller output post-scaler (R/W)
177 uint16_t minOutput ; // Minimum output value used for clamping (R/W)
178 uint16_t maxOutput ; // Maximum output value used for clamping (R/W)
179
180 uint16_t KfactorCoeffsB; //############FTX
181
182} SMPS_2P2Z_T ;
183
184//***********************************************************************
185/* Data type for the PID controller
186
187 Summary:
188 Data type for the PID controller
189
190 Description:
191 Data type for the Proportional Integral Derivative (PID) controller
192
193 This digital implementation of a PID controller is a filter which
194 generates a compensator characteristic considering the values of the
195 coefficients KA, KB, KC these coefficients will determine the
196 converter's frequency response. These coefficients are determined
197 externally using simulation tools.
198
199 This function call includes the pointer to the controller data
200 structure, pointer of the input source register, control reference
201 value, and to the pointer to the output register.
202 */
203typedef struct {
204
205 int16_t* abcCoefficients; // Pointer to A, B & C coefficients located in X-space
206 // These coefficients are derived from
207 // the PID gain values - Kp, Ki and Kd
208 int16_t* errorHistory; // Pointer to 3 delay-line samples located in Y-space
209 // with the first sample being the most recent
210 int16_t controlHistory; // Stores the most recent controller output (n-1)
211 int16_t postScaler; // PID basic Coefficient scaling Factor
212 int16_t preShift ; // Normalization from ADC-resolution to Q15 (R/W)
213 int16_t postShift; // Normalization from DSP to PWM register
214 uint16_t minOutput; // Minimum output value used for clamping
215 uint16_t maxOutput; // Maximum output value used for clamping
216
217} SMPS_PID_T;
218
219// *****************************************************************************
220// *****************************************************************************
221// Section: Interface Routines
222// *****************************************************************************
223// *****************************************************************************
224
225
252
253
310 volatile uint16_t* controllerInputRegister,
311 int16_t reference,
312 volatile uint16_t* controllerOutputRegister);
313
314
315
348void SMPS_Controller2P2ZUpdate_HW_Accel(void); // Function prototype for 2P2Z library
349
350
354
387void SMPS_Controller3P3ZUpdate_HW_Accel(void); // Function prototype for 3P3Z library
388
389
393
425void SMPS_Controller4P4ZUpdate_HW_Accel(void); // Function prototype for 3P3Z library
426
427
430
463void SMPS_ControllerPIDUpdate_HW_Accel(void); // Function prototype for PID library
464
465
469typedef struct {
470
471 uint16_t triggerSelectFlag; // 00 = No Trigger Enabled
472 // 01 = Trigger On-Time Enabled
473 // 10 = Trigger Off-Time Enabled
474
475 uint16_t delayValue; //
476 volatile unsigned int* trigger; // Pointer to trigger source
477 volatile unsigned int* period; // Pointer to time base (i.e., PTPER) register
478
479 // User to add additional structure elements as needed
480 // .
481 // .
482 // .
483
484} SMPS_Controller_Options_T; // Converter User Enabled Options
485
486
487
488//void SMPS_Controller3P3Z(CONVERTER* controllerData);
489
490
491
492
519//void SMPS_Controller2P2ZInitialize(SMPS_2P2Z_T *controllerData);
520
522
523
524
576 volatile uint16_t* controllerInputRegister,
577 int16_t reference,
578 volatile uint16_t* controllerOutputRegister);
579
580
606
607
662 volatile uint16_t* controllerInputRegister,
663 int16_t reference,
664 volatile uint16_t* controllerOutputRegister);
665
666
667
668
669
670//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
671
672typedef struct
673{
674 int16_t* aCoefficients ; // Pointer to A coefficients located in X-space
675 int16_t* bCoefficients ; // Pointer to B coefficients located in X-space
676 int16_t* controlHistory ; // Pointer to 2 delay-line samples located in Y-space
677 // with the first sample being the most recent
678 int16_t* errorHistory ; // Pointer to 3 delay-line samples located in Y-space
679 // with the first sample being the most recent
680 uint16_t preShift ; // Normalization from ADC-resolution to Q15 (R/W)
681 int16_t postShift ; // Normalization bit-shift from Q15 to PWM register resolution (R/W)
682 int16_t postScaler ; // Controller output post-scaler (R/W)
683 uint16_t minOutput ; // Minimum output value used for clamping (R/W)
684 uint16_t maxOutput ; // Maximum output value used for clamping (R/W)
686
688 volatile uint16_t* controllerInputRegister,
689 int16_t reference,
690 volatile uint16_t* controllerOutputRegister);
691//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
692
693
694
695
696#ifdef __cplusplus // Provide C++ Compatibility
697 }
698#endif
699
700#endif // _SMPS_CONTROL_H
701
702/* EOF */
703
704
void SMPS_Controller4P4ZUpdate_HW_Accel(void)
void SMPS_ControllerPIDUpdate(SMPS_PID_T *controllerData, volatile uint16_t *controllerInputRegister, int16_t reference, volatile uint16_t *controllerOutputRegister)
void SMPS_Controller3P3ZUpdate_HW_Accel(void)
void SMPS_Controller3P3ZInitialize(SMPS_3P3Z_T *controllerData)
void XFT_SMPS_Controller2P2ZUpdate(SMPS_2P2Z_T *controllerData, volatile uint16_t *controllerInputRegister, int16_t reference, volatile uint16_t *controllerOutputRegister)
void SMPS_Controller3P3ZUpdate(SMPS_3P3Z_T *controllerData, volatile uint16_t *controllerInputRegister, int16_t reference, volatile uint16_t *controllerOutputRegister)
void SMPS_Controller2P2ZInitialize(SMPS_2P2Z_T *controllerData)
void SMPS_ControllerPIDUpdate_HW_Accel(void)
void SMPS_Controller2P2ZUpdate(SMPS_2P2Z_T *controllerData, volatile uint16_t *controllerInputRegister, int16_t reference, volatile uint16_t *controllerOutputRegister)
void SMPS_Controller2P2ZUpdate_HW_Accel(void)
void SMPS_ControllerPIDInitialize(SMPS_PID_T *controllerData)
int16_t * controlHistory
uint16_t minOutput
int16_t postShift
int16_t * errorHistory
uint16_t maxOutput
int16_t postScaler
int16_t * aCoefficients
uint16_t preShift
int16_t * bCoefficients
int16_t * controlHistory
uint16_t minOutput
int16_t postShift
int16_t * errorHistory
uint16_t maxOutput
int16_t postScaler
uint16_t KfactorCoeffsB
int16_t * aCoefficients
uint16_t preShift
int16_t * bCoefficients
uint16_t minOutput
int16_t postShift
int16_t * errorHistory
int16_t preShift
int16_t * abcCoefficients
uint16_t maxOutput
int16_t postScaler
int16_t controlHistory
volatile unsigned int * period
volatile unsigned int * trigger
int16_t * controlHistory
int16_t * errorHistory
int16_t * aCoefficients
int16_t * bCoefficients