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