Electronic Circuit Simulation Tool

This tool simulates analog electronic circuits. An interactive schematic editor is included.
1.1K Downloads
Updated 28 Mar 2016

View License

CIRCUIT SIMULATION TOOL WITH SCHEMATIC EDITOR
This tool simulates analog electronic circuits. Schematic editor is interactive. Component library is still very small, but basic components are included. Component models for passive components and some semiconductors are included. Models are mostly algebraic ones. Semiconductor models are parametrized so they can be fit to any "real-world" component if one knows the appropriate parameters e.g. for Eber/Moll transistor equations.
This tools uses implicit differential equations to simulate electronic circuits. It might not be the most efficient and robust method, but it is very elegant. Equations are solved using ode15i. Consequently, all electronic components are modeled using implicit equations.

So it is very simple to model any kind of component in various ways. Capacitors, Inductors, Resistors can all be modeled with the same approach f(U,dU/dt,I,dI/dt)=0. Also, we can model real-world components using lookup-tables, then we'll have for example f=I-g(U) where g is the measured characteristic of a component. It is easy to make your own component models. Just look at the pre-defined ones and create a mat-file with the same structure. This tool just sets up all component equations together with conservation equations according to the circuit, and solves them with ode15i.

PRACTICAL USAGE
1. Place components, nodes and wires interactively. You can edit everything via context menus (right-click on any part of the schematic).
2. Calculate consistent initial conditions. For oscillators, it is usually important that initial conditions are not exactly symmetric. If you start in an equilibrium, even if it's unstable, you won't see oscillation. If the solver crashes right at the beginning, it is very likely that initial conditions are inconsistent.
3. After simulation completes, you can plot the results. You will get a plot of all node voltages and all currents except those flowing into the first terminal of a component. Usually you don't need to see them because they are redundant (can be expressed as negative sum of the other currents flowing into the component). Also, you can plot the voltages and currents of one particular component by right-clicking on it and chosing "plot results".

CONSIDER THE FOLLOWING CONVENTIONS
1. All component terminals must be connected.
2. A wire connects a component terminal and a node.
3. A wire can not connect component terminals to each other directly.
4. A wire can not connect nodes to each other.
5. node#1 always serves as ground reference. 6.
Don't build a circuit which has galvanically isolated parts.

LIMITATIONS
This is a tool for analog simulation. It is not really suitable for circuits showing transient behaviour. It might work (as the multivibrator example shows). But transient behaviour is just not a particular strength of this simulation method. All active components must be bandwidth-limited to avoid the solver to crash. Consequently, transistors need some damping. It can be as low as 1e-6 but if it's zero, you will see a lot of solver warnings.

COMPATIBILITY
This works with R2015b. It could be adapted for compatibility with any older Matlab version, however it makes more sense to update your Matlab.
Optimization Toolbox is recommended. If not present, we'll switch to fminsearch instead of lsqnonlin to calculate initial conditions. This might not produce good results.

Tillmann Stübler, 28-03-2016
tillmann.stuebler@mbtech-group.com

This is absolutely free software, use it for whatever you like to. If you make any further developments based on this code, please let me know of it.

Cite As

Tillmann Stübler (2024). Electronic Circuit Simulation Tool (https://www.mathworks.com/matlabcentral/fileexchange/56195-electronic-circuit-simulation-tool), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2015b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0