Is it possible to generate a voltage source that sweeps linearly over a range of frequencies, i.e.: a linear chirp? I’m trying to simulate the ‘sweep’ signal that some function generators have. see attached image.

Thanks,

-May

290px-Linear-chirp.svg|290x194

I am not aware of a readily available linear sweep generator.

As a first trial you might investigate the FFM voltage source (see chapt. 4.1.5 of the ngspice manual). This will give you a sinusoidal modulation of your frequency. And if you use a controlling signal with a very low frequency and a suitable phase offset, then you might explore the “quasi linear” portion of the controlling sine wave.

Best if you make a circuit comprising of the FFM source (library Simulation_SPICE:VSFFM) and run some transient simulations with varying parameters, to see if this somehow fits your needs.

If it is not sufficient, you may construct a chirp generator by assembling a subcircuit with appropriate ngspice components and attach this to a suitable KiCad symbol. First of all you would need to define some specifications, e.g. start time, stop time, start frequency, and stop frequency. Then we need a VCO, for example the ngspice code model 12.2.20 Controlled Sine Wave Oscillator. And we have to control it by a time based voltage ramp, made for example by a pwl voltage source (chapt. 4.1.4 of the ngspice manual).

Ngspice can work with Gnu Octave

Octave can generate chirps easily.

http://ngspice.sourceforge.net/octavespice.html

and

https://wiki.octave.org/Ocs_package

My littel project of a chirp generator with Eeschema/ngspice:

```
* chirp generator by Holger Vogt
* public domain
* bt start time, et end time of chirp
* bf start frequency, ef end frequency of chirp
* code model 'sine' will not accept control value 0, so 1e-12 is used
* r=0 will lead to repeated chirp pattern, cannot be parameterized, so
* has to be removed if a single shot only is required
* to be called by 'XChirp pp 0 chirp bf=1k ef=10k bt=80m et=120m'
.subckt chirp p m params: bf=200 ef=2k bt=30m et=100m
* Start at t=0 with 1e-12, ramp up to t=et-bt with output et, ramp down
* to 1e-12 after another 5% of ramp up time (to catch output 0 again).
* Delay the whole pattern by bt
vcont cc 0 dc 1e-12 pwl ( 0 1e-12 {et - bt} {et} {(et - bt) * 1.05} 1e-12 td={bt} r=0 )
* amplitude is set by out_low, out_high
asine cc %vd(p m) in_sine
.model in_sine sine(cntl_array = [ 0 {bt} {et} ]
+ freq_array=[ 0 {bf} {ef} ] out_low = -5.0
+ out_high = 5.0)
.ends
```

Symbol was generated by checking out Simulation_SPICE:VSIN and adding to it the subcircuit model found in chirp.lib fromChirp.zip (4.0 KB).

Thanks David. I’m not familiar with Octave.

Thanks a lot Holger. This looks very much like what I need. I’m new to KiCad, and circuit simulation in general. I downloaded the zip file you had attached and added the chirp-test-chache.lib file to the symbols library. The other lib file threw an error. Next, I tried to replicate the schematic, but I don’t have a VSIN-CHIRP component. When I search with ‘chirp’ in the component list, I see the chirp library and the Simulation_SPICE:VSIN component. I selected it and tried to edit its SPICE model, but didn’t know which file to select as model? Should there be a .mod file?

Again, taking my baby steps here

Place Simulation_SPICE:VSIN

Double click to open ‘Symbol Properties’ Window --> Edit Spice Model --> Select File -->chirp.lib–>Type: Subcircuit

In line Model: you now have ‘chirp’. Add 'bf=1k ef=3k bt=30m et=70m ’ to get

chirp bf=1k ef=3k bt=30m et=70m

–> ok

In ‘Symbol Properties’ Window, set line ‘Value’ to ‘VSIN-CHIRP’ --> ok

Thanks a ton Holger! Got it to work

and I guess I can change the amplitude by changing the out_low and out_high paramters inside the chirp.lib file.

Thanks again,

-May

You can parameterize the amplitude in the LIB file too. That way you don’t have to keep changing it.

```
* chirp generator by Holger Vogt
* modified by Ste Kulov, so he might've screwed it up, proceed with caution
* public domain
* bt start time, et end time of chirp
* bf start frequency, ef end frequency of chirp
* amp amplitude of chirp
* code model 'sine' will not accept control value 0, so 1e-12 is used
* r=0 will lead to repeated chirp pattern, cannot be parameterized, so
* has to be removed if a single shot only is required
* to be called by 'XChirp pp 0 chirp bf=1k ef=10k bt=80m et=120m amp=1.0'
.subckt chirp p m params: bf=200 ef=2k bt=30m et=100m amp=5.0
* Start at t=0 with 1e-12, ramp up to t=et-bt with output et, ramp down
* to 1e-12 after another 5% of ramp up time (to catch output 0 again).
* Delay the whole pattern by bt
vcont cc 0 dc 1e-12 pwl ( 0 1e-12 {et - bt} {et} {(et - bt) * 1.05} 1e-12 td={bt} r=0 )
* amplitude is set by out_low, out_high
asine cc %vd(p m) in_sine
.model in_sine sine(cntl_array = [ 0 {bt} {et} ]
+ freq_array=[ 0 {bf} {ef} ] out_low = {-amp}
+ out_high = {amp})
.ends
```

That is way more convenient. Thanks Ste!