Friday, March 29, 2013

Induction Machine Model for Start-Up Simulation

     This article is about the basic modelling of induction machine using the delta equivalent circuit parameters. With this model, we can easily observe how input voltage, stator current, electromechanical torque and shaft speed changes with time during start-up. Basic mathematical model of an induction machine is formed using the mathematical equations of current,torque and mechanical motion equation. The mathematical model is simulated for 1 second to observe the start-up situation. The MATLAB model for this purpose is as stated below;

% Induction Motor Model

t = 0:0.001:1; % 1sec simulation with time step of 0.001 sec
dt = 0.001;

% Motor Parameters
R1 = 0.205; % Ohm
R2 = 1.408; % Referred value, Ohm
X1 = 1.507; % Ohm
X2 = 1.507; % Ohm
Rc = 315.6; % Shunt branch, Ohm
Xm = 42.5; % Shunt branch, Ohm
Vin = 537.4*cos(2*pi*50*t); % Input voltage,50 Hz, Vphase 220 V
I = zeros(1,1001);
s = 1; % slip=1 at the beginning
w = zeros(1,1001); % rotor speed
Pe = 0; % Electromechanical power output
Te = zeros(1,1001); % Electromechanical torque
Jm = 0.1285; % kg/m2 , Inertia of machine

% Load parameters
Tl = 0; % Load Torque
Jl = 0; % Load Inertia

Xeq = X1 + X2;
Leq = Xeq / 100 / pi;

for n=2:1001
   Vth = abs(1i*Xm/(R1 + 1i*(X1 + Xm))*Vin(1,n)); 
   I(1,n) = (Vin(1,n) + I(1,n-1)*Leq/dt) / (R1 + R2/s + Leq/dt); % Motor Current 
   Te(1,n) = 3*Vth^2*R2/((R1 + R2/s)^2 + (X1 + X2)^2)/s/100/pi; % Electromechanical Torque
   % Torque balance equation
   w(1,n) = w(1,n-1) + (Te(1,n) - Tl)/(Jm + Jl)*dt; % new speed value 
   s = (100*pi-w(1,n))/100/pi ; % new slip value

     After we run this code, w, Te and I vectors against time is created at the workspace. We can plot them to see their variation in time during start-up.

     Simulation Results (NO-LOAD Start-Up)

 Simulation Results (LOAD with only inertia no torque Start-Up , inertia Jload = 3xJmotor)

     Note that the in rush current of the motor start-up is easily observed in current graphs. 
     Note that the results are for 2 pole machine
     When a load of only inertia that is 3 times larger than motor inertia, the start-up time is increased.
     Please investigate the torque graphs, the mean of the torque values shows a typical torque-speed curve, which is expected.
     Since there is no load torque and friction&windage torque is neglected, the motor current reduced to zero after rated speed is reached. 

     What if the motor is suddenly loaded with a constant torque of 40 Nm during 1.5 < t < 1.7 sec ?

MATLAB can be get from Amazon at link,

Wednesday, March 27, 2013

