The post Zeigler-Nichols Rule explained with example appeared first on .

]]>The Zeigler-Nichols is a heuristic approach for tuning the parameters of PID controller gain parameters:

- Kp – the controller path gain
- Ti – the controller’s integrator time constant
- Td – the controller’s derivative time constant

Given two measured feedback loop parameters derived from measurements:

- The period T0 of the oscillation frequency at the stability limit.
- The gain margin Kp0 for loop stability.

The main goal is to achieve good regulation in the system for rejecting the disturbance produced in the system.

Tuning rules work well when the controller required is analog, system is linear, monotonic and a response that is dominated by a single-pole exponential “lag”.

Actual plants are unlikely to have a perfect first-order lag characteristic. Higher-order poles will introduce an extra phase shift, phase shift matters a lot to loop stability. You can’t depend upon the single “lag” pole to match both the amplitude roll-off and phase shift accurately.

So the ZN model presumes an additional fictional phase adjustment that does not distort the assumed magnitude roll-off. At the stability margin there is a 180 degree phase shift around the feedback loop which is the Nyquist’s stability criteria. A first order lag can contribute no more than 90 degrees of that phase shift.

To summarize, then, the Ziegler-Nichols rule assumes that the system has a transfer function of the following form:

= (Ke^-sT)/ (a+s)

The model matches the system response at frequencies 0 and at the stability limit.

Given the magnitude and phase open-loop response curves of the plant, you can fit the assumed model in the following manner.

- The ratio of output level to input level at low frequencies determines the gain parameter K of the model.
- Observe the frequency F0 at which the phase passes through -pi radians (-180 degrees). The inverse of this frequency is the period of the oscillation, T0.
- Observe the plant gain Kc that occurs at the critical oscillation frequency Fu. The inverse of this is the gain marginK
_{0}.

The given transfer function is:

G_{p} = 1/s(s+11.6+5.8i)(s+11.6-5.8i)

num=1;

den=conv([1 0],conv([1 11.6+5.8i],[1 11.6-5.8i]));

figure

rlocus(num,den) %frequency response of the system

T0=(2*pi)/13; % Measuring the period T0 at the stability limit

Kp0=3900; % Measuring the gain margin Kp0 for loop stability

Ti=0.5*T0; % Calculating the tuning parameters

Td=0.125*T0;

kp=0.6*Kp0;

ki=kp/Ti;

kd=kp*Td;

numgc=kp*[Td*Ti Ti 1]; %Numerator of PID transfer function

dengc=[Ti 0]; %denominator of PID transfer function

gc=tf(numgc,dengc); % PID controller’s transfer function

gp=tf(num,den);

gf=gc*gp;

t=gf/(1+gf); %Closed loop transfer function

figure

step(t)

Root Locus

Values Calculated

>> Kp0

Kp0 = 3900

>> Td

Td = 0.0604

>> T0

T0 = 0.4833

>> Ti

Ti = 0.2417

>> kp

kp = 2340

>> kd

kd = 141.3717

>> ki

ki = 9.6830e+003

Step Response

Block diagram

After Tuning:

The post Zeigler-Nichols Rule explained with example appeared first on .

]]>The post Generate PWM signal in MATLAB Simulink of desired frequency appeared first on .

]]>PWM stands for pulse width modulation. It is a periodic square wave which controls the power delivery. It has a variety of applications in electrical and electronics engineering. It is a special method of delivering controlled power to equipment without dissipating it in other devices. PWM waves are generated by quickly turning on & off the power switch such that device only feels its effect. There are few terminologies which must be learnt in order to understand PWM.

**Frequency: **It is the number of cycles per unit second. In terms if PWM, it is the amount of times switch opens and closes in one second. The frequency is set according the requirements.

**Duty Cycle: **Duty cycle shows the amount of time the signal is high or switch is on. Mathematically It is the ratio of the on time to the total period of one cycle.

Duty cycle is the proportion of time during which a component, device, or system is On or operating. Duty cycle can be expressed as a ratio or as a percentage. Consider a bulbs glows for 1 second and then it shuts for continuous 9 seconds. After that it again glows for 1 second and shuts again for 9 seconds and so on. So the bulb glows for 1 seconds out of 10 seconds or 1/10 of the time. The duty cycle is therefore 10%. Following figure shows the various duty cycles.

