[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: gEDA-user: File instead of SPICE voltage source?



It works!

since my data was in a file with two columns the first being time the other amplitude, with a SED script I added a "+" at the front of every line.

$> sed -e 's/.*/ + &/' ./oldfile > ./newfile

then I added the header and footer.

then with a small deck like this:

test circuit
.include data.dat
r1 1 0 500
.tran 1m 10
.end

and the commands:
$> spice3 -b test.cir -r raw.file
$> nutmeg raw.file
and
plot v(1)

I could plot the values like a charm!

:-)

Only the whole calculation process took about 10min of over 95% of CPU usage on my ThinkPad-T22-900MHz, since the data contained 30,000 samples each 1ms apart!
And this was only plotting, i.e. display voltage over a resistor. I plan to feed the signal into a filter!



bests, Shahab.


Daniel Nilsson wrote:
On Sun, May 01, 2005 at 10:55:18PM +0200, Shahab Sanjari wrote:

Hi,

This one is somehow off topic, actually a general question about SPICE simulation, but I thought I'd better ask it here.

Is it possible to tell the SPICE, that a voltage source doesn't generate according to a fix function, but rather reads a file from hard disk which has data in it? For example an ASCII file that has two columns separated with tabs or space, one for time and the other for amplitude.
I could then feed this into my custom made filter to check the output.


I don't think there is a direct way to accomplish what you're looking
to do here, but there is a slight variant that I normally use. You
don't specify which SPICE version you are using, so the following idea
might need some tweaking but in general what I do is to create a file
with the voltage time pairs (one per line) and then include this file
in the top level spice netlist. For example, create a file that looks
like this:

+ 0e-9  1
+ 1e-9  1.1
+ 2e-9  2.1
+ 3e-9  3.1

etc...

Then it's easy to script a solution that adds a few lines at the top
and bottom of the file so that it looks like this:

Vsource pos_node neg_node pwl (
+ 0e-9  1
+ 1e-9  1.1
+ 2e-9  2.1
+ 3e-9  3.1
)

I use this in HSPICE, I hope it is supported in ngspice as well but
you might need to tweak this somewhat.

Then simply include this file in the toplevel netlist and you should
be good to go.

HTH

--
Daniel Nilsson



--

Shahab Sanjari (sanjariathrzdottu-darmstadtdotde)