Saturday, December 19, 2015

Diode state determination

Diodes and switches are high value resistances when off and low value resistances when on. The way of detecting when the turn on is to measure the voltage across them at every simulation cycle and change their status when the forward voltage exceeds 1 Volt. For a device in off state this might mean a current of 0.5 microAmps.

When running the simulation of a three-phase inverter, I found that the diodes were trying to turn on at every simulation instant even though the switch across them was conduction. On the contrary, the diodes that were across switches that were on and conducting was significantly higher and therefore were turning on.

To describe this look at this switch/diode combination when the switch is on.



The switch is a part of a loop with a current i1. The diode is off and forms a loop with the switch. By mere observation, it is clear that because of its association with i1, i2 will be large enough for the diode to turn on. There is absolutely nothing wrong with the loop, but the result is blatantly wrong.

This leads me to think about why do I need to use loop analysis to determine the current though stiff elements? The loop i2 could be written in several different ways. If it is written with respect to the dc bus voltage, it would result in a reverse current that would keep the diode off.

The same goes for any stiff element. By making an element stiff, it ensures that it will not disrupt the currents in the circuit. So the effect of the diode can be removed by making it a high resistance. But if the current through the diode matters and in this case it does, loop analysis is not an accurate way to determine the current through the diode.

Since nodal analysis is available and is being used to determine freewheeling, why not use it to determine the current through all stiff elements after the loop analysis ODE is solved.

Here is the code:


Excessive loops

I started working on the case of a three-phase inverter feeding an inductor-capacitor filter with the objective for designing a controller to regulate the voltage across the capacitor. In a nutshell simulate a UPS.

I ran into a number of problems which will be separate posts. I am still not sure if these problems have been completely solved.

The first problem. On simulating in open loop i.e giving balanced sine wave modulating signals I expected smooth balanced current and voltage waveforms. Instead all were badly distorted. The reason was that the circuit has 48 branches and 32 nodes but the number of loops calculated was 20. This isn't so bad because the loop finder works in random ways and could end up with extra loops. The assumption was that these extra loops would be linear combinations of the other loops and would be eliminated by loop manipulations. However, on looking at the system matrices in the differential equations I found 18 loops. So one loop was extra and solving this loop messed up the simulation.

So why did this loop linger? The loop manipulations are done only for stiff loops. This is to restrict stiff branches to the minimum number of loops. But if there are excess loops that are nonstiff to begin with, they may never be eliminated. So, to make sure that the loops are exact, on forming the system loops for the first time, row operations are performed to convert them to an upper triangular form. This will ensure that loops that are linear combinations are eliminated at the beginning of the simulation.

Here's the code:


Wednesday, December 9, 2015

Releasing version 1.0.1

I am releasing version 1.0.1 following a bug I discovered when I tried to simulate four-wire systems with a neutral wire. The problem lies with the solver and the sequence in which it solves equations. The solution has been to ensure that differential equations get solved before static equations rather than vice versa.

http://www.pythonpowerelectronics.com/downloads.html

 

Friday, December 4, 2015

Three phase grid connected inverter

I posted the next case study - a three phase inverter connected to a three phase grid in current control mode. Check out:

http://www.pythonpowerelectronics.com/blog.html

I have not included the complete control code and will not do so from now on as even though I am releasing Python Power Electronics open source, the control code may be protected legally by someone else. If you would like to write your own control code, check out the tutorials in the documentation section of the website.

Thursday, December 3, 2015

PPE Website

I haven't posted for the past week because I have been launching the Python Power Electronics Website. Check it out:

http://www.pythonpowerelectronics.com/

It probably will keep changing for a while until I finalize it. Suggestions are of course very welcome and can be sent to pythonpowerelectronics@gmail.com.

I'll continue this blog but the case studies that I was posting will be posted on the website. This will be more of an informal discussion from now onwards.

Tuesday, November 24, 2015

PLL with notch filter

The previous post was of a PLL that works when the voltages are balanced. When the voltages are unbalanced, it doesn't work as well. This is because the negative sequence component in the voltage appears as a double frequency (120 Hz) component in the "d" and "q" components of the transformed voltages is hard to suppress. The PI controller can remove higher frequency harmonics and noise present but the 120 Hz component generally gets through.

To describe this concept through simulations, I'll make the "b" phase component of voltage to be zero.



The green line is the "b" phase voltage. This is a fairly extreme case of unbalance and so this is chosen as a benchmark to design a notch filter. The PLL output without a notch filter is:



The above figure shows the double frequency creeping into all control signals and in the above case the angular frequency. Additionally, the double frequency can also be seen in then "d" and "q" components of the transformed voltage as below.





Now that the problem has been described, the notch filter has been inserted before the PI controller. Instead of feeding the "q" component of the transformed voltage to the PI controller, it is passed through a notch filter that removes the 120 Hz component and the filtered voltage is fed to the controller.

The voltage "vq" is the same as above, but the output of the notch filter is:



The 120 Hz component has been attenuated significantly. The output of the PLL is now:



