Difference between revisions of "ESim/C2/Subcircuit-Builder/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with "'''Subcircuit Builder in eSim''' '''Author: Gloria N ''' '''Keywords: eSim, Subcircuit, KiCad, Eeschema, Subcircuit, Part library, Schematic, Half adder, Subcircuit, Pin, Po...")
 
Line 628: Line 628:
  
 
||Do you have questions in this '''Spoken Tutorial'''?
 
||Do you have questions in this '''Spoken Tutorial'''?
 
Choose the minute and second where you have the question.
 
 
Explain your question briefly.
 
 
Someone from the '''FOSSEE''' team will answer them.
 
  
 
Please visit this site.
 
Please visit this site.

Revision as of 16:46, 5 August 2020

Subcircuit Builder in eSim

Author: Gloria N

Keywords: eSim, Subcircuit, KiCad, Eeschema, Subcircuit, Part library, Schematic, Half adder, Subcircuit, Pin, Port


Visual cue Narration
Show Slide:

Opening Slide

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

Learning Objectives

In this tutorial, using eSim we will learn to-
  • Create a Subcircuit and
  • Create a 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 how to create and simulate a circuit 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.

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:

Creating Subcircuit

Let us now create a Subcircuit for a Half adder.
eSim Main Window:

Click on Subcircuit

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

A subcircuit tab will open up.

Subcircuit tab:

Click on New Subcircuit Schematic >>

Enter Schematic Name as Halfadder_new>>

click OK

In the Subcircuit tab, click on the 'New Subcircuit Schematic button.

A New Schematic pop up window appears.

Enter Schematic Name as Halfadder underscore new.

Click on the OK button.

eSim Schematic Window:

Click Yes

Now, click the Yes button in the confirmation dialog box.

The schematic editor window opens up.

The user can create a schematic or import an existing schematic.

We will use the latter method.

To create a new schematic, you can refer to the previous tutorials in this series.

Slide show:

Adding Half_adder_basic_gates from the Code file section.

I have already created a half adder circuit using basic gates in eSim.

Pause the video here.

Download the Half Adder Basic Gates project file from the Code file section.

Extract and save the project file on the Desktop.

eSim Schematic Window:

Click on File>>

Click on Append Schematic Sheet>>

Click Yes

Click on Desktop>>

Double click on 'Half_adder_basic_gates >>

Select 'Half_adder_basic_gates.sch >>

click Open

On eeschema, click on the File option from the top menu.

Select Append Schematic Sheet option.

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

Click on Desktop.

Double-click on Half adder basic gates folder.

The schematic file, sch will be selected.

Click on the Open button in the file window.

You can see the schematic of the half adder is added to the editor.

eSim Schematic Window:

Zoom in the schematic

Press the F1 key, to zoom in the schematic.
eSim Schematic Window: Now we will connect ports to the input and output terminals of the gates.
eSim Schematic Window:

Click on Place Component Tool >>

click on editor>>

In the Filter field, type eSim_Miscellaneous >>

Select PORT >>

click on the Port drop-down>>

choose Unit A >>

click OK

Click on the Place component tool from the right toolbar.

Click on the editor.

In the Filter field, type eSim underscore Miscellaneous.

Select PORT and press the drop-down arrow.

Click on Unit A and click on the OK button.

Port Unit A will be tied to the cursor.

eSim Schematic Window:

Adding PORT A and PORT B

Place it near the input pin 1 of the XOR gate.

Similarly, place Port Unit B, near the input pin 1 of the AND gate.

eSim Schematic Window:

Adding PORT C and PORT D

Place Port Unit C and Port Unit D near the output pin of the XOR gate and AND gate respectively.

Here the Port unit indicates pins of the subcircuit.

Unit A is pin 1, Unit B, C and D are the pin number 2, 3,4 of the subcircuit respectively.

eSim Schematic Window:

Rotating PORT C and PORT D

To rotate the Port C, place the cursor on Port Unit C and press the R key.

A clarify selection pop-up window appears.

Select Port U and press the R key.

Similarly, rotate Port D.

eSim Schematic Window:

Place cursor on Port A, pin1>>

press W key, to start the wire

connect it to the wire connecting Pin 1 of Xor gate and And gate>>

Click once to end the wire

Connect the ports to the pins with wires.

Place the cursor on the pin1 of PORT A and press the W key to start the wire.

Drag it to the wire connecting the pin 1 of XOR gate and AND gate.

Click once to end the wire.

A junction will be placed on the wire.

Similarly, connect all the ports to the pins as shown here.

eSim Schematic Window:

Click on Annotate >>

click OK

Let us now 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.

eSim Schematic Window:

Press Ctrl+S keys together

Save the schematic by pressing Ctrl+S keys together.
eSim Schematic Window:

Click Generate netlist>>

select Spice tab >>

check Default format>>

click on Generate.

Click Save

Let us generate a netlist for the schematic.

Click on the Generate netlist icon from the top toolbar.

Select the Spice tab and check the Default format.

Click on Generate button and then click the Save button.

This creates a KiCad netlist file.

Subcircuit tab:

Click on Convert Kicad to Ngspice

Now, let us go back to the eSim window.

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

Subcircuit tab:

Point to transient analysis parameters

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

I am leaving these values blank.

Subcircuit tab:

Highlight Device modeling and Subcircuit tab.

If any Device model or Subcircuit is used, specify them under Device modeling or Subcircuit tab.
Subcircuit tab:

Press Convert >>

Click OK

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

Click on the OK button in the information dialog box.

This creates a Ngspice netlist of the subcircuit created.

eSim Subcircuit Library: You can see, the subcircuit Half Adder new is added to the subcircuit library in the eSim directory.
eSim Schematic Window: Now, let us create a component schematic for the Half Adder subcircuit.

The components are also referred to as Parts or symbols.

eSim Schematic Window:

Go back to the eSim editor of Half Adder schematic.

Click on Tools>>

click on Library Editor

Click on the Library Editor icon from the top toolbar.

The schematic window of the Part Library Editor opens up.

You can also find the Library Editor option from the Tools option on the top menu.

Part Library Editor window:

Click on File>>

click on Current Library>>

choose eSim_Subckt>>

click OK

Click on the File option from the top menu.

Click on the Current Library option.

Choose eSim underscore Subckt option.

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

The current library path of the library selected is displayed at the top of the Part Library editor window.


Part Library Editor window:

Click on Create a new Component

Enter the component details

To create a new component, click on Create a new Component icon from the top toolbar.

A Component Properties window opens up.

Enter the following.

Component name as HA underscore new.

Default Reference Designator as X.

The designatoris different for each eSim component. D is used for Diode. Q is used for BJT and so on.

Keep the default settings.

Click on the OK button in the window.

Part Library Editor window:

Place the cursor on text and press F1

Press F1 key to zoom in the schematic name and designator.

You can add a rectangle, circle, arc or polygons as the component body.

Part Library Editor window:

Click on Add graphic rectangle to component body from right toolbar>>

click on editor

Click and drag >>

click and end

I will add a rectangle as a component body.

Click on Add graphic rectangle to component body tool from the right toolbar.

Click on the editor.

Click and drag the rectangle.

Click again to end the rectangle body.

Part Library Editor window:

Place cursor on Ha_new and press M >>

Arrange the designator and name of the component.

Place the cursor on the name and designator and press the key M.

Part Library Editor window:

Click on Add pins to component >>

click on the editor.

Now add input and output pins.

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

Click on the editor.

Pin Properties window will appear.

Part Library Editor window:

Enter properties of pin A

Enter:

Pin name as A.

Pin Number as 1.

Orientation as Right.

Electrical Type as Input.

Graphic Style as Line.

Click on the OK button in the window.

The pin is tied to the cursor. Connect it as shown.

Part Library Editor:

Click on editor

Add Pin 2 properties.

Click on the editor again.

In a similar way, add Pin number 2 with Pin name as B.

Part Library Editor:

Click on editor

Add Pin 3 properties.

Click again on the editor.

Enter the following.

Pin name as Sum.

Pin Number as 3.

Orientation as left.

Electrical Type as output.

Graphic Style as Line.

Click on the OK button.

Part Library Editor:

Add Pin 4 properties.

In a similar way add Pin number 4 with Pin name Cy.
Part Library Editor window:

Click on File >>

click on Save Current Library

Click Yes >>

Click Yes

Let us save the schematic symbol.

Click on File option from the top menu.

Click on the Save Current Library option.

Click the Yes button in the confirmation box.

You can see here, the component is added to eSim underscore Subcircuit library.

Click once again the Yes button in the confirmation box.

Part Library Editor window:

Click on File from top menu>>

choose Quit

Close the Part Library editor window.


eSim_Subciruit library file: The eSim underscore Subckt library file is found in the Kicad library as shown here.

As you can see the component HA underscore new is defined here.

If you want to delete any component, you can also delete the component in this file.

eSim Main Window: Now we can verify the created Subcircuit and its component schematic.

You can use the Half Adder example project from the eSim Examples folder or create a new project.

Slide Show:

Code File

You can also download the example HA underscore Test from the Code file section.

You can verify the component and subcircuit created.

eSim Main Window:

Adding HA underscore Test.

I have created a new project HA underscore Test.

The project is already added to eSim windows under the Project section.

Select HA test and click on the Open schematic button from the left toolbar.

eSim Schematic editor:

Open the schematic of HA underscore Test

It directs us to the eSim schematic window.

You can see, the HA underscore new component will be present under eSim_Subckt library.

eSim Main Window:

Analyzing the HA_test project

Let us go back to the eSim window.

In the Kicad to Ngspice analysis tab, I have already specified transient parameters.

In the Source details tab, the voltage sources are assigned as 5 volts.

In the Subcircuit tab, the path of the Halfadder underscore new is added.

Ngspice window: You can see the Ngspice plots and terminal.

Since both the inputs are 5 volts, Sum will be 0 and carry will be 5 volts.

You can also see the values in the Ngspice terminal.

Close the Ngspice terminal and plots.

Python window: In the Python plot window, check the Sum and Cy node.

Click on the Plot button.

The sum is 0 volts and Carry is 5 volts.

Close the Python plot window.

Show Slide:

Summary

In this tutorial, we learnt how to,
  • Create a Subcircuit and
  • Create a 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