简体   繁体   中英

how to use data file as source in spice

I have designed a circuit in ngspice and would like to run a simulation using data from matlab as the input source voltage. ngspice has built in independent sources such as pulse, exponential, sine wave, etc. , but is there a way to use a custom file as a source for the circuit?

Specifically, I want to take data from a seizure simulation model in matlab and run it through my circuit to see how it responds to signals created during the seizure.

As far as I know, ngspice does not have a capability to read in a custom file to define a voltage or a current source. However, you can define any signal using a Piece-Wise Linear (PWL) voltage source:

  1. Use matlab to generate a linear approximation of the signal, that is sample the signal at regular or irregular intervals, with enough density of sampling to represent the signal and print out a list "(t0 v0 t1 v1 t2 v2 ... tN vN)", where each tX is the sample time and vX is a voltage level of the signal at time tx.

  2. Copy the list into your ngspice netlist as an argument for the PWL voltage source definition:

    Vsig N1 N2 PWL(t0 v0 t1 v1 t2 v2 ... tN vN)

Try this approach first with a simple sinusoidal signal to see how the sampling interval affects transient analysis results.

As far as I know, ngspice does not have a capability to read in a custom file to define a voltage or a current source.

Compile ngspice from Git and it will have this feature.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM