Saturday, May 14, 2022

Two port parameters

This post describes the calculation of two port parameters derived from the circuit's netlist. A Two-port network is a circuit that has two pairs of ports or terminals and the circuit is characterized by the currents and voltages at the ports by a 2 by 2 matrix. From a two port matrix the response of the network to signals applied to the ports to be calculated easily, without solving for all the internal voltages and currents in the network. For example filters, matching networks, transmission lines, and transistors are characterized by two port parameters.

The first circuit is an attenuator, which could be easily analyzed by hand with a pencil, paper and a calculator, but here I'm using python to step through the calculations. These same steps can be applied to larger, more complex circuits which would be difficult to analyze by hand. The Sympy and SciPy libraries can be used to obtain symbolic and numerical results, however as is shown below, when the circuit is large, symbolic results are not that useful nor do they provide much insight.

The procedure starts by first drawing a schematic of the circuit with a schematic capture program such as EasyEDA (links to the schematics are provided in the notebook, linked below) then the netlist is generated and exported as a text file. The netlist is used to generate modified nodal equations with the python program described here. The equations are solved for voltages and currents at the port terminals by using SymPy to generate the z-paramters. Z-parameters are also known as open-circuit impedance parameters as they are calculated under open circuit conditions. Once the z-parameters are obtained, these can be converted into other parameters, such as Y, H or S. 

The second circuit is a band pass filter. The filter is designed from a low pass prototype by using normalized values from a filter design handbook.  Z and s-parameters are calculated and the results are plotted using Matplotlib.


To view the notebook click here to open the notebook viewer.

The JupyterLab notebook is located on github, click here to following the link to the repository.


Saturday, May 7, 2022

Source free series circuit

In this post, the Python modules SymPy and SciPy are used to solve for currents and voltages in a series connected circuit with a resistor, inductor and capacitor. The characteristic differential equation for the circuit is derived and solutions are obtained with SymPy and SciPy. 

A source free series RLC circuit consists of a resistor, capacitor and inductor connected in series with some initial energy stored either in the inductor, capacitor or both. Since the circuit is a single loop, the current flowing around the loop is the same current in each component. Both parallel and series connected circuits are usually presented in electrical circuit analysis classes. The two textbooks I used while in college presented the parallel connected circuit in some detail then kind of glossed over the series connect circuit since it is the dual of the other. 

The schematic for the series connected circuit is shown below.

A Jupyter notebook with the python code was used to document the analysis. To view the notebook, click here to open the notebook nbviewer (nbviewer does not execute notebooks, it only renders the inputs and outputs).

The notebook source is located on github, click here to follow the link to the repository.