sin_gen :
An analog sinusoid generator
The sin_gen primitive generates a sinusoidal signal that can optionally be exponentially decaying or frequency/amplitude-modulated.
The generated stimulus waveform V(t) is defined as follows:
for t < delay: V(t) = offset + amp*AM_offset*sin(init_phase) for t >= delay: V(t) = offset + amp*exp(-damp(t-delay)) * [AM_offset + AM_amp*sin(2*PI*AM_freq*(t-delay)] * sin[2*PI*freq*(t-delay)+FM_index*sin(2*PI*FM_freq*(t-delay)) + init_phase]
In the last expression, the first, second, and third lines express the exponentially-decaying amplitude, amplitude modulation, and frequency modulation of the generated sinusoidal signal, respectively. The sinusoidal signal may have an arbitrary DC offset (offset) and start with an arbitrary initial phase (init_phase).
Some examples of generating a simple sinusoid, a sinusoid with exponentially-decaying amplitude, a sinusoid with single-frequency frequency modulation (FM), and a sinusoid with single-frequency amplitude-modulation (AM):
* A simple sinusoid: Set damp=0, AM_offset=1, AM_amp=AM_freq=0, FM_index=FM_freq=0 V(t) = offset + amp*sin(2*PI*freq(t-delay)+init_phase) for t >= delay * A sinusoid with exponentially-decaying amplitude: Set AM_offset=1, AM_amp=AM_freq=0, FM_index=FM_freq=0 V(t) = offset + amp*exp(-damp*(t-delay))*sin(2*PI*freq*(t-delay)+init_phase) for t >= delay * A sinusoid with single-frequency amplitude modulation (AM): Set damp=0, FM_index=FM_freq=0, init_phase=0 V(t) = offset + amp*[AM_offset+AM_amp*sin(2*PI*AM_freq*(t-delay)] * sin(2*PI*freq*(t-delay)) for t >= delay * A sinusoid with single-frequency frequency modulation (FM): Set damp=0, AM_offset=1, AM_amp=AM_freq=0, init_phase=0 V(t) = offset + amp*sin[2*PI*freq*(t-delay)+FM_index*sin(2*PI*FM_freq*(t-delay))] for t >= delay
Note: for frequency modulation, the narrowband FM is assumed. In other words, the modulation index, FM_index, which is defined as (max. deviation frequency) / (max. modulation frequency), is assumed to be << 1.
Input/Output Terminals
| Name | I/O | Type | Description |
| out | output | xreal | signal output |
Parameters
| Name | Type | Default | Unit | Description |
| offset | real | 0.0 | None | offset |
| amp | real | 1.0 | None | amplitude |
| freq | real | 1.0e9 | Hz | frequency |
| delay | real | 0.0 | seconds | initial delay |
| damp | real | 0.0 | 1/sec | damping factor |
| init_phase | real | 0.0 | radian | initial phase |
| AM_offset | real | 1.0 | None | AM offset |
| AM_amp | real | 0.0 | None | AM amplitude |
| AM_freq | real | 0.0 | Hz | AM frequency |
| FM_index | real | 0.0 | None | FM index |
| FM_freq | real | 0.0 | Hz | FM frequency |