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”

Circuit VR: Sink Or Swim With Current Sources

If you got your start in electronics sometime after 1980 your first project might well have been to light up an LED. Microcontroller projects often light up an LED, too, and a blinking LED is something of the “hello world” program for embedded systems. If you tried lighting up your LED with a 9 V battery directly — not that you’d admit to it — you found it would light up. Once, anyway. The excess current blows up the LED which is why you need a current-limiting resistor. However, those current limiting resistors are really a poor excuse for a current source or sink. In many applications, you need a real current source and luckily, they aren’t hard to create.

As always with Circuit VR, we’ll be using LT Spice to examine the circuits. If you need a quick tutorial, start here and come back after that. If you use Linux, don’t be dismayed. I run LT Spice under WINE and it works great. You can find all the Spice files on GitHub.

Continue reading “Circuit VR: Sink Or Swim With Current Sources”

Open-source Circuit Simulation

For simple circuits, it’s easy enough to grab a breadboard and start putting it together. Breadboards make it easy to check your circuit for mistakes before soldering together a finished product. But if you have a more complicated circuit, or if you need to do response modeling or other math on your design before you start building, you’ll need circuit simulation software.

While it’s easy to get a trial version of something like OrCAD PSpice, this software doesn’t have all of the features available unless you’re willing to pony up some cash. Luckily, there’s a fully featured free and open source circuit simulation software called Qucs (Quite Universal Circuit Simulator), released under the GPL, that offers a decent alternative to other paid circuit simulators. Qucs runs its own software separate from SPICE since SPICE isn’t licensed for reuse.

Qucs has most of the components that you’ll need for professional-level circuit simulation as well as many different transistor models. For more details, the Qucs Wikipedia page lists all of the features available, as does the project’s FAQ page. If you’re new to the world of circuit simulation, we went over the basics of using SPICE in a recent Hack Chat.

Thanks to [Clovis] for the tip!

Circuit VR: Oscillating Bridges

Circuit VR is where we talk about a circuit and examine how it works in simulation with LT Spice. This time we are looking at a common low-frequency oscillator known as the Wien bridge oscillator.

What makes an oscillator oscillate? A circuit with amplification that gets the same amount of the output signal fed back into its input, in phase, will oscillate. This is the Barkhausen criterion. Here, we’re going to look into what makes an oscillator work in simulation, and gain some insight into what happens when there’s too much feedback and too little.

In particular, we’ll look at the Wien bridge oscillator, a very simple design that originated as a way to measure impedance back in 1891. Modern versions add some additional features, but let’s start with the most simple implementation and work our way up.

Continue reading “Circuit VR: Oscillating Bridges”

Circuit VR: The Dickson Charge Pump

There was a time when taking a low DC voltage — say a single battery — and converting it to a higher voltage was painful. Now, however, cheap and easy-to-use DC to DC converters are readily available. For some small tasks, though, these can seem like overkill. For example, consider a case where you need to supply a higher voltage for a MOSFET gate that doesn’t draw much current. Perhaps you need that higher voltage to trigger a microcontroller’s programming mode and nothing else. The current draw is minimal, and a full-blown DC to DC converter is overkill. For cases like that, it is tempting to use some voltage multiplication scheme. There are many, but for this post, I’m going to take you inside a Dickson charge pump. This is Circuit VR because not only are we going to discuss the circuit, we’ll look at an LT Spice simulation you can try yourself.

The Dickson is interesting because it doesn’t require any AC conversion or transformers. Instead, it uses diodes or other switching elements to transfer charge between capacitors in stages. Each stage will effectively increase the voltage by the supply voltage — in theory. Reality isn’t so kind, though, as we’ll see.

Continue reading “Circuit VR: The Dickson Charge Pump”

Friday Hack Chat: Simulating Analog

Simulation is a valuable tool for any hardware developer. Instead of building hardware for a long debugging session, you can emulate a microcontroller and blink your lights with some Javascript. Instead of working on a Bluetooth protocol for your fitness wearable, you can just whip up some Javascript and get it working that way. Once all your Javascript is in order, then you can finally move over to hardware. It saves development time, and it saves money.

But this is all digital. What do you do if you’re working on an analog system? Lucky for you, there’s a system built for analog and mixed-signal analysis, and it’s been around for decades. This week we’re talking all about PSpice, a simulator for analog analysis that will give you voltages and currents across every node in a schematic.

For this week’s Hack Chat, we’re going to be talking about PSpice with [Abha Jain] and [Alok Tripathi]. [Abha] has worked at Cadence for 19 years and has been part of the PSpice R&D team for the last decade. She’s an MTech in VLSI Design Tools and Technology and holds multiple EDA patents. [Alok] graduated in 1993 with a B. Tech in Electrical Engineering. He started working at the Department of Atomic Energy in 1993 as a power supply and control system designer for particle accelerators. Currently, he’s working with Cadence and is the Product Engineering Architect for PSpice and OrCAD.

For this Hack Chat, we’re going to be discussing the challenges of system-level simulation, improving reliability, yield, and productivity of circuit design, the issues of Spice simulation, and answer the question, ‘on an infinite grid of one Ohm resistors, what is the resistance between two nodes a knight’s move apart?’ You are, of course, encouraged to add your own questions to the Hack Chat. You can do that by leaving the questions as a comment on this Hack Chat’s event page.

join-hack-chat

Our Hack Chats are live community events on the Hackaday.io Hack Chat group messaging. This week it’s going down at an unusual time: 8 AM Pacific, Friday, March 30th  Want to know what time this is happening in your neck of the woods? Have a countdown timer!

Click that speech bubble to the right, and you’ll be taken directly to the Hack Chat group on Hackaday.io.

You don’t have to wait until Friday; join whenever you want and you can see what the community is talking about.