Cette page est en cours de rédaction.
Apportez votre aide…

Ceci est une ancienne révision du document !



Ngspice rework

Ngspice est un logiciel de simulation électronique permettant notamment d'étudier des montages électriques, de tracer des diagrammes de Bode, de calculer des gains, etc.

Il est basé sur Spice3f5, Cider1b1 et Xspice

Depuis Lucid lynx ce logiciel est présent dans les dépôts: il suffit d'installer le paquet ngspice et ngspice-doc

Nous allons installer la dernière version ngspice des dépôts Debian non libre. Pour ce faire rechercher sur Google le fichier ngspice_22-1.dsc

Nous trouvons par exemple comme lien http://kambing.ui.ac.id/debian/pool/non-free/n/ngspice/

Pré-requis

Pour pouvoir effectuer cette installation un certain nombre de pré-requis sont nécessaires :

  • Les dépôts source doivent être disponibles dans synaptic (décommentez les lignes qui commencent par deb-src dans /etc/apt/sources.list)
  • Installez les paquets debhelper cdbs lintian build-essential fakeroot devscripts pbuilder dh-make debootstrap blt (en 1 clic).

Préparation de pbuilder

On va utiliser l'outil pbuilder, qui crée un chroot d'un système Ubuntu de base, puis le compresse dans un fichier base.tgz.
Lors de l'utilisation de pbuilder pour construire le paquet binaire, le chroot va être décompressé, les Build-Deps installées et le paquet compilé. S'il manque une Build-Dep, la compilation échouera.
Le principal intérêt de pbuilder est de vérifier que les Build Deps sont bonnes (cf. fichier control .dsc).

Pour supporter les dépôts Universe et Multiverse

sudo su
echo "COMPONENTS=\"main restricted universe multiverse\"" >> /etc/pbuilderrc
ctrl+d

Permet d'activer l'utilisation des dépôts universe et multiverse sous dapper (désactivés par défaut).

Installation

Compilation et création du paquet binaire

Création du chroot avec pbuilder

Pour initialiser pbuilder, tapez dans votre terminal :

sudo pbuilder create
Pour faire un chroot d'une autre version d'ubuntu que celle que vous utilisez actuellement (pour créer un paquet compatible), vous pouvez ajouter à la fin de la deuxième commande –distribution hardy:
  sudo pbuilder create --distribution hardy 

(hardy peut être remplacé par le nom de code d'une autre version d'Ubuntu).

Cette étape peut prendre un certain temps.

Création du paquet binaire

Une fois l'étape précédente terminée il ne vous reste plus qu'a taper la commande suivante pour compiler votre paquet source (dans « ~/packaging/ ») :

sudo pbuilder build *.dsc

Et à laisser mariner… en cas d'erreur de dépendance (eh oui cela peut encore arriver pendant la compilation) reprendre à l'étape Création du paquet binaire en ajoutant le paquet manquant avant de lancer le build, il est possible d'ajouter plusieurs paquet en les séparants avec une espace :

sudo pbuilder update --extrapackages nomdupaquetmanquant (ex: libq4t-dev)

Une fois cette étape terminée, votre .deb est dans /var/cache/pbuilder/result

Installer les packets

cd /var/cache/pbuilder/result
sudo dpkg -i ngspice-doc_20-1_all.deb ngspice_20-1_*.deb tclspice_20-1_*.deb

Copiez les exemples de netlist de ngspice

mkdir ngspice
cd ngspice
cp -R /usr/share/doc/ngspice-doc/examples ./
cd examples/cider/serial/

Simulation de la charge d'une capacitée

ngspice charge.cir

Exécution de la simulation

******                                                            
** ngspice-20 : Circuit level simulation program                  
** The U. C. Berkeley CAD Group                                   
** Copyright 1985-1994, Regents of the University of California.  
** Please submit bug-reports to: ngspice-bugs@lists.sourceforge.net
** Creation Date: Wed Dec 16 22:39:18 UTC 2009                     
******                                                             

Circuit: mos charge pump

ngspice 1 -> run
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000


Initial Transient Solution
--------------------------

Node                                   Voltage
----                                   -------
4                                            0
5                                            1
6                                            1
7                                            0
2                                            1
3                                            1
1                                            1
vc#branch                                    0
vs#branch                         -1.46927e-11
vbb#branch                         1.45234e-11
vdd#branch                         1.46927e-11
vin#branch                         3.03623e-19

 Reference value :  1.97932e-07

No. of Data Rows : 368

ngspice 2 ->

Affichage du résultat des nœuds vin vs et vc

ngspice 2 -> plot vin#branch vs#branch vc#branch
ngspice 3 ->

Pour réaliser vos propres netlist utilisez gschem de geda pour dessiner le schéma électronique (schema.sch) ou kicad. Puis pour gschem convertissez le schéma en un fichier netlist (schema.net) avec la commande gnetlist suivante :

gnetlist -g spice -o schema.net schema.sch

Les paramètres entre <> sont optionnels.

Résistances

Syntaxe

Rnom n1 n2 valeur

Exemple

Rin 2 0 100

Notes

n1 et n2 sont deux nœuds de connexion. Valeur est la résistance (en ohms), elle peut-être positive ou négative mais non nulle.

Résistances Semi conducteur

Syntaxe

Rnom n1 n2 <valeur> <Mnom> <L=Longueur> <W=Largeur> <Temp=T>

Exemple

Rcharge 3 7 RMODEL L=10u W=1u

Notes

C'est la forme la plus générale de résistance, elle permet de modéliser les effets de la température et de calculer sa résistance en fonction de sa géométrie et de spécifications propre.

Capacités

Syntaxe

Cnom n+ n- valeur <IC=INCOND>

Exemple

Cout 13 0 1UF IC=3V

Notes

n+ et n- sont les bornes positive et négative du condensateur. Valeur est la capacité en Farads. La condition initiale IC (optionnelle) est la valeur en volts de la tension au temps 0 de la capacitée.

Capacités Semi conductrice

Syntaxe

Cnom n1 n2 <value> <Mnom> <L=Longueur> <W=Largeur> <IC=VAL>

Exemple

Cfilter 3 7 CMODEL L=10u W=1u

Notes

C'est la forme la plus générale de condensateur, elle permet de calculer la valeur de la capacité à partir de la géométrie et de spécifications.

Inductances

Syntaxe

Lnom n+ n- valeur <IC=INCOND>

Exemple

LSHUNT 23 51 10U IC=15.7MA

Notes

n+ et n- sont les bornes positive et négative. Valeur est l'inductance en Henry. La condition initiale IC (optionnelle) est la valeur du courant en ampère au temps 0 de la borne n+ à la borne n-.

Inductance Mutuelle

Syntaxe

Knom Lnom1 Lnom2 valeur

Exemple

Kin L1 L2 0.87

Notes

Lnom1 et Lnom2 sont les nom des deux inductances couplées. VALEUR est le coefficient de couplage K, il doit être plus grand que 0 et inférieur ou égal à 1.

Switches

Syntaxe

Snom n+ n- nc+ nc- Mnon <ON><OFF>
Wnom n+ n- VNAM MnomL <ON><OFF>

Examples

Switch1 1 2 10 0 smodel1
W1 1 2 vclock switchmod1

Notes

Nodes n+ and n- are the nodes between which the switch terminals are connected. The model name is mandatory while the initial conditions are optional. For the voltage controlled switch, nodes nc+ and nc- are the positive and negative controlling nodes respectively. For the current controlled switch, the controlling current is that through the specified voltage source. The direction of positive controlling current flow is from the positive node, through the source, to the negative node.

Sources de tension

Syntaxe

Vnom n+ n- <DC<> DC/TRAN VALUE> <AC <ACMAG <ACPHASE>>> <DISTOF1 <F1MAG <F1PHASE>>> <DISTOF2 <F2MAG <F2PHASE>>>

Exemples

VCC 10 0 DC 6
Vin 13 2 0.001 AC 1 SIN(0 1 1MEG)

Notes

n+ et n- sont les bornes positive et négative. Les sources de tension ne sont pas à la masse. Le courant passe de la borne Positive à la borne négative. Un courant positive passe de la borne n+ à la borne n- au travers du circuit connecté.

DC/TRAN sont le régime continu et transitoire d'analyse, AC est la valeur alternative.

Current Sources

Syntax

Iname n+ n- <<DC> DC/TRAN VALUE> <AC <ACMAG <ACPHASE>>> <DISTOF1 <F1MAG <F1PHASE>>> <DISTOF2 <F2MAG <F2PHASE>>>

Examples

Igain 12 15 DC 1
Irc 23 21 0.333 AC 5 SFFM(0 1 1K)

Notes

ACMAG is the ac magnitude and ACPHASE is the ac phase. The source is set to this value in the ac analysis. If ACMAG is omitted following the keyword AC, a value of unity is assumed. If ACPHASE is omitted, a value of zero is assumed. If the source is not an ac small-signal input, the keyword AC and the ac values are omitted.

DISTOF1 and DISTOF2 are the keywords that specify that the independent source has distortion inputs at the frequencies F1 and F2 respectively (see the description of the .DISTO control line). The keywords may be followed by an optional magnitude and phase. The default values of the magnitude and phase are 1.0 and 0.0 respectively.

Linear Voltage-Controlled Current Sources

Syntax

Gname n+ n- nc+ nc- value

Example

G1 2 0 5 0 0.1MMHO

Notes

n+ andn- are the positive and negative nodes, respectively. Current flow is from the positive node, through the source, to the negative node. nc+ and nc- are the positive and negative controlling nodes, respectively. VALUE is the transconductance (in mhos).

Linear Voltage-Controlled Voltage Sources

Syntax

Ename n+ n- nc+ nc- value

Example

E1 2 3 14 1 2.0

Notes

