ChirpConfig

ChirpConfig stores the complete AWG output waveform definition: the ordered list of frequency-sweep and gap segments for each chirp in a multi-chirp sequence, the inter-chirp interval, the AWG sample rate, and the marker channel definitions. All time quantities are in microseconds; all frequency quantities are in MHz. ChirpConfig is owned by RfConfig as the d_chirpConfig member and is a child HeaderStorage node in the experiment header tree. The user-facing controls for building chirp waveforms are described in Chirp Setup.

The segment list is a two-dimensional structure: a vector of chirps, each containing an ordered vector of ChirpConfig::ChirpSegment records. A segment is either a linear frequency sweep (empty = false) or a silent gap (empty = true). If all chirps share the same segment list, ChirpConfig::allChirpsIdentical() returns true, which allows RfConfig to simplify sweep accounting.

Marker channels

MarkerChannel descriptors define the timing and role of each AWG marker output. Each AWG reports how many physical marker outputs it supports via the BC::Key::AWG::markerCount setting. The waveform generation methods produce output indexed in logical channel order; each AWG driver maps logical bit positions to hardware bit positions as required by its data format.

The MarkerRole classification drives safety validation in the experiment wizard:

  • Protection — the marker pulse that prevents high-power chirp energy from reaching sensitive amplifiers. The wizard warns when no enabled protection marker fully encloses the gate and chirp windows.

  • Gate — the amplifier-enable pulse. Enclosed by the protection marker.

  • Trigger — a general digitizer or instrument trigger.

  • Custom — any other use; no safety constraints are enforced.

All marker channels use ChirpRelative timing: startTime is the start offset in μs relative to each chirp’s start (negative = before the chirp begins) and endTime is the end offset in μs relative to each chirp’s end (positive = after the chirp ends). The waveform lead time and tail time are computed as the maximum required offsets across all enabled channels.

For guidance on integrating ChirpConfig into a new experiment mode, see Adding an Experiment Mode.

API Reference

class ChirpConfig : public HeaderStorage

Chirp waveform and marker configuration.

ChirpConfig stores the complete definition of the AWG output waveform: the segment list for each chirp in a multi-chirp sequence, the inter-chirp interval, the AWG sample rate, and the marker channel definitions. All time values are in microseconds; all frequency values are in MHz.

The chirp waveform is a vector of chirp intervals, each containing an ordered list of ChirpSegment records. Segments may be linear-frequency sweeps or silent gaps (empty = true). Each chirp’s total duration is the sum of its segment durations. If all chirps have identical segments, allChirpsIdentical() returns true, which allows RfConfig to optimize sweep accounting.

Marker channels are defined by a QVector<MarkerChannel>; the AWG reports its physical marker count via the BC::Key::AWG::markerCount setting. The waveform generation methods (getMarkerData(), getPackedMarkerData()) produce output indexed by the logical channel order; each AWG driver remaps logical bit positions to physical output positions as required by its hardware data format.

Note

The AWG sample rate must be set via setAwgSampleRate() before calling any waveform generation method; it is not persisted in the header and is reconstructed from the active AWG profile on load.

Public Functions

ChirpConfig()

Constructs a default ChirpConfig with no segments and no marker channels.

~ChirpConfig()
void readChirpFile(BlackchirpCSV *csv, int num, QString path = QString(""))

Reads the chirp segment CSV file for experiment num.

Populates d_chirpList from the chirps.csv file located under the experiment directory for num. If path is empty the default data directory is used.

bool writeChirpFile(int num) const

Writes the chirp segment CSV file for experiment num.

Returns false if the file cannot be opened for writing.

void readMarkersFile(BlackchirpCSV *csv, int num, QString path = QString(""))

Reads the marker channel CSV file for experiment num.

Replaces the current marker channel list with the contents of markers.csv. If path is empty the default data directory is used.

bool writeMarkersFile(int num) const

Writes the marker channel CSV file for experiment num.

Returns false if the file cannot be opened for writing.

double leadTimeUs() const

Returns the waveform lead time in µs before the first chirp start.

Computed as max(0, max(-m.startTime)) over all enabled channels with ChirpRelative timing. This is the pre-roll added before each chirp interval to accommodate markers that begin before the chirp itself.

