| 1 | function pwm(compute) |
|---|
| 2 | if nargin<1, |
|---|
| 3 | compute=1; |
|---|
| 4 | end |
|---|
| 5 | |
|---|
| 6 | if compute |
|---|
| 7 | M=pmsm_estim_mex('pwm_mx.cfg'); |
|---|
| 8 | save pwm M |
|---|
| 9 | else |
|---|
| 10 | load pwm |
|---|
| 11 | end |
|---|
| 12 | |
|---|
| 13 | time =0.000125*[0:size(M.xia,1)-1]; |
|---|
| 14 | |
|---|
| 15 | %%%%%%%%%%%%%% U |
|---|
| 16 | figure(1); |
|---|
| 17 | detail=14000:20000; |
|---|
| 18 | % ua |
|---|
| 19 | subplot(2,2,1); |
|---|
| 20 | plot(time(detail),M.oua(detail)-M.tua(detail)); |
|---|
| 21 | title('Difference between simulated and non-compensated observed u_{s,\alpha} (detail)') |
|---|
| 22 | |
|---|
| 23 | subplot(2,2,2); |
|---|
| 24 | hist(M.oua-M.tua,30); |
|---|
| 25 | title('Histogram of difference on the full data record of 8s') |
|---|
| 26 | |
|---|
| 27 | %ub |
|---|
| 28 | subplot(2,2,3); |
|---|
| 29 | plot(time(detail),M.modelua(detail)-M.tua(detail)); |
|---|
| 30 | title('Difference between simulated and compensated observed u_{s,\alpha} (detail)') |
|---|
| 31 | |
|---|
| 32 | subplot(2,2,4); |
|---|
| 33 | hist(M.modelua-M.tua,30); |
|---|
| 34 | title('Histogram of difference on the full data record of 8s') |
|---|
| 35 | |
|---|
| 36 | dt=0.000125; |
|---|
| 37 | Ls=0.003465; |
|---|
| 38 | |
|---|
| 39 | bnds = [max(abs(M.modelua-M.tua)), max(abs(M.modelub-M.tub)) 0 0]; |
|---|
| 40 | Qpwm = (dt/Ls)^2*[1 1 0 0]%(2*bnds).^2/12 |
|---|
| 41 | |
|---|
| 42 | figure(3); |
|---|
| 43 | plot(M.xom); |
|---|
| 44 | |
|---|
| 45 | %%%%%%%%%%%%%%% Integration |
|---|
| 46 | |
|---|
| 47 | figure(2) |
|---|
| 48 | subplot(4,2,1); plot(time,M.erria);xlabel('time [s]'); |
|---|
| 49 | title('Integration error on state variables') |
|---|
| 50 | ylabel('Error on i_{s,\alpha}') |
|---|
| 51 | subplot(4,2,2); hist(M.erria,30); |
|---|
| 52 | title('Histogram of errors on state variables') |
|---|
| 53 | |
|---|
| 54 | subplot(4,2,3); plot(time,M.errib);xlabel('time [s]'); |
|---|
| 55 | ylabel('Error on i_{s,\beta}') |
|---|
| 56 | subplot(4,2,4); hist(M.errib,30); |
|---|
| 57 | %title('Histogram of error on i_{s,\beta}') |
|---|
| 58 | |
|---|
| 59 | subplot(4,2,5); plot(time,M.errom);xlabel('time [s]'); |
|---|
| 60 | ylabel('Error on \omega_{me}') |
|---|
| 61 | subplot(4,2,6); hist(M.errom,30); |
|---|
| 62 | %title('Histogram of error on \omega_{me}') |
|---|
| 63 | |
|---|
| 64 | subplot(4,2,7); plot(time,M.errth); xlabel('time [s]'); |
|---|
| 65 | ylabel('Error on \vartheta_{me}') |
|---|
| 66 | subplot(4,2,8); hist(M.errth,30); |
|---|
| 67 | %title('Histogram of error on \vartheta_{me}') |
|---|
| 68 | |
|---|
| 69 | Qint=[var(M.erria), var(M.errib), var(M.errom), var(M.errth)] |
|---|
| 70 | |
|---|
| 71 | bnds=[max(abs(M.erria)), max(abs(M.errib)), max(abs(M.errom)), max(abs(M.errth))] |
|---|
| 72 | Qint = [(2*bnds).^2/12] |
|---|
| 73 | |
|---|
| 74 | %%%%%%%%%%%%%%%% Mz prop |
|---|
| 75 | Fmag= 0.1989; |
|---|
| 76 | p = 4.0; |
|---|
| 77 | J = 0.04; |
|---|
| 78 | |
|---|
| 79 | Tl=10; |
|---|
| 80 | dom = p/J*Tl*dt |
|---|
| 81 | Qrat=(2*[Fmag/Ls*dt,Fmag/Ls*dt, 1, dt]).^2/12 |
|---|
| 82 | |
|---|
| 83 | Qtot=Qpwm+Qint |
|---|
| 84 | Qtot+Qrat |
|---|
| 85 | |
|---|
| 86 | %%%%%%%%%%%%%%%% R |
|---|
| 87 | R=(2*0.085)^2/12*[1 1] |
|---|