POWER SYSTEM HARMONICS IN DETAIL: Subject 1: Effect of Two Closely Located Harmonics

     Harmonics in power system can be basicly introduced as the unintended frequency components, generally higher than system frequency, of current or voltage in the power system. The sources of current harmonics and the harm of them to the power system is stated in an article about Active Power Filters in the blog, thus; I will skip that part. Instead of the drowning in details, I will mention the case of two very closely located harmonics and their effect on harmonic spectrum. Almost everyone who is dealing with power system signal processing can know that the close harmonics tend to increase the magnitude of frequencies between them in FFT spectrum. However, the point that I will draw attention will be a different side of this situation, actually, the behaviors while they are approaching each other to almost 2 Hz. 
     Some loads in Metal Industry behaves very different than other widely known industrial load. For example, arc furnaces, laddle furnaces or induction furnaces for metal melting purposes have very distructive behaviours to the power system. For the introduction of this article, I will briefly mention some behaviours of induction furnaces. For one of the induction furnaces that I take measurements with my collegues in the field, We recognised that the load creates harmonic spectrum other than the characteristics of any other load in industry. The induction furnace creates variety of interharmonics whose frequency value is changing dynamically between 280 Hz and 550 Hz. In other words, there are not fixed frequency harmonics, there can be for example 312 Hz harmonic currents, while the harmonic was in 290 Hz 10 minutes before 312 Hz. The harmonic frequencies are changing during the melting process. I and my collegues are recognised that there can be two harmonics ,which are 2 Hz apart each other, at the same time. Let me know explain what happens at this case.
     As you may know the whole current or voltage signal can be expressed as the sum of fundemental and harmonics frequency sine waves. Therefore, for our example ,for the sake of simplicity, we can consider the sum of 282 Hz and 280 Hz harmonic components whose magnitudes are A and B, respectively. Considering the fundemental Cosine Sum formulation in equation (1), we can apply the rule to our power system signal to get equation (2).

     For the sake of simplicity, we can consider that the phases of our harmonics are equal to zero in order to reach equation (3). If we consider that the magnitudes A and B of the harmonic components are equal to each other as A, we can reach to equation (4).

     When we apply our example to the equation (3) , by putting the frequency values 282 and 280 Hz, we can reach to the result of equation (5). Similarly if we consider that the magnitudes of the harmonics are the same at A, the equation (6) is reached. What is the interpretation of the equation (5) ? Equation (5) means a 282 Hz signal whose amplitude is modulated with a sine wave of 1 Hz. The physical meaning of this situation is that the 282 Hz harmonic component has high magnitude during 0.5 seconds and low magnitude in the following 0.5 seconds. Actually, if you have an active or passive filter for filtering this harmonic, you can hear an audible voice whose intensity is increasing and decreasing at every 0.5 seconds. What if the magnitudes are the same for two harmonics ? This causes the most severe result. The magnitude of the harmonic is increased up to double and decreased down to zero at a frequency of 1 Hz. Similarly, the physical meaning of this situation in active or passive filter case gives that the audible voice is extremely increased and totally ceased with a period of 0.5 seconds.

     Now let me verify this situation using MATLAB.
MATLAB can be get from Amazon at link,

Used MATLAB code for different magnitudes;

t = 0:1.5625e-4:1; % 6400 samples/second sampling frequency
A = 1; % magnitude of 282 Hz component
B = 0.3; % magnitude of 280 Hz component
X = A*cos(2*pi*282*t) + B*cos(2*pi*280*t); % Signal to be analysed
plot(X); % plotting the resultant waveform

Figure 1: Resultant Waveform with A = 1 and B = 0.3

Figure 2: Resultant Waveform(zoomed) with A = 1 and B = 0.3

Used MATLAB code for same magnitudes;

t = 0:1.5625e-4:1; % 6400 samples/second sampling frequency
A = 1; % magnitude of 282 Hz component
B = 1; % magnitude of 280 Hz component
X = A*cos(2*pi*282*t) + B*cos(2*pi*280*t); % Signal to be analysed
plot(X); % plotting the resultant waveform

Figure 3: Resultant Waveform with A = 1 and B = 1

Figure 4: Resultant Waveform with(zoomed) A = 1 and B = 1

Monday, March 25, 2013

TCP/IP Ethernet Communication Using Stellaris ARM Cortex M3

     Stellaris ARM Cortex M3 is a product  of Texas Instruments (TI). Unlike powerful DSP’s or floating point microcontrollers, this microcontroller is not suitable for Power Electronics applications control system. However, due to its communication features it can be a very good monitoring processor. The microcontroller has an Ethernet module and its evaluation kit has already mounted Ethernet connector. I am using Stellaris ARM Cortex M3 for monitoring purposes in one of my Active Power Filter project. The microcontroller has the analog inputs for necessary channels like active filter current, line voltage, dc link voltage and heatsink temperatures. These analog information is converted to digital and sent to the Human Machine Interface (HMI) of automation system via Ethernet communication. This is the duty to be conducted by this microcontroller. In this article, I will try to explain the methods to conduct this applications with basic TCP/IP protocol and explain ,in detail, my solution.
     TI provides lots of sample codes and manuals for different applications. One of these sample codes and manuals is about TCP/IP protocol. There are two modules served for this purpose which are generated by Adam Dunkels namely uIP (micro IP) and lwIP (lightweight IP). One can use these methods to communicate to any device using Ethernet communication.
     uIP is smaller in size than lwIP. It contains basic functions to establish or finish the connection and sending or receiving data. uIP is not a complex structure thus; it is better for simple applications. lwIP , on the other hand, has more complex structure than uIP but its features are a bit more developed. Actually, for basic communication purposes, one can use uIP easily for Ethernet communications.
     My solution ,on the other hand, uses the open-sourced uIP stack ,however; I add my functions for establishing, finishing connections and receiving or sending data routins. By this way, I form a code that listens any of the device that requires connection establishment and sends the data immediately after receiving data from the host. 
     The physical connection is started when the host sends a broadcast in ARP (Adress Resolution Protocol), stating its own MAC adress, IP and the destination IP adress. If our microcontroller has the same IP adress of host requires, our system sends an answer stating its own MAC address and IP in ARP. After this process, now the host knows our IP address. To establish the connection the host sends a SYN flaged packet in order to initialize the sequence number and the rules of connection (like window size, protocol number IPv4, TCP protocol and its listening port). Our system turns an answer of SYN/ACK packet to understand the rules and port numberof the host. Finally, the host send and ACK packet to show that it succesfully establish the connection and ready to transfer data with the stated rules. After the synchronisation is handled, the host sends a data whenever it wants using the PSH,ACK flaged packet. This packet contains the data to be transfered and requires an acknowledge that the data is reached correctly. Once, our system get the PSH,ACK flaged packet, we immediately send an ACK packet to say that we succesfully get the data. After we successfully receive the data we send our information to the host using PSH,ACK flaged packet. Similarly, it is expected that the host sends ACK packet when it reads our information. The data sending cycle continues until the host finishes or reset the connection. To finish the connection, host sends FIN,ACK packet for healty ending of connection or RST,ACK packet if it needs to force the connection to end.
      My code for handling all these TCP/IP communication procedure is as stated below.

EthernetPacketGetDMA(unsigned long ulBase, unsigned char *pucBuf, long lBufLen)
    int k,freq_index;
                long len;
                int Data_len = 0;
    // Check the arguments.
    ASSERT(ulBase == ETH_BASE);
    ASSERT(pucBuf != 0);
    ASSERT(lBufLen > 0);
        len=ROM_EthernetPacketGetNonBlocking(ulBase, pucBuf, lBufLen); // get the received packet on pointer pucBuf
                // ARP packets handled here
                                if(*(pucBuf+12)==0x08 && *(pucBuf+13)==0x06 && *(pucBuf+41)==DEFAULT_IPADDR3)
                                               {ARP_SEND[k] = *(pucBuf+k+6);  // Dest MAC
                                               ARP_SEND[k+32] = *(pucBuf+k+6);   // target mac }
                                               {ARP_SEND[k+38]=*(pucBuf+k+28); }

                    // IP packets handled here
                                if(*(pucBuf+12)==0x08 && *(pucBuf+13)==0x00) // IP packets here
                                for(k=0;k<6;k++)                // destination MAC
                                 if(TCP_SEND[19]==0xFF)   // identification increments every send procedure
                                               TCP_SEND[k+30]=*(pucBuf+k+26);     // Destination IP
                                               TCP_SEND[36]=*(pucBuf+34);     // Destination Port
                                               TCP_SEND[46]=0x50; // header length
                                 ///****** SYN packets here
                                if(*(pucBuf+47)==0x02)  //SYN packets
                                {    for(k=0;k<4;k++)
                                 {TCP_SEND[k+42]=*(pucBuf+38+k);  }
                                 TCP_SEND[45]++; // Ack num + 1
                                 TCP_SEND[47]=0x12; // SYN,ACK
                                 TCP_SEND[48]=*(pucBuf+48);  // window size
                               TCP_SEND[46]=*(pucBuf+46);  // header length
                               for(k=54;k<len;k++)      // options
                                }// end SYN
                                ////////*** ACK packets here
                                else if (*(pucBuf+47)==0x10)
                                {  // data transfer cycle is ended. Nothing is necessary to do                 
                                }// end ACK
                                ////////*** PSH,ACK packets here
                                else if (*(pucBuf+47)==0x18) 
                           {Data_len = *(pucBuf+17)-0x28; // how many bytes of data are received?
                                 {TCP_SEND[k+38] = *(pucBuf+k+42);
                                 TCP_SEND[k+42] = *(pucBuf+38+k); }
                                TCP_SEND[45] += Data_len;
                                 TCP_SEND[46] = 0x50;
                                 TCP_SEND[47] = 0x10; // ACK
                                 TCP_SEND[48]=*(pucBuf+48);  // window size
                                if(*(pucBuf+55) == 0xCC)
                                if(*(pucBuf+55)==0xAA && Data_len == 22)
                                                               receiveArray[k] = *(pucBuf+54+k); }
                                sendArray[0] = 0x02; // ID2
                                sendArray[1] = 0xBB; // ack
                                               sendArray[k] = receiveArray[k];
                                sendArray[22] = (mALARM >> 8) & 0x00FF;            // alarm high byte
                                sendArray[23] = mALARM& 0x00FF;                         //alarm low byte
                                sendArray[24] = (_IQ7int(Vdc_mean) >> 8) & 0x00FF;   //dc link voltage
                                sendArray[25] = _IQ7int(Vdc_mean) & 0x00FF;
                                GP_CURRENT = _IQ7int(Iha_mean);
                                GP_CURRENT = isqrt(GP_CURRENT);
                                sendArray[26] = (GP_CURRENT >> 8) & 0x00FF;  // active filter current
                                sendArray[27] = GP_CURRENT& 0x00FF;
                                freq_index = 0;
                                for(k=28;k<108;k=k+4)  // send frequency values
                                                               sendArray[k] = (freq[freq_index][0]>>8) & 0x00FF;
                                                               sendArray[k+1] = freq[freq_index][0] & 0x00FF;
                                                               sendArray[k+2] = (freq[freq_index][1]>>8) & 0x00FF;
                                                               sendArray[k+3] = freq[freq_index][1] & 0x00FF;
                                sendArray[108] = T1_int;   // send temperatures
                                sendArray[109] = T2_int;
                                sendArray[110] = T3_int;
                               }// end PSH,ACK
                    ////********** FIN,ACK packets here
                   else if(*(pucBuf+47)==0x11)  
                                 {TCP_SEND[k+38] = *(pucBuf+k+42);
                                 TCP_SEND[k+42] = *(pucBuf+38+k); }
                               TCP_SEND[45] += 1;
                                 TCP_SEND[42]++; }
                                 TCP_SEND[46] = 0x50;
                                 TCP_SEND[47] = 0x10; // ACK
                                 TCP_SEND[48]=*(pucBuf+48);  // window size
                                TCP_SEND[47] = 0x11; // FIN,ACK
                               }// end FIN,ACK
 } // end else if
            // Clear the RX Packet event and re-enable RX Packet interrupts.
            if(HWREGBITW(&g_ulFlags, FLAG_RXPKT) == 1)
                HWREGBITW(&g_ulFlags, FLAG_RXPKT) = 0;
                ROM_EthernetIntEnable(ETH_BASE, ETH_INT_RX);
  return len; 
}// end function 

