Reputation: 21
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.
Upvotes: 2
Views: 1780
Reputation: 161
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.
Upvotes: 1
Reputation: 187
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:
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.
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.
Upvotes: 0