From owner-freebsd-questions@FreeBSD.ORG Sun Oct 28 17:55:18 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 301F7B64 for ; Sun, 28 Oct 2012 17:55:18 +0000 (UTC) (envelope-from russo@bogodyn.org) Received: from bogodyn.org (mail.bogodyn.org [69.49.164.40]) by mx1.freebsd.org (Postfix) with ESMTP id B89EF8FC08 for ; Sun, 28 Oct 2012 17:55:17 +0000 (UTC) Received: from bogodyn.org (localhost [127.0.0.1]) by bogodyn.org (8.14.5/8.14.5) with ESMTP id q9SHRQD0098142; Sun, 28 Oct 2012 11:27:27 -0600 (MDT) (envelope-from russo@bogodyn.org) Received: (from russo@localhost) by bogodyn.org (8.14.5/8.14.5/Submit) id q9SHRPEB098138; Sun, 28 Oct 2012 11:27:25 -0600 (MDT) (envelope-from russo) Date: Sun, 28 Oct 2012 11:27:25 -0600 From: Tom Russo To: freebsd-questions@freebsd.org Subject: Re: OT: gEDA, SPICE, electronic cad/simulation Message-ID: <20121028172725.GA37922@bogodyn.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: International Institute for Advanced Quantum Bogodynamical Studies User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on bogodyn.org Cc: Da Rock X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: russo@bogodyn.org List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Oct 2012 17:55:18 -0000 Date: Sun, 14 Oct 2012 22:26:34 +1000 From: Da Rock Subject: OT: gEDA, SPICE, electronic cad/simulation > I'm struggling with this damn gEDA/SPICE thing - I think I have gEDA > schem figured, but I can't be sure because I can't test it. For the life > of me I can't seem to get my head around it, but then I might just be > too tired. > Can anyone point out what I'm missing? I open geda, create a sch file > (circuit), and then run gnetlist -g spice-sdb . I then run > ngspice (or gspiceui) but it comes up with errors over the 555 (U1) and > diodes (d?) I'm running like this: > > Error on line 9 : d1 2 0 unknown > unable to find definition of model unknown - default assumed > Error on line 13 : u1 0 4 3 +9v 1 4 5 +9v unknown > unable to find definition of model +9v - default assumed > unknown parameter (4) I see some folks have tried to answer you, but it seems that it's expected that these models somehow already exist on your system and you're just not finding them. That's not the case. Without seeing the entire netlist, I can't be precise, but there are several important things to know about SPICE and device models: 1) SPICE provides only the infrastructure for simulating diodes, i.e. a module that lets you specify all the parameters of a diode and which will then simulate the circuit using the parameters you provide. A "model" in this case means a set of parameters, which is specified in a .model "card". Basically, your schematic has defined a diode without telling the simulator the name of a model card to look for, so gnetlist has inserted "unknown" as the model name. You then did not provide a ".model unknown d" card to define "unknown" as a diode model. No open-source SPICE-like simulator provides model "cards" for common devices. You either have to find one from a manufacturer's web site, find one someone has posted on a web site somewhere, or extract the relevant parameters yourself (this list sorted in order of increasing complexity). Commercial spice packages do come with enormous model, libraries, but you pay big, big bucks for those versions. Werner Hoch wrote a system called "spicelib" for gEDA that attempts to download a large number of spice-compatible models from vendor web sites and massage them to work with ng-spice. I have run it once, and found that it needed a little patching up to make it work on FreeBSD instead of Linux (for example, the "md5sum" program is used througout, and this doesn't exist on BSD --- I had to hand-edit scripts all over the place to make it use md5 instead). Even so, there are few basic parts in these model libraries. Once in a while I have found cool web sites with hundreds of spice models for common discrete parts. They disappear after a year or five. You *COULD* try adding ".model unknown d" to your netlist to let ng-spice use all the default parameters for the diode. It might not work well, but it *will* shut up the error. It's what SPICE wound up doing itself when it couldn't find the model named "unknown." For details about spice diode models, see, for example, http://www.acsu.buffalo.edu/~wie/applet/spice_pndiode/spice_diode_table.html 2) There is no 555 model in SPICE, ng-spice, or any other spice. Such devices are always simulated by creating a subcircuit model (.subckt). gschem will gleefully create a line in your netlist for such a device, but unless you also provide a subcircuit model for it, you won't be able to simulate it, no way, no how. ng-spice does NOT come with a 555 subcircuit model, nor does geda/gschem. gschem merely provides a symbol for such a device. Try googling for "spice 555 model subcircuit" and go from there. One post in the thread on this site: http://www.electro-tech-online.com/general-electronics-chat/5806-spice-555-timer.html has a UA555 subcircuit model that you may be able to use, if you make sure that the subcircuit "pins" match the pins gschem/gnetlist are assigning. 3) SPICE (and ng-spice) always uses the first character of a device line to determine the type of the device. While most designers will draw a circuit with an IC in it and give the IC a name like "U1", the character "u" in the first position on a device line means "lossy transmission line" in spice, not "IC." Thus, in your netlist you're simply telling the simulator to create a lossy transmission line using nodes "0", "4", "3" and "+9v" as its four ports, and it's getting confused by all the extra parameters on the line. To create a subcircuit instance (which is what you want), you need to use the "X" device. The format of the X device is: X [nodes] so, in your case, you would want something like: XU1 0 4 3 +9v 1 4 5 +9v UA555 and a .subckt UA555 card like the one in the post I mentioned in point 2 above. Note that I can't be absolutely certain that gschem's 555 symbol has its pins defined so that it maps exactly onto the input nodes of the UA555 subcircuit model in the forums post I pointed you at. You will have to check for yourself. 4) Your circuit as is is having a really hard time in the solvers (not surprising, given all the errors), so SPICE is using its "gmin stepping" process trying to force a solution. 5) You are attempting to use expressions somewhere (on a print line?) and this is not a supported feature in most free versions of spice. 6) gnetlist will dutifully produce a netlist from the schematic you give it, but unless you've prepared the netlist with an understanding of how gnetlist is going to process it, you can get garbage. While gEDA/gschem/gnetlist/ng-spice are cool tools, they are not easy to dive into without a previous knowledge of spice. You can try looking at the internal help in ngspice. Just fire up ngspice and type help, then explore. This will not teach you the answers to your specific issue, but *will* let you know what the format of various netlist features are. For more detail, you're better off with a textbook on SPICE simulation, and probably need to ask more detailed questions on a gEDA mailing list. HTH, T. -- Tom Russo KM5VY SAR502 DM64ux http://www.swcp.com/~russo/ Tijeras, NM QRPL#1592 K2#398 SOC#236 http://kevan.org/brain.cgi?DDTNM "And, isn't sanity really just a one-trick pony anyway? I mean all you get is one trick, rational thinking, but when you're good and crazy, oooh, oooh, oooh, the sky is the limit!" --- The Tick