Thursday, September 26, 2013

Power Factor Measurement

Today, I would like to talk about Power Factor Measurement on Simulink.

When I had to face this problem I found a really interesting block on internet:

After some tests, I found the block ideal to measure power factor correction to displaced waves (not to distorted waves)

I did some modifications to it, but basicaly it works the same way as before. Now, I would like to explain the block:

Power Factor Measurement Block
Inside the block there are the following elements:
Inside Power Factor Measurement Block

The functionality of this block is the following:

The integrator block calculates an integration of '1' until voltage or current go to zero, then the value of the integration starts again (value of each signal). This is calculating the voltage phase offset and the current phase offset in each moment t.





Voltage phase offset and Current phase offset

The last period of the simulation will be the one the block considers. Now the constant of the phase of each signal is known, it is compared and multiplied by 2*pi*f to have the actual phase difference of the signals.

Since

The power factor is measured after cos block is applied to the actual phase difference calculated before.

After all that blocks the power factor for displaced waves is measured.

Finally, I would like to show an example:

Example: PF Measurement of displaced signals
If the output of the example is plotted the dispersion can be seen:

Example: V vs I (displaced waves)**

If we calculate the power factor theoretically:
Theoretical PF Measurement of displaced signals

It can be seen that both results match.



References:
Saurabh Kabdal
Gautam Buddha Technical University (GBTU), U.P, India

Notes:
**Notice that current wave has been multiplied in order to be compared with voltage in the plot

Licencia Creative Commons

Thursday, September 19, 2013

Create a Subsystem

A helpful way to understand a complex circuit is by creating different subsystems to have a general view. Here I would like to explain the steps to create this block in Simulink.

There are many ways to create a subsystem, but the easiest way I found is the following:

First of all, draw the circuit you like in a Simulink model as normally:

Circuit inside subsystem
After selecting all components, go to Diagram/Subsystem & Model Reference/Create subsystem from selection. The block created would be like the next one:
Subsytem created

Notice that the different pins have been created acorded with the signal type inside the block. And if now we double click the model, it can be seen that the input and output pins have been added.

Circuit inside subsytem


After that, we just need to rename the model and we can use it as a subsystem in a bigger circuit and repeat it as many times as it is needed.

Final circuit with subsytem
Hope this post was helpful!


Licencia Creative Commons

Wednesday, September 11, 2013

Hysteresis Comparator with Simscape Library

In this post, I would like to implement a simple hysteresis comparator. I use to simulate this type of circuits with PSPICE, since the drawing of the circiuit is easier than Simulink. However, if interaction with some logic signals is needed, it would be easier to create all the schematic with Simulink.

Note: In order to create this example, SimScape library is needed.

First of all, the schematic I am going to follow can be seen in the next figure:

Hysteresis Comparator general schematic
For this circuit, the equations to design the values we want are the following:

Vref = Vcc * (R4 / (R4 + R3)
Vu = Vref * (R1 + R2) / R2  Vupper threshold
Vl = (Vref * (R1 + R2) - Vcc * R1) / R2  Vlower threshold

Base on that, the first step is to chose the components depending on whatever we want. I wanted Vu = 2.33V and Vl= 2.95. Since Vcc = 5V then the R values calculated are the following:
After chose normalized values, I recalculate my constrains. Since they fits with what I need, I can continue with the example.
Final designed values

To simulate these theoretical values, the Simulink schematic is created:
Hysteresis comparator Simulink Schematic


After designing the circuit, the values of the components must be set. The input signal I chose to test the circuit was 'Pulse Voltage Source' block

Pulse voltage source configuration
Finally the output of the example is showed in the next figure:
Output signals

Zoom in at Vupper value

Zoom in at Vlower value
It can be seen that the output is the one expected.


Licencia Creative Commons

Wednesday, September 4, 2013

Simulink Signals Conversion

A problem I found when I just started with simulink was connecting the different signals. Finally, I did a summary with all the combinations and I want to share it.

Data type:

  • Simulink: S
  • Physical: PS
  • Electrical:
    • SimPowerSystems
    • SimScape
S to PS
Simulink-PS Converter





S to SimPowerSystems
Controlled Voltage Source





Same block with current.

S to SimScape
S to SimScape








PS to S
PS-Simulink Converter





PS to SimPowerSystems
PS to SimPowerSystems









PS to SimScape





SimPowerSystems to S
Voltage Measurement





Same block with current.


SimScape to PS
Voltage Sensor





Same block with current.


SimPowerSystems and SimScape signals can be converted to whatever it is required just combining these blocks.

Example:



Note: Using conversion blocks slows the simulation significantly.


Licencia Creative Commons