Code help please

Joined
May 19, 2023
Messages
3
Reaction score
0
Hello, I want to generate switching signals for a quasi z source inverter using the svpwm method. I can generate the traditional svpwm method, but I couldn't add shoot through time on it. I have researched on MathWorks and found that the code, but I don't fully understand the code. Although I understand what it does in general, I can't adapt it to the format used in my switching time table. I would be very grateful if someone help me on understanding how this code works. I have been trying to find a solution for 2 weeks.
My main problem is the second code; what sw_array and time_int do, why sw_array has 13 columns but there is only 12 it values. Also an example for sw_array:),:,1) = [0 1 1 1 1 1 1 1 1 1 1 1 0; what is mathematical representation.

function [t1,t2,t0,int1,int2,int3,int4,int5,...
int6,int7,int8,int9,int10,int11,int12] ...
= fcn(M,angle,Sector,D,Ts)

a = M;
n = Sector;

t1 = aTssin(npi/3 - angle);
t2 = a
Ts*sin(angle - ((n-1)pi/3));
t0 = Ts - t1 - t2;
tsh = D
Ts;

switch Sector
case 1
int1 = t0/4 - tsh/4;
int2 = int1 + tsh/6;
int3 = int2 + t1/2;
int4 = int3 + tsh/6;
int5 = int4 + t2/2;
int6 = int5 + tsh/6;
int7 = int6 + t0/2 - tsh/2;
int8 = int7 + tsh/6;
int9 = int8 + t2/2;
int10 = int9 + tsh/6;
int11 = int10 + t1/2;
int12 = int11 + tsh/6;

case 2
int1 = t0/4 - tsh/4;
int2 = int1 + tsh/6;
int3 = int2 + t2/2;
int4 = int3 + tsh/6;
int5 = int4 + t1/2;
int6 = int5 + tsh/6;
int7 = int6 + t0/2 - tsh/2;
int8 = int7 + tsh/6;
int9 = int8 + t1/2;
int10 = int9 + tsh/6;
int11 = int10 + t2/2;
int12 = int11 + tsh/6;

case 3
int1 = t0/4 - tsh/4;
int2 = int1 + tsh/6;
int3 = int2 + t1/2;
int4 = int3 + tsh/6;
int5 = int4 + t2/2;
int6 = int5 + tsh/6;
int7 = int6 + t0/2 - tsh/2;
int8 = int7 + tsh/6;
int9 = int8 + t2/2;
int10 = int9 + tsh/6;
int11 = int10 + t1/2;
int12 = int11 + tsh/6;

case 4
int1 = t0/4 - tsh/4;
int2 = int1 + tsh/6;
int3 = int2 + t2/2;
int4 = int3 + tsh/6;
int5 = int4 + t1/2;
int6 = int5 + tsh/6;
int7 = int6 + t0/2 - tsh/2;
int8 = int7 + tsh/6;
int9 = int8 + t1/2;
int10 = int9 + tsh/6;
int11 = int10 + t2/2;
int12 = int11 + tsh/6;

case 5
int1 = t0/4 - tsh/4;
int2 = int1 + tsh/6;
int3 = int2 + t1/2;
int4 = int3 + tsh/6;
int5 = int4 + t2/2;
int6 = int5 + tsh/6;
int7 = int6 + t0/2 - tsh/2;
int8 = int7 + tsh/6;
int9 = int8 + t2/2;
int10 = int9 + tsh/6;
int11 = int10 + t1/2;
int12 = int11 + tsh/6;

otherwise
int1 = t0/4 - tsh/4;
int2 = int1 + tsh/6;
int3 = int2 + t2/2;
int4 = int3 + tsh/6;
int5 = int4 + t1/2;
int6 = int5 + tsh/6;
int7 = int6 + t0/2 - tsh/2;
int8 = int7 + tsh/6;
int9 = int8 + t1/2;
int10 = int9 + tsh/6;
int11 = int10 + t2/2;
int12 = int11 + tsh/6;
end
function [Time_int,S1,S2,S3,S4,S5,S6] = ...
fcn(int1,int2,int3,int4,int5,int6,int7,int8,int9,int10,int11,...
int12,ref,Sector)

Time_int = 1 + (ref>=int1) + (ref>=int2) + (ref>=int3) + (ref>=int4) ...
  • (ref >= int5) + (ref >= int6) + (ref >= int7) + (ref >= int8) ...
  • (ref >= int9) + (ref >= int10) + (ref >= int11) + (ref >= int12);

%% format of the array sw_array(x,y,z)
sw_array = zeros(6,13,6); %initialize the switching table
% x=[LegA LegB LegC] % y=[Timeint1 timeint2 ..] % z=[sector1 sector2 ..]
sw_array:),:,1) = [0 1 1 1 1 1 1 1 1 1 1 1 0; ...
1 1 0 1 0 1 0 1 0 1 0 1 1; ...
0 1 0 1 1 1 1 1 1 1 0 1 0; ...
1 1 1 1 0 1 0 1 0 1 1 1 1; ...
0 1 0 1 0 1 1 1 0 1 0 1 0; ...
1 1 1 1 1 1 0 1 1 1 1 1 1];
sw_array:),:,2) = [0 1 0 1 1 1 1 1 1 1 0 1 0; ...
1 1 1 1 0 1 0 1 0 1 1 1 0; ...
0 1 1 1 1 1 1 1 1 1 1 1 0; ...
1 1 0 1 0 1 0 1 0 1 0 1 1; ...
0 1 0 1 0 1 1 1 0 1 0 1 0; ...
1 1 1 1 1 1 0 1 1 1 1 1 1];
sw_array:),:,3) = [0 1 0 1 0 1 1 1 0 1 0 1 0; ...
1 1 1 1 1 1 0 1 1 1 1 1 1; ...
0 1 1 1 1 1 1 1 1 1 1 1 0; ...
1 1 0 1 0 1 0 1 0 1 0 1 1; ...
0 1 0 1 1 1 1 1 1 1 0 1 0; ...
1 1 1 1 0 1 0 1 0 1 1 1 1];
sw_array:),:,4) = [0 1 0 1 0 1 1 1 0 1 0 1 0; ...
1 1 1 1 1 1 0 1 1 1 1 1 1; ...
0 1 0 1 1 1 1 1 1 1 0 1 0; ...
1 1 1 1 0 1 0 1 0 1 1 1 1; ...
0 1 1 1 1 1 1 1 1 1 1 1 0; ...
1 1 0 1 0 1 0 1 0 1 0 1 1];
sw_array:),:,5) = [0 1 0 1 1 1 1 1 1 1 0 1 0; ...
1 1 1 1 0 1 0 1 0 1 1 1 1; ...
0 1 0 1 0 1 1 1 0 1 0 1 0; ...
1 1 1 1 1 1 0 1 1 1 1 1 1; ...
0 1 1 1 1 1 1 1 1 1 1 1 0; ...
1 1 0 1 0 1 0 1 0 1 0 1 1];
sw_array:),:,6) = [0 1 1 1 1 1 1 1 1 1 1 1 0; ...
1 1 0 1 0 1 0 1 0 1 0 1 1; ...
0 1 0 1 0 1 1 1 0 1 0 1 0; ...
1 1 1 1 1 1 0 1 1 1 1 1 1; ...
0 1 0 1 1 1 1 1 1 1 0 1 0; ...
1 1 1 1 0 1 0 1 0 1 1 1 1];