For the whole source code and detailed information please contact me.

Saturday, March 23, 2013

Space Vector Modulation in 3-Level Voltage Sourced Neutral Point Clamped Inverter

          Three Level Voltage Sourced Neutral Point Clamped Inverter

            3-Level Neutral Point Clamped (NPC) inverter is one of the DC/AC converters with partitioned dc-link by diode clamps. The diode clamps are located such that each phase voltage is produced with respect to neutral point, which is actually the mid-point of dc-link. Since each phase voltage is produced with respect to neutral point (Z), the line-to-line voltages form a balanced three phase set for the load. Dc-link voltage is distributed such that two equal valued capacitors share the total dc-link voltage. For the three level operation there will be two capacitior to share the dc-link, meaning that each capacitor has voltage value E which is half of total dc-link voltage value.  
         With the changing switching schema each phase voltage (phase - neutral) can have three different voltage level. One of them is called P state, for this state corresponding phase has a voltage level of E. The second state is called O state, which corresponds to zero voltage on a phase. The last state is called the N state which corresponds to -E voltage on a phase. Since each phase voltage has three levels, the line-to-line voltages has five different voltage levels, namely +2E,+E,0,-E,-2E. With this voltage kind of voltage waveform, one can easily say that the most dominant voltage harmonic for this scheme should be larger than 10th harmonic. In addition to that information, naturally the voltage harmonics may lay around switching frequency and its integer multiplications. This kind of topology gives us lower dv/dt values than the traditional 2 level inverters with same dc-link value. However, one of the most challenging drawback is that the user should keep the upper and lower side capacitor voltages the same. The three level NPC topology is as shown in figure 1.
Figure 1 : 3 Phase NPC

         Space Vector Modulation

        Space Vector Modulation (SVM) technique is a bit more complex and challenging method than carrier based Pulse Width Modulation (PWM) techniques. To introduce SVM, let me remember some points about three phase systems. The three phase voltages at any instant ,actually, forms a space vector which is rotating around cartesian coordinates with an angular frequency 2*pi*f, f being system frequency. This space vector has a constant magnitude and its phase changing in time with the integral of angular frequncy stated. Please think that an observer sitting on the origin of cartesian coordinates sees this space vector as I stated before. What about an observer on a frame which is rotating with the same angular speed with the space vector? Actually the observer in synchronously rotating frame sees this vector space as constant in time. Knowing these concepts, our controller should be like an observer sitting in a fixed frame on cartesian coordinates. Suppose our observer has two point of views which are direct and quadrature axes. The instantaneous values of direct and quadrature axes represents the direct and quadrature components of the Space Vector for the 3 phase voltage. We are using a transformation called Clarke transformation (or alpha-beta transformation) in order to create a 2 phase representation of 3 phase voltage such that their space vectors coincide each other. 
       Space Vector Modulation technique creates a fixed valued reference space vector which is rotating with angular frequency of w. And to use this technique, the whole space is divided into 6 sectors and each sector is divided into 4 regions for 3-level operation. The corresponding divisions are shown in figure 2.

Figure 2 - Space Vector Modulation Divisions

      Note that each position in dq space is represented a voltage state for phases a,b and c. For example Sector 1, Region II is enclosed with three space vectors 100(V1),210(V7) and 221(V2), meaning ONN,PON and PPO. To get a reference space vector using these three vectors in Sector 1 - Region II, these three vectors states should be applied some defined time intervals of Ta,Tb and Tc respectively so that the following equation holds. The time intervals Ta, Tb and Tc are called Dwell Times.

Vref * Ts = V1 * Ta + V7 * Tb + V2 * Tc , where Ts is switching period

Using our fixed space vectors, we can form any reference vector at any instant. By this way, for every period Ts we should calculate the direct and quadrature componenets of reference vector and find in which sector and region the reference vector lies. After we find the exact location of reference vector, we know which vectors are used for composing a reference for the corresponding section and region; thus, if we apply these vectors with the duration of calculated Dwell Times, we can form the required reference space vector. The calculation of Dwell Times are stated below in figure 3;

Figure 4: Dwell Times Formulas

        In figure 4, Dwell Times calculations are stated, in these equations theta value will be the angle of corresponding sector and it must be between 0 and 60 degrees. The theta value for each sector is as stated below;
theta_Sector = theta_Reference - (Sector_Number - 1) * PI / 3

Also for the formulation in Dwell Times, there is another variable called modulation index, Ma. This modulation index is used for creating a reference with different magnitudes. 

Ma = sqrt(3) * Vref / Vd     , where Vd is DC-LINK voltage
0 <= Ma <= 1   , range of modulation index 

        Spece Vector Modulation Sequence Design

       In previous sections, I mentioned how reference space vector is composed and how we can realize it using Dwell Times. After calculation of Dwell Times, one can ask that in which sequence we can apply the space vectors. This is actually one of the important parts of control system, because switching sequence determines some key points like even voltage distribution of dc link capacitors or elimination of even harmonics.
          At the beginning, I said that there are 3 levels for each phase at any instant and since we have three phases, there are 27 different switching state for the inverter. All of this states corresponds to a space vector in figure 1. These space vectors are used to form the reference space vector which is rotation at a speed of w and has a constant magnitude which is determined by the modulation index Ma. Actually, some of the states corresponds to the same space vector. The whole table for the space vectors are as stated in figure 5.

Figure 5 : Space Vectors

        I will mention one of the switching sequences called Seven-Segment switching sequence, which is actually the one I used for my application. The switching sequence is shown in figure 6.

Figure 6 : Seven-Segment Switching Sequence for Sector 1 - Region IV

            Figure 7 represents the locations of Space Vectors.

Figure 7 : Space Vector Positions

        The Inverter Results

        PSCAD Simulation with topology in figure 1.
        Ma = 1
        frequency = 50 Hz
       For SVM Control Block FORTRAN codes contact me from
Figure 8 : Output Voltage and Current Waveforms

Figure 9 : FFT for Vab/Vd for load side

     REFERENCE : WU, B. High-Power Converters and AC Drives. 2006
     Amazon -

     Abe Books - -

     BN - Barnes&Noble - -

     BAM - - (hardcover)

 (e-book) -