ESim/C2/Editing-a-Subcircuit/English

From Script | Spoken-Tutorial
Revision as of 16:53, 5 August 2020 by Glorianandihal (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Editing a Subcircuit in eSim

Author: Gloria N

Keywords: eSim, Subcircuit, KiCad, Eeschema, Subcircuit, Part library,Port


Visual cue Narration
Show Slide:

Opening Slide

Welcome to the spoken tutorial on Editing a Subcircuit in eSim.
Show Slide:

Learning Objectives

In this tutorial, using eSim we will learn to-
  • To edit a Subcircuit.
  • To modify the component schematic.
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
  • To create and simulate a circuit and a subcircuit in eSim.

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

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:

Clicking on Subcircuit

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

A subcircuit tab will open up.

In the previous tutorial, we have seen to create a Subcircuit.

Subcircuit tab:

Click Edit Subcircuit Schematic>>

Double click half_adder>>

Click Open

Let us now edit a Subcircuit of a Half adder.

In the subcircuit tab, click on the Edit Subcircuit Schematic button.

The Subcircuit library opens up.

Select the half underscore adder and click on the Open button.

The schematic of Half adder subcircuit opens in eeschema.

eSim Schematic Window

Press F1

Press F1 key to zoom in the schematic.

Let us connect an additional Inverter gate to the output of the AND gate.

eSim Schematic Window:

Select Place Component from right toolbar>>

click on editor>>

Type eSim_Digital in the filter field>>

select d_inverter>>

click OK.

On eeschema, click on the Place Component tool from the right toolbar.

Click on the editor.

In the Filter field, type eSim underscore Digital.

Select d underscore Inverter and click on the OK button.

Place it below the PORT D.

The inverter is tied to the cursor.

Place it below the PORT D.

eSim Schematic Window:

Connecting AND gate and Inverter gate

Connect a wire from Pin 3 of the AND gate to Pin 1 of the Inverter gate.

A junction will be placed.

eSim Schematic Window:

Select Place Component from right toolbar>>

click on editor>>

Type eSim_Miscellaneous in the filter field>>

select PORT>>

select Unit E >>

click OK

Now, we will connect a Port to the Inverter output.

Click on the Place Component tool from the right toolbar.

Click on the editor.

In the Filter field, type eSim underscore Miscellaneous.

Select Port from the list.

Click on the drop-down arrow.

Select Unit E and click on the OK button.

eSim Schematic Window:

Place it near the output pin of the Inverter >>

Place the cursor on the Port Unit E >>

press the R key to rotate.

Place the Port E near the output pin of the Inverter.

Place the cursor on the Port Unit E and press the R key to rotate.

In the clarify selection window, select component Port U and press the R key.

Connect the output pin of the Inverter to Port Unit E.

The Port Unit E will be pin 5 of the component schematic.

eSim Schematic Window:

Click on Annotate schematic components from top toolbar >>

click Annotate >>

click OK

Press Ctrl+S keys together

Now we will annotate the schematic.

Click on the Annotate schematic components icon from the top toolbar.

Keep the default settings.

Click on the Annotate button.

Click on the OK button.

Press Ctrl+S keys together to save the schematic.

eSim Schematic Window:

Click Generate netlist>>

select Spice tab >>

check Default format>>

click on Generate.

Click Save

To generate a netlist, click on Generate Netlist.

Select the Spice tab and check the Default Format.

Click on the Generate button.

Then click on the Save button.

This creates the KiCad netlist of the half adder subcircuit.

eSim Main Window:

Subcircuit tab >>

Click on Convert Kicad to Ngspice

Point to transient analysis parameters

Point to Ngspice Model and Device Modeling tabs

Let us go back to the eSim window.

In the Subcircuit tab, click on the Convert Kicad to Ngspice button.

You can specify the transient analysis parameters or leave them blank.

I am leaving these values blank.

Skip the Ngspice Model and Device Modeling tabs.

If any device modeling or subcircuit is used, please specify here.

eSim Main Window:

Subcircuit tab

Press Convert >>

Click OK

Press the Convert button in the Kicad to Ngspice tab.

Click on the OK button in the information dialog box.

This creates the Ngspice netlist of the Subcircuit.

eSim Schematic Window: An additional port is added to the Half adder subcircuit.

Hence, the component schematic has to be modified to include pin 5.

eSim Schematic Window:

Back to Half Adder schematic.

Directing to Part Library Editor window

Go back to the Half Adder schematic.

On the schematic editor, click on the Library Editor icon from the top toolbar.

It directs us to the Part Library Editor window.

Part Library Editor window:

Adding Current Library

Click on the File option from the top menu, and click on the Current Library option.

Scroll down and choose eSim underscore Subckt.

Click on the OK button.

Part Library Editor window:

Hover the mouse on the top of the Part library editor window pointing /usr/share/kicad/library/eSim_Subckt

You can see the path of the selected library is displayed on top of the Part Library window.
Part Library Editor window:

Loading the component from the current library.

Click on the Load component to edit from the current library icon in the top toolbar.

Click on the half underscore adder and click on the OK button.

Part Library Editor window:

Moving the pin 4 of the component schematic

Place the cursor on Pin 4, Cout.

Press M key to move the pin and place it just below pin 3.

Part Library Editor window:

Demo of adding Pin 5, Out to the Half Adder component.

Click on Add pins to component tool from the right toolbar.

Click on the editor.

Pin Properties window will appear.

Enter Pin name as Out.

If you wish, you can give any other Pin name of your choice.

Pin Number should match with the Port Unit Name.

Port E represents Pin 5 of the subcircuit.

Enter Pin Number as 5.

Enter Orientation as left as it is an output pin.

Enter Electrical Type as Output.

Keep Graphic Style as Line.

You can choose Orientation and Electrical Type based on the requirement of the subcircuit.

Click on the OK button.

The pin is attached to the cursor.

Place it below Pin 4 with a single click.

Part Library Editor window:

Save the current component schematic

Now, let us save the schematic symbol.

Press Ctrl+S keys together to save the schematic.

In the confirmation box click on the Yes button.

In the second confirmation box, click on the Yes button.

Part Library Editor window:

Point to Update current component in current library option from the top toolbar.

You can save the component using the Save Current Library to Disc icon from the top toolbar.

You can select the current library using the Select Working Library option.

You can delete the component using the Delete option.

You can also use Update current component in current library option from the top toolbar.

This will save the modified component to the current library.

Part Library Editor window:

Point to Create a new component from the current one in the top toolbar.

There is an option Create a new component from the current one in the top toolbar.

This imports the schematic of the components and can be used to create a new one.

Part Library Editor window:

Click on File from top menu>>

choose Quit

Let us now close the Part Library Editor window.
eSim Main Window:

Open Project Half underscore Adder

Now, let us simulate a circuit with the newly added subcircuit and its component.

Let us open the Half underscore Adder from the Example folder of eSim.

On the eSim window, click on the Open Project button from the top menu.

Locate the directory where eSim is installed and click on the Example folder.

Select Half underscore Adder and then click on Open.

The Half underscore Adder is added to the eSim window under Projects.

eSim Main Window:

Select Half_Adder from Projects>>

Click on the Open Schematic option from the left toolbar

To open the schematic, select Half Adder from Projects.

Click on the Open Schematic button from the left toolbar.

eSim Schematic Window:

Place cursor on schematic and press F1

It directs us to the schematic editor.

Zoom in the schematic by pressing F1 key.

eSim Schematic Window:

Place and connect half adder subcircuit

Let us replace the Half Adder subcircuit with the modified Half Adder component.

Click on the Place Component tool from the left toolbar.

Click on the editor.

In the filter field, type eSim underscore Subckt.

Scroll down and select the half underscore adder.

Click on the OK button.

Place and connect it as shown here.

eSim Schematic Window:

Demo of adding dac bridge 1 to the pin 5

Connecting Plot_V to the DAC

Adding a Global Label Out

Similarly connect DAC , plot V1 and global label out as shown here.
eSim Schematic Window:

Performing Annotation.

Generating the Netlist.

Saving the schematic.

Now annotate the schematic using Annotate Schematic Components from the top toolbar.

Generate the Spice netlist.

Refer to previous tutorials to learn annotation and generating netlist of the schematic.

Save the schematic by pressing Ctrl+S keys together.

eSim Main Window:

Click on Convert Kicad to Ngspice

Let us go back to the eSim window.

Click on Convert Kicad to Ngspice from the left toolbar

Kicad to Ngspice Converter:

In the Analysis Tab:

Let us not change the Transient Analysis parameters.
Kicad to Ngspice Converter:

Source Details Tab V1: Enter Value>>5 Source Details Tab V2: Enter Value>>5

Click on the Source details tab.

Enter 5V for DC source, V1 and V2.

Kicad to Ngspice Converter:

Subcircuit Tab

Click on ADD >>

click on Half underscore Adder >>

click Open

Skip the Ngspice Model and Device Modeling tab.

In the Subcircuit tab, click on the ADD button.

Click on Half underscore Adder and then click on the Open button.

In the KiCad to Ngspice tab, press the Convert button.

Click the OK button in the Confirmation box.

eSim Main Window:

Click on Simulation

To generate plots, click on the Simulation button from the left toolbar.
Ngspice Terminal:

Highlight the sum and carry and out output.

An Ngspice terminal and plot windows open along with a python plot window.

Since both the inputs are 5 volts, the sum is 0,

carry will be 5 volts and the Out will be 0 volts.

Close the Ngspice plots and terminal windows.

Python Plot Window:

Check sum node >>

check cout node >>

click Plot

In the Python plot, check the Sum node,cout node and the Out node.

Click on the Plot button.

You can see the plots for sum,cout and Out nodes.

Close the Python plot.

Show Slide:

Summary

Let us summarise.

In this tutorial, we learnt-

  • To edit a Subcircuit and
  • To modify the component schematic.
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