n+ is the positive node, and n- is the negative node. nc+ and nc- are the positive and negative controlling nodes, respectively. Value is the voltage gain.

Linear Current-Controlled Current Sources

Syntax

Fname n+ n- Vname value

Example

F1 13 5 Vsen 5

Notes

n+ andn- are the positive and negative nodes, respectively. Current flow is from the positive node, through the source, to the negative node. Vname is the name of a voltage source through which the controlling current flows. The direction of positive controlling current flow is from the positive node, through the source, to the negative node of Vname. Value is the current gain.

Linear Current-Controlled Voltage Sources

Syntax

Hname n+ n- Vname value

Example

Hx1 5 17 Vz 0.5K

Notes

n+ and n- are the positive and negative nodes, respectively. Vnameis the name of a voltage source through which the controlling current flows. The direction of positive controlling current flow is from the positive node, through the source, to the negative node of Vname. Value is the transresistance (in ohms).

Non-linear Dependent Sources

Syntax

Bname n+ n- <I=EXPR> <V=EXPR>

Example

B1 0 1 I=cos(v(1))+sin(v(2))

Notes

n+ is the positive node, and n- is the negative node. The values of the V and I parameters determine the voltages and currents across and through the device, respectively. If I is given then the device is a current source, and if V is given the device is a voltage source. One and only one of these parameters must be given. The small-signal AC behavior of the nonlinear source is a linear dependent source (or sources) with a proportionality constant equal to the derivative (or derivatives) of the source at the DC operating point.

Lossless Transmission Lines

Syntax

Oname n1 n2 n3 n4 Mname

Example

O23 1 0 2 0 LOSSYMOD

Notes

This is a two-port convolution model for single-conductor lossy transmission lines. n1 and n2 are the nodes at port 1; n3 and n4 are the nodes at port 2. Note that a lossy transmission line with zero loss may be more accurate than than the lossless transmission line due to implementation details.

Uniform Distributed RC Lines (lossy)

Syntax

Uname n1 n2 n3 Mname L=LEN <N=LUMPS>

Example

U1 1 2 0 URCMOD L=50U

Notes

n1 and n2 are the two element nodes the RC line connects, while n3 is the node to which the capacitances are connected. Mname is the model name, LEN is the length of the RC line in meters. Lumps, if specified, is the number of lumped segments to use in modeling the RC line (see the model description for the action taken if this parameter is omitted).

Junction Diodes

Syntax

Dname n+ n- Mname <Area> <OFF> <IC=VD> <TEMP=T>

Example

Dfwd 3 7 DMOD 3.0 IC=0.2

Notes

n+ and n- are the positive and negative nodes, respectively. Mname is the model name, Area is the area factor, and OFF indicates an (optional) starting condition on the device for dc analysis.

Bipolar Junction Transistors (BJT)

Syntax

Qname nC nB nE <nS> Mname <AREA> <OFF> <IC=VBE, VCE> <TEMP=T>

Example

Q23 10 24 13 QMOD IC=0.6, 5.0

Notes

nC, nB, andnE are the collector, base, and emitter nodes, respectively. nS is the (optional) substrate node. If unspecified, ground is used. Mname is the model name, Area is the area factor, and OFF indicates an (optional) initial condition on the device for the dc analysis.

Junction Field-Effect Transistors (JFET)

Syntax

Jname nD nG nS Mname <Area> <OFF> <IC=VDS, VGS> <TEMP=T>

Example

J1 7 2 3 JM1 OFF

Notes

nD, nG, and nS are the drain, gate, and source nodes, respectively. Mname is the model name, Area is the area factor, and OFF indicates an (optional) initial condition on the device for dc analysis.

MOSFETs

Syntax

Mname ND NG NS NB MNAME <L=VAL> <W=VAL> <AD=VAL> <AS=VAL> <PD=VAL> <PS=VAL> <NRD=VAL> <NRS=VAL> <OFF> <IC=VDS, VGS, VBS> <TEMP=T>

Example

M31 2 17 6 10 Mname L=5U W=2U

Notes

nD, nG, nS, and nB are the drain, gate, source, and bulk (substrate) nodes, respectively. Mname is the model name. L and W are the channel length and width, in meters. AD and AS are the areas of the drain and source diffusions, in 2 meters . Note that the suffix U specifies microns (1e-6 m) 2 and P sq-microns (1e-12 m ). If any of L, W, AD, or AS are not specified, default values are used.

MESFETs

Syntax

Zname nD nG nS Mname <Area> <OFF> <IC=VDS, VGS>

Exemple

Z1 7 2 3 ZM1 OFF

Notes

nD, nG, andnS are the drain, gate, and source nodes, respectively. Mname is the model name, Area is the area factor, and OFF indicates an (optional) initial condition on the device for dc analysis.

Documentation (en)

Tutoriel

gEDA


Contributeur principal :Sefran Le 17/12/2009, 00:31

  • ngspice.1480236736.txt.gz
  • Dernière modification: Le 27/11/2016, 09:52
  • par sefran