spice simulator output vectors to csv in reasonable format - Page 1
Forum section: electronics / general

author: javascripter
author_rank: Newbie
timestamp: March 28, 2021, 03:01:47 pm
content: hello,I am trying to output some vectors (specifically .catvect of measurements of times) to a csv so that I can make nicer looking plots of one of these vectors against another and do some other calculations more easilyCurrently I just using one sweep, so I could get something usable by using a separate .printfile or .print command for each catvect and then manually deleting everything except the last line (since .printfile adds a new set of data each time the sweep is run, with every new one including all the previous data as well), but I will soon run a sweep of the sweep and that would be an unreasonable amount of work to do every time I change something and rerun the simulation (and even for just one sweep it is pretty suboptimal to need to copy and paste multiple things to update a picture or whatever).If it matters and currently using eldo, but I think pretty much any spice commands should work on any spice simulator? I think I also have access to spectre. There is ezwave for viewing results by default, but its export as csv looks the same as results of .printfilegoogle has been pretty useless on spice simulation info, and eldo user manual doesn't seem to have anything more than print and printfile; so I ask here if anyone knows anything that gives more useful output format

author: PKTKS
author_rank: Super Contributor
timestamp: March 28, 2021, 06:42:33 pm
content: it may be easier to just dump the data for post processing.Post processing data languages are suited for parsing that...(AWK or PERL mostly).I usually go this way using just:Code:; in which $argv is the selectorset dumpfle = 'relavant_vectors'write {$dumpfle}.tmp $argv; or justset tabular = $argvwrdata $argvPaul

author: javascripter
author_rank: Newbie
timestamp: March 29, 2021, 12:01:44 pm
content: sorry to bother so much about such a basic thing, but with that I am not able to dump the dataif I try:Code:set dumpfile = 'dumpfile'write {$dumpfile}.tmp = $vect_nameI get an error of unknown parameter TMP; if I try:Code:set dumpfile = 'dumpfile'write {$dumpfile} = $vect_nameI get an error of unknown parameter vect_name; if I try:Code:set dumpfile = 'dumpfile'no output file is created; if I try:Code:set tabular = $vect_namewrdata $vect_nameI get an error for the line with wrdata that it is not consistent with language usage; if I try:Code:set tabular = $vect_namethen the simulation will run, but again no output file is created. I also get bunch of warnings about the netlist where the simulator things I'm trying to use tabular as part of the netlist.Also, possibly more important question; how on earth do I google things about spice simulator code? I can just find things about food and a some drug forums. (or like with this I can find some things, but pretty much only issues that either apply specifically to other simulators or that are talking about a slightly different format than you are that gives me similar errors as your format does)

author: PKTKS
author_rank: Super Contributor
timestamp: March 29, 2021, 01:44:16 pm
content: Ooops sorry...Looks you have missed the point - my fault..These hints came straight from my scripts...These "aliens" are my variables...SPICE is a programmable tool.. a damn good one..I can not enter details here.. the Program Reference will do that...Here is more or less how parts go together...Code:beginunset dumpfleset dumpfle = $argvset wargs = "$argv $argv"write /tmp/{$dumpfle}.tmp $wargs(..)* the other way..unset tabularset tabular = $argvwrdata $argvshell processData {$tabular}(..)So your scripts should be completed with proper variablesand the external applet is a damn powerful PERL data parser..This stuff s a gradual program learning curve..Also .. in any *NIX environment such script may be executableby the spice interpreter...Paul

author: javascripter
author_rank: Newbie
timestamp: March 29, 2021, 07:04:28 pm
content: that script is some linux script (I don't know the proper word for them, but the sort you run just by typing the filename in a terminal) or part of a spice script?*NIX = unix, or something more specific? (I'm using some strange old version of linux) (this is for school; otherwise I wouldn't be worried about making nice graphs and would be happy with results from ezwave)if it is spice, I provide minimum (ish) nonworking example: (less sure of what variables need replacing now though than I was before)Code:*test sweep.param Hres=100.param Vdd=1Vsup VSUP 0 pwl(0 0 1p Vdd)Rdiv VSUP VDiv HresCcon VDiv 0 1p.step param Hres 100 200 50.step param Vdd 1 2 .5.tran 1p 1n 0 1p.meas CATVECT tran risetime TRIG V(VDiv) VAL={.1} TARG V(VDiv) VAL={.9}*begin *line not consistent with langauge syntax*unset tabular *object "ynset": model TRIG not yet defined*set tabular = risetime*wrdata risetime *line not consistent with language syntax*shell processData {$tabular} *object "shell" missing pins*unset dumpfile *object "ynset": model TRIG not yet defined*set dumpfile = risetime*set wargs = "risetime risetime" *warning object "=" already defined*write ./{$dumpfile}.tmp $wargs *object "{" unknown parameter*write "./tmp.txt" "risetime" *line not consistent with language syntax.printfile tran meas(risetime) FILE="./tmp.txt" *this gives something but not in a sensible wayalso, here is some of the file that is outputted by the printfile bit:Code:# PARAM HRES = 2.000000e+02# PARAM VDD = 1.500000e+00# TEMPERATURE = 2.700000e+01# X MEAS(RISETIME) MEAS(RISETIME) MEAS(RISETIME) MEAS(RISETIME) MEAS(RISETIME) MEAS(RISETIME) MEAS(RISETIME) MEAS(RISETIME)1.50000000000e+00 2.19720379586e-10 8.47298349919e-11 5.46541021738e-11 3.29582759339e-10 1.27094267242e-10 8.19812766547e-11 4.39444440386e-10 1.69459315783e-10# PARAM HRES = 2.000000e+02# PARAM VDD = 2.000000e+00# TEMPERATURE = 2.700000e+01# X MEAS(RISETIME) MEAS(RISETIME) MEAS(RISETIME) MEAS(RISETIME) MEAS(RISETIME) MEAS(RISETIME) MEAS(RISETIME) MEAS(RISETIME) MEAS(RISETIME)2.00000000000e+00 2.19720379586e-10 8.47298349919e-11 5.46541021738e-11 3.29582759339e-10 1.27094267242e-10 8.19812766547e-11 4.39444440386e-10 1.69459315783e-10 1.09308636106e-10also, to be clear writing a parser isn't the problem; I will avoid using PERL/AWK because I haven't used them before; but it shouldn't be too hard in anything that can read text files (just a bit annoying), I was just hoping there is an easier way build into spice than writing a parser (also given that if I were to have multiple measurements in that file it would still only have one line per step of the sweep of output data)

author: PKTKS
author_rank: Super Contributor
timestamp: March 30, 2021, 04:45:27 pm
content: Quote from: javascripter on March 29, 2021, 07:04:28 pmHere the things:It is a SPICE specific script - it works as a repository of common re-usable stuffeach script takes arguments when called from the SPICE terminal or other SPICE scriptI AM USING NGSPICE on generic LINUX (it works on any *NIX as well)you can *think* of it as a library of *functions* you call at willand the PIPE and SHELL interaction are just a BONUSby running PERL data analysis tools the job is piece of cakethe vectors should be properly *named* and referenced to be exported*OR* dumped in TABULAR formats...on *ANY* *NIX machine a proper SHELL uses the "shebang" indicator to run any scriptin this case the shebang will run the spice (ngspice) ..Consult NGSPICE Programmer reference from the folks there...very clear to understand.. but gradual steephttp://ngspice.sourceforge.net/start slow and grow your script library..Paul

author: javascripter
author_rank: Newbie
timestamp: March 31, 2021, 04:20:07 pm
content: Thanks, that link is something I was unable to find with google, hadn't even heard of ngspice beforeanyway, I will just write a parser for the csv format I'm getting, I look through that user manual and still get same errors for wrdata and write; only place I can find the errors referenced is eldo user manual which doesn't actually give any more information on them than the error logi guess maybe eldo just doesn't support wrdata/write, seems strange for something so expensive that I can't find the priceand the other simulator available to me (spectre) seems to not even support category vectors (or something with the .meas it has a problem with at least)

author: PKTKS
author_rank: Super Contributor
timestamp: April 01, 2021, 01:06:42 pm
content: Perhaps the current best alternative..Runs integrated in KiCAD although you won't benefitthe power of programmable scripts in any GUI.http://ngspice.sourceforge.net/docs/ngspice-manual.pdfHolger and the folks integrated also wide PSPICE and VDMOS(ala LTSPICE MOS) into ngspice.. so currently you can convertold LTSPICE directly to SPICE and use VDMOS directly.I already converted all my old stuff to ngspice..Single comment is that now the compilation requires atleast a very very recent GCC version... which limitsthe hardware based support.IMHO? proprietary stuff will only lock you out from all thenew good stuff popping due to the OSS new user base..Paul