With this done, the next step is to simulate a grid connected inverter feeding a controlled current into the grid.

Questions or comments about this? Email to pythonpowerelectronics@gmail.com 

Monday, November 23, 2015

Phase locked loop

In order to move on to simulating a grid connected inverter, the next step is to implement a Phase Locked Loop (PLL). The method used is the synchronous transfer frame reference alignment. In more detail, starting with a frequency that could be close to what could be the normal frequency, using a Proportional Integral (PI) controller, we adjust the frequency until the signal being locked on to is aligned with the reference frame. So with the frequency being adjusted, calculate the d and q axis components in the rotating reference frame, and adjust the frequency until the q component is zero.

The circuit is pretty simple:




There is an unbalanced three phase resistor bank connected across a three-phase voltage source. Well it doesn't really matter, because we just want the voltage source. The parameters of the circuit are:





Run-time parameters:

-------------------------------------------------------------------------------------------------------------------------
>>>
CSV file containing the network layout --> grid_pll

Enter parameters in file grid_pll_params.csv. When done, close the file and press y and enter to continue -> y

**************************************************
Voltmeter is  Vb  located at  22O  with positive polarity towards 21O
Voltmeter is  Va  located at  22L  with positive polarity towards 21L
Voltage Source is  Vcn of 120.000000 V(peak), 60.000000 Hz(frequency), -240.000000 (degrees phase shift) and 0.000000 dc offset  located at  16D  with positive polarity towards 16E
Resistor is  Rc = 0.100000  located at  16G
Resistor is  Rbc = 1000000.000000  located at  11I
Resistor is  Rb = 0.100000  located at  8G
Voltage Source is  Vbn of 120.000000 V(peak), 60.000000 Hz(frequency), -120.000000 (degrees phase shift) and 0.000000 dc offset  located at  8D  with positive polarity towards 8E
Voltmeter is  Vc  located at  19S  with positive polarity towards 18S
Voltage Source is  Van of 120.000000 V(peak), 60.000000 Hz(frequency), 0.000000 (degrees phase shift) and 0.000000 dc offset  located at  1D  with positive polarity towards 1E
Resistor is  Ra = 0.100000  located at  1G
Resistor is  Rab = 1000000.000000  located at  4I
**************************************************

Enter the control files. Omit the .py extension and just leave spaces between files --> pll_3ph
Enter control parameters in the following files -->
pll_3ph_desc.csv
When ready press y and enter to continue -> y
Enter control code in the following files -->
pll_3ph.py
When ready press y and enter to continue -> y

**************************************************
Meters are in the following sequence: ['19S', '22L', '22O']
Control variables to be plotted are in the following sequence
['control_signal1', 'control_signal3', 'control_signal2', 'control_signal4']
**************************************************
Simulation time step in seconds (recommended <= 10.0e-6) --> 10.0e-6
Duration of simulation in seconds --> 1.0
Data storage time step in seconds ( >= 0.000010) --> 10.0e-6
Output data file name (.dat extension will be added) --> ckt_out


Data stored in ckt_out.dat. Check output log file output_log.txt for description of output
35.8410000801
-------------------------------------------------------------------------------------------------------------------------


In this case, there is a control file called pll_3ph even though there is no controllable element. VoltageSource, Resistor and Voltmeter are the only components in the circuit. In this case, the control file does not perform any control but is merely a signal processing code that generated control_signal1, control_signal2, control_signal3, control_signal4.

I will skip the details of the control and move on to the results. The control_signals 1,2,3,4 generated by the control code are
control_signal1 --> volt_d i.e d component of the voltage in the rotating reference frame
control_signal2 --> volt_q i.e d component of the voltage in the rotating reference frame
control_signal3 --> omega i.e angular frequency of rotating reference frame and the system
control_signal4 --> phase_angle of the sinusoidal signals


So first and foremost, frequency:



 In steady state tracks 377 rad/s which is 2*pi*60.
Next, volt_q:


As stated above in the principle of operation of the PLL, in steady state the q component of voltage in the rotating reference frame will be zero. This is when the rotating frame is at the same frequency as that of the source.

Next, volt_d:



 The d component of the voltage settles to 147V. This is the Root Mean Square (RMS) value of the Line to Line (L-L) voltage of the system. There are several forms of transformations that use several multiplying factors that could case d component to have all kinds of values - peak of Line to Line, peak of phase etc.

The last is the phase angle. This needs to be plotted with the a component of the voltage to give you an idea of the alignment.




 The way the component VoltageSource generates voltage is as a sine template with respect to time. As seen above, the phase angle starts at 0 from the peak of what is the "a" phase voltage. This is because the PLL uses cosine and sine templates of the phase angle to align the rotating reference frame. The cosine of the above phase angle will therefore turn out to be a cosine function corresponding to the sine waveform of the voltage.

The next step is including a notch filter to make sure the PLL works even when the grid is unbalanced. After which I can simulate a grid connected inverter.

 Questions or comments? Send an email to pythonpowerelectronics@gmail.com.