All About Circuits Forum  

Go Back   All About Circuits Forum > Software, Microcomputing, and Communications Forums > Programmer's Corner


Programmer's Corner Discussion forum for all aspects of programming and software engineering. Any software programming language welcome: C, C++, C#, Fortran, Java, Matlab, etc.

Reply   Post New Thread
Thread Tools Display Modes
Old 04-17-2012, 01:25 PM is offline
Junior Member
Join Date: Apr 2012
Posts: 10
Default PWM inverter matlab code/simulink

hi everyone,
I need the matlab code or simulink for a 3-phase PWM inverter i found exactly what I need here
( ) 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!
Reply With Quote
Old 04-18-2012, 03:19 AM
panic mode's Avatar
panic mode panic mode is offline
Senior Member
Join Date: Oct 2011
Location: Mississauga, Ontario
Posts: 1,096

how about some details? for example what error? where?
Reply With Quote
Old 04-18-2012, 03:15 PM is offline
Junior Member
Join Date: Apr 2012
Posts: 10

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
Reply With Quote
Old 04-18-2012, 03:21 PM is offline
Junior Member
Join Date: Apr 2012
Posts: 10
Default matlab code

This is the code : if its working with u guys tell me plz :) % Input data Vdc= 400; % DC-link voltage Lf= 800e-6;% Inductance for output filter Cf= 400e-6; % Capacitance for output filter Lload = 2e-3; %Load inductance Rload= 5; % Load resistance f= 60; % Fundamental frequency fz = 3e3; % Switching frequency m= 0.8; % Modulation index % Coefficients for State-Space Model A=[zeros(3,3) eye(3)/(3*Cf) -eye(3)/(3*Cf) -eye(3)/Lf zeros(3,3) zeros(3,3) eye(3,3)/Lload zeros(3,3) -eye(3)*Rload/Lload]; % system matrix B=[zeros(3,3) eye(3)/Lf zeros(3,3)]; % coefficient for the control variable u C=[eye(9)]; % coefficient for the output y D=[zeros(9,3)]; % coefficient for the output y Ks = 1/3*[-1 0 1; 1 -1 0; 0 1 -1]; % Conversion matrix to transform [iiAB iiBC iiCA] to [iiA iiB iiC]
A.2 Matlab Code for Plotting the Simulation Results
% Written by Jin Woo Jung % Date: 02/20/05 % ECE743, Simulation Project #1 (Sine-PWM) % Matlab program for plotting Simulation Results % using Simulink ViAB = Vi(:,1); ViBC = Vi(:,2); ViCA = Vi(:,3); VLAB= VL(:,1); VLBC= VL(:,2); VLCA= VL(:,3); iiA= IiABC(:,1); iiB= IiABC(:,2); iiC= IiABC(:,3); iLA= ILABC(:,1); iLB= ILABC(:,2); iLC= ILABC(:,3); figure(1) subplot(3,1,1) plot(t,ViAB) axis([0.9 1 -500 500]) ylabel('V_i_A_B [V]') title('Inverter output line to line voltages (V_i_A_B, V_i_B_C, V_i_C_A)') grid subplot(3,1,2) plot(t,ViBC) axis([0.9 1 -500 500]) ylabel('V_i_B_C [V]') grid subplot(3,1,3) plot(t,ViCA) axis([0.9 1 -500 500]) ylabel('V_i_C_A [V]') xlabel('Time [Sec]') grid figure(2) subplot(3,1,1) plot(t,iiA) axis([0.9 1 -100 100]) ylabel('i_i_A [A]') title('Inverter output currents (i_i_A, i_i_B, i_i_C)') grid subplot(3,1,2) plot(t,iiB) axis([0.9 1 -100 100]) ylabel('i_i_B [A]') grid subplot(3,1,3) plot(t,iiC) axis([0.9 1 -100 100]) ylabel('i_i_C [A]') xlabel('Time [Sec]') grid figure(3) subplot(3,1,1) plot(t,VLAB) axis([0.9 1 -400 400]) ylabel('V_L_A_B [V]') title('Load line to line voltages (V_L_A_B, V_L_B_C, V_L_C_A)') grid subplot(3,1,2) plot(t,VLBC) axis([0.9 1 -400 400]) ylabel('V_L_B_C [V]') grid subplot(3,1,3) plot(t,VLCA) axis([0.9 1 -400 400]) ylabel('V_L_C_A [V]') xlabel('Time [Sec]') grid figure(4) subplot(3,1,1) plot(t,iLA) axis([0.9 1 -50 50]) ylabel('i_L_A [A]') title('Load phase currents (i_L_A, i_L_B, i_L_C)') grid subplot(3,1,2) plot(t,iLB) axis([0.9 1 -50 50]) ylabel('i_L_B [A]') grid subplot(3,1,3) plot(t,iLC) axis([0.9 1 -50 50]) ylabel('i_L_C [A]') xlabel('Time [Sec]') grid figure(5) subplot(4,1,1) plot(t,ViAB) axis([0.9 1 -500 500]) ylabel('V_i_A_B [V]') grid subplot(4,1,2) plot(t,iiA,'-', t,iiB,'-.',t,iiC,':') axis([0.9 1 -100 100]) ylabel('i_i_A, i_i_B, i_i_C [A]') legend('i_i_A', 'i_i_B', 'i_i_C') grid subplot(4,1,3) plot(t,VLAB,'-', t,VLBC,'-.',t,VLCA,':') axis([0.9 1 -400 400]) ylabel('V_L_A_B, V_L_B_C, V_L_C_A [V]') legend('V_L_A_B', 'V_L_B_C', 'V_L_C_A') grid subplot(4,1,4) plot(t,iLA,'-', t,iLB,'-.',t,iLC,':') axis([0.9 1 -50 50]) ylabel('i_L_A, i_L_B, i_L_C [A]') legend('i_L_A', 'i_L_B', 'i_L_C') xlabel('Time [Sec]') grid %For only Sine PWM figure(6) subplot(4,1,1) plot(t,Vtri,'-', t,Vsin,'-.') axis([0.9 0.917 -1.5 1.5]) ylabel('V_t_r_i, V_s_i_n [V]') legend('V_t_r_i', 'V_s_i_n') title('V_t_r_i and V_s_i_n') grid subplot(4,1,2) plot(t,ViAn) axis([0.9 0.917 -500 500]) ylabel('V_i_A_n [V]') grid subplot(4,1,3) plot(t,Vtri,'-', t,Vsin,'-.') axis([0.9 0.909 -1.5 1.5]) ylabel('V_t_r_i, V_s_i_n [V]') legend('V_t_r_i', 'V_s_i_n') grid subplot(4,1,4) plot(t,ViAn) axis([0.9 0.909 -500 500]) ylabel('V_i_A_n [V]') xlabel('Time [Sec]')
Select All

Last edited by bertus; 04-18-2012 at 07:52 PM. Reason: used code tags
Reply With Quote
Old 06-04-2012, 08:04 PM
TonyLennon TonyLennon is offline
New Member
Join Date: Jun 2012
Posts: 1

This site may give you some help.
Reply With Quote
Reply   Post New Thread

, , ,

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help Variable PWM using A/D PIC18F2431 trr85 Embedded Systems and Microcontrollers 5 06-12-2009 04:36 AM
About a PWM power inverter gaetan8888 The Projects Forum 7 03-10-2009 04:27 PM
Need help about a diy 2kw PWM true sine inverter I've found on the Net gaetan8888 The Projects Forum 9 11-15-2008 06:34 PM
Useful Matlab Information Dave Programmer's Corner 7 11-09-2008 05:51 AM
Learning - project pwm MrWoo The Projects Forum 5 06-19-2007 07:47 PM

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 02:02 PM.

User-posted content, unless source quoted, is licensed under a Creative Commons Public Domain License.
Powered by vBulletin
Copyright ©2000 - 2014, vBulletin Solutions, Inc.