S1 = sw_array(1,Time_int,Sector);
S2 = sw_array(2,Time_int,Sector);
S3 = sw_array(3,Time_int,Sector);
S4 = sw_array(4,Time_int,Sector);
S5 = sw_array(5,Time_int,Sector);
S6 = sw_array(6,Time_int,Sector);
 
Joined
Jan 8, 2023
Messages
27
Reaction score
2
Let's delve into the key elements of the code, breaking them down for better understanding.

The initial function computes t1, t2, and t0, which denote the on-times for the active vectors and zero vectors within one modulation period. This procedure adheres to the standard SVPWM technique. D typically represents the shoot-through duty cycle, while Ts denotes the sampling period. Subsequently, the interval times are determined based on the current sector (referred to as Sector).

Moving on to the second function, the Time_int value is derived by comparing the reference time (ref) with the interval times. The expression ref>=intX evaluates to 1 if the condition holds true; otherwise, it yields 0. Consequently, Time_int accumulates the occurrences of these true conditions, signifying the current time interval. This information plays a critical role in determining the appropriate system state at any given moment.

The sw_array is a three-dimensional array utilized to represent the switching states for each phase (comprising 6 legs), each time interval (consisting of 13 intervals), and each sector (a total of 6 sectors). To interpret the sw_array:),:,1) notation, it specifies the switching states for all phases and intervals within the first sector.

