Article Index

Electronics is a physical pursuit in the sense that you have to build circuits to test and use them. However there is a lot to be said for using simulation to try things out. Its much easier and you can check that you have correctly designed a circuit before going to the trouble of building it. The good news is that circuit simulation is a lot easier than you might imagine using open source software.

 

This is a chapter from our ebook on electronics as applied to the art of digital design or the IoT. 

The full contents can be seen below. Notice this is a first draft and a work in progress. 

Chapter List

  1. Resistance Is (Not) Futile
    Electronics is a complicated subject with lots of different types of electronic components. Electronics as it is applied to the IoT or digital electronics in general is in fact a much simpler subject. In particular you can master it with a knowledge of just a small number of devices - the resistor being the number one. In this chapter we look at the basic ways that electricity behaves and how resistors control it. 
     

  2. Meet The Sims - Simulating Circuits
    Electronics is a physical pursuit in the sense that you have to build circuits to test and use them. However there is a lot to be said for using simulation to try things out. Its much easier and you can check that you have correctly designed a circuit before going to the trouble of building it. The good news is that circuit simulation is a lot easier than you might imagine using open source software.
     

  3. Lowering The Voltage Coming Soon

  4. The Transistor BJT

  5. The FET

  6. Your Workshop - Basic Tools

  7. Driving Simple Loads

  8. Motors

  9. Inputs

  10. DAC

  11. ADC

  12. Logic

If you are new to electronics I encourage you to try using a simulator. At first it will help you understand what you are doing much better than actually building a circuit. You can modify things very easily and make lots of measurements in a single click - measurements that would take too long any other way. You can see the effects of your changes and learn so much more so much more quickly. Even when you move from the beginner stage you will still find that a simulator lets you test your circuits before you invest time in building them. 

There are so many advantages to learning to use a simulator that it is surprising that it isn't the standard way to learn electronics.

In the rest of the book a simulator will be used to explain and explore the circuits and behaviors that are under discussion so you do need a simulator and know how to use it.

The good news is that it isn't difficult and it doesn't cost anything.

The only big problem is selecting which simulation package to use. There are some well known commercial packages and if you are serious about electronic design then investing in one of these is a good idea. There are also free but not open source, my own favorite is LTSpice from Linear Technology. However these free simulators have their own problems in being linked to the commercial interests of companies selling you particular components. 

Installing Qucs

My own preferred open source solution is Qucs - it works well and has lots of models, simulations and it can be extended easily. Its biggest problem is that it lacks documentation and its not often intuitive. Its name stands fro Quite Universal Circuit Simulator which confirms the observation that open source project aren't very good at finding names for their creations. 

Qucs isn't the most polished simulator from the point of view of the UI but it is very capable and once you get used to its peculiarities you start to ignore them. 

Your first task is to download a binary for the OS you want to work with from the Qucs website. 

http://qucs.sourceforge.net/

There is a binary for Windows, OSX and Ubuntu (and other Linux OS). All you have to do is do expand the compressed file into a suitable directory - which directory doesn't matter. Then find gucs.exe in the bin directory and create a shortcut on the desktop or where ever you find convenient. 

When you start the program you will see a blank design area and a palette on the left hand side. 

The first thing to do is select the components tab to see a selection of common components:

 

You can select one of the components, a resistor say and each time you click on the design surface you can drop another resistor symbol. This way you can build up the components you need. 

The components are autonumbered, in the case of resistors R1, R2 and so on and have default properties - 50Ohms for resistors. 

You can change the properties by selecting the point tool and then right clicking on the symbol and select Edit Properties

 

 

In the case of most components you will only change the major property i.e. the resistance of a resistor and trust that everything else is set appropriately.   

The symbol you have placed on the surface might not be in the correct orientation. You can rotate or mirror it by selecting the arrow tool, clicking on the component and then selecting one of the mirror or rotation tools.:

 

You can also right click while you are placing the component into the diagram to rotate it. 

These tools are easy to understand but there is one small trick you need to know if you are to avoid a lot of frustration. When you first place a component on the surface it is grid aligned which makes it possible to wire up the circuit. If you rotate or mirror a component its wire ends might become un-aligned with the grid and this makes it impossible to wire them up. To align them to the grid use the Positioning, Set on Grid command - short cut Ctrl-U.

The final tool you need to know about is the wiring tool which you can use to connect components together. This is tricky at first but eventually you get used to it. Click on wire endpoints and move horizontally and vertically to route a wire to the next end point where the wire is terminated automatically when you click a second time. You can change the direction of the wire either by clicking on the surface to anchor it or by right clicking. 

The best way to learn it to simply try out what happens. 

Notice that the circuit that you create is naturally a schematic diagram rather than a picture of real components wired together. This is yet another good reason to learn to use and read schematics. 

Now it is time to create the first circuit we looked at in chapter 1.


A First Circuit Simulation

All we are going to do is create a circuit with a single resistor connected to a battery. 

Place a resistor on the surface. You will find the resistor in the "lumped components" section of the drop down components menu:

 

When you have place the resistor use the selection tool to select it and then the rotation tool to turn it 90 degrees so that it is vertical. After this use the Set to Grid command to make is possible to wire it up later.

Next we need to put a battery symbol in the circuit. This will be found in the sources section. Generally in electronics we refer to anything that can generate a voltage or a current as a source. In this case we want a simple dc Voltage source otherwise often known as a battery.

 After placing the battery symbol into the schematic we are ready to wire up

Use the wiring tool to connect the resistor to the battery/voltage source. This can be tricky at first but you quickly learn how to control what is happening. If you get it wrong the simplest thing to do is delete the wire, use the selection tool to select it and then press delete. 

