Você está na página 1de 13

NgSpice

Notes
-Yogesh Mahajan
14D070022,IITB

Index
1)
2)
3)
4)
5)
6)
7)

Document Format
Rules
Multipliers & Key Words
Components
Voltage & Current Sources
Analysis
Measurement

Document Format
1)

.trans = Transient Analysis

Syntax : .trans delay transient time_end time_start(default 0)


// lines of trans

2)

.control = Control Commands

In NgSpice control statements are dented by (.)


To avoid Writing (.) again and again use .control
Control ends with .endc

3)

.end = End of Script

Every script must end with .end otherwise it wont run

Rules
1) Every component name must start with given key character.
2) Name of component can have 7 other characters after key
character.
3) Fields on a line are separated by one or more blanks, a
comma, an equal (=) sign, or a left or
right parenthesis; extra spaces are ignored. A line may be
continued by entering a + (plus) in
column 1 of the following line; ngspice continues reading
beginning with column.
4) First line of document is title and never executed
5) Comment starts with (*)
6) Letters immediately following a number that are not scale
factors are ignored, and letters immediately following a scale
factor are also neglected.
7) Node names may be strings of characters and are case
sensitive.
8) Scaling factors or multipliers are not case sensitive.
9) Node 0 is always GND.
10)
The circuit cannot contain a loop of voltage sources
and/or inductors and cannot contain a cut-set of current
sources and/or capacitors.
11)
Each node in the circuit must have a dc path to ground.
12)
Every node must have at least two connections except
for transmission line nodes (to permit unterminated
transmission lines) and MOSFET substrate nodes (which have
two internal connections anyway).

Multipliers & Key


Characters/Identifiers
Multipliers:

Identifiers:

Operators:

Components
1)

Resistors:

Must start with R


Syntax: R<anything> v+ v- val
val = +ve/-Ve but not zero
for small resistances below 0.001Ohm use CCVS transresistance.
2)

Capacitors
Must start with C
Syntax: C<anything> v+ v- val Initial_Condition(IC=<val>V)
c1 13 0 1UF IC=3V

3)

Inductors
Must start with L
Syntax: L<anything> v+ v- val Initial_Condition(IC=<val>MA)
L1 13 0 1UH IC=3MA

Voltage & Current


Sources
Independent Sources
Voltage Sources:
Syntax: V<anything> N+ N- Magnitude* Or Type*

Current Sources:
Syntax: I<anything> N+ N- Magnitude* Or Type*

Types

pulse,
exponential,
sinusoidal,
piece-wise linear,
single-frequency FM
AM
transient noise
random voltages or currents

1) Pulse

2)Exponential :

3)

Sinusoidal :

4)

Piecewise Linear :

5)

Single Frequency FM :

8)AM :

Analysis
AC Analysis
Source : Vin V+ V- DC DC_component AC AC_Component
.Control
AC dec 100 1 1Meg//(decade points /decade start frequency end frequency)
Run
Plot vdb(decibel)(2) xlog

DC Analysis
DC Source_Name initial_value End_value Increment_value
Temperature Analysis:
TEMP Initial_Temp Final_temp Increment_Value
Resistance Analysis :
DC/AC Resistor_Name initial_value End_value Increment_value

* In general
You can nest different loops, such as
1)
2)
3)
4)

Temp & DC
Temp & AC
Temp & Resistor
Resistor & AC/DC

Buy writing them in same line


Eg. DC V1 1 5 0.02 TEMP 35 75 10

7) Measurement
.MEAS <analysis_type> <name_for_measured_vector(value)> FIND
<measuring_vector> WHEN <Referance_Vector> = <value @ which
vector is measured>
Let Statement
Allows user to create user defined vector.
Eg. 1) let logI = ln(vcurrent#branch)
2) let slope = DERIV(vcurrent#branch)
## Deriv function cant be used directly in reference vector for
.MEAS
Eg. MEAS dc n1 FIND DERIV(vcurrent#branch) WHEN I(vcurrent)=1ma
Is not valid as meas function cant create derivative vector
So we can do this as follows:
.let slope = DERIV(logI)
.MEAS dc n1 FIND slope WHEN I(vcurrent)=1ma

Você também pode gostar