double tailTimeUs() const

Returns the waveform tail time in µs after each chirp end.

Computed as max(0, max(m.endTime)) over all enabled channels with ChirpRelative timing.

int numChirps() const

Returns the number of chirps in the sequence.

double chirpInterval() const

Returns the inter-chirp interval in µs.

The interval is measured from the start of one chirp window to the start of the next, including the lead time. A value of -1 indicates the interval has not been set.

bool allChirpsIdentical() const

Returns true if every chirp in the sequence has identical segment lists.

QVector<QVector<ChirpSegment>> chirpList() const

Returns a copy of the full chirp segment list (chirps × segments).

double segmentStartFreq(int chirp, int segment) const

Returns the start frequency in MHz for the given chirp and segment indices.

Returns -1.0 if either index is out of range.

double segmentEndFreq(int chirp, int segment) const

Returns the end frequency in MHz for the given chirp and segment indices.

Returns -1.0 if either index is out of range.

double segmentDuration(int chirp, int segment) const

Returns the duration in µs for the given chirp and segment indices.

Returns -1.0 if either index is out of range.

bool segmentEmpty(int chirp, int segment) const

Returns true if the segment at the given indices is a silent gap.

Returns true if either index is out of range.

QByteArray waveformHash() const

Returns a SHA-256 hash of the waveform parameters.

The hash covers the marker channel definitions (name, role, start time, end time, enabled state) and all chirp segment parameters (start and end frequencies, duration, empty flag), along with the chirp count and interval. Two ChirpConfig objects with identical hashes will produce identical AWG waveforms. The sample rate is excluded because it is hardware-derived and not recorded in the stored configuration.

double chirpDurationUs(int chirpNum) const

Returns the total duration of chirp chirpNum in µs.

Sums the durations of all segments in that chirp. Returns 0 if chirpNum is out of range.

double totalDuration() const

Returns the total waveform duration in µs.

Computed as leadTimeUs() + (numChirps() - 1) * chirpInterval() + chirpDurationUs(last) + tailTimeUs().

QVector<QPointF> getChirpMicroseconds() const

Returns the chirp waveform as a vector of (time_µs, amplitude) points spanning the full duration.

QVector<QPointF> getChirpSegmentMicroSeconds(double t1, double t2) const

Returns a slice of the chirp waveform for the time range [t1, t2) in µs.

Used by ChirpConfigPlot to render a zoomed view without computing the full waveform.

QVector<QVector<bool>> getMarkerData() const

Returns per-channel marker data as a 2-D boolean array (channels × samples).

The outer dimension is indexed by logical marker channel index (matching markerChannels()); the inner dimension is indexed by waveform sample. Only enabled channels contribute non-false entries. The AWG sample rate must be set via setAwgSampleRate() before calling this method.

QVector<quint32> getPackedMarkerData() const

Returns marker data packed into one quint32 per sample (bit 0 = channel 0).

This is a convenience format for AWG drivers that can consume packed data directly. Each driver is responsible for remapping the logical bit order to its hardware’s physical output bit positions. Requires the AWG sample rate to be set via setAwgSampleRate().

const QVector<MarkerChannel> &markerChannels() const

Returns a const reference to the marker channel list.

const MarkerChannel *findEnabledMarkerByRole(MarkerRole role) const

Returns a pointer to the first enabled marker channel with the given role.

Returns nullptr if no enabled channel with that role exists. Used by FtmwConfig to obtain trigger timing and by the validation page to check protection/gate enclosure.

void setAwgSampleRate(const double samplesPerSecond)

Sets the AWG sample rate from the hardware value in samples per second.

Converts to the internal representation (samples per µs and µs per sample). Must be called before any waveform generation method.

void setNumChirps(const int n)

Sets the total number of chirps, extending or truncating the chirp list.

When growing the list, new entries are copied from the first chirp (or left empty if the list is currently empty). When shrinking, trailing entries are removed.

void setChirpInterval(const double i)

Sets the inter-chirp interval in µs.

void setMarkerChannels(const QVector<MarkerChannel> &channels)

Replaces the entire marker channel list.

void addSegment(const double startMHz, const double endMHz, const double durationUs, const int chirpNum = -1)

Appends a frequency-sweep segment to the specified chirp (or all chirps when chirpNum < 0).

Negative values for startMHz, endMHz, or durationUs are ignored.

Parameters:
  • startMHz – Segment start frequency in MHz.

  • endMHz – Segment end frequency in MHz.

  • durationUs – Segment duration in µs.

  • chirpNum – Chirp index to append to; -1 appends to all chirps.

void addEmptySegment(const double durationUs, const int chirpNum = -1)

Appends a silent-gap segment of durationUs to the specified chirp (or all chirps when chirpNum < 0).

void setChirpList(const QVector<QVector<ChirpSegment>> l)

Replaces the entire chirp segment list with l.

Protected Functions

virtual void storeValues() override

Writes chirp interval and sample rate to the header storage tree.

virtual void retrieveValues() override

Reads chirp interval and sample rate back from the header storage tree.

Private Functions

int getFirstSample(double time) const
int getLastSample(double time) const
double getSampleTime(const int sample) const
double calculateChirp(const ChirpSegment segment, const double t, const double phase) const
double calculateEndingPhaseRadians(const ChirpSegment segment, const double endingTime, const double startingPhase) const

Private Members

QVector<MarkerChannel> d_markerChannels
double d_chirpInterval = {-1.0}
double d_sampleRateSperUS
double d_sampleIntervalUS
QVector<QVector<ChirpSegment>> d_chirpList
struct ChirpSegment

Single frequency-sweep or gap segment within a chirp.

Public Members

double startFreqMHz = {0.0}

Start frequency in MHz; ignored when empty is true.

double endFreqMHz = {0.0}

End frequency in MHz; ignored when empty is true.

double durationUs = {0.0}

Segment duration in microseconds.

double alphaUs = {0.0}

Chirp rate in MHz/µs, computed as (endFreqMHz - startFreqMHz) / durationUs.

bool empty = {false}

When true the segment generates zero-amplitude samples (a gap).

struct MarkerChannel

Descriptor for a single AWG marker output channel.

Each MarkerChannel maps to one physical marker output on the AWG. The timingMode determines how startTime and endTime are interpreted:

  • ChirpRelative: startTime is measured in µs relative to each chirp’s start (negative values extend before the chirp); endTime is measured relative to each chirp’s end (positive values extend after the chirp). The marker repeats for every chirp interval.

  • Absolute: reserved for future use; storage and readback are supported but the Absolute branch is not yet honored by the waveform generator.

The lead time before each chirp interval and the tail time after it are derived from the maximum required startTime and endTime values across all enabled channels.

Public Types

enum TimingMode

Timing reference for startTime and endTime.

Values:

enumerator Absolute

Times are measured from the first chirp start (reserved; not yet honored by waveform generation).

enumerator ChirpRelative

Times are measured relative to each chirp’s start/end, repeating per interval.

Public Members

QString name

User-visible label for this marker channel.

TimingMode timingMode = {ChirpRelative}

Timing mode; ChirpRelative by default.

double startTime = {-0.5}

Start offset in µs relative to the chirp start (ChirpRelative) or waveform origin (Absolute). Negative values precede the chirp.

double endTime = {0.5}

End offset in µs relative to the chirp end (ChirpRelative) or waveform origin (Absolute). Positive values follow the chirp.

bool enabled = {true}

Whether this channel contributes to the generated waveform.

MarkerRole role = {MarkerRole::Custom}

Role classification used for safety validation.

enum class MarkerRole

Role classification for an AWG marker channel.

The role drives safety validation in the experiment wizard: Protection and Gate roles are checked to ensure the protection pulse encloses the gate and chirp windows, preventing high-power energy from reaching sensitive amplifiers. Trigger marks a general digitizer or instrument trigger. Custom imposes no safety constraints.

Values:

enumerator Protection

Safety interlock: must enclose the Gate window and the chirp. Absence triggers a wizard warning.

enumerator Gate

Amplifier-enable pulse. Must be enclosed by the Protection marker.

enumerator Trigger

General digitizer or instrument trigger.

enumerator Custom

Any other use. No safety constraints are enforced.