The final circuit is:

 One of the odd things about using Qucs is that you have to put a block that indicates the simulation type you want to carry out into the diagram. In this case we want to do a DC Simulation so select Simulations from the drop down menu and put a dc simulation block on the diagram 

 

Now we can run a simulation. Use the command Simulation,Calculate DC bias or press F8. This works out the voltages at all points in the circuit and displays them on the schematic. Notice that you have to save the circuit before you can get the results.

 

Of course this isn't particularly useful because we know that we are working with 1V battery and this voltage is placed across the resistor. However things get more complex and more useful very quickly.

What we would like to know is what the current in R1 is. There is a very easy way to find the current, voltage and any other quantity of interest but a very direct way to find the current is to insert a simulated current or ammeter.

You can find this in the probes section of the components drop down. You need to change the wiring to insert the current meter into the wire connecting the battery to the resistor. Notice that is is obvious that to measure a current the current has to flow through the measuring device so you have to wire it in as shown. In practice this makes measuring a current in a real circuit a very tedious operation because you usually have to break into a wire or worse a track on a PCB. Voltages are much easier to measure in practice because you don't need to break into wires - see the next chapter. Of course in a simulation placing a current device is a matter of a few clicks.

 

If you rerun the DC bias calculation you will see that the current is -20mA. Why minus? Simply because the current meter measures current flow relative to the arrow shown in is symbol.  You can change the direction of the arrow by mirroring the symbol about the Y axis. 

To make this simulation do some useful work we can now change the battery voltage to 3V to check the calculation in the first chapter. Right click on the battery and change the voltage in the dialog box that appears:

 

With the voltage set to 3V you can now repeat the simulation - press F8 to see:

 

This agrees with the calculation in chapter 1 but which leaves us one last problem.

Why are the voltages shown as -3V rather than +3V? 

The answer is that you have to specify where the 0V point is in the circuit by placing an earth or ground symbol. Where ever you place ground is at zero volts and the other voltages are calculated relative to this. Where you take the zero when measuring voltages is more-or-les arbitrary.

With a ground symbol, you can find it in the toolbar, the voltages in the simulation work out correctly:

  


Simulating the LED Resistor

As an example of something slightly more useful we close this chapter with the simulation of the LED current limiting resistor as introduced in chapter 1. 

Start a new project and place a resistor (vertical) and a DC voltage source on the diagram. Right click on the DC source and set its voltage to 5V. Repeat for the resistor and set its value to 240 Ohms. 

 

Next we need an LED. You wont find this in the components tab because LEDs vary in their characteristics so they are put together with a range of real components in the Libraries tab:

 

Place red LED into the diagram (right click to make it vertical) and then wire it up as shown:

You also need to add a ground symbol and a DC Simulation block. Save the design and use the Calculate DC bias command or F8 key. 

The result is:

 

You can see that with a 240 Ohm resistor the LED's forward voltage is 1.97V which is higher than we assumed in the calculation.

Full Simulation

The real question is what is the current?

We could put a current probe into the circuit but there is an easier and more general way to find out. If you run a general simulation F2 rather than a DC bias calculation you will discover that you are taken to look at a new blank tab. This is where you can examine the full results of the simulation. 

 

 

The palette to the left is now showing a range of plots that you can create to illustrate the results. In our case the simulation is so simple and we don't have any time varying data so the only sensible thing to do is display the static values in a table. 

Place a table - corresponding to the icon Tabular - onto the page. A dialog box appears:

 

If you look at the Dataset box you will see that there is a single variable V1.I. In general you will find variables like name.I and name.V which correspond to the voltage and current in the named device. In this case we only have the current in V1 the battery. It is possible to add additional variables but more of this later. We only need V1.I because the current in the battery is the current in the resistor and in the LED - where else could the current go. You can select V1.I by double clicking on it when it will appear in the Graph box. Clicking ok places the table on the page:

From this you can see that the current is -0.0126A or 12mA which is a bit less than the 20mA we were aiming for. The discrepancy is entirely due to the different forward voltage used by the simulator. 

If you want to you can place a table of results on the same page as the schematic diagram so that you can see both at the same time. Simply drag and drop a table onto the same page and then customize it.

You can now play around with varying the load resistor, battery voltage and even LED type to see what happens. In the real world this would take a so much time that you are unlikely to actually do it.

This is the big advantage of using a simulator - you can learn so much in a very short time. 

Exercise

Simulate the two LED circuit given at the end of chapter 1 but don't change the 240 Ohm resistor in the one LED circuit above.

What is the current through the LEDs?

Will the LEDs be bright?

What is the current if you change to a 75 Ohm resistor?

Will the LEDs be bright?

Rollover For Answers

 

 

 

 

 

This is a chapter from our ebook on electronics as applied to the art of digital design or the IoT. 

The full contents can be seen below. Notice this is a first draft and a work in progress. 

Chapter List

  1. Resistance Is (Not) Futile
    Electronics is a complicated subject with lots of different types of electronic components. Electronics as it is applied to the IoT or digital electronics in general is in fact a much simpler subject. In particular you can master it with a knowledge of just a small number of devices - the resistor being the number one. In this chapter we look at the basic ways that electricity behaves and how resistors control it. 
     

  2. Meet The Sims - Simulating Circuits
    Electronics is a physical pursuit in the sense that you have to build circuits to test and use them. However there is a lot to be said for using simulation to try things out. Its much easier and you can check that you have correctly designed a circuit before going to the trouble of building it. The good news is that circuit simulation is a lot easier than you might imagine using open source software.
     

  3. Lowering The Voltage Coming Soon

  4. The Transistor BJT

  5. The FET

  6. Your Workshop - Basic Tools

  7. Driving Simple Loads

  8. Motors

  9. Inputs

  10. DAC

  11. ADC

  12. Logic

 

 

comments powered by Disqus