Main Content

Chirp

Generate swept-frequency cosine (chirp) signal

  • Chirp block

Libraries:
DSP System Toolbox / Sources

Description

The Chirp block outputs a swept-frequency cosine (chirp) signal with unity amplitude and continuous phase. To specify the desired output chirp signal, you must define its instantaneous frequency function, also known as the output frequency sweep. The frequency sweep can be linear, quadratic, or logarithmic, and repeats once every Sweep time by default. For a description of the algorithms used by the Chirp block, see Algorithms.

Examples

expand all

In this example, the Chirp block outputs a bidirectional, linearly swept chirp signal, which is displayed by the Time Scope and the Spectrum Analyzer. You can also export the signal to the MATLAB workspace by the Signal To Workspace block.

To create a bidirectional sweep, set the Sweep mode parameter to Bidirectional. Specify the final frequency of a bidirectional sweep by setting Target time equal to Sweep time, in which case the Target frequency becomes the final frequency in the sweep. Note that in the bidirectional sweep, the period of the sweep is twice the Sweep time of the unidirectional sweep.

Run the model to see the output in the Time Scope and the Spectrum Analyzer.

You can also view the spectrogram by saving the output to the workspace and using this command:

spectrogram(dsp_examples_yout,hamming(128),110,0:.01:40,400)

In this example, the Chirp block outputs a unidirectional, linearly swept chirp signal. The Time Scope displays the signal output in the time domain and the Spectrum Analyzer displays the spectrogram in the frequency domain.

To obtain a unidirectional sweep with known initial and final frequency values, in the Chirp block set the Target time equal to Sweep time. In which case, the Target frequency becomes the final frequency in the sweep. Since the Target time is set to equal Sweep time (1 second), the Target frequency (25 Hz) is the final frequency of the unidirectional sweep. This technique might not work for swept cosine sweeps. For details, see the Frequency sweep described for the Frequency sweep parameter.

Run the model to see the time domain output:

This example shows the unexpected behavior that might arise in the Chirp block when the Sweep time is greater than Target time. The Time Scope displays the signal output, and the Spectrum Analyzer displays the spectrogram in the frequency domain.

Set the Sweep time parameter to 1.5 and specify the final frequency of a bidirectional sweep by setting Target time equal to Sweep time. The sweep reaches the Target frequency (25 Hz) at the Target time (1 second), but since Sweep time is greater than Target time, the sweep continues on its linear path until one Sweep time (1.5 seconds) is traversed.

Unexpected behavior might arise when you set Sweep time greater than Target time.

Run the model to see the chirp signal output and a spectrogram of the frequency domain.

In this example, the Chirp block outputs a chirp signal containing negative frequencies. The Time Scope displays the signal output in the time domain, and the Spectrum Analyzer displays the spectrogram in the frequency domain.

Set the Sweep time to 1.5, Initial frequency to 25, Target frequency to 0, and Target time equal to Sweep time. The output chirp of this example might not behave as you expect because the sweep contains negative frequencies between 1 and 1.5 seconds. The sweep reaches the Target frequency (0 Hz) at 1 second, then continues on its negative slope, taking on negative frequency values until it traverses one Sweep time (1.5 seconds).

Run the model to see the time domain output.

In this example, the Chirp block outputs a chirp signal containing negative frequencies. The Time Scope displays the signal output in the time domain, and the Spectrum Analyzer displays the spectrogram in the frequency domain.

Set the Target frequency to 275 and specify Target time equal to Sweep time. The output chirp of this example might not behave as you expect because the sweep contains frequencies greater than half the sampling frequency (200 Hz). If you unexpectedly get a chirp output with a spectrogram resembling the one following, your chirp's sweep might contain frequencies greater than half the sampling frequency.

Run the model to see the signal output and the spectrogram.

Extended Examples

Ports

Output

expand all

Swept-frequency cosine (chirp) signal. In Linear, Logarithmic, and Quadratic modes (set by the Frequency sweep parameter), the block outputs a swept-frequency cosine with instantaneous frequency values specified by the frequency and time parameters. In Swept cosine mode, the block outputs a swept-frequency cosine with a linear instantaneous output frequency that may differ from the one specified by the frequency and time parameters.

For more information about how the block computes the output, see Algorithms.

