1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python3
# Two versions of the chirp function are provided. Depending on need
# it is more convenient sometimes to describe a chirp in terms of low
# and high frequencies, along with time length of chirp. Other times
# it is convenient to describe chirp in terms of number of center frequency,
# bandwidth, repetition rate, and sample rate.
#
# The frequency based version generates the chirp waveform. The center
# frequency described version simply has its parameters used to generate
# new parameters to call the first version.
#
# See http://en.wikipedia.org/wiki/Chirp for details on derivation.
#
# Mike Markowski, mike.ab3ap@gmail.com
# Mar 4, 2015
# chirp
#
# Generate a frequency sweep from low to high over time.
# Waveform description is based on number of samples.
#
# Inputs
# fs_Hz: float, sample rate of chirp signal.
# rep_Hz: float, repetitions per second of chirp.
# f0_Hz: float, start (lower) frequency in Hz of chirp.
# f1_Hz: float, stop (upper) frequency in Hz of chirp.
# phase_rad: float, phase in radians at waveform start, default is 0.
#
# Output
# Time domain chirp waveform of length numnSamples.
= 1 / # Period of chirp in seconds.
= / # Chirp rate in Hz/s.
= # Samples per repetition.
= # Chirp sample times.
# Phase, phi_Hz, is integral of frequency, f(t) = ct + f0.
= / 2 + # Instantaneous phase.
= 2 * * # Convert to radians.
+= # Offset by user-specified initial phase.
return # Complex I/Q.
# chirpCtr
#
# Convenience function to create a chirp based on center frequency and
# bandwidth. It simply calculates start and stop freuqncies of chirp and
# calls the chirp creation function.
#
# Inputs
# fs_Hz: sample rate in Hz of chirp waveform.
# fc_Hz: float, center frequency in Hz of the chirp.
# rep_Hz: integer, number of full chirps per second.
# bw_Hz: float, bandwidth of chirp.
# phase_rad: phase in radians at waveform start, default is 0.
#
# Output
# Time domain chirp waveform.
= - / 2.
= + / 2.
return