Circuit Simulation In Python

Using SPICE to simulate an electrical circuit is a common enough practice in engineering that “SPICEing a circuit” is a perfectly valid phrase in the lexicon. SPICE as a software tool has been around since the 70s, and its open source nature means there are more SPICE tools around now to count. It also means it is straightforward enough to use with other software as well, like integrating LTspice with Python for some interesting signal processing circuit simulation.

[Michael]’s latest project involves simulating filters in LTspice (a SPICE derivative) and then using Python/NumPy to both provide the input signal for the filter and process the output data from it. Basically, it allows you to “plug in” a graphical analog circuit of any design into a Python script and manipulate it easily, in any way needed. SPICE programs aren’t without their clumsiness, and being able to write your own tools for manipulating circuits is a powerful tool.

This project is definitely worth a look if you have any interest in signal processing (digital or analog) or even if you have never heard of SPICE before and want an easier way of simulating a circuit before prototyping one on a breadboard.

Endless Electronic Problems For Solving

We know not everyone who likes to build circuitry wants to dive headfirst into the underlying electrical engineering that makes everything work. However, if you want to, now is a great time. Many universities have most or all of their material online and you can even take many courses for free. If you want an endless pool of solved study problems, check out autoCircuits. It can create many different kinds of electronics problems and their solutions.

You can get a totally random circuit, or choose if you want to focus on DC, AC, two-ports, or several other types of problems. You can also alter the general form of the problem. For example, for a DC analysis, you can have it assign circuit values so that the answer is a value such as 45 ohms, or you can have it just use symbols so that the answer might be i4=V1/4R. You even get to pick the difficulty level and pick certain types of problems to avoid. Just be fast. After the site generates a problem, you have 10 seconds to download it before it is gone forever.

Continue reading “Endless Electronic Problems For Solving”

Spice With A Sound Card

In years gone by, trying out a new circuit probably would have meant heating up a soldering iron. Solderless breadboards have made that even easier and computer simulation is easier still, but there’s something not quite as satisfying about building a circuit virtually. [Thedeuluiz] has a way to get some of the best of both worlds with the RTSpice project.

The idea is simple in concept, although not as simple in execution. The program does a Spice-like simulation of a circuit and can accept input and produce output from a PC’s sound card. Obviously, that means you can’t simulate RF circuits — at least not at the input and the output. It also means the simulation has to run lightning fast to keep up with the sound card sample rate. According to the author, it works best with modest circuits but exactly how big you can go will depend on your hardware.

Continue reading “Spice With A Sound Card”

Visualizing How Signals Travel In A PCB

If you play with high speed design for long enough, eventually you’re going to run into clock skew and other weird effects. [Robert Feranec] recently ran into this problem and found an interesting solution to visualizing electric fields in a PCB.

A word of warning before we dig into this, for most of the projects we see on Hackaday something like this is completely superfluous. There aren’t many people dealing with high speed interfaces here, and there aren’t many people dealing with 100 Gigabit per second data links, period. That said, it’s not unheard of, and at the very least it’s interesting to look at.

The basics of this video is simulating the signals visually in a differential pair on a (virtual) printed circuit board. The software for this is Simbeor, and [Robert] talked to the founder of the company behind this software after watching a video on simulating electric fields in differential traces. This software does what it says, and is a great illustration of why differential pairs must have the same length.

While this might not be for everyone, it is a fantastic visualization of signals in high-speed design that goes above and beyond what you would expect from a Spice simulation. Even if you’re not doing high-speed design, you may someday and it’s never too soon to get an intuitive understanding of how electrons work.

Continue reading “Visualizing How Signals Travel In A PCB”

Simulating A Speaker

Speakers are one of those components that are simple to use, but difficult to simulate. Most of us have used a simple resistor to do the job. But a speaker’s response is much more complex, and while that might be enough for a simple simulation the fidelity is nowhere near close. [Sourav Gupta] recently shared his technique for modeling speakers and it looks as though it does a credible job.

[Sourav] shows how a simple resistor and an inductor can do the job, but for better fidelity you need more components to model some mechanical effects. The final model has six components which keeps it easy enough to construct but the problem lies in finding the values of those six components. [Sourav] shows how to use the Thiele-Small parameters to solve that problem. Speaker makers provide these as a guide to low frequency performance, and they capture things such as Q, mass, displacement, and other factors that affect the model.

Continue reading “Simulating A Speaker”

Simulate PIC And Arduino/AVR Designs With No Cloud

I’ve always appreciated simulation tools. Sure, there’s no substitute for actually building a circuit but it sure is handy if you can fix a lot of easy problems before you start soldering and making PCBs. I’ve done quite a few posts on LTSpice and I’m also a big fan of the Falstad simulator in the browser. However, both of those don’t do a lot for you if a microcontroller is a major part of your design. I recently found an open source project called Simulide that has a few issues but does a credible job of mixed simulation. It allows you to simulate analog circuits, LCDs, stepper and servo motors and can include programmable PIC or AVR (including Arduino) processors in your simulation.

The software is available for Windows or Linux and the AVR/Arduino emulation is built in. For the PIC on Linux, you need an external software simulator that you can easily install. This is provided with the Windows version. You can see one of several videos available about an older release of the tool below. There is also a window that can compile your Arduino code and even debug it, although that almost always crashed for me after a few minutes of working. As you can see in the image above, though, it is capable of running some pretty serious Arduino code as long as you aren’t debugging.

Continue reading “Simulate PIC And Arduino/AVR Designs With No Cloud”

Circuit VR: Simple Buck Converters

The first thing I ever built without a kit was a 5 V regulated power supply using the old LM309K. That’s a classic linear regulator like a 7805. While they are simple, they waste a lot of energy as heat, especially if the input voltage goes higher. While there are still applications where linear regulators make sense, they are increasingly being replaced by switching power supplies that are much more efficient. How do switchers work? Well, you buy a switching power supply IC, add an inductor and you are done. Class dismissed. Oh wait… while that might be the best way to do it from a cost perspective, you don’t really learn a lot that way.

In this installment of Circuit VR, we’ll look at a simple buck converter — that is a switching regulator that takes a higher voltage and produces a lower voltage. The first one won’t actually regulate, mind you, but we’ll add that in a future installment. As usual for Circuit VR, we’ll be simulating the designs using LT Spice.

Interestingly, LT Spice is made to design power supplies so it has a lot of Linear Technology parts in its library just for that purpose. However, we aren’t going to use anything more sophisticated than an op amp. For the first pass, we won’t even be using those.

Continue reading “Circuit VR: Simple Buck Converters”