Difference between revisions of "ESim/C2/Uploading-a-spice-Subcircuit-file/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with "'''Uploading a spice Subcircuit file in eSim''' '''Author: Gloria N ''' '''Keywords: esim, Subcircuit, KiCad, Eeschema, .include, device models {| border="1" |- | style="c...")
 
 
Line 18: Line 18:
 
||'''Show Slide:'''
 
||'''Show Slide:'''
 
Learning Objectives
 
Learning Objectives
||In this tutorial, using '''eSim''' we will learn to-
+
||In this tutorial, using '''eSim''' we will learn to upload an external '''spice subcircuit''' file in '''eSim'''.
*Upload an external spice '''Subcircuit''' file in '''eSim'''.
+
  
 
|-
 
|-
Line 31: Line 30:
 
||'''Show Slide:'''
 
||'''Show Slide:'''
 
Pre-requisites
 
Pre-requisites
||To practice this tutorial, you should know how to create and simulate a circuit in '''eSim'''.
+
||To practice this tutorial, you should know how to create and '''simulate''' a '''circuit''' and '''subcircuit''' in '''eSim'''.
  
 
If not, watch the prerequisite '''eSim''' tutorials on this website.
 
If not, watch the prerequisite '''eSim''' tutorials on this website.
Line 38: Line 37:
 
||'''Show Slide:'''
 
||'''Show Slide:'''
 
General form of Subcircuit
 
General form of Subcircuit
||The subcircuit file always begins with the dot '''subckt''' statement.
+
||The '''subcircuit''' file always begins with the '''dot subckt''' statement.
  
'''Subname''' is the subcircuit component name.
+
'''Subname''' is the '''subcircuit component''' name.
  
'''N1''','''N2'''  are the nodes.
+
'''N1, N2'''  are the nodes.
  
The subcircuit ends with dot '''ENDS''' followed by the subcircuit name.
+
The '''subcircuit''' ends with '''dot Ends''' followed by the '''subcircuit''' name.
  
 
|-
 
|-
 
||'''Show Slide:'''
 
||'''Show Slide:'''
 
Introduction
 
Introduction
||This option is available in the '''eSim 2''' point '''0''' and later versions.
+
||This option is available in the '''eSim 2 point 0''' and later versions.
  
The subcircuit file is added to the '''eSim subcircuit''' library.
+
The '''subcircuit''' file is added to the '''eSim subcircuit library'''.
  
You can also refer to the subcircuit files available in the '''Ngspice''' manual.
+
You can also refer to the '''subcircuit''' files available in the '''Ngspice''' manual.
  
 
|-
 
|-
Line 70: Line 69:
 
||On the '''eSim''' main window, click on the '''Subcircuit''' button from the left toolbar.
 
||On the '''eSim''' main window, click on the '''Subcircuit''' button from the left toolbar.
  
In the previous tutorial, we have seen how to create a '''new''' subcircuit and '''edit''' an existing subcircuit.
+
In the previous tutorial, we have seen how to create a new''' subcircuit''' and edit an existing '''subcircuit'''.
  
 
|-
 
|-
Line 77: Line 76:
 
||Pause the video here.
 
||Pause the video here.
  
Download '''Fulladder_using_Nand''' text file from the '''Code''' file section available on this page.
+
Download '''Fulladder_using_Nand''' text file from the '''Code file''' section available on this page.
  
Save it on '''Desktop''' with a  dot '''sub''' extension.
+
Save it on '''Desktop''' with a  '''dot sub''' extension.
  
 
|-
 
|-
Line 97: Line 96:
 
||Double-click on the '''Desktop''' folder.
 
||Double-click on the '''Desktop''' folder.
  
Click on '''Full_adder_using_Nand''' dot '''sub''' and then click on the '''Open''' button.
+
Click on '''Full_adder_using_Nand dot sub''' and then click on the '''Open''' button.
  
 
|-
 
|-
 
||'''System computer:'''
 
||'''System computer:'''
 
Opening the subcircuit '''FA using NAND''' folder.
 
Opening the subcircuit '''FA using NAND''' folder.
||The subcircuit uploaded using '''Upload''' option loads only '''.sub''' file.
+
||The '''subcircuit''' uploaded using '''Upload''' option loads only '''dot sub''' file.
  
As you can see here, only dot '''sub''' files will be available.
+
As you can see here, only '''dot sub''' files will be available.
  
 
No '''sch''' or '''cir''' files will be present in this folder.
 
No '''sch''' or '''cir''' files will be present in this folder.
Line 120: Line 119:
 
Click '''Open'''
 
Click '''Open'''
  
||Let us simulate the '''Full Adder''' example with the newly added subcircuit library.
+
||Let us simulate the '''Full Adder''' example with the newly added '''subcircuit library'''.
  
 
Open the '''FullAdder''' example from the '''Examples''' folder of '''eSim''' installer.
 
Open the '''FullAdder''' example from the '''Examples''' folder of '''eSim''' installer.
Line 136: Line 135:
 
click on '''Convert Kicad to Ngspice'''
 
click on '''Convert Kicad to Ngspice'''
  
||On the '''eSim''' window, select '''FullAdder''' under Projects.
+
||On the '''eSim''' window, select '''FullAdder''' under '''Projects'''.
  
 
Then click on '''Convert Kicad to Ngspice''' button from the left toolbar.
 
Then click on '''Convert Kicad to Ngspice''' button from the left toolbar.
Line 146: Line 145:
 
'''Source Details''' Tab
 
'''Source Details''' Tab
  
||Let the '''transient analysis''' parameters and '''Source details''' be the same.  
+
||Let the '''transient analysis parameters''' and '''Source details''' be the same.  
  
 
We will not change it.
 
We will not change it.
Line 181: Line 180:
 
||'''Ngspice plot:'''
 
||'''Ngspice plot:'''
  
||An '''Ngspice''' terminal and ''plot'' windows open along with a '''python''' plot window.
+
||An '''Ngspice terminal''' and '''plot''' windows open along with a '''Python plot''' window.
  
We have given the inputs as '''5''', '''5''' and '''0'''.
+
We have given the '''inputs''' as '''5, 5''' and '''0'''.
  
Hence, the output for '''Sum''' is '''0''' volts and '''Carry''' is '''5''' volts.
+
Hence, the '''output''' for '''Sum''' is '''0''' volts and '''Carry''' is '''5''' volts.
  
Close the '''Ngspice''' terminal and plot windows.
+
Close the '''Ngspice terminal''' and '''plot''' windows.
  
 
|-
 
|-
Line 196: Line 195:
  
 
click '''Plot'''
 
click '''Plot'''
||In the '''python''' plot window, check the '''Sum''' node and '''Cout''' node.
+
||In the '''Python plot''' window, check the '''Sum''' node and '''Cout''' node.
  
 
And click on the '''Plot''' button.
 
And click on the '''Plot''' button.
Line 218: Line 217:
 
open '''UJT.sub''' file.
 
open '''UJT.sub''' file.
  
||The subcircuit file can also have ''model'' or ''subcircuit'' components within it.
+
||The '''subcircuit''' file can also have '''model''' or '''subcircuit components''' within it.
  
These components can be from existing '''eSim''' libraries.
+
These '''components''' can be from existing '''eSim libraries'''.
  
If the models or subcircuits are not present in '''eSim''' library then the user has to define the same.
+
If the '''models''' or '''subcircuits''' are not present in '''eSim library''' then the user has to define the same.
  
For example: Let us open the '''UJT''' subcircuit file present in '''eSim'''.
+
For example: Let us open the '''UJT subcircuit''' file present in '''eSim'''.
  
In this file, there is a '''subcircuit''' of a '''Half adder''' and this is from '''eSim''' libraries.
+
In this file, there is a '''subcircuit''' of a '''Half adder''' and this is from '''eSim libraries'''.
  
Hence the statement, dot '''include''' is added in this file.
+
Hence the statement, '''dot include''' is added in this file.
  
 
|-
 
|-
Line 236: Line 235:
 
Explaining the '''model RMOD''' and '''model Emitter'''  
 
Explaining the '''model RMOD''' and '''model Emitter'''  
  
||Here, the '''model RMOD''' and '''Emitter''' are the two models which are defined by the user.
+
||Here, the '''model RMOD''' and '''Emitter''' are the two '''models''' which are defined by the user.
  
These model files are not available under '''eSim''' libraries.
+
These '''model''' files are not available under '''eSim libraries'''.
 
   
 
   
Hence, you need to mention the parameters in the '''spice model''' format.
+
Hence, you need to mention the '''parameters''' in the '''spice model''' format.
  
If any subcircuit is used, then the parameters are defined in the '''spice subcircuit''' format.
+
If any '''subcircuit''' is used, then the '''parameters''' are defined in the '''spice subcircuit''' format.
  
 
|-
 
|-
Line 249: Line 248:
  
 
||Let us summarize.
 
||Let us summarize.
In this tutorial, we learnt to -
+
In this tutorial, we learnt to upload an external '''spice subcircuit''' file in '''eSim'''
*Upload an external spice '''Subcircuit''' file in '''eSim'''
+
  
 
|-
 
|-

Latest revision as of 15:30, 10 August 2020

Uploading a spice Subcircuit file in eSim

Author: Gloria N

Keywords: esim, Subcircuit, KiCad, Eeschema, .include, device models


Visual cue Narration
Show Slide:

Opening Slide

Welcome to the spoken tutorial on Uploading a spice Subcircuit file in eSim.
Show Slide:

Learning Objectives

In this tutorial, using eSim we will learn to upload an external spice subcircuit file in eSim.
Show Slide:

Systems Requirements

To record this tutorial, we will use-
  • Ubuntu Linux OS version 16.04
  • eSim version 2.0
Show Slide:

Pre-requisites

To practice this tutorial, you should know how to create and simulate a circuit and subcircuit in eSim.

If not, watch the prerequisite eSim tutorials on this website.

Show Slide:

General form of Subcircuit

The subcircuit file always begins with the dot subckt statement.

Subname is the subcircuit component name.

N1, N2 are the nodes.

The subcircuit ends with dot Ends followed by the subcircuit name.

Show Slide:

Introduction

This option is available in the eSim 2 point 0 and later versions.

The subcircuit file is added to the eSim subcircuit library.

You can also refer to the subcircuit files available in the Ngspice manual.

System Computer:

Desktop icon

To launch eSim, you need to double-click on the eSim icon on your Desktop.
System Computer:

eSim startup window

I have already opened eSim.
eSim Main Window:

Click on Subcircuit.

On the eSim main window, click on the Subcircuit button from the left toolbar.

In the previous tutorial, we have seen how to create a new subcircuit and edit an existing subcircuit.

Slide Show:

Code File

Pause the video here.

Download Fulladder_using_Nand text file from the Code file section available on this page.

Save it on Desktop with a dot sub extension.

Subcircuit tab:

Click on Upload a Subcircuit

Now, on the Subcircuit tab, click on Upload a Subcircuit option.

I have saved this file on my Desktop.

System Computer:

Double click on Desktop>>

click on Fulladder_using_Nand.sub >>

Click Open

Double-click on the Desktop folder.

Click on Full_adder_using_Nand dot sub and then click on the Open button.

System computer:

Opening the subcircuit FA using NAND folder.

The subcircuit uploaded using Upload option loads only dot sub file.

As you can see here, only dot sub files will be available.

No sch or cir files will be present in this folder.

eSim Main Window:

Click on Open Project option from top menu>>

click on eSim-2.0>>

Double click on Examples>>

select FullAdder >>

Click Open

Let us simulate the Full Adder example with the newly added subcircuit library.

Open the FullAdder example from the Examples folder of eSim installer.

Click on the Open Project option from the top menu.

Locate the directory where the eSim is installed and double-click on the Examples folder.

Now select the FullAdder example and click on the Open button.

eSim Main Window:

Select FullAdder under Projects>>

click on Convert Kicad to Ngspice

On the eSim window, select FullAdder under Projects.

Then click on Convert Kicad to Ngspice button from the left toolbar.

Kicad to Ngspice Converter:

Analysis Tab

Source Details Tab

Let the transient analysis parameters and Source details be the same.

We will not change it.

Skip the Ngspice Model and Device Modeling tab.

Kicad to Ngspice Converter:

Subcircuit Tab

Click on 'ADD>>

click on FA_using_NAND >>

click on Open.

Click on Convert button

Under the Subcircuits tab, click the ADD button.

Click on FA using NAND dot sub file.

Now click on the Open button.

On the Kicad to Ngspice tab, click on the Convert button.

eSim Main Window:

Click on Simulation.

On the eSim window, click on the Simulation button from the left toolbar.
Ngspice plot: An Ngspice terminal and plot windows open along with a Python plot window.

We have given the inputs as 5, 5 and 0.

Hence, the output for Sum is 0 volts and Carry is 5 volts.

Close the Ngspice terminal and plot windows.

Python Plot Window:

Check sum node >>

check cout node >>

click Plot

In the Python plot window, check the Sum node and Cout node.

And click on the Plot button.

You can see the output of the sum and carry node.

Close the Python plot window.

System Computer:

UJT.sub file

Open eSim 2.0 folder>>

Double click on Library folder >>

Double click on SubcircuitLibrary folder >>

Click on UJT folder>>

open UJT.sub file.

The subcircuit file can also have model or subcircuit components within it.

These components can be from existing eSim libraries.

If the models or subcircuits are not present in eSim library then the user has to define the same.

For example: Let us open the UJT subcircuit file present in eSim.

In this file, there is a subcircuit of a Half adder and this is from eSim libraries.

Hence the statement, dot include is added in this file.

System Computer:

UJT.sub file

Explaining the model RMOD and model Emitter

Here, the model RMOD and Emitter are the two models which are defined by the user.

These model files are not available under eSim libraries.

Hence, you need to mention the parameters in the spice model format.

If any subcircuit is used, then the parameters are defined in the spice subcircuit format.

Show Slide:

Summary

Let us summarize.

In this tutorial, we learnt to upload an external spice subcircuit file in eSim

Show Slide:

Forum to answer questions

https://forums.spoken-tutorial.org/

Do you have questions in this Spoken Tutorial?

Please visit this site.

Show Slide:

FOSSEE Forum

https://forums.fossee.in/

For any general or technical questions on eSim, visit the FOSSEE forum and post your question.
Show Slide:

Circuit Simulation

https://esim.fossee.in/circuit-simulation-project

The FOSSEE team coordinates the Circuit Simulation project.

We give Certificates and Honorarium to the contributors.

For more details, please visit this site.

Show Slide:

Lab Migration

https://esim.fossee.in/lab-migration-project

The FOSSEE team coordinates the Lab Migration project.

For more details, please visit this site.

Show Slide:

Acknowledgment

http://spoken-tutorial.org

Spoken Tutorial Project is funded by NMEICT, MHRD, Govt. of India.

For more details, visit this site.

Thank you slide This is Gloria N from IIT Bombay signing off.

Thank you

Contributors and Content Editors

Glorianandihal, Nancyvarkey