PWM inverter matlab code/simulink

Discussion in 'Programmer's Corner' started by h.immo, Apr 17, 2012.

  1. h.immo

    h.immo Thread Starter New Member

    Joined:
    Apr 17, 2012
    10
    0
    hi everyone,
    I need the matlab code or simulink for a 3-phase PWM inverter i found exactly what I need here
    (www2.ece.ohio-state.edu/ems/PowerConverter/Sine_PWM_Inverter.pdf ) but it doesnt work correctly i get some error in the code and the simulink is also not working correct ( or at least i dont know how it works). It would be very nice if someone could help me with it.
    thank you very much!
    Regards
     
    #1
  2. panic mode

    panic mode Well-Known Member

    Joined:
    Oct 10, 2011
    1,207
    254
    how about some details? for example what error? where?
     
    #2
  3. h.immo

    h.immo Thread Starter New Member

    Joined:
    Apr 17, 2012
    10
    0
    Well if i implement the code i get the error that (Vi ) is undifiend
    Have u tried the code? Is it working with u?
    Sorry for bothering you
    Thanks again
     
    #3
  4. h.immo

    h.immo Thread Starter New Member

    Joined:
    Apr 17, 2012
    10
    0
    Code ( (Unknown Language)):
    1.  
    2. [FONT=TimesNewRomanPSMT][LEFT]This is the code : if its working with u guys tell me plz :)
    3.  
    4. % Input data
    5. Vdc= 400; % DC-link voltage
    6. Lf= 800e-6;% Inductance for output filter
    7. Cf= 400e-6; % Capacitance for output filter
    8. Lload = 2e-3; %Load inductance
    9. Rload= 5; % Load resistance
    10. f= 60; % Fundamental frequency
    11. fz = 3e3; % Switching frequency
    12. m= 0.8; % Modulation index
    13. % Coefficients for State-Space Model
    14. A=[zeros(3,3) eye(3)/(3*Cf) -eye(3)/(3*Cf)
    15. -eye(3)/Lf zeros(3,3) zeros(3,3)
    16. eye(3,3)/Lload zeros(3,3) -eye(3)*Rload/Lload]; % system matrix
    17. B=[zeros(3,3)
    18. eye(3)/Lf
    19. zeros(3,3)]; % coefficient for the control variable u
    20. C=[eye(9)]; % coefficient for the output y
    21. D=[zeros(9,3)]; % coefficient for the output y
    22. Ks = 1/3*[-1 0 1; 1 -1 0; 0 1 -1]; % Conversion matrix to transform [iiAB iiBC iiCA] to [iiA iiB
    23. iiC]
    24.  [/LEFT]
    25. [/FONT][B][FONT=Times New Roman][LEFT]A.2 Matlab Code for Plotting the Simulation Results[/LEFT]
    26. [/FONT][/B][FONT=Times New Roman][/FONT][FONT=TimesNewRomanPSMT][LEFT]% Written by Jin Woo Jung
    27. % Date: 02/20/05
    28. % ECE743, Simulation Project #1 (Sine-PWM)
    29. % Matlab program for plotting Simulation Results
    30. % using Simulink
    31. ViAB = Vi(:,1);
    32. ViBC = Vi(:,2);
    33. ViCA = Vi(:,3);
    34. VLAB= VL(:,1);
    35. VLBC= VL(:,2);
    36. VLCA= VL(:,3);
    37. iiA= IiABC(:,1);
    38. iiB= IiABC(:,2);
    39. iiC= IiABC(:,3);
    40. iLA= ILABC(:,1);
    41. iLB= ILABC(:,2);
    42. iLC= ILABC(:,3);
    43. figure(1)
    44. subplot(3,1,1)
    45. plot(t,ViAB)
    46. axis([0.9 1 -500 500])
    47. ylabel('V_i_A_B [V]')
    48. title('Inverter output line to line voltages (V_i_A_B, V_i_B_C, V_i_C_A)')
    49.  
    50. grid
    51. subplot(3,1,2)
    52. plot(t,ViBC)
    53. axis([0.9 1 -500 500])
    54. ylabel('V_i_B_C [V]')
    55. grid
    56. subplot(3,1,3)
    57. plot(t,ViCA)
    58. axis([0.9 1 -500 500])
    59. ylabel('V_i_C_A [V]')
    60. xlabel('Time [Sec]')
    61. grid
    62. figure(2)
    63. subplot(3,1,1)
    64. plot(t,iiA)
    65. axis([0.9 1 -100 100])
    66. ylabel('i_i_A [A]')
    67. title('Inverter output currents (i_i_A, i_i_B, i_i_C)')
    68. grid
    69. subplot(3,1,2)
    70. plot(t,iiB)
    71. axis([0.9 1 -100 100])
    72. ylabel('i_i_B [A]')
    73. grid
    74. subplot(3,1,3)
    75.  
    76. plot(t,iiC)
    77. axis([0.9 1 -100 100])
    78. ylabel('i_i_C [A]')
    79. xlabel('Time [Sec]')
    80. grid
    81. figure(3)
    82. subplot(3,1,1)
    83. plot(t,VLAB)
    84. axis([0.9 1 -400 400])
    85. ylabel('V_L_A_B [V]')
    86. title('Load line to line voltages (V_L_A_B, V_L_B_C, V_L_C_A)')
    87. grid
    88. subplot(3,1,2)
    89. plot(t,VLBC)
    90. axis([0.9 1 -400 400])
    91. ylabel('V_L_B_C [V]')
    92. grid
    93. subplot(3,1,3)
    94. plot(t,VLCA)
    95. axis([0.9 1 -400 400])
    96. ylabel('V_L_C_A [V]')
    97. xlabel('Time [Sec]')
    98. grid
    99. figure(4)
    100. subplot(3,1,1)
    101. plot(t,iLA)
    102. axis([0.9 1 -50 50])
    103.  
    104. ylabel('i_L_A [A]')
    105. title('Load phase currents (i_L_A, i_L_B, i_L_C)')
    106. grid
    107. subplot(3,1,2)
    108. plot(t,iLB)
    109. axis([0.9 1 -50 50])
    110. ylabel('i_L_B [A]')
    111. grid
    112. subplot(3,1,3)
    113. plot(t,iLC)
    114. axis([0.9 1 -50 50])
    115. ylabel('i_L_C [A]')
    116. xlabel('Time [Sec]')
    117. grid
    118. figure(5)
    119. subplot(4,1,1)
    120. plot(t,ViAB)
    121. axis([0.9 1 -500 500])
    122. ylabel('V_i_A_B [V]')
    123. grid
    124. subplot(4,1,2)
    125. plot(t,iiA,'-', t,iiB,'-.',t,iiC,':')
    126. axis([0.9 1 -100 100])
    127. ylabel('i_i_A, i_i_B, i_i_C [A]')
    128. legend('i_i_A', 'i_i_B', 'i_i_C')
    129. grid
    130.  
    131. subplot(4,1,3)
    132. plot(t,VLAB,'-', t,VLBC,'-.',t,VLCA,':')
    133. axis([0.9 1 -400 400])
    134. ylabel('V_L_A_B, V_L_B_C, V_L_C_A [V]')
    135. legend('V_L_A_B', 'V_L_B_C', 'V_L_C_A')
    136. grid
    137. subplot(4,1,4)
    138. plot(t,iLA,'-', t,iLB,'-.',t,iLC,':')
    139. axis([0.9 1 -50 50])
    140. ylabel('i_L_A, i_L_B, i_L_C [A]')
    141. legend('i_L_A', 'i_L_B', 'i_L_C')
    142. xlabel('Time [Sec]')
    143. grid
    144. %For only Sine PWM
    145. figure(6)
    146. subplot(4,1,1)
    147. plot(t,Vtri,'-', t,Vsin,'-.')
    148. axis([0.9 0.917 -1.5 1.5])
    149. ylabel('V_t_r_i, V_s_i_n [V]')
    150. legend('V_t_r_i', 'V_s_i_n')
    151. title('V_t_r_i and V_s_i_n')
    152. grid
    153. subplot(4,1,2)
    154. plot(t,ViAn)
    155. axis([0.9 0.917 -500 500])
    156. ylabel('V_i_A_n [V]')
    157. grid
    158.  
    159. subplot(4,1,3)
    160. plot(t,Vtri,'-', t,Vsin,'-.')
    161. axis([0.9 0.909 -1.5 1.5])
    162. ylabel('V_t_r_i, V_s_i_n [V]')
    163. legend('V_t_r_i', 'V_s_i_n')
    164. grid
    165. subplot(4,1,4)
    166. plot(t,ViAn)
    167. axis([0.9 0.909 -500 500])
    168. ylabel('V_i_A_n [V]')
    169. xlabel('Time [Sec]')[/LEFT]
    170. grid
    171. [/FONT]
    172.  
     
    Last edited by a moderator: Apr 18, 2012
    #4
  5. TonyLennon

    TonyLennon New Member

    Joined:
    Jun 4, 2012
    1
    0
Loading...