Created
April 26, 2020 11:31
-
-
Save controlpaths/ed55ebbf8d022cbace08468af8370678 to your computer and use it in GitHub Desktop.
Script for Buck model.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## Buck model | |
| clc | |
| close all | |
| clear all | |
| pkg load control | |
| s = tf('s'); | |
| fs = 1e6; | |
| L = 660e-6; | |
| C = 600e-6; | |
| RC = 1e-4; | |
| R = 1; | |
| vin = 24; | |
| vref = 6; | |
| ## LC filter definition | |
| h = 1/(L*C)*(s*RC*C+1)/(s^2+s*1/(R*C)+1/(L*C)); | |
| ## Discretize system | |
| hz = c2d(h,1/fs) | |
| step(hz) | |
| [num,den]=tfdata(hz); | |
| ## (Az^2+Bz+C)/(z^2+D*z+E) | |
| A = num{1}(1) | |
| B = num{1}(1) | |
| C = num{1}(2) | |
| D = den{1}(2) | |
| E = den{1}(3) | |
| ## Quantification | |
| nbits = 30; | |
| Aq = floor(A*2^(nbits)) | |
| Bq = floor(B*2^(nbits)) | |
| Cq = floor(C*2^(nbits)) | |
| Dq = floor(D*2^(nbits)) | |
| Eq = floor(E*2^(nbits)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment