Wcp0 ( S + Wcz1 )
Calculate the transfer function Hc(s) = ---- X ------------------------
S ( S + Wcp1 )( S + Wcp2 )
Error Normalization
------------
| prsft |
------------
Reference | e(n) e(n-1) e(n-2)
Input | -------- --------
- - - | | | |
o----|-|-|x|-|x|----o->| z^(-1) |-o->| z^(-1) |-o Post
- - - | | | | | | | Scaling
| NORM | -------- | -------- |
| | | | --------
Measured| --- --- --- | | - - - - - - - - - -
Input | B0=>| X | B1=>| X | B2=>| X | |posft | | |
| --- --- --- |postScalar| | P O W E R |
| | | | ---------- | P L A N T |
| ------------------------------------- | | |
| | | U[n] --- | |
| | A C C U M U L A T O R |--o--| X |------O Duty Ratio=>PWM |
| | | | --- | |
| ------------------------------------- | | Voltage/Current |
| | | | | Feedback |
| --- --- | | O |
| A2=>| X | A1=>| X | | | | |
| --- --- | - - - - - - - - - -
| | | | |
| | -------- | -------- | | A/D
| | | | | | | | | Input
| o--| z^(-1) |<-o-| z^(-1) |<----------- |
| | | | | |
| -------- -------- |
| u[n-2] u[n-1] |
| |
| |
---------------------------------------------------------------------------
controlHistory[n] = errorHistory[n] * bCoefficients[0]
+ errorHistory[n-1] * bCoefficients[1]
+ errorHistory[n-2] * bCoefficients[2]
+ controlHistory[n-1] * aCoefficients[0]
+ controlHistory[n-2] * aCoefficients[1]
where:
aCoefficients[0] = A1
aCoefficients[1] = A2
bCoefficients[0] = B0
bCoefficients[1] = B1
bCoefficients[2] = B2
controlHistory[0] = u(n)
controlHistory[1] = u(n-1)
errorHistory[0] = e(n) => most recent error {(controlReference) - (sourceRegister)}
errorHistory[1] = e(n-1)
errorHistory[2] = e(n-2)
preShift = prsft => pre scaling factor for Q15 normalization purposes
postShift = posft => post scaling factor for normalization purposes
postScaler = postScaler => post scaling coefficient for normalization purpose
Function call inputs:
sourceRegister = ADBUFx => measured feedback input
controlReference = V_ref => reference voltage
targetRegister = PDCx => output duty cycle
where:
aCoefficients, bCoefficients, controlHistory, errorHistory,
preShift and postShift are all members of the data structure
SMPS_2P2Z_T.
Input:
w1 = Address of the Source Register (Input)
w2 = Control Reference
w3 = Address of the Target Register (Output)
Return:
w1 = Address of the Source Register (Input)
w2 = Control Reference
w3 = Address of the Target Register (Output)
System resources usage:
{w4..w5} saved, used, restored
{w8,w10} saved, used, restored
AccA used, not restored
CORCON saved, used, restored