Data Types: single | double

Parameters

expand all

The type of output instantaneous frequency sweep, fi(t): Linear, Logarithmic, Quadratic, or Swept cosine. For more information, see Shaping the Frequency Sweep and Algorithms.

Limitations

When you want a linearly swept chirp signal, we recommend that you use a Linear frequency sweep. Though a Swept cosine frequency sweep also yields a linearly swept chirp signal, the output might have unexpected frequency content.

  • The swept cosine sweep value at the Target time is not necessarily the Target frequency. This is because the user-specified sweep is not the actual frequency sweep of the swept cosine output, as noted in Output Computation Method for Swept Cosine Frequency Sweep. See the table Instantaneous Frequency Sweep Values for the actual value of the swept cosine sweep at the Target time.

  • In Swept cosine mode, do not set the parameters so that 1/Tsw is much greater than the values of the Initial frequency and Target frequency parameters. In such cases, the actual frequency content of the swept cosine sweep might be closer to 1/Tsw, far exceeding the Initial frequency and Target frequency parameter values.

The Sweep mode parameter determines whether your sweep is unidirectional or bidirectional, which affects the shape of your output frequency sweep (see Shaping the Frequency Sweep). The following table describes the characteristics of unidirectional and bidirectional sweeps.

Sweep Mode Parameter SettingsSweep Characteristics

Unidirectional

  • Lasts for one Sweep time, Tsw

  • Repeats once every Tsw

Bidirectional

  • Lasts for twice the Sweep time, 2Tsw

  • Repeats once every 2Tsw

  • First half is identical to its unidirectional counterpart.

  • Second half is a mirror image of the first half.

The following diagram illustrates a linear sweep in both sweep modes. For information on setting the frequency values in your sweep, see Setting Instantaneous Frequency Sweep Values.

For Linear, Quadratic, and Swept cosine sweeps, the initial frequency, f0, of the output chirp signal. You can specify the Initial frequency (Hz) as a scalar, greater than or equal to zero. For Logarithmic sweeps, Initial frequency is one less than the actual initial frequency of the sweep. Also, when the sweep is Logarithmic, you must set the Initial frequency to be less than the Target frequency.

For more information, see Setting Instantaneous Frequency Sweep Values.

Tunable: Yes

For Linear, Quadratic, and Logarithmic sweeps, the instantaneous frequency, fi(tg), of the output at the Target time, tg. You can specify the Target frequency (Hz) as a scalar, greater than or equal to zero. For a Swept cosine sweep, Target frequency is the instantaneous frequency of the output at half the Target time, tg/2. When Frequency sweep is Logarithmic, you must set the Target frequency to be greater than the Initial frequency.

For more information, see Setting Instantaneous Frequency Sweep Values.

Tunable: Yes

For Linear, Quadratic, and Logarithmic sweeps, the time, tg, at which the sweep reaches the Target frequency, fi(tg). For a Swept cosine sweep, Target time is the time at which the sweep reaches 2fi(tg) - f0. Target time must be a scalar that is greater than or equal to zero, and less than or equal to Sweep time , Tswtg.

For more information, see Setting Instantaneous Frequency Sweep Values.

Tunable: Yes

In Unidirectional Sweep mode, the Sweep time, Tsw, is the period of the output frequency sweep. In Bidirectional Sweep mode, the Sweep time is half the period of the output frequency sweep. Sweep time must be a scalar that is greater than or equal to Target time, Tswtg.

Tunable: Yes

The phase, ϕ0, of the cosine output at t=0; ychirp(t)=cos(ϕ0). You can specify the Initial phase (rad) as a scalar that is greater than or equal to zero.

Tunable: Yes

The sample period, Ts, of the output. The output frame period is MoTs, where Mo is the number of samples per frame.

The number of samples, Mo, to buffer into each output frame, specified as a positive integer scalar.

The data type of the output, specified as single precision or double precision.

Block Characteristics

Data Types

double | single

Direct Feedthrough

no

Multidimensional Signals

no

Variable-Size Signals

no

Zero-Crossing Detection

no

More About

expand all

Algorithms

expand all

The Chirp block uses one of two formulas to compute the block output, depending on the Frequency Sweep parameter setting. For details, see the following sections.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced before R2006a