103
Electronic Circuit Simulation using eSim Kavya Manohar August 7, 2016

Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

  • Upload
    vudat

  • View
    257

  • Download
    3

Embed Size (px)

Citation preview

Page 1: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

Electronic Circuit Simulation using eSim

Kavya Manohar

August 7, 2016

Page 2: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

2

Page 3: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

Copyright ©2015

This work is licensed under a Creative Commons Attribution-Share Alike 4.0India License. See http://creativecommons.org/licenses/by-sa/4.0/ formore details.

3

Page 4: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

4

Page 5: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

Acknowledgemnt

Thanks to eSim by FOSSEE team. eSim wraps up the open source electronicdesign automation software Kicad and ngspice into a single package.

Thanks to every collegue at Aryanet Institute of Technology, Palakkad fortheir support in this venture.

Thanks in advance to every reader finding this work useful. Your feed backis most welcome.

Kavya Manohar

5

Page 6: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

6

Page 7: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

Preface

This is a quick guide to design and simulate electronic circuits using open sourceEDA tool- eSim.

eSim is an open source EDA tool for circuit design, simulation, analysisand PCB design, developed by FOSSEE team (http://fossee.in/) underMHRD based at IIT Bombay. It is an integrated tool built using open sourcesoftwares Kicad and (http://www.kicad-pcd.org) Ngspice (http://ngspice.sourcefouge.net/). It is released under GNU GPL License. It runs on UbuntuLinux, Windows.

This guide provides solutions to specific simulation problems using eSim. Ex-perimental procedures are explained with screen shots. This has been preparedas a part of lab migration project supported by FOSSEE aimed at migratingthe labs in educational institutions to free and open source softwares. Thesource code of every experiment described in this guide will be released byFOSSEE under Creative Commons Attribution-ShareAlike 4.0 International Li-cense. You may use eSim manual (http://esim.fossee.in/resource/book/esimusermanual.pdf) for further reference.

Kavya Manohar

Page 8: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

8

Page 9: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

Contents

1 INTRODUCTION TO eSim 13

2 DIODE CHARACTERISTICS 15

3 RC FILTERS 25

4 CLIPPING CIRCUIT 33

5 CLAMPING CIRCUIT 41

6 HALF WAVE RECTIFIERS 47

7 FULL WAVE RECTIFIERS 55

8 JFET CHARACTERISTICS 63

9 MOSFET CHARACTERISTICS 71

10 BJT COMMON EMITTER CHARACTERISTICS 79

11 BJT COMMON BASE CHARACTERISTICS 85

12 ZENER REGULATOR WITH SERIES PASS TRANSISTOR 91

Page 10: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

10 CONTENTS

Page 11: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

List of Figures

2.1 Schematic diagram for diode characteristics . . . . . . . . . . . . 162.2 Launching eSim will take you to this window . . . . . . . . . . . 162.3 Creating new project . . . . . . . . . . . . . . . . . . . . . . . . . 172.4 Creating new schematic diagram . . . . . . . . . . . . . . . . . . 172.5 The Kicad Eeschema page . . . . . . . . . . . . . . . . . . . . . . 182.6 Place component icon . . . . . . . . . . . . . . . . . . . . . . . . 182.7 Place wire icon . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182.8 The Kicad Libraries of components . . . . . . . . . . . . . . . . . 192.9 Editing the value field of component R . . . . . . . . . . . . . . . 192.10 Choose annotate from the toop tool bar . . . . . . . . . . . . . . 202.11 Annotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212.12 Netlist Generation . . . . . . . . . . . . . . . . . . . . . . . . . . 212.13 Choose Kicad to Ngspice tool . . . . . . . . . . . . . . . . . . . . 212.14 Choose DC analysis type and enter the values . . . . . . . . . . . 212.15 Choose the required diode model . . . . . . . . . . . . . . . . . . 222.16 The characteristics of Diode . . . . . . . . . . . . . . . . . . . . . 23

3.1 Schematic diagram for passive RC high pass filter . . . . . . . . . 253.2 Schematic diagram for passive RC low pass filter . . . . . . . . . 263.3 Editing the value field of component R . . . . . . . . . . . . . . . 273.4 Choose annotate from the toop tool bar . . . . . . . . . . . . . . 283.5 Annotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293.6 Netlist Generation . . . . . . . . . . . . . . . . . . . . . . . . . . 293.7 Choose Kicad to Ngspice tool . . . . . . . . . . . . . . . . . . . . 293.8 Choose AC analysis type and enter the values . . . . . . . . . . . 303.9 The frequency response of RC highpass filter . . . . . . . . . . . 313.10 The frequency response of RC low pass filter . . . . . . . . . . . 31

4.1 Schematic diagram for series clipper circuit . . . . . . . . . . . . 344.2 Schematic diagram for shunt clipper circuit . . . . . . . . . . . . 354.3 Annotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364.4 Netlist Generation . . . . . . . . . . . . . . . . . . . . . . . . . . 364.5 Choose analysis type as ‘transient’ and enter the values . . . . . 364.6 Enter the parameters of ‘Sine’ source . . . . . . . . . . . . . . . . 37

11

Page 12: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

12 LIST OF FIGURES

4.7 The transient response of the series clipper on python plottingwindow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

4.8 The transient response of the series clipper in ngspice plottingwindow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

4.9 The transient response of the shunt clipper on python plottingwindow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

5.1 Schematic diagram for clamper circuit . . . . . . . . . . . . . . . 425.2 Annotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435.3 Netlist Generation . . . . . . . . . . . . . . . . . . . . . . . . . . 435.4 Choose analysis type as ‘transient’ and enter the values . . . . . 445.5 Enter the parameters of ‘Sine’ source . . . . . . . . . . . . . . . . 445.6 The transient response of the clamper on python plotting window 45

6.1 Schematic diagram for half wave rectifier with C filter . . . . . . 486.2 Schematic diagram for half wave rectifier with LC filter . . . . . 496.3 Annotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 506.4 Netlist Generation . . . . . . . . . . . . . . . . . . . . . . . . . . 506.5 Choose analysis type as ‘transient’ and enter the values . . . . . 506.6 Enter the parameters of ‘Sine’ source . . . . . . . . . . . . . . . . 516.7 The transient response of the half wave rectifier with capacitor

filter on python plotting window . . . . . . . . . . . . . . . . . . 526.8 The transient response of the half wave rectifier with inductor

and capacitor filter on python plotting window . . . . . . . . . . 53

7.1 Schematic diagram for bridge rectifier with C filter . . . . . . . . 557.2 Schematic diagram for bridge rectifier with LC filter . . . . . . . 567.3 Annotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587.4 Netlist Generation . . . . . . . . . . . . . . . . . . . . . . . . . . 587.5 Choose analysis type as ‘transient’ and enter the values . . . . . 587.6 Enter the parameters of ‘Sine’ source . . . . . . . . . . . . . . . . 597.7 The transient response of the bridge rectifier with capacitor filter

on python plotting window . . . . . . . . . . . . . . . . . . . . . 607.8 The transient response of the bridge rectifier with inductor and

capacitor filter on python plotting window . . . . . . . . . . . . . 61

8.1 Schematic diagram for JFET characteristics . . . . . . . . . . . . 648.2 Annotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 658.3 Netlist Generation . . . . . . . . . . . . . . . . . . . . . . . . . . 658.4 Choose Kicad to Ngspice tool . . . . . . . . . . . . . . . . . . . . 668.5 Choose DC analysis type and enter the values of V2 . . . . . . . 668.6 Choose DC analysis type and enter the values of V1 . . . . . . . 678.7 Enter the details of fixed source V1 . . . . . . . . . . . . . . . . . 678.8 Enter the details of fixed source V2 . . . . . . . . . . . . . . . . . 688.9 Choose the required JFET model . . . . . . . . . . . . . . . . . . 688.10 The drain characteristics of JFET with gate voltage =0V . . . . 69

Page 13: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

LIST OF FIGURES 13

8.11 The drain characteristics of JFET with gate voltage =1V . . . . 698.12 The transfer characteristics of JFET with drain voltage =3V . . 70

9.1 Schematic diagram for MOSFET characteristics . . . . . . . . . . 729.2 Annotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 739.3 Netlist Generation . . . . . . . . . . . . . . . . . . . . . . . . . . 739.4 Choose Kicad to Ngspice tool . . . . . . . . . . . . . . . . . . . . 749.5 Choose DC analysis type and enter the values of V2 . . . . . . . 749.6 Choose DC analysis type and enter the values of V1 . . . . . . . 759.7 Enter the details of fixed source V1 . . . . . . . . . . . . . . . . . 759.8 Enter the details of fixed source V2 . . . . . . . . . . . . . . . . . 769.9 Choose the required MOSFET model . . . . . . . . . . . . . . . . 769.10 The drain characteristics of MOSFET with gate voltage =3V . . 779.11 The transfer characteristics of MOSFET with drain voltage =10V 78

10.1 Schematic diagram for CE output characteristics . . . . . . . . . 8110.2 Annotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8210.3 Netlist Generation . . . . . . . . . . . . . . . . . . . . . . . . . . 8210.4 Choose Kicad to Ngspice tool . . . . . . . . . . . . . . . . . . . . 8210.5 Choose DC analysis type and enter the values of V1 and I1 . . . 8310.6 GiveSource Details of V1 and I1 . . . . . . . . . . . . . . . . . . 8310.7 Choose the required NPN model . . . . . . . . . . . . . . . . . . 8410.8 The output characteristics of NPN transistor . . . . . . . . . . . 84

11.1 Schematic diagram for CE output characteristics . . . . . . . . . 8711.2 Annotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8811.3 Netlist Generation . . . . . . . . . . . . . . . . . . . . . . . . . . 8811.4 Choose Kicad to Ngspice tool . . . . . . . . . . . . . . . . . . . . 8811.5 Choose DC analysis type and enter the values of V1 and I1 . . . 8911.6 Give Source Details of V1 and I1 . . . . . . . . . . . . . . . . . . 8911.7 Choose the required NPN model . . . . . . . . . . . . . . . . . . 9011.8 The output characteristics of NPN transistor . . . . . . . . . . . 90

12.1 Launching eSim will take you to this window . . . . . . . . . . . 9212.2 Creating new project . . . . . . . . . . . . . . . . . . . . . . . . . 9212.3 Creating new schematic diagram . . . . . . . . . . . . . . . . . . 9312.4 The Kicad Eeschema page . . . . . . . . . . . . . . . . . . . . . . 9312.5 Place component icon . . . . . . . . . . . . . . . . . . . . . . . . 9412.6 Place wire icon . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9412.7 The Kicad Libraries of components . . . . . . . . . . . . . . . . . 9412.8 Editing the value field of component R . . . . . . . . . . . . . . . 9512.9 Choose annotate from the toop tool bar . . . . . . . . . . . . . . 9512.10Schematic diagram for Zener Diode Regulator . . . . . . . . . . . 9612.11Annotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9712.12Netlist Generation . . . . . . . . . . . . . . . . . . . . . . . . . . 9712.13Choose Kicad to Ngspice tool . . . . . . . . . . . . . . . . . . . . 97

Page 14: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

12.14Choose DC analysis type and enter the values . . . . . . . . . . . 9812.15Choose ngspice model values . . . . . . . . . . . . . . . . . . . . 9812.16Choose the required Transistor model . . . . . . . . . . . . . . . 9912.17The line regulation characteristics of zener diode . . . . . . . . . 100

Page 15: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

Chapter 1

INTRODUCTION TOeSim

eSim is a CAD tool that helps electronic system designers to design, testand analyse their circuits. But the important feature of this tool is that it isopen source and hence the user can modify the source as per his/her need. Thesoftware provides a generic, modular and extensible platform for experimentwith electronic circuits. This software runs on all Ubuntu Linux distributionsand some flavours of Windows. It uses Python, KiCad and Ngspice.

The objective behind the development of eSim is to provide an open sourceEDA solution for electronics and electrical engineers. The software should becapable of performing schematic creation, PCB design and circuit simulation(analog, digital and mixed signal). It should provide facilities to create newmodels and components. The architecture of eSim has been designed by keepingthese objectives in mind [1] .

WORKFLOW OF eSimThis section describes the workflow of eSim for circuit simulation. The flow

would be slightly different for PCB designing. For a generic treatment on theworkflow, please refer to the user manual .

The first step in circuit simulation is to draw a schematic diagram of thecircuit. In eSim it is drawn using Eeschema. The next step is to obtain anetlist file. The schematic drawing tool provides this file, which describes theelectrical connections between components. The netlist generated by SchematicEditor cannot be directly used for simulation due to compatibility issues. NetlistConverter converts it into Ngspice compatible format.The type of simulation tobe performed and the corresponding options are provided through a graphical

15

Page 16: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

16 CHAPTER 1. INTRODUCTION TO ESIM

user interface (GUI). This is called KiCad to Ngspice Converter in eSim. eSimuses Ngspice for analog, digital, mixed-level/mixed-signal circuit simulation.

To summarise the simulation workflow:

1. Strat a new project in the eSim GUI.

2. Draw the schematic diagram of the circuit in Eeschema.

3. Convert it to netlist for simulation using Eeshema.

4. Come back to the eSim GUI and convert the netlist for use by Ngspiceusing KiCad to Ngspice Converter. Give details of the type of simulationsduring this step.

5. Simulate the circuit and plot the required variables.

Details on every step given above is avilable in the esim usermanual[1].

Page 17: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

Chapter 2

DIODECHARACTERISTICS

AIM

To design and implement a circuit to simulate the V-I characteristics of adiode.

DESIGN AND CIRCUIT DIAGRAM

Inorder to draw the diode characteristics, we have to use a DC source ofvoltage. Its value may be varied during simulation. The diode in the circuitshould be associated with a ‘diode model’. A curernt limiting resistor mayalso be used in series with the diode and the DC source. The resulting circuitdiagram is shown in the Figure 2.1.

PROCEDURE

Launch eSim

Launching eSim will take you to the dialog box. It asks for the defaultworkspace. Browse the folders and set the wokspace location. It will end up inthe eSim window shown in Figure 12.1.

17

Page 18: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

18 CHAPTER 2. DIODE CHARACTERISTICS

Figure 2.1: Schematic diagram for diode characteristics

Figure 2.2: Launching eSim will take you to this window

Create a New Project

The new project is created by clicking the New icon on the menubar. Give thename of the project ,’Diodechar’ in the pop up window as shown in Figure.12.2.

Page 19: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

19

Figure 2.3: Creating new project

Create the Schematic

To create the schematic, click the very first icon of the left toolbar as shownin the Figure 12.3 .This will open KiCad Eeschema.

Figure 2.4: Creating new schematic diagram

To create a schematic in KiCad, we need to place the required components.See Figure 12.4. Figure 12.5 shows the icon on the right toolbar which opens thecomponent library. After all the required components of the simple RC circuitare placed, wiring is done using the Place Wire option as shown in the Figure12.6. Scroll up and down for zooming in and out.

Page 20: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

20 CHAPTER 2. DIODE CHARACTERISTICS

Figure 2.5: The Kicad Eeschema page

Figure 2.6: Place component icon Figure 2.7: Place wire icon

Placing the Components: Normally all the components availbale in eSimcan be chosen by left mouse click in the grid. The components are listed indifferent libraries. See Figure 12.7.

Page 21: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

21

Figure 2.8: The Kicad Libraries of components

• Choose DC source from eSim_Sources

• Choose R from eSim_Devices

• Choose D from eSim_Devices

• Choose GND from power

Select the resistor and edit its component value to 1k as shown in Figure12.8.

Figure 2.9: Editing the value field of component R

Wire the components to get the circuit. A global label ‘diode’ has beenadded to identify that node whose voltage will be later recorded and plotted.

Annotating the circuit: Once the schematic diagram is completed, annotateit so that the ‘question marks’ associated with the components are convertedto meaningful numbers automatically.For that choose annotate button from the

Page 22: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

22 CHAPTER 2. DIODE CHARACTERISTICS

top toolbar(See Figure 12.9 and in the subsequenct dialogue boxes appearingclick ok and finally close. See Figure 12.11.

Figure 2.10: Choose annotate from the toop tool bar

Now we have the circuit diagram as shown in Figure 2.1.

Note: If some libraries are found missing, you can add them from the ‘Pref-erences‘ menu by following the procedure:

1. Choose ‘Component Libraries’ from Preferences menu.

2. Click on the Add button on the top right side of the window.

3. Choose the required libraries from ‘user/share/kicad/library’ and click OKbutton

Create Netlist

To simulate the circuit that has been created in the previous section, we needto generate its netlist. Netlist is a list of components in the schematic alongwith their connection information. To do so, click on the Generate netlist toolfrom the top toolbar. Click on spice from the window that opens up. Checkthe option Default Format. Then click on Generate. This is shown in Fig. 5.15.Save the netlist. This will be a .cir file. Do not change the directory whilesaving.See Figure 12.12. Now the netlist is ready to be simulated.

KiCad to Ngspice conversion

To convert KiCad netlist of the circuit to NgSpice compatible netlist click onKiCad to Ngspice icon as shown in Figure 12.13. Now you can choose the typeof analysis, source details, device models ngspice models and subcircuit models.

Page 23: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

23

Figure 2.11: AnnotationFigure 2.12: Netlist Generation

Figure 2.13: Choose Kicad to Ngspice tool

Analysis: Choose DC analysis type. Give the values of DC variables as shownin Figure 2.14. Enter the name of your DC source as on the circuit (here v1)and let its value be varied from -15V to +15V with a step of 0.1 V.

Figure 2.14: Choose DC analysis type and enter the values

Page 24: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

24 CHAPTER 2. DIODE CHARACTERISTICS

Source Details: Leave this empty.

Ngspice Model: No Ngspice model to be given.

Device Model: The Diode is a device whose model details must be given forsimulation. Let us choose the generic diode model availabe in the eSim modellibrary. Browse it from /opt/eSim/src/deviceModelLibrary/Diode/D.lib. SeeFigure 2.15.

Figure 2.15: Choose the required diode model

Subcircuits: No subcircuits to be given.Once these details are provided click on convert button. See Figure 2.15. Nowyou are ready to see the simulation results.

Simulate

To run Ngspice simulation click the simulation icon in the left tool bar. It willopen up two windows - ngspice plotting window and python plotting window.Inorder to plot the diode characteristics let us use the commands in ngspiceplotting window.

We need to plot the value of voltage across the diode Vs the current throughit. Since the current through the diode is same as the current through thevoltage source, v1 (since both are in series connection) let us use the command:

plot i(v1) vs v(diode)This would pop up the required characteristics fo the diode as defined in

the diode model D.lib. For a differnt diode model the characteristics would beslightly different.

Page 25: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

25

The resultant characteristics is shown in the Figure 2.16.

Figure 2.16: The characteristics of Diode

RESULTThe circuit for plotting the charateristics of diode was implemented and simu-lated.

Page 26: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

26 CHAPTER 2. DIODE CHARACTERISTICS

Page 27: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

Chapter 3

RC FILTERS

AIMTo design and implement circuits for passive RC highpass and lowpass filters.

DESIGN AND CIRCUIT DIAGRAMInorder to plot the frequency response of RC highpass and lowpass filters

use an AC source whose frequency can be varied durinmg simulation. The ACsource of voltage. It is connected across a series connection of resistor andcapacitor. The corresponding circuits for RC highpass filter and lowpass filtersare shown in figures 3.1 and 3.2 respectively. The cutoff frequency of the filterwill be given by

fc =1

2πRC(3.1)

Figure 3.1: Schematic diagram for passive RC high pass filter

27

Page 28: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

28 CHAPTER 3. RC FILTERS

Figure 3.2: Schematic diagram for passive RC low pass filter

PROCEDUREThe steps to plot the characteristics of RC high pass filter are explained below.

Follow the same procedure to obtain the response of RC lowpass filter. Notethat these are two separate projects.

Launch eSimLaunching eSim will take you to the dialog box which asks for the default

workspace. Browse the folders and set the wokspace location. It will finally endup in the eSim window.

Create a New ProjectThe new project is created by clicking the New icon on the menubar. The

name of the project is given in the pop up window as RC_HPF for highpassfilter.

Create the SchematicTo create the schematic, click the very first icon of the left toolbar. This will

open KiCad Eeschema.To create a schematic in KiCad, we need to place the required components.

After all the required components of the simple RC circuit are placed, wiring

Page 29: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

29

is done using the Place Wire option. The ‘Place Wire’ and ‘Place Component’tools are available in the left toolbar. Scroll up and down for zooming in andout.

Placing the Components: Normally all the components availbale in eSimcan be chosen by left mouse click in the grid. The components are listed indifferent libraries.

• Choose AC source from eSim_Sources

• Choose R from eSim_Devices

• Choose C from eSim_Devices

• Choose GND from power

Select the resistor and edit its component value to 1k as shown in Figure3.3. Also edit the value of capacitor as 1 µ F. You can just type in 1u.

Figure 3.3: Editing the value field of component R

Wire the components to get the circuit. A global label ‘Input’ and ‘Output’has been added to identify that node whose voltage will be later recorded andplotted. Global label is added from the right toolbar of Eeschema.

Annotating the circuit: Once the schematic diagram is completed, annotateit so that the ‘question marks’ associated with the components are convertedto meaningful numbers automatically.For that choose annotate button from thetop toolbar. See Figure 3.4 and in the subsequent dialogue boxes appearingclick ok and finally close. See Figure 3.5. Now we have the circuit diagram asshown in Figure 3.1.

Page 30: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

30 CHAPTER 3. RC FILTERS

Figure 3.4: Choose annotate from the toop tool bar

Note: If some libraries are found missing, you can add them from the ‘Pref-erences‘ menu by following the procedure:

1. Choose ‘Component Libraries’ from Preferences menu.

2. Click on the Add button on the top right side of the window.

3. Choose the required libraries from ‘user/share/kicad/library’ and click OKbutton

Create NetlistTo simulate the circuit that has been created in the previous section, we need

to generate its netlist. Netlist is a list of components in the schematic alongwith their connection information. To do so, click on the Generate netlist toolfrom the top toolbar. Click on spice from the window that opens up. Check theoption Default Format. Then click on Generate. Save the netlist. This will bea .cir file. Do not change the directory while saving. See Figure 3.6. Now thenetlist is ready to be simulated.

KiCad to Ngspice conversionTo convert KiCad netlist of RC circuit to NgSpice compatiable netlist click

on KiCad to Ngspice icon as shown in Figure 3.7. Now you can choose the typeof analysis, source details, device models ngspice models and subcircuit models.

Analysis: Choose AC analysis type and choose Dec scale. Dec sclae allowsplotting as in a semilog graph sheet. Give the values of AC variables as shownin Figure 3.8. Enter the name of your AC source as on the circuit (here v1)and let its frequency be varied from 1Hz to 10kHz with 10 points chosen in eachdeacade interval of frequency.

Source Details: Set amplitude as 5 and phase shift as 0.

Page 31: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

31

Figure 3.5: AnnotationFigure 3.6: Netlist Generation

Figure 3.7: Choose Kicad to Ngspice tool

Ngspice Model: No Ngspice model to be given.

Device Model: No Device model to be given.

Subcircuits: No subcircuits to be given.Once these details are provided click on convert button. Now you are ready tosee the simulation results.

SimulateTo run Ngspice simulation click the simulation icon in the left tool bar. It willopen up two windows - ngspice plotting window and python plotting window.Inorder to plot the frequency response characteristics let us use the commandsin ngspice plotting window.

Page 32: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

32 CHAPTER 3. RC FILTERS

Figure 3.8: Choose AC analysis type and enter the values

We need to plot two graphs.

1. Input voltage value for different frequencies.

2. Output voltage value for different frequencies.

To plot these, let us use the command:

plot v(Input), v(Output)

This would plot the frequency response characteristics of input and output ofthe RC high pass filter. The resultant characteristics is shown in the Figure 3.9.The red indicates the Input and the blue indicates the output. The charcteristicsof RC low pass filter would be as shown in Figure 3.10.

RESULTThe circuit for plotting the frequency response of filter was implemented andsimulated.

Page 33: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

33

Figure 3.9: The frequency response of RC highpass filter

Figure 3.10: The frequency response of RC low pass filter

Page 34: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

34 CHAPTER 3. RC FILTERS

Page 35: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

Chapter 4

CLIPPING CIRCUIT

AIMTo design and implement a circuit for clipping waveforms

DESIGN AND CIRCUIT DIAGRAMInorder to plot the transient response of clipping circuits use a SINE source

whose amplitude, frequency, phase etc can be fixed during simulation. TheSINE source is connected across a series connection of resistor and diode. Thecircuits for series clipper (Diode connected in series with the load) and shuntclippers (Diode connected in shunt with the load) are shown in figures 4.1 and4.2 respectively.

PROCEDUREThe steps to plot the transient response of a clipper are explained below.

Launch eSimLaunching eSim will take you to the dialog box which asks for the default

workspace. Browse the folders and set the wokspace location. It will finally endup in the eSim window.

Create a New ProjectThe new project is created by clicking the New icon on the menubar. The

name of the project is given in the pop up window as ‘seriesclipper’ for thecircuit in figure 4.1 and ‘shuntclipper’ for the circuit in Figure 4.2. Follow thesteps explaied below to implement either of them.

35

Page 36: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

36 CHAPTER 4. CLIPPING CIRCUIT

Figure 4.1: Schematic diagram for series clipper circuit

Create the SchematicTo create the schematic, click the very first icon of the left toolbar. This will

open KiCad Eeschema.To create a schematic in KiCad, we need to place the required components.

After all the required components of the clipper circuit are placed, wiring isdone using the Place Wire option. The ‘Place Wire’ and ‘Place Component’tools are available in the left toolbar. Scroll up and down for zooming in andout.

Placing the Components: Normally all the components availbale in eSimcan be chosen by left mouse click in the grid. The components are listed indifferent libraries.

• Choose SINE source from eSim_Sources

• Choose R from eSim_Devices

• Choose D from eSim_Devices

• Choose GND from power

Select the resistor and edit its component value to 1k.Wire the components to get the circuit. A global label ‘in’ and ‘out’ has been

added to identify the node whose voltage will be later recorded and plotted.Global label is added from the right toolbar of Eeschema.

Page 37: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

37

Figure 4.2: Schematic diagram for shunt clipper circuit

Annotating the circuit: Once the schematic diagram is completed, annotateit so that the ‘question marks’ associated with the components are convertedto meaningful numbers automatically.For that choose annotate button from thetop toolbar and in the subsequenct dialogue boxes appearing click ok and finallyclose. See Figure 4.3.

Now we have the circuit diagram as shown in Figure 4.1.

Note: If some libraries are found missing, you can add them from the ‘Pref-erences‘ menu by following the procedure:

1. Choose ‘Component Libraries’ from Preferences menu.

2. Click on the Add button on the top right side of the window.

3. Choose the required libraries from ‘user/share/kicad/library’ and click OKbutton

Create NetlistTo simulate the circuit that has been created in the previous section, we need

to generate its netlist. Netlist is a list of components in the schematic alongwith their connection information. To do so, click on the Generate netlist toolfrom the top toolbar. Click on spice from the window that opens up. Check theoption Default Format. Then click on Generate. Save the netlist. This will bea .cir file. Do not change the directory while saving. See Figure 4.4. Now thenetlist is ready to be simulated.

Page 38: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

38 CHAPTER 4. CLIPPING CIRCUIT

Figure 4.3: AnnotationFigure 4.4: Netlist Generation

KiCad to Ngspice conversionTo convert KiCad netlist of clipper circuit to NgSpice compatible netlist click

on KiCad to Ngspice icon . Now you can choose the type of analysis, sourcedetails, device models ngspice models and subcircuit models.

Analysis: Choose analysis type as ‘Transient’. Give the values of time vari-ables as shown in Figure 4.5. Enter the time to be varied from ‘Start time=0ms’ to ‘Stop time=20ms’ with a ‘Step time=1 ms’.

Figure 4.5: Choose analysis type as ‘transient’ and enter the values

Source Details: Set the details of ‘sine’ source as shown in Figure 4.6.

• Offset value(volts): 0

• Amplitude(volts): 5

• Frequency(Hz): 50

Page 39: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

39

• Delay time(Seconds): 0

• Damping factor(1/seconds):0

Figure 4.6: Enter the parameters of ‘Sine’ source

Ngspice Model: No Ngspice model to be given.

Device Model: Add thediode model availablein the eSim library by browsingthe folder, /opt/eSim/src/deviceModelLibrary/Diode/D.lib

Subcircuits: No subcircuits to be given.Once these details are provided click on convert button. Now you are ready tosee the simulation results.

SimulateTo run Ngspice simulation click the simulation icon in the left tool bar. It willopen up two windows - ngspice plotting window and python plotting window.Inorder to plot the transient response of the clipper you can use either plottingtypes.

Python plotting: This provides a graphical interface for plotting. We need toplot the value of voltage across the ‘SINE’ source as well as the load resistor withrespect to time. We have already labled these nodes as in and out respectivelyThe nodes will be listed on the GUI. Choose ‘in’ and ‘out’ and click on ‘plot’button. See Figure 4.7.

Page 40: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

40 CHAPTER 4. CLIPPING CIRCUIT

Figure 4.7: The transient response of the series clipper on python plottingwindow

Ngspice plotting: . Time of simulation has already been set in the previousstep as 0 ms to 20 ms. Use the commands in ngspice plotting window forobtaining the required plots.

plot v(out), v(in)

This would plot the transient response of input and output of the series clip-per. The resultant characteristics is shown in the Figure 4.8.

Repeat the same set of procedures for implementing the shunt clipper. Usethe schematic as shown in Figure 4.2. Upon using python plotting, the resultanttransient analysis would look like Figure 4.9

RESULTThe circuit for plotting the transient analysis of clipper was implemented andsimulated.

Page 41: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

41

Figure 4.8: The transient response of the series clipper in ngspice plotting win-dow

Figure 4.9: The transient response of the shunt clipper on python plottingwindow

Page 42: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

42 CHAPTER 4. CLIPPING CIRCUIT

Page 43: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

Chapter 5

CLAMPING CIRCUIT

AIMTo design and implement circuit for clamping waveforms

DESIGN AND CIRCUIT DIAGRAMInorder to plot the transient response of clamping circuits use a SINE source

whose amplitude, frequency, phase etc can be fixed during simulation. TheSINE source is connected across a series connection of a diode and a capacitorand the output is taken across the diode and the GND.The circuit for a clampercircuit is in Figure 5.1 .

PROCEDUREThe steps to plot the transint resonse of a clamper are explained below..

Launch eSimLaunching eSim will take you to the dialog box which asks for the default

workspace. Browse the folders and set the wokspace location. It will finally endup in the eSim window.

Create a New ProjectThe new project is created by clicking the New icon on the menubar. The

name of the project is given in the pop up window as ‘clamper’ for the circuitin Figure 5.1. Follow the steps explaied below to implement the circuit.

43

Page 44: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

44 CHAPTER 5. CLAMPING CIRCUIT

Figure 5.1: Schematic diagram for clamper circuit

Create the SchematicTo create the schematic, click the very first icon of the left toolbar. This will

open KiCad Eeschema.To create a schematic in KiCad, we need to place the required components.

After all the required components of the clipper circuit are placed, wiring isdone using the Place Wire option. The ‘Place Wire’ and ‘Place Component’tools are available in the left toolbar. Scroll up and down for zooming in andout.

Placing the Components: Normally all the components availbale in eSimcan be chosen by left mouse click in the grid. The components are listed indifferent libraries.

• Choose SINE source from eSim_Sources

• Choose C from eSim_Devices

• Choose D from eSim_Devices

• Choose GND from power

Select the capacitor and edit its component value to 1u.Wire the components to get the circuit. A global label ‘in’ and ‘out’ has been

added to identify the node whose voltage will be later recorded and plotted.Global label is added from the right toolbar of Eeschema.

Page 45: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

45

Figure 5.2: AnnotationFigure 5.3: Netlist Generation

Annotating the circuit: Once the schematic diagram is completed, annotateit so that the ‘question marks’ associated with the components are convertedto meaningful numbers automatically. Choose annotate button from the toptoolbar and in the subsequenct dialogue boxes appearing click ok and finallyclose. See Figure 5.2.

Now we have the circuit diagram as shown in Figure 5.1.

Note: If some libraries are found missing, you can add them from the ‘Pref-erences‘ menu by following the procedure:

1. Choose ‘Component Libraries’ from Preferences menu.

2. Click on the Add button on the top right side of the window.

3. Choose the required libraries from ‘user/share/kicad/library’ and click OKbutton

Create NetlistTo simulate the circuit that has been created in the previous section, we need

to generate its netlist. Netlist is a list of components in the schematic alongwith their connection information. To do so, click on the Generate netlist toolfrom the top toolbar. Click on spice from the window that opens up. Check theoption Default Format. Then click on Generate. Save the netlist. This will bea .cir file. Do not change the directory while saving. See Figure 5.3. Now thenetlist is ready to be simulated.

KiCad to Ngspice conversionTo convert KiCad netlist of clipper circuit to NgSpice compatible netlist click

on KiCad to Ngspice icon . Now you can choose the type of analysis, sourcedetails, device models ngspice models and subcircuit models.

Page 46: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

46 CHAPTER 5. CLAMPING CIRCUIT

Analysis: Choose analysis type as ‘Transient’. Give the values of time vari-ables as shown in Figure 5.4. Enter the time to be varied from ‘Start time=0ms’ to ‘Stop time=4ms’ with a ‘Step time=0.01 ms’.

Figure 5.4: Choose analysis type as ‘transient’ and enter the values

Source Details: Set the details of ‘sine’ source as shown in Figure 4.6.

• Offset value(volts): 0

• Amplitude(volts): 4

• Frequency(Hz): 1k

• Delay time(Seconds): 0

• Damping factor(1/seconds):0

Figure 5.5: Enter the parameters of ‘Sine’ source

Ngspice Model: No Ngspice model to be given.

Page 47: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

47

Device Model: Add the diode model availablein the eSim library by browsingthe folder, /opt/eSim/src/deviceModelLibrary/Diode/D.lib

Subcircuits: No subcircuits to be given.Once these details are provided click on convert button. Now you are ready tosee the simulation results.

SimulateTo run Ngspice simulation click the simulation icon in the left tool bar. It willopen up two windows - ngspice plotting window and python plotting window.Inorder to plot the transient response of the clipper you can use either plottingtypes.

Python plotting: This provides a graphical interface for plotting. We needto plot the value of voltage across the ‘SINE’ source as well as the diode withrespect to time. We have already labled these nodes as in and out respectivelyThe nodes will be listed on the GUI. Choose ‘in’ and ‘out’ and click on ‘plot’button. See Figure 5.6.

Figure 5.6: The transient response of the clamper on python plotting window

Page 48: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

48 CHAPTER 5. CLAMPING CIRCUIT

Ngspice plotting: . Time of simulation has already been set in the previousstep. Use the commands in ngspice plotting window for obtaining the requiredplots.

plot v(out), v(in)

This would plot the transient response of input and output of the clamper.

RESULTThe circuit for plotting the transient analysis of clamper was implemented andsimulated.

Page 49: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

Chapter 6

HALF WAVERECTIFIERS

AIMTo design and implement circuit for half wave rectifier with C and LC filter.

DESIGN AND CIRCUIT DIAGRAMInorder to plot the transient response of half wave rectifier use a SINE source

whose amplitude, frequency, phase etc can be fixed during simulation. The SINEsource is connected across a series connection of a diode and a load of resistance1kΩ. The output is filtered using a capacitor as shown in Figure 6.1 as well asan LC filter as shown in Figure 6.2. The two circuits can be implemented asseparate projects.

PROCEDUREThe steps to plot the transint resonse of a half wave rectifier with filter are

explained below.

Launch eSim

Launching eSim will take you to the dialog box which asks for the defaultworkspace. Browse the folders and set the wokspace location. It will finally endup in the eSim window.

49

Page 50: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

50 CHAPTER 6. HALF WAVE RECTIFIERS

Figure 6.1: Schematic diagram for half wave rectifier with C filter

Create a New ProjectThe new project is created by clicking the New icon on the menubar. The

name of the project is given in the pop up window as ‘halfwaverectifierC’ for thecircuit in figure 6.1. Follow the steps explaied below to implement the circuit.

Create the SchematicTo create the schematic, click the very first icon of the left toolbar. This will

open KiCad Eeschema.To create a schematic in KiCad, we need to place the required components.

After all the required components of the half wave circuit are placed, wiring isdone using the Place Wire option. The ‘Place Wire’ and ‘Place Component’tools are available in the left toolbar. Scroll up and down for zooming in andout.

Placing the Components: Normally all the components availbale in eSimcan be chosen by left mouse click in the grid. The components are listed indifferent libraries.

• Choose SINE source from eSim_Sources

• Choose C from eSim_Devices

• Choose L from eSim_Devices

• Choose D from eSim_Devices

Page 51: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

51

Figure 6.2: Schematic diagram for half wave rectifier with LC filter

• Choose GND from power

Select the capacitor and edit its component value to 1u and edit the com-ponent value of inductor to 5.

Wire the components to get the circuit. A global label ‘in’ and ‘out’ has beenadded to identify the node whose voltage will be later recorded and plotted.Global label is added from the right toolbar of Eeschema.

Annotating the circuit: Once the schematic diagram is completed, annotateit so that the ‘question marks’ associated with the components are convertedto meaningful numbers automatically.For that choose annotate button from thetop toolbar and in the subsequenct dialogue boxes appearing click ok and finallyclose. See Figure 6.3.

Now we have the circuit diagram as shown in Figure 6.1.

Note: If some libraries are found missing, you can add them from the ‘Pref-erences‘ menu by following the procedure:

1. Choose ‘Component Libraries’ from Preferences menu.

2. Click on the Add button on the top right side of the window.

3. Choose the required libraries from ‘user/share/kicad/library’ and click OKbutton

Create NetlistTo simulate the circuit that has been created in the previous section, we need

to generate its netlist. Netlist is a list of components in the schematic along

Page 52: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

52 CHAPTER 6. HALF WAVE RECTIFIERS

Figure 6.3: AnnotationFigure 6.4: Netlist Generation

with their connection information. To do so, click on the Generate netlist toolfrom the top toolbar. Click on spice from the window that opens up. Check theoption Default Format. Then click on Generate. Save the netlist. This will bea .cir file. Do not change the directory while saving. See Figure 6.4. Now thenetlist is ready to be simulated.

KiCad to Ngspice conversionTo convert KiCad netlist of half wave rectifier circuit to NgSpice compatiable

netlist click on KiCad to Ngspice icon . Now you can choose the type of analysis,source details, device models ngspice models and subcircuit models.

Analysis: Choose analysis type as ‘Transient’. Give the values of time vari-ables as shown in Figure 6.5. Enter the time to be varied from ‘Start time=0ms’ to ‘Stop time=500ms’ with a ‘Step time=1 ms’.

Figure 6.5: Choose analysis type as ‘transient’ and enter the values

Page 53: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

53

Source Details: Set the details of ‘sine’ source as shown in Figure 6.6.

• Offset value(volts): 0

• Amplitude(volts): 4

• Frequency(Hz): 50

• Delay time(Seconds): 0

• Damping factor(1/seconds):0

Figure 6.6: Enter the parameters of ‘Sine’ source

Ngspice Model: No Ngspice model to be given.

Device Model: Add thediode model availablein the eSim library by browsingthe folder, /opt/eSim/src/deviceModelLibrary/Diode/D.lib

Subcircuits: No subcircuits to be given.Once these details are provided click on convert button. Now you are ready tosee the simulation results.

SimulateTo run Ngspice simulation click the simulation icon in the left tool bar. It willopen up two windows - ngspice plotting window and python plotting window.Inorder to plot the transient response of the clipper you can use either plottingtypes.

Page 54: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

54 CHAPTER 6. HALF WAVE RECTIFIERS

Python plotting: This provides a graphical interface for plotting. We needto plot the value of voltage across the ‘SINE’ source as well as the load withrespect to time. We have already labled these nodes as in and out respectivelyThe nodes will will listed on the GUI. Choose ‘in’ and ‘out’ and click on ‘plot’button. See Figure 6.7.

Figure 6.7: The transient response of the half wave rectifier with capacitor filteron python plotting window

Ngspice plotting: . Time of simulation has already been set in the previousstep. Use the commands in ngspice plotting window for obtaining the requiredplots.

plot v(out), v(in)

This would plot the transient response of input and output of the half waverectifier.

Repeat the same set of steps for the circuit with LC filter shown in Figure6.2. The corresponding output is shown in Figure 6.8. It can be seen that theripple has largely been reduced in Figure 6.8. The change in characteristics ofthe ripple may be experimentally observed by varying the value of inductor asL=15H, L=0.1H etc. This is left as an exercise for the user.

Page 55: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

55

Figure 6.8: The transient response of the half wave rectifier with inductor andcapacitor filter on python plotting window

.

RESULTThe circuit for plotting the transient analysis of half wave rectifier was imple-mented and simulated.

Page 56: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

56 CHAPTER 6. HALF WAVE RECTIFIERS

Page 57: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

Chapter 7

FULL WAVE RECTIFIERS

AIMTo design and implement circuit for full wave rectifiers with C and LC filter.

DESIGN AND CIRCUIT DIAGRAMInorder to plot the transient response of fullwave bridge rectifier use a SINE

source whose amplitude, frequency, phase etc can be fixed during simulation.The SINE source is connected across a bridge combination of diodes and theoutput is taken across a load of resistance 1kΩ. The output is filtered using acapacitor as shown in Figure 7.1 as well as an LC filter as shown in Figure 7.2.The two circuits can be implemented as separate projects.

Figure 7.1: Schematic diagram for bridge rectifier with C filter

57

Page 58: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

58 CHAPTER 7. FULL WAVE RECTIFIERS

Figure 7.2: Schematic diagram for bridge rectifier with LC filter

PROCEDUREThe steps to plot the transient response of a bridge rectifier with filter are

explained below.

Launch eSimLaunching eSim will take you to the dialog box which asks for the default

workspace. Browse the folders and set the wokspace location. It will finally endup in the eSim window.

Create a New ProjectThe new project is created by clicking the New icon on the menubar. The

name of the project is given in the pop up window as ‘bridgerectifierC’ for thecircuit in figure 7.1. Follow the steps explaied below to implement the circuit.

Create the SchematicTo create the schematic, click the very first icon of the left toolbar. This will

open KiCad Eeschema.To create a schematic in KiCad, we need to place the required components.

After all the required components of the clipper circuit are placed, wiring isdone using the Place Wire option. The ‘Place Wire’ and ‘Place Component’tools are available in the left toolbar. Scroll up and down for zooming in andout.

Page 59: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

59

Placing the Components: Normally all the components availbale in eSimcan be chosen by left mouse click in the grid. The components are listed indifferent libraries.

• Choose SINE source from eSim_Sources

• Choose C from eSim_Devices

• Choose L from eSim_Devices

• Choose D from eSim_Devices

• Choose GND from power

Select the capacitor and edit its component value to 1u and edit the com-ponent value of inductor to 15H.

Wire the components to get the circuit. A global label ‘in’ and ‘out’ has beenadded to identify the node whose voltage will be later recorded and plotted.Global label is added from the right toolbar of Eeschema.

Annotating the circuit: Once the schematic diagram is completed, annotateit so that the ‘question marks’ associated with the components are convertedto meaningful numbers automatically.For that choose annotate button from thetop toolbar and in the subsequenct dialogue boxes appearing click ok and finallyclose. See Figure 7.3.

Now we have the circuit diagram as shown in Figure 7.1.

Note: If some libraries are found missing, you can add them from the ‘Pref-erences‘ menu by following the procedure:

1. Choose ‘Component Libraries’ from Preferences menu.

2. Click on the Add button on the top right side of the window.

3. Choose the required libraries from ‘user/share/kicad/library’ and click OKbutton

Create NetlistTo simulate the circuit that has been created in the previous section, we need

to generate its netlist. Netlist is a list of components in the schematic alongwith their connection information. To do so, click on the Generate netlist toolfrom the top toolbar. Click on spice from the window that opens up. Check theoption Default Format. Then click on Generate. Save the netlist. This will bea .cir file. Do not change the directory while saving. See Figure 7.4. Now thenetlist is ready to be simulated.

Page 60: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

60 CHAPTER 7. FULL WAVE RECTIFIERS

Figure 7.3: AnnotationFigure 7.4: Netlist Generation

KiCad to Ngspice conversionTo convert KiCad netlist of bridge rectifier circuit to NgSpice compatible

netlist click on KiCad to Ngspice icon . Now you can choose the type of analysis,source details, device models ngspice models and subcircuit models.

Analysis: Choose analysis type as ‘Transient’. Give the values of time vari-ables as shown in Figure 7.5. Enter the time to be varied from ‘Start time=0ms’ to ‘Stop time=500ms’ with a ‘Step time=1 ms’.

Figure 7.5: Choose analysis type as ‘transient’ and enter the values

Source Details: Set the details of ‘sine’ source as shown in Figure 7.6.

• Offset value(volts): 0

• Amplitude(volts): 4

• Frequency(Hz): 50

Page 61: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

61

• Delay time(Seconds): 0

• Damping factor(1/seconds):0

Figure 7.6: Enter the parameters of ‘Sine’ source

Ngspice Model: No Ngspice model to be given.

Device Model: Add thediode model availablein the eSim library by browsingthe folder, /opt/eSim/src/deviceModelLibrary/Diode/D.lib

Subcircuits: No subcircuits to be given.Once these details are provided click on convert button. Now you are ready tosee the simulation results.

SimulateTo run Ngspice simulation click the simulation icon in the left tool bar. It willopen up two windows - ngspice plotting window and python plotting window.Inorder to plot the transient response of the clipper you can use either plottingtypes.

Python plotting: This provides a graphical interface for plotting. We needto plot the value of voltage across the ‘SINE’ source as well as the load withrespect to time. We have already labled these nodes as in and out respectivelyThe nodes will will listed on the GUI. Choose ‘in’ and ‘out’ and click on ‘plot’button. See Figure 7.7.

Page 62: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

62 CHAPTER 7. FULL WAVE RECTIFIERS

Figure 7.7: The transient response of the bridge rectifier with capacitor filteron python plotting window

Ngspice plotting: . Time of simulation has already been set in the previousstep. Use the commands in ngspice plotting window for obtaining the requiredplots.

plot v(out), v(in)

This would plot the transient response of input and output of the bridgerectifier.

Repeat the same set of steps for the circuit with LC filter shown in Figure7.2. The corresponding output is shown in Figure 7.8. It can be seen that theripple has largely been reduced in Figure 7.8. The change in characteristics ofthe ripple may be experimentally observed by varying the value of inductor asL=5H, L=0.1H etc. This is left as an exercise for the user.

RESULTThe circuit for plotting the transient analysis of clamper was implemented andsimulated.

Page 63: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

63

Figure 7.8: The transient response of the bridge rectifier with inductor andcapacitor filter on python plotting window

.

Page 64: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

64 CHAPTER 7. FULL WAVE RECTIFIERS

Page 65: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

Chapter 8

JFETCHARACTERISTICS

AIMTo design and implement a circuit for simulating the drain and transfer char-

acteristics of a JFET.

DESIGN AND CIRCUIT DIAGRAMInorder to draw the JFET characteristics, we have to use a DC source of volt-

age which may be varied during simulation. The JFET in the circuit should beassociated with a coresponding ‘JFET model’ during simulations. The resultingcircuit diagram is shown in the Figure 8.1.

Drain charcteristics is a plot between the drain current and drain to sourcevoltage keeping the gate voltage constant. Transfer charcteristics is a plot be-tween the drain current and gate to source voltage keeping the drain voltageconstant.

PROCEDURELaunch eSim

Launching eSim will take you to the dialog box which asks for the defaultworkspace. Browse the folders and set the wokspace location. It will finally endup in the eSim window

Create a New Project

The new project is created by clicking the New icon on the menubar. Thename of the project is given in the pop up window.

65

Page 66: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

66 CHAPTER 8. JFET CHARACTERISTICS

Figure 8.1: Schematic diagram for JFET characteristics

Create the Schematic

To create the schematic, click the very first icon of the left toolbar.This willopen KiCad Eeschema.

To create a schematic in KiCad, we need to place the required components.Clicking on the icon on the right toolbar opens the component library. After

all the required components of the circuit are placed, wiring is done using thePlace Wire option. Scroll up and down for zooming in and out.

Placing the Components: Normally all the components availbale in eSimcan be chosen by left mouse click in the grid. The components are listed indifferent libraries.

• Choose DC sources from eSim_Sources

• Choose NJF from eSim_Devices

• Choose GND from power

Wire the components to get the circuit. A global labels ‘GATE’ and ‘DRAIN’hav been added to identify those nodes whose voltage will be later recorded andplotted.

Page 67: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

67

Figure 8.2: AnnotationFigure 8.3: Netlist Generation

Annotating the circuit: Once the schematic diagram is completed, annotateit so that the ‘question marks’ associated with the components are convertedto meaningful numbers automatically.For that choose annotate button from thetop toolbarand in the subsequenct dialogue boxes appearing click ok and finallyclose. See Figure 8.2.

Now we have the circuit diagram as shown in Figure 8.1.

Note: If some libraries are found missing, you can add them from the ‘Pref-erences‘ menu by following the procedure:

1. Choose ‘Component Libraries’ from Preferences menu.

2. Click on the Add button on the top right side of the window.

3. Choose the required libraries from ‘user/share/kicad/library’ and click OKbutton

Create Netlist

To simulate the circuit that has been created in the previous section, we needto generate its netlist. Netlist is a list of components in the schematic alongwith their connection information. To do so, click on the Generate netlist toolfrom the top toolbar. Click on spice from the window that opens up. Checkthe option Default Format. Then click on Generate. Save the netlist. This willbe a .cir file. Do not change the directory while saving.See Figure 8.3. Now thenetlist is ready to be simulated.

KiCad to Ngspice conversion

To convert KiCad netlist of JFET circuit to NgSpice compatible netlist clickon KiCad to Ngspice icon as shown in Figure 8.4. Now you can choose the typeof analysis, source details, device models ngspice models and subcircuit models.

Page 68: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

68 CHAPTER 8. JFET CHARACTERISTICS

Figure 8.4: Choose Kicad to Ngspice tool

Analysis: Choose DC analysis type. On the same netlist you can simulatethe drain characteristics as well as transfer charcteristics. Choose the valuesof two DC sources, V1 and V2 in the netlist properly as described below. Fol-low the procedures for drain characteristics first. After obtaining the requiredplots do the procedures for the transfer characteristics and obtain the requiredcharcteristics curves.

• Drain Charcteristics: Give the values of DC variables as shown inFigure 8.5. Enter the name of your DC source V2 and let its value bevaried from 0V to 30V with a step of 0.1 V.

• Transfer Charcteristics: Give the values of DC variables as shown inFigure 8.6. Enter the name of your DC source V1 and let its value bevaried from 0V to 4V with a step of 0.1 V.

Figure 8.5: Choose DC analysis type and enter the values of V2

Source Details:

• Drain Charcteristics: Give the value of DC variables as shown in Figure8.7. Leave the column of V2 blank. Give the value of V1 as 0V, which

Page 69: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

69

Figure 8.6: Choose DC analysis type and enter the values of V1

is the gate voltage. (You may repeat the experiment by varying the gatevoltage as V1=1V, V1=2V etc.)

Figure 8.7: Enter the details of fixed source V1

• Transfer Charcteristics: Give the value of DC variables as shown inFigure 8.8. Leave the column of V1 blank. Give the value of V2 as 3V,which is the drain voltage.

Ngspice Model: No Ngspice model to be given.

Device Model: The JFET is a device whose model details must be given forsimulation. Let us choose the generic N-chnnel JFET model availabe in the eSimmodel library. Browse it from /opt/eSim/src/deviceModelLibrary/JFET/NJF.lib.See Figure 8.9.

Subcircuits: No subcircuits to be given.

Page 70: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

70 CHAPTER 8. JFET CHARACTERISTICS

Figure 8.8: Enter the details of fixed source V2

Figure 8.9: Choose the required JFET model

Once these details are provided click on convert button. Now you are readyto see the simulation results.

Simulate

To run Ngspice simulation click the simulation icon in the left tool bar. It willopen up two windows - ngspice plotting window and python plotting window.Inorder to plot the JFET characteristics let us use the commands in ngspiceplotting window. We need to plot the drain charcteristics as well as transfercharacteristics.

Drain Characteritics: In the ngspice plotting window, type the followingcommand:

Page 71: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

71

plot -i(v2) vs v(drain)This would pop up the drain characteristics of the JFET as defined in the

JFET model NJF.lib. For a differnt device model the characteristics would beslightly different.

The resultant characteristics is shown in the Figure 8.10 and 8.11.

Figure 8.10: The drain characteristics of JFET with gate voltage =0V

Figure 8.11: The drain characteristics of JFET with gate voltage =1V

Transfer Characteritics: In the ngspice plotting window, type the followingcommand:

plot -i(v2) vs v(gate)

Page 72: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

72 CHAPTER 8. JFET CHARACTERISTICS

This would pop up the transfer characteristics of the JFET as defined in theJFET model NJF.lib. For a differnt device model the characteristics would beslightly different.

The resultant characteristics is shown in the Figure 8.12.

Figure 8.12: The transfer characteristics of JFET with drain voltage =3V

RESULTThe circuit for plotting the charateristics of JFET was implemented and simu-lated.

Page 73: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

Chapter 9

MOSFETCHARACTERISTICS

AIMTo design and implement a circuit for simulating the drain and transfer char-

acteristics of a MOSFET.

DESIGN AND CIRCUIT DIAGRAMInorder to draw the MOSFET characteristics, we have to use a DC source of

voltage which may be varied during simulation. The MOSFET in the circuitshould be associated with a coresponding ‘MOSFET model’ during simulations.The resulting circuit diagram is shown in the Figure 9.1.

Drain charcteristics is a plot between the drain current and drain to sourcevoltage keeping the gate voltage constant. Transfer charcteristics is a plot be-tween the drain current and gate to source voltage keeping the drain voltageconstant.

PROCEDURELaunch eSim

Launching eSim will take you to the dialog box which asks for the defaultworkspace. Browse the folders and set the wokspace location. It will finally endup in the eSim window

Create a New Project

The new project is created by clicking the New icon on the menubar. Thename of the project is given in the pop up window.

73

Page 74: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

74 CHAPTER 9. MOSFET CHARACTERISTICS

Figure 9.1: Schematic diagram for MOSFET characteristics

Create the Schematic

To create the schematic, click the very first icon of the left toolbar.This willopen KiCad Eeschema.

To create a schematic in KiCad, we need to place the required components.Clicking on the icon on the right toolbar opens the component library. After

all the required components of the circuit are placed, wiring is done using thePlace Wire option. Scroll up and down for zooming in and out.

Placing the Components: Normally all the components availbale in eSimcan be chosen by left mouse click in the grid. The components are listed indifferent libraries.

• Choose DC sources from eSim_Sources

• Choose resistors from eSim_Devices

• Choose MOS_N from eSim_Devices

• Choose GND from power

Wire the components to get the circuit. A global labels ‘GATE’ and ‘DRAIN’hav been added to identify those nodes whose voltage will be later recorded andplotted.

Page 75: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

75

Figure 9.2: AnnotationFigure 9.3: Netlist Generation

Annotating the circuit: Once the schematic diagram is completed, annotateit so that the ‘question marks’ associated with the components are convertedto meaningful numbers automatically.For that choose annotate button from thetop toolbarand in the subsequenct dialogue boxes appearing click ok and finallyclose. See Figure 9.2.

Now we have the circuit diagram as shown in Figure 9.1.

Note: If some libraries are found missing, you can add them from the ‘Pref-erences‘ menu by following the procedure:

1. Choose ‘Component Libraries’ from Preferences menu.

2. Click on the Add button on the top right side of the window.

3. Choose the required libraries from ‘user/share/kicad/library’ and click OKbutton

Create Netlist

To simulate the circuit that has been created in the previous section, we needto generate its netlist. Netlist is a list of components in the schematic alongwith their connection information. To do so, click on the Generate netlist toolfrom the top toolbar. Click on spice from the window that opens up. Checkthe option Default Format. Then click on Generate. Save the netlist. This willbe a .cir file. Do not change the directory while saving.See Figure 9.3. Now thenetlist is ready to be simulated.

KiCad to Ngspice conversion

To convert KiCad netlist of MOSFET circuit to NgSpice compatible netlistclick on KiCad to Ngspice icon as shown in Figure 9.4. 8Now you can choose

Page 76: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

76 CHAPTER 9. MOSFET CHARACTERISTICS

the type of analysis, source details, device models ngspice models and subcircuitmodels.

Figure 9.4: Choose Kicad to Ngspice tool

Analysis: Choose DC analysis type. On the same netlist you can simulatethe drain characteristics as well as transfer charcteristics. Choose the valuesof two DC sources, V1 and V2 in the netlist properly as described below. Fol-low the procedures for drain characteristics first. After obtaining the requiredplots do the procedures for the transfer characteristics and obtain the requiredcharcteristics curves.

• Drain Charcteristics: Give the values of DC variables as shown inFigure 9.5. Enter the name of your DC source V2 and let its value bevaried from 0V to 20V with a step of 0.1 V.

• Transfer Charcteristics: Give the values of DC variables as shown inFigure 9.6. Enter the name of your DC source V1 and let its value bevaried from 0V to 4V with a step of 0.1 V.

Figure 9.5: Choose DC analysis type and enter the values of V2

Page 77: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

77

Figure 9.6: Choose DC analysis type and enter the values of V1

Source Details:

• Drain Charcteristics: Give the value of DC variables as shown in Figure9.7. Leave the column of V2 blank. Give the value of V1 as 3V, whichis the gate voltage. (You may repeat the experiment by varying the gatevoltage as V1=4V, V1=6V etc.)

Figure 9.7: Enter the details of fixed source V1

• Transfer Charcteristics: Give the value of DC variables as shown inFigure 9.8. Leave the column of V1 blank. Give the value of V2 as 10V,which is the drain voltage.

Ngspice Model: No Ngspice model to be given.

Device Model: The MOSFET is a device whose model details must be givenfor simulation. Let us choose the generic N-chnnel MOSFET model availabe inthe eSim model library. Browse it from /opt/eSim/src/deviceModelLibrary/MOS/NMOS-5um.lib.See Figure 9.9.

Page 78: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

78 CHAPTER 9. MOSFET CHARACTERISTICS

Figure 9.8: Enter the details of fixed source V2

Figure 9.9: Choose the required MOSFET model

Subcircuits: No subcircuits to be given.

Once these details are provided click on convert button. Now you are readyto see the simulation results.

Simulate

To run Ngspice simulation click the simulation icon in the left tool bar. It willopen up two windows - ngspice plotting window and python plotting window.Inorder to plot the MOSFET characteristics let us use the commands in ngspiceplotting window. We need to plot the drain charcteristics as well as transfercharacteristics.

Page 79: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

79

Drain Characteritics: In the ngspice plotting window, type the followingcommand:

plot -i(v2) vs v(drain)This would pop up the drain characteristics of the MOSFET as defined in the

MOSFET model NMOS-5um.lib. For a differnt device model the characteristicswould be slightly different.

The resultant characteristics is shown in the Figure 9.10.

Figure 9.10: The drain characteristics of MOSFET with gate voltage =3V

Transfer Characteritics: In the ngspice plotting window, type the followingcommand:

plot -i(v2) vs v(gate)This would pop up the transfer characteristics of the MOSFET as defined

in the MOSFET model NMOS-5um.lib. For a differnt device model the char-acteristics would be slightly different.

The resultant characteristics is shown in the Figure 9.11.

RESULTThe circuit for plotting the charateristics of MOSFET was implemented andsimulated.

Page 80: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

80 CHAPTER 9. MOSFET CHARACTERISTICS

Figure 9.11: The transfer characteristics of MOSFET with drain voltage =10V

Page 81: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

Chapter 10

BJT COMMON EMITTERCHARACTERISTICS

AIMTo design and implement a circuit for simulating the output characteristics

of a NPN Bipolar Junction Transistor.

DESIGN AND CIRCUIT DIAGRAMIn common emitter configuration the emitter terminal is grounded. Input

characteristics is the plot between the base current ib and base -emitter volatageVbe, keeping the collector voltage constant. Output characteristics is the plotbetween the collector current Ic and the colector- emitter volatage Vce

Inorder to draw the BJT CE output characteristics,we have to use a DCsource of current at the base terminal which may be kept constsnt during simu-lation. Different plots can be obtained by keeping the base current at a differentconstant value. The BJT in the circuit should be associated with a coresponding‘NPN BJT model’ during simulations. The resulting circuit diagram is shownin the Figure 10.1.

The output characteristics is a plot between collector current and collector-emitter voltage while keeping the base current constant.

PROCEDURELaunch eSim

Launching eSim will take you to the dialog box which asks for the defaultworkspace. Browse the folders and set the wokspace location. It will finally endup in the eSim window

81

Page 82: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

82 CHAPTER 10. BJT COMMON EMITTER CHARACTERISTICS

Create a New Project

The new project is created by clicking the New icon on the menubar. Thename of the project is given in the pop up window.

Create the Schematic

To create the schematic, click the very first icon of the left toolbar.This willopen KiCad Eeschema.

To create a schematic in KiCad, we need to place the required components.Clicking on the icon on the right toolbar opens the component library. After

all the required components of the circuit are placed, wiring is done using thePlace Wire option. Scroll up and down for zooming in and out.

Placing the Components: Normally all the components availbale in eSimcan be chosen by left mouse click in the grid. The components are listed indifferent libraries.

• Choose DC sources from eSim_Sources

• Choose resistors from eSim_Devices

• Choose NPN from eSim_Devices

• Choose GND from power

• Choose plot_i2 from eSim_Plots

Wire the components to get the circuit. A global labels ‘ib’ and ‘vce’ havebeen added to identify the nodes.

Now we have the circuit diagram as shown in Figure 10.1.

Annotating the circuit: Once the schematic diagram is completed, annotateit so that the ‘question marks’ associated with the components are convertedto meaningful numbers automatically.For that choose annotate button from thetop toolbarand in the subsequenct dialogue boxes appearing click ok and finallyclose. See Figure 10.2.

Note: If some libraries are found missing, you can add them from the ‘Pref-erences‘ menu by following the procedure:

1. Choose ‘Component Libraries’ from Preferences menu.

2. Click on the Add button on the top right side of the window.

3. Choose the required libraries from ‘user/share/kicad/library’ and click OKbutton

Page 83: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

83

Figure 10.1: Schematic diagram for CE output characteristics

Create Netlist

To simulate the circuit that has been created in the previous section, we needto generate its netlist. Netlist is a list of components in the schematic alongwith their connection information. To do so, click on the Generate netlist toolfrom the top toolbar. Click on spice from the window that opens up. Check theoption Default Format. Then click on Generate. Save the netlist. This will bea .cir file. Do not change the directory while saving.See Figure 10.3. Now thenetlist is ready to be simulated.

KiCad to Ngspice conversion

To convert KiCad netlist of the circuit to NgSpice compatible netlist click onKiCad to Ngspice icon as shown in Figure 10.4. Now you can choose the typeof analysis, source details, device models ngspice models and subcircuit models.

Analysis: Choose DC analysis type. Choose the values of two DC sources,V1 and I1 in the netlist properly as described below. Change V1 from 0V to 5Vat an interval of 0.05V. I1 is to be changed from 0 mA to 5 mA at an incrementof 1 mA. See Figure 10.5

Source: Give the details of source as in Figure 10.6.

Ngspice Model: No Ngspice model to be given.

Page 84: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

84 CHAPTER 10. BJT COMMON EMITTER CHARACTERISTICS

Figure 10.2: AnnotationFigure 10.3: Netlist Generation

Figure 10.4: Choose Kicad to Ngspice tool

Device Model: The NPN transistor is a device whose model details must begiven for simulation. Let us choose the generic NPN model availabe in the eSimmodel library. Browse it from /opt/eSim/src/deviceModelLibrary/Transistor/NPN.lib.See Figure 10.7.

Subcircuits: No subcircuits to be given.

Once these details are provided click on convert button. Now you are readyto see the simulation results.

Simulate

To run Ngspice simulation click the simulation icon in the left tool bar. Sincewe have used plot components, the required output characteristic plots willautomatically pop-up as shown in Figure. 10.8

Page 85: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

85

Figure 10.5: Choose DC analysis type and enter the values of V1 and I1

Figure 10.6: GiveSource Details of V1 and I1

RESULTThe circuit for plotting the common emitter charateristics of NPN transistorwas implemented and simulated.

Page 86: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

86 CHAPTER 10. BJT COMMON EMITTER CHARACTERISTICS

Figure 10.7: Choose the required NPN model

Figure 10.8: The output characteristics of NPN transistor

Page 87: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

Chapter 11

BJT COMMON BASECHARACTERISTICS

AIMTo design and implement a circuit for simulating the output characteristics

of a NPN Bipolar Junction Transistor in common base configuration.

DESIGN AND CIRCUIT DIAGRAMIn common base configuration the base terminal is grounded. Input charac-

teristics is the plot between the emitter current ib and collector-base volatageVcb, keeping the collector voltage constant. Output characteristics is the plotbetween the collector current Ic and the colector- baser volatage Vbe

Inorder to draw the BJT CB output characteristics,we have to use a DCsource of current at the base terminal which may be kept constant during sim-ulation. Different plots can be obtained by keeping the emitter current at adifferent constant value. The BJT in the circuit should be associated with acoresponding ‘NPN BJT model’ during simulations. The resulting circuit dia-gram is shown in the Figure 11.1.

The output characteristics is a plot between collector current and collector-base voltage while keeping the emitter current constant.

PROCEDURELaunch eSim

Launching eSim will take you to the dialog box which asks for the defaultworkspace. Browse the folders and set the wokspace location. It will finally endup in the eSim window

87

Page 88: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

88 CHAPTER 11. BJT COMMON BASE CHARACTERISTICS

Create a New Project

The new project is created by clicking the New icon on the menubar. Thename of the project is given in the pop up window.

Create the Schematic

To create the schematic, click the very first icon of the left toolbar.This willopen KiCad Eeschema.

To create a schematic in KiCad, we need to place the required components.Clicking on the icon on the right toolbar opens the component library. After

all the required components of the circuit are placed, wiring is done using thePlace Wire option. Scroll up and down for zooming in and out.

Placing the Components: Normally all the components availbale in eSimcan be chosen by left mouse click in the grid. The components are listed indifferent libraries.

• Choose DC sources from eSim_Sources

• Choose resistors from eSim_Devices

• Choose NPN from eSim_Devices

• Choose GND from power

• Choose plot_i2 from eSim_Plots

Wire the components to get the circuit. A global labels ‘ie’ and ‘vcb’ havebeen added to identify the nodes.

Now we have the circuit diagram as shown in Figure 11.1.

Annotating the circuit: Once the schematic diagram is completed, annotateit so that the ‘question marks’ associated with the components are convertedto meaningful numbers automatically.For that choose annotate button from thetop toolbarand in the subsequenct dialogue boxes appearing click ok and finallyclose. See Figure 11.2.

Note: If some libraries are found missing, you can add them from the ‘Pref-erences‘ menu by following the procedure:

1. Choose ‘Component Libraries’ from Preferences menu.

2. Click on the Add button on the top right side of the window.

3. Choose the required libraries from ‘user/share/kicad/library’ and click OKbutton

Page 89: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

89

Figure 11.1: Schematic diagram for CE output characteristics

Create Netlist

To simulate the circuit that has been created in the previous section, we needto generate its netlist. Netlist is a list of components in the schematic alongwith their connection information. To do so, click on the Generate netlist toolfrom the top toolbar. Click on spice from the window that opens up. Check theoption Default Format. Then click on Generate. Save the netlist. This will bea .cir file. Do not change the directory while saving.See Figure 11.3. Now thenetlist is ready to be simulated.

KiCad to Ngspice conversion

To convert KiCad netlist of the circuit to NgSpice compatible netlist click onKiCad to Ngspice icon as shown in Figure 11.4. Now you can choose the typeof analysis, source details, device models ngspice models and subcircuit models.

Analysis: Choose DC analysis type. Choose the values of two DC sources, V1and I1 in the netlist properly as described below. Change V1 from -1V to 5V atan interval of 0.02V. I1 is to be changed from -1 mA to 5 mA at an incrementof 1 mA. See Figure 11.5

Source: Give the details of source as in Figure 11.6.

Ngspice Model: No Ngspice model to be given.

Page 90: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

90 CHAPTER 11. BJT COMMON BASE CHARACTERISTICS

Figure 11.2: AnnotationFigure 11.3: Netlist Generation

Figure 11.4: Choose Kicad to Ngspice tool

Device Model: The NPN transistor is a device whose model details must begiven for simulation. Let us choose the generic NPN model availabe in the eSimmodel library. Browse it from /opt/eSim/src/deviceModelLibrary/Transistor/NPN.lib.See Figure 11.7.

Subcircuits: No subcircuits to be given.

Once these details are provided click on convert button. Now you are readyto see the simulation results.

Simulate

To run Ngspice simulation click the simulation icon in the left tool bar. Sincewe have used plot components, the required output characteristic plots willautomatically pop-up as shown in Figure. 11.8

Page 91: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

91

Figure 11.5: Choose DC analysis type and enter the values of V1 and I1

Figure 11.6: Give Source Details of V1 and I1

RESULTThe circuit for plotting the common base charateristics of NPN transistor wasimplemented and simulated.

Page 92: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

92 CHAPTER 11. BJT COMMON BASE CHARACTERISTICS

Figure 11.7: Choose the required NPN model

Figure 11.8: The output characteristics of NPN transistor

Page 93: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

Chapter 12

ZENER REGULATORWITH SERIES PASSTRANSISTOR

AIM

To design and implement a zener diode regulator with series pass transistor andto plod the line regulation characteristics.

DESIGN AND CIRCUIT DIAGRAM

Zener diode maintains a constant voltage acroos its terminals when reversebiased and the applied volatage is above the reverse breakdown voltage of thediode.

The circuit diagram for implementing a series pass transistor zener dioderegulator is shown in Figure 12.10.

PROCEDURE

Launch eSim

Launching eSim will take you to the dialog box. It asks for the defaultworkspace. Browse the folders and set the wokspace location. It will end up inthe eSim window shown in Figure 12.1.

93

Page 94: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

94CHAPTER 12. ZENER REGULATOR WITH SERIES PASS TRANSISTOR

Figure 12.1: Launching eSim will take you to this window

Create a New Project

The new project is created by clicking the New icon on the menubar. Givethe name of the project ,’ZenerRegulator’ in the pop up window as shown inFigure.12.2.

Figure 12.2: Creating new project

Create the Schematic

To create the schematic, click the very first icon of the left toolbar as shownin the Figure 12.3 .This will open KiCad Eeschema.

Page 95: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

95

Figure 12.3: Creating new schematic diagram

To create a schematic in KiCad, we need to place the required components.See Figure 12.4. Figure 12.5 shows the icon on the right toolbar which opens thecomponent library. After all the required components of the simple RC circuitare placed, wiring is done using the Place Wire option as shown in the Figure12.6. Scroll up and down for zooming in and out.

Figure 12.4: The Kicad Eeschema page

Page 96: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

96CHAPTER 12. ZENER REGULATOR WITH SERIES PASS TRANSISTOR

Figure 12.5: Place component icon Figure 12.6: Place wire icon

Placing the Components: Normally all the components availbale in eSimcan be chosen by left mouse click in the grid. The components are listed indifferent libraries. See Figure 12.7.

Figure 12.7: The Kicad Libraries of components

• Choose DC source from eSim_Sources

• Choose R from eSim_Devices

• Choose zener from eSim_Devices

Page 97: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

97

• Choose NPN from eSim_Devices

• Choose plot_v1 from eSim_Plot

• Choose GND from power

Select the resistor and edit its component value to 1k as shown in Figure12.8.

Figure 12.8: Editing the value field of component R

Wire the components to get the circuit. A global label ‘in’ and ‘out’ has beenadded to identify that node whose voltage will be later recorded and plotted.

Annotating the circuit: Once the schematic diagram is completed, annotateit so that the ‘question marks’ associated with the components are convertedto meaningful numbers automatically.For that choose annotate button from thetop toolbar(See Figure 12.9 and in the subsequenct dialogue boxes appearingclick ok and finally close. See Figure 12.11.

Page 98: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

98CHAPTER 12. ZENER REGULATOR WITH SERIES PASS TRANSISTOR

Figure 12.10: Schematic diagram for Zener Diode Regulator

Figure 12.9: Choose annotate from the toop tool bar

Now we have the circuit diagram as shown in Figure 12.10.

Note: If some libraries are found missing, you can add them from the ‘Pref-erences‘ menu by following the procedure:

1. Choose ‘Component Libraries’ from Preferences menu.

2. Click on the Add button on the top right side of the window.

Page 99: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

99

Figure 12.11: AnnotationFigure 12.12: Netlist Generation

3. Choose the required libraries from ‘user/share/kicad/library’ and click OKbutton

Create Netlist

To simulate the circuit that has been created in the previous section, we needto generate its netlist. Netlist is a list of components in the schematic alongwith their connection information. To do so, click on the Generate netlist toolfrom the top toolbar. Click on spice from the window that opens up. Checkthe option Default Format. Then click on Generate. Save the netlist. This willbe a *.cir file. Do not change the directory while saving.See Figure 12.12. Nowthe netlist is ready to be simulated.

KiCad to Ngspice conversion

To convert KiCad netlist of the circuit to NgSpice compatible netlist click onKiCad to Ngspice icon as shown in Figure 12.13. Now you can choose the typeof analysis, source details, device models ngspice models and subcircuit models.

Figure 12.13: Choose Kicad to Ngspice tool

Page 100: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

100CHAPTER 12. ZENER REGULATOR WITH SERIES PASS TRANSISTOR

Analysis: Choose DC analysis type. Give the values of DC variables as shownin Figure 12.14. Enter the name of your DC source as on the circuit (here v1)and let its value be varied from 6V to +15V with a step of 1 V.

Figure 12.14: Choose DC analysis type and enter the values

Source Details: Leave this empty.

Ngspice Model: Ngspice model of zener diode will be loaded. You can seethe default values of various zener parameters there. You can change thoseif required. In this example the breakdown voltage has been set as 8V. SeeFigure.12.15

Figure 12.15: Choose ngspice model values

Device Model: The NPN Transistor is a device whose model details must begiven for simulation. Let us choose the generic BJT model availabe in the eSimmodel library. Browse it from /opt/eSim/src/deviceModelLibrary/Transistor/NPN.lib.See Figure 12.16.

Page 101: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

101

Figure 12.16: Choose the required Transistor model

Subcircuits: No subcircuits to be given.Once these details are provided click on convert button. See Figure 12.16. Nowyou are ready to see the simulation results.

Simulate

To run Ngspice simulation click the simulation icon in the left tool bar. It willopen up two windows - ngspice plotting window and python plotting window.Inorder to plot the voltages at input and output let us use the commands inngspice plotting window.

Since we have used eSim_plot components at in and out, simulate buttonclick will automatically plot the voltages.

To plot the value of voltages on a signle plot window type the followingcommand

plot v(in), v(out)This would pop up the required characteristics fo the diode as defined in

the diode model D.lib. For a differnt diode model the characteristics would beslightly different.

The resultant characteristics is shown in the Figure 12.17.

Page 102: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

102CHAPTER 12. ZENER REGULATOR WITH SERIES PASS TRANSISTOR

Figure 12.17: The line regulation characteristics of zener diode

RESULTThe circuit for plotting the charateristics of zener regulator was implementedand simulated.

Page 103: Electronic Circuit Simulation using eSim - thottingal.in · Preface Thisisaquickguidetodesignandsimulateelectroniccircuitsusingopensource EDAtool-eSim. eSim is an open source EDA

Bibliography

[1] User Manual of eSim by FOSSEE, IIT Bombay.(http://esim.fossee.in/resource/book/esimusermanual.pdf

103