User Tools

Site Tools


kicad:using_arbitrary_spice_engines_in_kicad_5

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
kicad:using_arbitrary_spice_engines_in_kicad_5 [2018/09/09 07:34] mithatkicad:using_arbitrary_spice_engines_in_kicad_5 [2019/01/04 21:41] (current) mithat
Line 1: Line 1:
 ====== Using Arbitrary SPICE Engines in KiCad 5 ====== ====== Using Arbitrary SPICE Engines in KiCad 5 ======
  
-SPICE support in KiCad 5 has been significantly reworked to make it a better simulation platform. One casualty of this is that the OldWays no longer to work((At least not on my Debian sid system))and I have a lot of simulations I set up under KiCad 4. In particularwhen KiCad generates ''*cir'' filesit no longer prepends ''-PSPICE''/''-GNUCAP'' or appends ''+PSPICE''/''+GNUCAP'' text blocks found on your schematic to the file. But it does add a ''.title'' directive to the file that my simulator doesn'understand and chokes on.+Simulation support in KiCad 5 has been significantly reworked to make it a better simulation platform. Howeveryou might have a lot of SPICE projects that you created in KiCad 4, and reworking them to fit the way things work in KiCad 5 might be more work than you want to undertakeAlsoyou might be running KiCad on a Debian systemwhich (as of this writing) [[http://kicad-pcb.org/download/debian/#_build_from_source| doesn'have]] the new simulation support.
  
-So I hacked together a script that makes it relatively easy to convert KiCad 4 simulation setups to something that works in KiCad 5. I'm dumping the source code here for now but will probably be moving it to Git[lab|hub] soon.+The UI bits for the OldWays((Open the //Generate netlist// dialog, click the //Spice// tab and then the //Run Simulator// button)) are still there in KiCad 5, but they no longer work the same way --- at least not on my Debian sid systemIn particular, when KiCad generates ''*cir'' files, it no longer prepends ''-PSPICE''/''-GNUCAP'' nor appends ''+PSPICE''/''+GNUCAP'text blocks found on the schematic to the file. But it does add a ''.title'' directive to the file that my simulator doesn't understand and chokes on.
  
-<code bash> +So, I hacked together a bash script that makes it relatively easy to convert KiCad 4 simulations to something that works in KiCad 5. I'm dumping the source code here for now but may move it to Git[lab|hub] soon.
-#! /bin/bash+
  
 +<file bash simulate.sh>
 +#!/bin/bash
 + 
 # (C) 2018 Mithat Konar https://mithatkonar.com # (C) 2018 Mithat Konar https://mithatkonar.com
 + 
 # A scheme to use arbitrary SPICE simulators in Kicad 5. # A scheme to use arbitrary SPICE simulators in Kicad 5.
 # #
 # Usage: # Usage:
 # * Put all the stuff to be prepended (e.g., -PSPICE stuff) in pre.cir. # * Put all the stuff to be prepended (e.g., -PSPICE stuff) in pre.cir.
-# * Put all the stuff to be appended  (e.g., +PSPICE stuff) in post.cir.+# * Put all the stuff to be appended (e.g., +PSPICE stuff) in post.cir.
 # * In this script: # * In this script:
-#       * Set CIRCUITNAME to point to the .cir file Kicad 5 generates. +#       * Set CIRCUITNAME to point to the .cir file KiCad 5 generates. 
-#       * Set SPICE_ENGINE to your desired SPICE engine. (You'll need to +#       * Set SPICE_ENGINE to your desired SPICE engine. (Hack the line 
-#         hack the line where it's invoked to add command line +#         where it's invoked to add any needed command line parameters.) 
-#         parameters or if it's weird.) +# * In the KiCad Netlist dialog's Spice tab, set the simulator to this 
-# * Set the simulator in Kicad to this file using an absolute path. +#   file using an absolute path. 
-# * Run Simulator +# * In the KiCad Netlist dialog's Spice tab, Run Simulator. 
- +  
-### --- config ------------------------------------------------------- # +----- config --------------------------------------------------------- 
-# The name of the cir file to simulate with (w/o extension).+# The name of the cir file to simulate with (w/o extension):
 CIRCUITNAME=opa-x5-spice CIRCUITNAME=opa-x5-spice
- +  
-# The SPICE engine you want to use. +# The command for the SPICE engine you want to use: 
-SPICE_ENGINE=spiceopus +SPICE_ENGINE="xterm -e ngspice" 
-# -------------------------------------------------------------------- # +# ---------------------------------------------------------------------- 
 + 
 ### constants ### constants
 CIRCUITFILE=${CIRCUITNAME}.cir CIRCUITFILE=${CIRCUITNAME}.cir
 CIRCUITFILE_CLEANED=${CIRCUITNAME}-cleaned.cir CIRCUITFILE_CLEANED=${CIRCUITNAME}-cleaned.cir
 GENERATED_CIR=${CIRCUITNAME}-complete.cir GENERATED_CIR=${CIRCUITNAME}-complete.cir
- +  
-### Go!+### go!
 # set the script's directory as the working directory # set the script's directory as the working directory
 cd $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) cd $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
 + 
 # remove all lines starting with .title from CIRCUITFILE # remove all lines starting with .title from CIRCUITFILE
 sed '/^.title/d' $CIRCUITFILE > $CIRCUITFILE_CLEANED sed '/^.title/d' $CIRCUITFILE > $CIRCUITFILE_CLEANED
 + 
 # concatenate the final file # concatenate the final file
 cat pre.cir > $GENERATED_CIR cat pre.cir > $GENERATED_CIR
 cat $CIRCUITFILE_CLEANED >> $GENERATED_CIR cat $CIRCUITFILE_CLEANED >> $GENERATED_CIR
 cat post.cir >> $GENERATED_CIR cat post.cir >> $GENERATED_CIR
 + 
 # run it # run it
 $SPICE_ENGINE $GENERATED_CIR $SPICE_ENGINE $GENERATED_CIR
 + 
 # cleanup # cleanup
 #~ rm $GENERATED_CIR #~ rm $GENERATED_CIR
 rm $CIRCUITFILE_CLEANED rm $CIRCUITFILE_CLEANED
-</code>+ 
 +</file>
  
kicad/using_arbitrary_spice_engines_in_kicad_5.1536478469.txt.gz · Last modified: 2018/09/09 07:34 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki