Dangerous Prototypes

In development => Project logs => Topic started by: ian on March 05, 2011, 03:04:56 pm

Title: Simulation packages
Post by: ian on March 05, 2011, 03:04:56 pm
What are you using? I made big use of LTspice over the past week, and this looks (nicer?) different.
Title: Re: upgrading a hakko clone
Post by: sqkybeaver on March 05, 2011, 03:10:51 pm
i'v been using a combination of java based simulator, full of bugs, and a calculator.
Title: Re: upgrading a hakko clone
Post by: ian on March 05, 2011, 03:36:22 pm
Sorry about that, I meant the simulator that arhi is using for the attached schematics.
Title: Re: upgrading a hakko clone
Post by: arhi on March 05, 2011, 03:44:26 pm
[quote author="ian"]What are you using?[/quote]

Proteus ISIS v7.7 sp2 (http://http://www.labcenter.com/products/vsm_overview.cfm)

simulates (realtime) also pic's (including pic24fj64ga002), avr's, 8051's, some generic arm7's, basic stamp, even some msp430's :) .. and bunch of external stuff like buttons, 16x2 displays some gfx displays ... it also can install virtual usb driver so you can actually simulate usb, so when I run my usb firmware on simulated mcu it actually behaves like I attached it to host computer ... etc etc .. it has a plugin for MPLAB so you can debug in mplab and watch it simulated environment with all the io stuff working..

very good software, very good pcb design tool too, excellon output (both RS274D and RS274X), unfortunately costs arm and a leg (if you are not the illegal download person)
Title: Re: upgrading a hakko clone
Post by: arhi on March 05, 2011, 04:58:38 pm
Mine choice (basic pcb, analog + mcu simulation and pic only:

223    Proteus PCB Design Level 1+    â‚¬525.00
234    Advanced Simulation Features    â‚¬260.00
311    Proteus VSM for PIC16    â‚¬385.00
312    Proteus VSM for PIC18    â‚¬385.00
313    Proteus VSM for PIC24    â‚¬525.00
314    Proteus VSM for dsPIC33    â‚¬525.00
370    Proteus USB Transaction Analyser    â‚¬260.00
Euro (EUR) Total    â‚¬2865.00

With no pcb, only pic18 and 24 without usb support
234    Advanced Simulation Features    $319.00
312    Proteus VSM for PIC18    $479.00
313    Proteus VSM for PIC24    $649.00
United States Dollars (USD) Total    $1447.00

just the pic18 without usb support is 500$ ..

maybe if one can go for educational licence, maybe those are cheaper ...
Title: Re: upgrading a hakko clone
Post by: sqkybeaver on March 05, 2011, 05:01:59 pm
id find more use for the analog simulation
Title: Re: upgrading a hakko clone
Post by: arhi on March 05, 2011, 05:09:12 pm
the worst part is - you pay 3K5E and that's it, when the new version comes out you have to pay again, and again and again ... you get like 6 months of updates only for free .. . so - it is very expensive stuff imho .. (again, unless you use it illegally as 90% of users on forums I seen do)

btw, wrt mcu simulation I purchased the super cool simulation pack from oshonsoft (http://http://www.oshonsoft.com/). Vlada (the guy who made it) is super cool guy and you can write your own peripherals to the system and expand is as much as you want. It is not as fancy as ISIS but - it is sooooooooooooooo simple to use and works great. There is no 24/33/32 pic support yet but I heard he's working on pic32 version.
Title: Re: upgrading a hakko clone
Post by: arhi on March 05, 2011, 05:17:48 pm
btw Ian, you might want to split this thread and move this simulation talk to the separate one ... might be interested for others and noone will ever find it under "upgrading hakko clone" :D
Title: Re: Simulation packages
Post by: ian on March 06, 2011, 11:31:01 am
Done
Title: Re: Simulation packages
Post by: arhi on March 06, 2011, 12:07:50 pm
Cool, btw http://www.labcenter.com/download/prodemo_download.cfm (http://www.labcenter.com/download/prodemo_download.cfm) there's some "demo" version of the proteus .. I never tried it but ..

Wrt mcu simulation - again, I think oshonsoft (http://http://www.oshonsoft.com/) is a must to try.

As for analog stuff spice works great, it's free ... the only problem is - it's really not easy to use... good thing is that most manufacturers will provide spice libraries for their parts.. and making libraries yourself for some simpler parts is not that dificult (for e.g. I just made BD681 transistor for ISIS as ISIS don't have it and it uses pspice to simulate it so I just made a simple pspice script, I'm sure that if I looked bit harder I could of find script for it already made on some of the manufacturers website but I wanted to make it myself :D as en exercise ) ..

On Linux there are GNU-CAP (http://http://www.gnu.org/software/gnucap/) and NG-SPICE (http://http://ngspice.sourceforge.net/) and GNU-SPICE GUI (http://http://sourceforge.net/projects/gspiceui/). They are open source, free... ppl say they are "very good", but all I can say is - interface sucks... use flow is idiotic and if today was 1974 this would be great application but today being 2011. it really fit my description of kicad and rest of geda package "if it was not free - no one would ever use it"
Title: Re: Simulation packages
Post by: rsdio on March 06, 2011, 01:24:06 pm
[quote author="arhi"]making libraries yourself for some simpler parts is not that dificult (for e.g. I just made BD681 transistor for ISIS as ISIS don't have it and it uses pspice to simulate it so I just made a simple pspice script, I'm sure that if I looked bit harder I could of find script for it already made on some of the manufacturers website but I wanted to make it myself :D as en exercise ) .. [/quote]
Would you mind writing up a tutorial on how you did this?  I'm sure there's an appropriate forum somewhere on this site.  Alternatively, if you followed some existing tutorial, then a link would be nice.  I first used Spice on a Silicon Graphics workstation in college, with a whole mess of patched together Unix software, but have only used manufacturer models recently.
Title: Re: Simulation packages
Post by: arhi on March 06, 2011, 05:22:51 pm
[quote author="rsdio"]Would you mind writing up a tutorial on how you did this?[/quote]

I am not a master but here's a short manual on how to make BD681 transistor in Proteus ISIS. (note that maybe I am not doing this the "proper" or the "best" way as I learned how to do this by trial and error).

1. draw a component in ISIS - just like you would any other.
2. name the 3 pins B, C, E and assign them pin numbers. electrical type property is irrelevant
3. edit "script" for the component (this is where it gets interesting):

example script (BD681):
Code: [Select]
{*DEVICE}
NAME=BD681
{PREFIX=Q}
{*PROPDEFS}
{PACKAGE="PCB Package",PACKAGE,1,TO220}
{SPICEMODEL="SPICE Model",STRING}
{PRIMITIVE="Primitive Type",HIDDEN STRING}
{SPICEPINS="SPICE SUBCKT Pin List",?}
{*INDEX}
{CAT=Transistors}
{SUBCAT=BOGDAN}
{MFR=SGS-Thompson}

{PACKAGE=TO220}
{*COMPONENT}
{PACKAGE=TO220}
{SPICEMODEL=BD681,BD681.LIB}
{PRIMITIVE=ANALOGUE,SUBCKT}
{SPICEPINS=E,C,B}

{*PINOUT TO220}
{ELEMENTS=1}
{PIN "B" = 3}
{PIN "C" = 2}
{PIN "E" = 1}

lemme explain line by line:


{*DEVICE}
NAME=BD681
{PREFIX=Q}

I'm not sure if the {*DEVICE} is just a comment or it defines the section, but I find it works like this so I leave it like that :D

NAME=BD681 defines name of the device. If line is in {} it will not be visible, if it is not it is visible (near the part).
PREFIX=Q - this is how the ISIS will name your device - so Q1, Q2 ... Q99999

this one you can define when creating object trough gui - so you can ignore this segment


{*PROPDEFS}
{PACKAGE="PCB Package",PACKAGE,1,TO220}
{SPICEMODEL="SPICE Model",STRING}
{PRIMITIVE="Primitive Type",HIDDEN STRING}
{SPICEPINS="SPICE SUBCKT Pin List",?}


Again not sure about PROPDEFS but I leave it as title of the segment.

Now here we have 2 set of lines that are important
PACKAGE defines the package and it is something you can define later when you create object
Other lines define editable variables of the part.


{*INDEX}
{CAT=Transistors}
{SUBCAT=BOGDAN}
{MFR=SGS-Thompson}
{PACKAGE=TO220}


The INDEX section just defines where your part will be when you search it in ISIS database. this one you also can define when creating object trough gui - so you can ignore this segment


{*PINOUT TO220}
{ELEMENTS=1}
{PIN "B" = 3}
{PIN "C" = 2}
{PIN "E" = 1}


I'd say this one is pretty clear :) ... this one you also can define when creating object trough gui - so you can ignore this segment


{*COMPONENT}
{PACKAGE=TO220}
{SPICEMODEL=BD681,BD681.LIB}
{PRIMITIVE=ANALOGUE,SUBCKT}
{SPICEPINS=E,C,B}


This is what tells ISIS what the part is.

SPICEPINS define the NAMES of the pins (these must be same as names on the pins you use in package). The "order" you put them is important!!

PRIMITIVE defines what primitive to expect. I used SUBCKT, NPN and PNP as primitive types. I believe you understand what each is :)

SPICEMODEL uses NAME,FILENAME syntax .. name is NAME of the "object" inside the FILENAME to load.

PACKAGE is irrelevant


now let's look at the BD681.LIB. Note that ISIS uses PSPICE syntax:
check out: http://www.seas.upenn.edu/~jan/spice/sp ... rview.html (http://www.seas.upenn.edu/~jan/spice/spice.overview.html)

Code: [Select]
.SUBCKT BD681 3 1 2
* Made by Bogdan Kecman <bogdan.kecman@gmail.com>
* Node 1 -> Collect
* Node 2 -> Base
* Node 3 -> Emitter
Q1 1 2 4 QA
Q2 1 4 3 QB 5.21716
D1 3 1 DA
R1 2 4 8000
R2 4 3 120
*
.MODEL DA D(IS=1e-12 RS=9.53186 N=0.964987 XTI=2.96499 CJO=0 VJ=0.75 M=0.33 FC=0.5 EG=1.11 TT=0 BV=infinite)
*
.MODEL QA NPN(IS=6.82736e-17 BF=43.4441 NF=0.85 VAF=30 IKF=1.14362 ISE=9.48937e-15
+            NE=2.04295 BR=0.665831 NR=1.5 VAR=64.8234 IKR=0.0980345 ISC=9.48937e-15
+            NC=1 RB=20.4512 IRB=0.277791 RBM=16.9143 RE=0.574152 RC=6.88011
+            XTB=0.401039 XTI=2.96301 EG=1.05 CJE=1e-11 VJE=0.75 MJE=0.33 TF=1e-09
+            XTF=1 VTF=10 ITF=0.01 CJC=1e-11 VJC=0.75 MJC=0.33 XCJC=0.9 FC=0.5
+            TR=1e-07 PTF=0 KF=0 AF=1)
*
.MODEL QB NPN(IS=6.82736e-17 BF=43.4441 NF=0.85 VAF=30 IKF=1.14362 ISE=9.48937e-15
+            NE=2.04295 BR=0.665831 NR=1.5 VAR=64.8234 IKR=0.0980345 ISC=9.48937e-15
+            NC=1 RB=20.4512 IRB=0.277791 RBM=16.9143 RE=0.574152 RC=6.88011
+            XTB=0.401039 XTI=2.96301 EG=1.05 CJE=1e-11 VJE=0.75 MJE=0.33 TF=1e-09
+            XTF=1 VTF=10 ITF=0.01 CJC=0 VJC=0.75 MJC=0.33 XCJC=0.9 FC=0.5
+            TR=1e-07 PTF=0 KF=0 AF=1)
.ENDS

every line that start with * (asterisk) is comment, every line that start with + (plus) is "continuation of previous line"

.SUBCKT BD681 3 1 2
here we name the subckt (the name you specified in SPICEMODEL line in isis) BD681 and assign "pin number" to the input pins (SPICEPINS line in ISIS).


Q1 1 2 4 QA
Q2 1 4 3 QB 5.21716
D1 3 1 DA
R1 2 4 8000
R2 4 3 120


Q1, Q2, D1, R1, R2 are "internal devices"

Q1 defines a "device of type QA" and links pins of QA to pins 1,2,4 -- note that pin4 is not "exposed" so it is internal junction point.

Q2 defines a "device of type QB" and links pins of QB to pins 1,4,3 with additional parameter 5.21 (area)

D1 defines a "device of type DA" and links pins of DA to 3,1

R1 defines resistor of 8000 ohm with it's ends connected to 2,4 (when a name start with R it is resistor, when it start with C it is capactor...)

R2 defines resistor of 120 ohm with its ends connected to 4,3

and finally .MODEL lines define device as you would in spice. the syntax is .MODEL NAME TYPE (VAR=VALUE VAR=VALUE VAR=VALUE...). The available VAR's depend on the TYPE (D is diode, NPN is well npn transistor..)

Now, as you can see, there's a bunch of parameters there. Those you mostly have to get from manufacturer. The names of the variables are "standard" across all spice variants - use only those values you know.
Title: Re: Simulation packages
Post by: arhi on March 06, 2011, 05:26:02 pm
now for e.g. for simpler components .. there is SPICE2.DSN example that comes with proteus isis:

the script you need to define like:
Code: [Select]
PRIMITIVE=ANALOGUE,NPN
SPICEMODEL=Q2N2222,Q2N2222.LIB

and the script is super simple:
Code: [Select]
.MODEL Q2N2222 NPN(IS=3.108E-15 XTI=3 EG=1.11 VAF=131.5 BF=300 NE=1.541
+ISE=190.7E-15 IKF=1.296 XTB=1.5 BR=6.18 NC=2 ISC=0 IKR=0 RC=1
+CJC=14.57E-12 VJC=.75 MJC=.3333 FC=.5 CJE=26.08E-12 VJE=.75
+MJE=.3333 TR=51.35E-9 TF=451E-12 ITF=.1 VTF=10 XTF=2)

You can even add this script directly on to dsn page if you want.
Title: Re: Simulation packages
Post by: arhi on March 06, 2011, 05:29:49 pm
I hope this helps. In general, you need to get get the real model data from manufacturer. You can't read all the data from data sheet, especially with transistors ...  ISIS also comes with OP-AMP example (SPICE1.DSN)

for e.g. the script is:
Code: [Select]
PRIMITIVE=ANALOGUE,SUBCKT
SPICEMODEL=LMC660,SPICEMOD.LIB
SPICEPINS=POS IP,NEG IP,V+,V-,OP

and the spice code is:
Code: [Select]
* This file is an extract from the Nat Semi model library
* that we have carved up to use for demonstrating the
* SPICELINK utility.
*
* Model developed by:
* David Hindi
* National Semiconductor      For information on the models, contact:
* 2900 Semiconductor Dr.      Linear Applications   
* Santa Clara, CA 95052        (408) 721-3877
* M/S C2500                   
* FAX (408) 721-7321          For ordering information, contact:
*                              Customer Response Center
*                              (408) 721-4902
* ---------------------------------------------------------
*//////////////////////////////////////////////////////////
*LMC660AM/AI/C CMOS Quad OP-AMP MACRO-MODEL
*//////////////////////////////////////////////////////////
*
* connections:      non-inverting input
*                  |  inverting input
*                  |  |  positive power supply
*                  |  |  |  negative power supply
*                  |  |  |  |  output
*                  |  |  |  |  |
*                  |  |  |  |  |
.SUBCKT LMC660      1  2  99  50  41
*
*Features:
*Operates from single supply
*Rail-to-rail output swing
*Ultra low input current =            40fA
*Slew rate =                        1.1V/uS
*
*NOTE: Model is for single device only and simulated
*      supply current is 1/4 of total device current.
*      Noise is not modeled.
*      Asymmetrical gain is not modeled.
*
*****************INPUT STAGE**************
*
I1  99  4 20U
M1  5  2 4 99 MOSFET
R3  5 50 5.2696K
M2  6  7 4 99 MOSFET
R4  6 50 5.2696K
*Fp2=7.5 MHz
C4  5  6 2.0135P
CI1  1  0 2P
CI2  2  0 2P
DP1  1 99 DA
DP2 50  1 DX
DP3  2 99 DX
DP4 50  2 DB
G0  98  9 6 5 23.721E-3
R0  98  9 1K
*For accurate Ib , set GMIN<=1E-16 on .OPTIONS line.
*
***********COMMON MODE EFFECT***********
*
I2  99 50 305U
*^Quiescent current                 
EOS  7  1 POLY(1) 16 49 1E-3 1
*Offset voltage.........^
R8  99 49 100K
R9  49 50 100K
*
***************POLE STAGE***************
*
*Fp=13.3 MHz
G3  98 15 9 49 1E-3
R12 98 15 1K
C5  98 15 11.967P
*
************POLE/ZERO STAGE*************
*
*Fp=1 MHz, Fz= 2.6MHz
G5  98 18 15 49 1E-3
R14 98 18 1K
R15 98 19 625
C6  19 18 97.94P
*
*********COMMON-MODE ZERO STAGE*********
*
*Fpcm=20 KHz
G4  98 16 POLY(2) 1 49 2 49 0 3.5397E-8 3.5397E-8
L2  98 17 7.958M
R13 17 16 1K
*
**************OUTPUT STAGE**************
*
EH  99 98 99 49 1
G1  98 29 18 49 8.253E-6
R5  98 29 510.8MEG
D1  8 99 DX
V2  8 29 1.363
D2  50 10 DX
V3  29 10 1.363
F6  99 50 VA7 1
*^Dynamic supply current
F5  99 35 VA8 1
D3  36 35 DX
VA7 99 36 0
D4  35 99 DX
E1  99 37 99 49 1
VA8 37 38 0
G6  38 40 49 29 11.765E-3
R16 38 40 2.688K 
D5  30 99 DX
V4  30 40 .77
D6  50 31 DX
V5  40 31 .77
*Fp1=.5294 Hz
C3  29 39 18.182P
R6  39 40 1K
R17 40 41 47
*
***************MODELS USED**************
*
.MODEL DA D(IS=5E-14)
.MODEL DB D(IS=4E-14)
.MODEL DX D(IS=1E-14)
.MODEL MOSFET PMOS(VTO=-2.35 KP=1.801E-3)
.ENDS
Title: Re: Simulation packages
Post by: rsdio on March 07, 2011, 07:05:45 am
Hey, thanks.  This makes sense.  So, when the data sheets show "equivalent circuits" for their I/O pins or other pins, then you can re-create that "circuit" inside a SPICE model and predict how the chip will function on your board.  Usually there is an output resistance, or an input impedance, or an equivalent capacitance - or multiples combinations.  Even though SPICE cannot literally simulate every transistor inside a chip, you can probably get close enough by modeling the "equivalent circuit."  I've found that nearly every manufacturer provides these equivalent circuits in their data sheets.
Title: Re: Simulation packages
Post by: arhi on March 07, 2011, 11:15:24 pm
yes, that is exactly what you do with spice .. (this what I shown is basically same for any spice tool - the part where you create subckt, I even heard there are some graphical tools to do it :) ) ... I seen some rather fancy libraries :D .. literally you can take the equivalent circuit from data sheet and put it in subckt and simulate it ..

what is important is that most new parts (op's, transistors, even multifunction chips) come with spice libraries .. I recently found http://homepages.which.net/~paul.hills/ ... Index.html (http://homepages.which.net/~paul.hills/Circuits/Spice/ModelIndex.html)

the links there are not all true nor existing but you can find some gold pots there :D like

http://www.fairchildsemi.com/models/PSP ... index.html (http://www.fairchildsemi.com/models/PSPICE/Discrete/index.html)

almost all Bipolar Transistor, Diode, IGBT, MOSFET, Small Signal TR that fairchild makes :D

Then here you get spice library from IRF ... serious stuff:
http://www.irf.com/product-info/models/spice/ (http://www.irf.com/product-info/models/spice/)

Now, motorola ( http://www.onsemi.com/ (http://www.onsemi.com/) )is cool too .. they don't have "summary" page like fairchild nor archive with all models like IRF but most of the parts they have with datasheet you can also download simulation package ..
Title: Re: Simulation packages
Post by: rsdio on March 08, 2011, 09:58:42 am
Thanks for all of those links!

( ! ) Fatal error: Uncaught exception 'Elk_Exception' with message 'Please try again. If you come back to this error screen, report the error to an administrator.' in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
( ! ) Elk_Exception: Please try again. If you come back to this error screen, report the error to an administrator. in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
Call Stack
#TimeMemoryFunctionLocation
10.01232127272session_write_close ( )...(null):0
20.01262258848ElkArte\sources\subs\SessionHandler\DatabaseHandler->write( )...(null):0
30.01262259624Database_MySQL->query( ).../DatabaseHandler.php:119
40.05822398344Database_MySQL->error( ).../Db-mysql.class.php:273