Regarding the inclusion of 13 columns, it is due to the division of each SVPWM cycle into 13 intervals in this particular implementation, encompassing shoot-through intervals. The additional column may be employed for zero-padding or to ensure the completion of a full switching cycle.

The values contained within the sw_array correspond to the states of the inverter switches. For instance, in sw_array:),:,1) = [0 1 1 1 1 1 1 1 1 1 1 1 0;... 0 indicates an off state, while 1 signifies an on state.

The final code block simply retrieves the state of each leg by indexing the sw_array based on the current Time_int and Sector. The states of the six legs of the inverter are denoted by S1 to S6.

Should you wish to adapt this code for your specific purposes, you will need to make adjustments to the time calculations and the sw_array to match the states defined in your own switching table. Remember to modify the size of the sw_array if you utilize a different number of intervals or sectors.

It is important to note that the actual content of the sw_array may vary depending on the specific implementation of SVPWM and the incorporation of shoot-through states. Hence, it is crucial to comprehend the underlying theory when developing your own switch table.
 
Joined
May 19, 2023
Messages
3
Reaction score
0
Let's delve into the key elements of the code, breaking them down for better understanding.

The initial function computes t1, t2, and t0, which denote the on-times for the active vectors and zero vectors within one modulation period. This procedure adheres to the standard SVPWM technique. D typically represents the shoot-through duty cycle, while Ts denotes the sampling period. Subsequently, the interval times are determined based on the current sector (referred to as Sector).

Moving on to the second function, the Time_int value is derived by comparing the reference time (ref) with the interval times. The expression ref>=intX evaluates to 1 if the condition holds true; otherwise, it yields 0. Consequently, Time_int accumulates the occurrences of these true conditions, signifying the current time interval. This information plays a critical role in determining the appropriate system state at any given moment.

The sw_array is a three-dimensional array utilized to represent the switching states for each phase (comprising 6 legs), each time interval (consisting of 13 intervals), and each sector (a total of 6 sectors). To interpret the sw_array:),:,1) notation, it specifies the switching states for all phases and intervals within the first sector.

Regarding the inclusion of 13 columns, it is due to the division of each SVPWM cycle into 13 intervals in this particular implementation, encompassing shoot-through intervals. The additional column may be employed for zero-padding or to ensure the completion of a full switching cycle.

The values contained within the sw_array correspond to the states of the inverter switches. For instance, in sw_array:),:,1) = [0 1 1 1 1 1 1 1 1 1 1 1 0;... 0 indicates an off state, while 1 signifies an on state.

The final code block simply retrieves the state of each leg by indexing the sw_array based on the current Time_int and Sector. The states of the six legs of the inverter are denoted by S1 to S6.

Should you wish to adapt this code for your specific purposes, you will need to make adjustments to the time calculations and the sw_array to match the states defined in your own switching table. Remember to modify the size of the sw_array if you utilize a different number of intervals or sectors.

It is important to note that the actual content of the sw_array may vary depending on the specific implementation of SVPWM and the incorporation of shoot-through states. Hence, it is crucial to comprehend the underlying theory when developing your own switch table.
thanks for the explanation. but I need to exact mathematical equation for the array to modify my svpwm switching table. I hope anyone help me for that.
 

Attachments

  • geleneksel svpwm tablosu.jpg
    geleneksel svpwm tablosu.jpg
    89 KB · Views: 5

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top