kicad:using_arbitrary_spice_engines_in_kicad_5
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
kicad:using_arbitrary_spice_engines_in_kicad_5 [2018/09/09 14:23] – mithat | kicad:using_arbitrary_spice_engines_in_kicad_5 [2018/10/17 15:29] – mithat | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Using Arbitrary SPICE Engines in KiCad 5 ====== | ====== Using Arbitrary SPICE Engines in KiCad 5 ====== | ||
- | Simulation support in KiCad 5 has been significantly reworked to make it a better simulation platform. | + | Simulation support in KiCad 5 has been significantly reworked to make it a better simulation platform. |
- | I have a lot of simulations I built under KiCad 4 that I still want to use. 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 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 system. In particular, when KiCad generates |
- | <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 |
- | #! /bin/bash | + | |
+ | <file bash simulate.sh> | ||
+ | #!/bin/bash | ||
+ | |||
# (C) 2018 Mithat Konar https:// | # (C) 2018 Mithat Konar https:// | ||
+ | |||
# A scheme to use arbitrary SPICE simulators in Kicad 5. | # A scheme to use arbitrary SPICE simulators in Kicad 5. | ||
# | # | ||
Line 17: | Line 19: | ||
# * 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 |
- | # parameters | + | # * In the KiCad Netlist dialog |
- | # * In the KiCad Netlist dialog | + | # using an absolute path. |
- | # * In KiCad, Run Simulator | + | # * In the KiCad Netlist dialog 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 command for the SPICE engine you want to use: | # The command for the SPICE engine you want to use: | ||
SPICE_ENGINE=spiceopus | SPICE_ENGINE=spiceopus | ||
- | # -------------------------------------------------------------------- | + | # ---------------------------------------------------------------------- |
+ | |||
### 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' | # set the script' | ||
cd $( cd "$( dirname " | cd $( cd "$( dirname " | ||
+ | |||
# remove all lines starting with .title from CIRCUITFILE | # remove all lines starting with .title from CIRCUITFILE | ||
sed '/ | sed '/ | ||
+ | |||
# 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.txt · Last modified: 2019/01/04 21:41 by mithat