The effectiveness of PWM and it duty cycle can be seen from one of its most common application which is __speed of DC motor with PWM.__

MATLAB is one of the most widely used simulation & programming software used by Engineers of different fields. It has a rich library enabling the user to perform variety of simulations and analysis. However not every type of functions and blocks are available readily. For example there is no block in the MATLAB Simulink which can produce PWM waves. Therefore available building blocks must be used to generate PWM signal in MATLAB Simulink of desired frequency and Duty Cycle.

Following blocks are used to generate PWM signal n MATLAB Simulink.

**Repeating Sequence**: This block generates a sawtooth wave. The Frequency of the waveform can be adjusted in the parameter settings of the block.**Constant**: it gives a constant output number.**Relational operator.**It compares two values at its input and gives output according to its settings. It can perform greater, less, equal and many other such logical operations.**Data Type conversion:**This block usually converts one data type to another one. It makes different blocks compatible to each other. For example if one block works on Boolean data type while other on double, this block can be used to convert Boolean type output to double type and make it compatible with other block.**Multiplexer:**It combines different signals and overlap them on each other. Its output can be seen on the scope.**Scope:**This block displays the signal against the time.

The above described blocks works as follows. Sawtooth wave is generated. It is than compared with the constant by the comparator. If the value sawtooth is higher than constant, output is high else it is low. The output of this is a PWM wave however it may not be compatible with many other blocks. Therefore it is converted from Boolean to double data type to make it compatible with most of the blocks. In order to show the comparison, different signals are overlapped using mux and displayed on scope.

In order to vary the frequency, the parameters of repeating sequence block needs to be changed.

As shown in the above figure, first slot can be used adjust time period. The time slot specifies the time period. Difference between two values in time slot gives the time period. In given figure, first value is 0 and second value is 0.2 so time period is 0.2. The frequency can therefore be calculated as

f= 1/T = 1/0.2 = 5Hz.

In order to vary the duty cycle the value of constant needs to be varied. Its minimum value can be 0 and maximum value can be 1. If the value of 1 set, the duty cycle of PWM will be 0 or 0%. Conversely if the constant value is taken as 0, the duty cycle is 1 or 100%. The relation between the duty cycle and constant is inverse that is the higher the value of constant, the lower will be the duty cycle and vice versa.

Duty cycle = 1- constant value ( 0 <= Constant value <= 1)

For example if value of constant is 0.2

Duty cycle = 1 – 0.2 = 0.8 or 80%

The post Generate PWM signal in MATLAB Simulink of desired frequency appeared first on .

]]>The post Modeling of overvoltage relay in MATLAB Simulink appeared first on .

]]>It is a protective device used in electrical system which provides protection from over voltage condition. Power system can encounter over voltage condition which can be due to sudden drop of load, addition of power source and due to switching transients. If the voltage increases from certain limit, it can damage insulation and can lead to insulation puncture. Therefore it is necessary to monitor the voltage of system continuously. If high voltage is encountered in any part of power system, that faulty portion of network should be isolated. Over voltage relay continuously monitors the system voltage and if over voltage condition occurs, it sends tripping command to the breaker.

MATLAB is one of the most extensively used software by the engineers. It has a rich library enabling user to perform a number of tasks. However not every component is available in the MATLAB library among which overvoltage relay is also included. So Engineers use the available components in library of MATLAB is used to model the unavailable devices. The purpose of this article is to explain the process of modeling of over voltage relay in MATLAB Simulink using the readily available components. Please note that this presents the modeling in MATLAB simulink however actual construction of over voltage relay will be different. The overview of construction of overvoltage relay is presented in following article

Following blocks are used to model over voltage relay in MATLAB.

- De-multiplexer (Demux)
- Relational operator
- RS flip-flop
- Constant
- AND gate
- Data type conversion
- Transport delay
- Detect Change

Function of each block along with connection diagram is shown in the figure.

**DEMUX**: The three phase measurement block (labeled as Bus) is used to take three phase measurements collectively. In order to separate the phase currents and voltage, Demux is used. The position and number of inputs & outputs can be seen in the connection diagram.

**Relational operator: **This block play key role in modelling of overvoltage relay. It compares the current in the circuit (particular bus) with the predetermined relay settings. In the given case, if the quantity at input 1 is greater than quantity at its input 2, the output of this block will becomes high. So when the load current is less than relay setting, low output is achieved. When the fault occurs making the voltage high, the system voltage will exceed the relay setting, the relational operator gives high output.

**Constant (Settings): **A constant block which is named settings in our circuit is used to specify pre-determined settings of the relay. This block is connected to the input of the relational operator

**S-R Flip Flop and AND gate: **Flip flop has two inputs S set and R reset. Output Q reflects the input S when input R is low. It means what appears on S also appears on Q. The output !Q is inverts the input S. In this setup output !Q is used.

In normal condition when load current is less than relay settings, relation operator gives low output. So S input is low and output !Q is high. Since all inputs at AND gate are high, output of AND gate is also high (1). High input to breaker keeps it close ensuring continues operation. When the load current exceeds relay settings, high input S makes output !Q low, resulting in low output from AND gate.

**Data Type conversion (Double): ** The output of the AND gate is Boolean data type. Such data type is only readable by digital electronic devices. The output of AND gate needs to be given to the Circuit breaker which works with double data type values. So the output of AND gate is converted from Boolean to double by data type conversion block. This makes the AND gate compatible with Circuit breaker.

**Transport Delay: **In every practical scenario, it takes some time for the relay to sense the faulty condition and gives tripping signal to circuit breaker. To include that practical aspect, a transport delay bock is added which sends trips command to circuit breaker with 0.001 s delay.

**Re-closure of Circuit breaker (Transport delay + detect change + Data conversion): **During fault, the circuit breaker opens thus isolating faulty part of the power system from the rest of the system. However after the fault is cleared, the circuit breaker has to reclose in order to reinstate the detached part of system. For this purpose a reclosing signal needs to be given to the circuit breaker by the relay. To add this facility, transport delay + detect change + data conversion blocks are used. It gives the reset signal to the flip flop after every 5 sec when circuit breaker is tripped. Transport delay counts 5 sec. Detect change is such a block which gives high output whenever a change occurs in its initial state. The initial state of relay is high (1). When fault occurs, relay changes its output state to low (0) to give trip signal to breaker. Detect change block senses the alteration and reset the relay by giving reset signal to flip flop after every 10 sec.

Designed overvoltage relay in MATLAB Simulink is shown in the above figure.

After completing the modeling of overvoltage relay in MATLAB Simulink, a simple power system is modeled in Simulink. It consists of a 40MVA grid, whose power is transferred to 15 MW industrial and 20 MW domestic loads through 50Km transmission line. Transmission voltage is 33KV which is step down to 440V using transformers. A measurement block is added to show the voltages and currents of each bus. To test the modeled relay, fault is introduced at domestic load. Position of overvoltage relay and breaker are shown in the following figure. The details of power system are also shown. Over voltage fault is introduced by adding a voltage source at load end. In real condition, over voltage can occur due to several reasons including sudden drop of load, switching transients or any un-symmetrical faults.

Following figure shows the voltage at bus 4 without using the relay. It can be seen that at instant of 1.5 sec, over voltage fault is introduced in the system by adding a voltage source at load end and it is cleared at 2.5 sec. It can be seen that voltage level is increased to 900V which can be dangerous for electrical as well as home appliances.

The following figure shows the voltage and relay output signal when over voltage relay is installed.

Lower graph shows the bus 4 voltage. At 1.5 sec, over voltage fault is introduced as explained above and its value exceeds relay setting. Soon after the fault, the voltage becomes normal because the over voltage relay tripped the breaker isolating domestic load from system. Near 2.1 sec, some voltage spikes can be seen which is due to momentary closing of breaker by relay.

Upper graph shows the relay output signal and preset relay settings. During normal condition its output is one. But when voltage of system exceeds the preset voltage settings; its output signal becomes zero, tripping the breaker. At 2.1 sec, the relay sends reclosing signal to the breaker however the over voltage condition still exists, so the breaker is tripped again. At 2.5 sec the fault is cleared and breaker is reclosed at 2.55 sec shown by relay output signal.

NOTE: ignore the initial tripping signal it is due to high initial voltage. Such false tripping can be avoided in practical situations.

The post Modeling of overvoltage relay in MATLAB Simulink appeared first on .

]]>The post Find symmetrical components in MATLAB Simulink appeared first on .

]]>**Symmetrical components **are imaginary components which represents currents and voltages in the poly phase system. Unbalance three phase voltages and currents can be represented by balanced three phase components. The algebraic sum of these symmetrical components is always equal to the system voltage and currents. Three symmetrical components are

**Positive sequence:**It consists of a balanced three phase components with a sequence abc.**Negative Sequence:**It consists of a balanced three phase components with a sequence acb.**Zero Sequence**components consists of three single phase components all equal in magnitude but with same phase angles.

In component form, the calculation for symmetrical components is

In balanced condition, the power system can be analyzed using per phase approach. However in case of unbalanced fault, all the phases become unequal. Therefore usual per phase method is no more applicable for fault analysis. In such cases, the currents and voltages are divided into its balanced symmetrical components. Unbalanced faults are computed using these symmetrical components.

Unbalance fault relays like negative sequence relays, earth fault relays, positive sequence relays etc are based on the symmetrical components of the current.

Following blocks are used to find symmetrical components in MATLAB Simulink.

**Gain:**This block is used to multiply certain value or signal with a specific number or term.**Summation:**It adds or subtracts input. When there is only one input port, it add or subtract elements over all dimensions or one specified dimension**Complex to magnitude-Angle**: This block split up complex value or signal into magnitude and angle**From:**This block can receive signal from another block without physical connection. It is used to reduce the complexity of the diagram.**Display:**This block can display the value at its input.

Using from block, the value of current and voltage of the system is fed into the gain blocks. The gain blocks implements the equation 1, 2 and 3 by multiplying phase current (or voltage) with the respective operators according to the given equations. It must be noted that operators are entered in gain blocks in exponential form.

After multiplying each term, they are added using the summation block. Another gain block following the summation has value 1/3 which completes the implementation of equation 1, 2 and 3. The answer is immediately displayed in rectangular form using a display. Also for convenience, the components are split into its magnitude and angle and displayed in polar form as well.

To test the proposed system, simplest test bed is selected which consists of a three phase source and a load. Three phase measurement block is connected named as bus 1 to take current and voltage values from the system

For convenience all the phase voltages and their respective angles are displayed so that the calculation can be confirmed. An unbalanced fault is also introduced in the system to create unbalance phase condition. The value of currents after introducing unbalance fault is shown in the figure

In order to verify our modeling, result of the modeled block is also verified by manual calculation. Due to the introduction of unbalance fault, phase and current of system becomes unbalance and the symmetrical components are calculated by MATLAB Simulink block is shown below

To verify our results, symmetrical components are calculated manually using excel sheet. The manual calculation is shown in the following figure.

By comparing values it can be seen that the symmetrical components calculated by MATLAB Simulink is same as manual calculation. Comparison verifies our exercise to find symmetrical components in MATLAB Simulink.

The post Find symmetrical components in MATLAB Simulink appeared first on .

]]>The post Modeling of overcurrent relay in Simulink MATLAB appeared first on .

]]>It is an electrical protective device which senses the overcurrent condition and trips the circuit breaker if the current increase from certain preset value. In simple words it protects the electrical system by tripping the circuit breaker when the current exceeds certain value. There are basically three main types of over current relay.

**Instantaneous over current relay**: It gives the trip command to the circuit breaker instantaneously without any delay when the current exceeds certain limit.**Definite time over current relay:**This over current relay trip the circuit breaker after a preset delay when current exceeds preset limit.**Inverse time over current relay:**This relay sends trip command to the breaker after a time delay which is inversely proportional to the current magnitude. When the magnitude is very high the delay is less. When the magnitude of current is comparatively low, the time delay is more. So the delay in the trip signal has inverse relation with the magnitude of current.

MATLAB is one of the most extensively used software by the engineers. It has a rich library enabling user to perform a number of tasks. However not every equipment is given the MATLAB library. So the rich library of MATLAB is used to construct the unavailable devices. Overcurrent relay which is already described above is not available in MATLAB library. In this regard this article will explain the step by step process of constructing, testing and modeling of overcurrent relay in simulink MATLAB.

Blocks which are needed for modeling the overcurrent relay in simulink MATLAB are as follows

- De-multiplexer (Demux)
- Relational operator
- RS flip-flop
- Constant
- AND gate
- Data type conversion
- Transport delay
- Detect Change

Function of each block along with connection diagram is shown in the figure.

**DEMUX**: The three phase measurement block (labeled as Bus) gives current and voltage of three phases collectively. In order to separate the phase currents and voltage we use Demux. The position and number of inputs, output can be seen in the figure.

**Relational operator: **This block play key role in modelling of overcurrent relay in MATLAB simulink. It compares the current in the circuit (particular bus) with the predetermined relay settings. In the given case, if the quantity at input 1 which is current in bus 4 (load current) is greater than quantity at its input 2 which is preset settings, the output of this block will becomes high. So when the load current is less than relay setting, the output is low.

**Constant (Settings):** A constant block is named settings in our circuit. It is used to set pre-determined pick up value of the relay. This block is connected to relational operator which compares the current of circuit with preset settings.

**S-R Flip Flop and AND gate: **Flip flop has two inputs S set and R reset. Output Q gives reflects the input S when input R is low. It means what appears on S also appears on Q. The output !Q is inverts the input S. In this setup output !Q is used. In normal condition when load current is less than relay settings, relation operator gives low output. So S input is low and output !Q is high. Since all input at AND gate is high output of AND gate is also high (1). High input to breaker keeps it close and continues circuit operation. When the load current exceeds relay settings, high input (S) makes output (!Q) low. Consequently AND gate gives low output.

**Data Type conversion (Double): ** The output of the AND gate is Boolean data type. Such data type is only readable by digital electronic devices. Since the output of AND gate needs to be given to the Circuit breaker which works with double data type values. So the output of AND gate is converted from Boolean to double by data type conversion block. This makes the AND gate compatible with Circuit breaker.

**Transport Delay: **In every practical scenario it takes some time for the relay to sense the faulty condition and gives tripping signal to circuit breaker. To include this practical aspect, a transport delay bock is added which sends trips command to circuit breaker with 0.001 s delay.

**Re-closure of Circuit breaker (Transport delay + detect change + Data conversion): **During fault, the circuit breaker opens thus isolating faulty part of the power system from the rest of the system. However after the fault is cleared, the circuit breaker has to re-close in order to reinstate the detached part of system. For this purpose a re-closing signal needs to be given to the circuit breaker by the relay. To model this facility, transport delay + detect change + data conversion blocks are used. It gives the reset signal to the flip flop after every 5 sec when circuit breaker is tripped. Detect change is such a block which gives high output whenever a change occurs in its initial state. The initial state of relay is high (1). When fault occurs, relay changes its output state to low (0) to give trip signal to breaker. Detect change block senses the change and reset the relay by giving reset signal to flip flop after every 10 sec.

To validate the modeling of overcurrent relay in simulink MATLAB, a simple power system is modeled in Simulink. It consists of a 40MVA grid, whose power is transferred to 15 MW industrial and 20MW domestic load through 50Km transmission line. Transmission voltage is 33KV which is step down to 440V using transformers. A measurement block is added to show the voltages and currents of each bus. To test relay, fault is introduced at domestic load. Position of overcurrent relay and breaker is shown in the following figure. The details of power system are also shown. Three phase symmetrical Fault is introduced at 1.2 sec and cleared at 2.5 sec.

Following figure shows the voltage and current of bus 4 without using the relay. It can be seen that very high current flows through the system during fault while voltage is very low during fault.

The following figure shows the voltage and current of bus 4 when overcurrent relay in MATLAB Simulink is installed.

Upper graph shows the voltage. It can be seen that during fault, small voltage dip occurs as compared to condition when relay was not installed.

Middle graph shows the relay setting and current through bus 4. It can be observed that during normal condition, system current is less than relay settings. At 1.2 sec, fault occurs and system current exceeds relay settings. In 0.05 sec, the breaker is tripped and fault current is reduced.

So the given results our exercise of modeling of overcurrent relay in simulink MATLAB.

The post Modeling of overcurrent relay in Simulink MATLAB appeared first on .

]]>