This JupyterLab notebook uses the SymPy, NumPy, SciPy and the Python programming language libraries to analyize an electrical circuit. A circuit analysis method called the Modified Nodal Analysis was used to derive the symbolic circuit equations and Python libraries were used to solve the equations. The purpose of this analysis is to demonstrate the capability of using the Python libraries in electrical engineering circuit analysis. A link to my Jupyter Notebook rendered as a web page is here.
Solving Electrical Engineering Problems with Python
This blog is a collection of posts describing electrical engineering problems solved with the aid of Python and the SciPy, SymPy, NumPy, Pandas and Matplotlib libraries. Jupyter notebooks for the problems are located on github and there are links provided in the blog posts. The blog posts are mainly a summary of the notebooks and some analysis results.
Monday, December 25, 2023
Sunday, November 26, 2023
Analysis of two amplifier RIAA phone preamp
This post analyizes the circuit for the RIAA preamp given in the Texas Instruments application note AN346, High-Performance Audio Applications of the LM833, shown in the app note as Figure 3. The schematic for the phono preamplifier was entered into LTSpice and the circuit net list was generated. A circuit analysis method called the Modified Nodal Analysis was used to derive the symbolic circuit equations and Python libraries were used to solve the equations. The preamplifier transfer function was used to calculate the Bode, impuse and step response plots. The Python results were compared to those from LTSpice. Deviation from the RIAA response curve was also examined. The sensitivity, Monte Carlo and worst case analysis for the preamplifier circuit was performed. The JupyterLab notebook show cases the use of Python in electrical engineering and circuit analysis. A link to my Jupyter Notebook rendered as a web page is here.
Thursday, February 2, 2023
Password Card
This blog post summarizes the results from my Jupyter notebook, which can be viewed here. The notebook is hosted on Github. You might be wondering what a password card has to do with electrical engineering and Python. The field of Electrical Engineering is very diverse and encompasses topics that range from the generation, transmission and conversion of electric power to topics such as electronics and computers, which cover the storage and transmission of information. The password card touches on the area of information theory.
The Jupyter notebook describes the use of a password card and the Python code that generates the password card. The password card is a grid of random letters, numbers and special characters that provides a convenient aid to generate and remember long and complex passwords. A basic description of the password card and instructions are provided along with the Python code used to generate the password card. A security analysis and an analysis of alternatives is provided.
A sample card is shown below:
Sunday, August 28, 2022
SciPy analog filter design
This blog post summarizes the results from my Jupyter notebook, which can be viewed here. The notebook is hosted on Github.
The Jupyter notebook examines the general use of filter functions in the SciPy library which can be used to design analog filters. Filters are one of the basic building blocks of signal processing. In general terms, filters used for signal processing can be divided into two groups, analog and digital filters. Analog filters, the topic of this notebook, are filters which can be described with linear differential equations and implemented in circuits which operate on continuously varying signals. A digital filter is a system that performs operations on a sampled, discrete-time signal with numerical operations.
The first part of this notebook uses SciPy functions to calculate analog filter polynomials based on the classical Butterworth, Chebyshev, Elliptic and Bessel filters. The last section of this notebook walks through a Butterworth filter design and Cauer synthesis of an LC ladder type filter.
Sunday, July 17, 2022
Overshot waterwheel hydroelectric power system analysis
In the notebook, I document my analysis of a small hydroelectric system built by Michael Loftis, a YouTuber, real estate and insurance broker, who had a dam and waterwheel built for his off-grid cabin. The cabin and hydro system are unique and look really interesting. The cabin is available for rent as an AirBnB and is located in Thornfield, Missouri. The cabin is now advertised as having some solar panels with a gas powered generator to supplement the solar.
Michael's hydroelectric project looked really interesting and I was curious about the technical details. In videos, which I watched first, he discusses the status of the system. I was disappointed to hear that his system wasn't working, because at first glance it looked very impressive. I decided to learn a little about small hydroelectric systems and document in the notebook what I've learned.
The photo above from shows the end of the flume and the waterwheel with a large amount of splash over. Also you can see the pulley system which when connected, steps up the rotations per minute to the generator. As described in video, the hydro system is not working as he had hoped.
My Jupyter notebook, can be viewed here. The notebook is hosted on Github.
Last update: 23 Dec 2023
Saturday, July 2, 2022
How to include math equations
To add math equations to your Blogger blog, you need to edit the HTML code of your Blogger post.
What seems to work is to copy this line, for example,
<img src="https://render.githubusercontent.com/render/math?math=A = \begin{bmatrix}G B\\C D\end{bmatrix}">
into the html view in the correct spot, and you get:
end of test.
So the above seemed to only work for this equation and failed when I tried other equations.
Now, I think a good work around is to use latex2png and insert an image of the equation you want.
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.