ngspice – Interactive Mode!

Welcome back for the 5th tutorial on SPICE in Fedora Electronic Lab. πŸ™‚ This time we’ll look at ngspice’s interactive mode. We’ll see what this means in some time. Before that, make sure that you have gone through the previous tutorials. These are all filed under the SPICE category (point your mouse to Tutorials, then click SPICE). We will reuse the example circuits we created in the previous tutorials for this one. I hope you’ve gone through those first. We’ll begin with two circuits to show how some simple analysis can be done just like in batch mode. Finally we’ll end with an example which shows a great aspect of the interactive simulations – tweaking circuits automatically.

Before we begin any circuit, delete the SPICE include symbol from the schematic and get the netlist again. We do not need the cmd files now. Alternatively you could just open the netlist and delete the .INCLUDE line. We will be looking at the Bridge Rectifier, the BJT Amplifier andΒ  the op-amp non-inverting amplifier. Now lets begin πŸ™‚

Read more of this post

Breaking it down – The .SUBCKT

Having done so many simulation examples, ever wondered how complex actual circuits can be? When you go on to design a circuit with some application it won’t be just one amplifier or one rectifier. It’ll have dozens of blocks. How do you fit all that in one schematic? Well you can’t – at least not without getting totally mixed up with where each block is. Thats where hierarchical design comes in. This means that you break down a system into blocks. Break these blocks down even further till you get the simplest ones – like a tree branching out and having leaves at the end. The advantage of this is that most of the time, these “leaves” will repeat across your circuit and with a hierarchical design, these circuits need to be defined just once and reused again.

I hope you have read my previous tutorial on symbol creation in gschem as well as other tutorials on SPICE. You can get these tutorials by pointing your mouse to the Tutorials menu at the top and then selecting SPICE. You need the symbol of the previous tutorial to go through this one. Click Here to go to the symbols creation tutorial.

We will first look at a few op-amp circuits. I will be using LM741 for the examples. You can get the model (and many others) from Texas Instruments. Next we’ll build a two-stage BJT amplifier using a single BJT amplifier as a building block. Just like last time, I will explain only what is new. So lets begin, with my favorite part of analog circuits – operational amplifiers πŸ™‚

Read more of this post

Creating Your Own Symbols in gschem

Before writing another tutorial on SPICE, I thought of spending some time on creating symbols. This will be necessary because we will be looking at op-amp circuits next. There are op-amps in the gschem library but there are incompatibilities between those and the model files which the manufacturers provide. While trying to figure out how to create symbols, I found an excellent 3 part tutorial on this. I will take you through the creation of an op-amp symbol in this tutorial but I still feel this video will do better than that. Take a look at these before reading on:

Read more of this post

Simulating Circuits – More Examples!

Hope you liked my previous tutorials on SPICE simulation in Fedora Electronic Lab. Well this post comes a little late because I had a lot of circuits in mind. So take a deep breadth and get ready for Part 3! πŸ™‚

I’m assuming that you’ve read through the previous two tutorials and that you are now comfortable with using gschem. After this tutorial, you must go through the ngspice manual atleast once. I’ll be moving a bit fast from now on because there is a lot to cover. If something is not clear, feel free to post a comment. I also assume that you’ve completed a course on analog electronic circuits. If you are currently in such a course, go through the circuits you are familiar with and come back later.

Remember to plan a directory structure before each example. Also, the models for the transistors are available from Fairchild Semiconductors and diodes from I’m not posting these here due to copyright restrictions.

A quick recap:

  1. You draw you circuits in gschem.
  2. Generate the netlist by running: gnetlist -g spice-sdb -o <> Β <input_schematic.sch>
  3. Always check the netlist once yourself. Also see which are the input and output nodes.
  4. Simulate the circuit using: ngspice -b -r <raw_file.raw> -o <log_file.log> <>
  5. Finally open the waveform viewer by running gwave <raw_file.raw> and dragging the output you want to see to the panel.

Ready? Go! Read more of this post

Simulating Circuits in the CLI

My previous tutorial on EDA in FEL showed you how to simulate circuits using gspiceui with the gnucap simulator. This time I’ll show you to do the same using the command line interface (CLI) with the ngspice simulator. I had a few doubts regarding the use of ngspice and got them cleared in FEL mailing lists. We’ll not look at gnucap for now because I have to learn to use it myself. Alright so lets begin! πŸ™‚

Prerequisites and References

These are the same as

Do go through that tutorial first if you haven’t already.

In addition to this, you need to be familiar with SPICE netlists. Check the ngspice manual. It has a well explained, detailed description with a few examples in the end. To get started quickly go through this tutorial

I got some help with ngspice at the FEL mailing list as well. You can sign up here Β

gschem > gnetlist > ngspice > gwave

Read more of this post

Circuit Simulation in GNU/Linux – Lets begin!

Welcome back! πŸ™‚

As promised, here is the first of my tutorials on EDA in GNU/Linux. In this post we will start with SPICE simulations. Please remember that I’m a total beginner to these tools as well so I could be wrong at places (post a comment and I’d be happy to correct) and that my examples will remain very simple.


For this tutorial you’ll need these tools installed.

  • gEDA gschem – A schematic capture program.
  • gnetlist – a program that converts your schematic to a netlist.
  • ngspice and gnucap – circuit simulators.
  • gspiceUI – A graphical circuit simulator.
  • gwave – a waveform viewer.

This tutorial assumes that you have taken up a course on basic electronic circuits. It would help if you know how to write a spice netlist but its not a necessity. Read more of this post

%d bloggers like this: