Chirp wave#

typedef struct uz_wavegen_chirp uz_wavegen_chirp#

Object definition for generating a chirp signal.

struct uz_wavegen_chirp_config#

Configuration struct for chirp generation, pass to init function. Accessible by the user.

Public Members

float amplitude#

Amplitude of the chirp signal

float start_frequency_Hz#

Start frequency of the chirp in Hz. Only positive values are permitted

float end_frequency_Hz#

End frequency of the chirp in Hz. Only positive values are permitted

float duration_sec#

Duration of the transition from start to end frequency in seconds. Only positive values are permitted

float initial_delay_sec#

Delay after first function call until transition starts in seconds. No negative values are permitted

float offset#

Offset of the chirp wave

uz_wavegen_chirp *uz_wavegen_chirp_init(struct uz_wavegen_chirp_config config)#

Initialization of a wavegenerator for a chirp signal.

Parameters:
  • config – Configuration struct

Returns:

Pointer to wavegen_chirp instance

float uz_wavegen_chirp_sample(uz_wavegen_chirp *self)#

Returns one sample of the chirp.

Parameters:
  • self – wavegen_chirp instance

Returns:

One sample of the chirp output for current system time

void uz_wavegen_chirp_reset(uz_wavegen_chirp *self)#

Resets the wavegen_chirp instance.

Parameters:
  • self – wavegen_chirp instance

Chrip wave example#

The following define has to be set in uz_global_configuration.h to set the maximum of required instances, with x defining the maximum for how often uz_wavegen_chirp_init will be called.

#define UZ_WAVEGEN_CHIRP_MAX_INSTANCES x

Initialize the config file:

struct uz_wavegen_chirp_config config_chirp = {
        .amplitude = 2.0f,
        .start_frequency_Hz = 1.0f,
        .end_frequency_Hz = 10.0f,
        .duration_sec = 10.0f,
        .initial_delay_sec = 0.0f,
        .offset = 1.0f
};

Call the init function:

int main(void) {
   uz_wavegen_chirp* chirp_instance=uz_wavegen_chirp_init(config_chirp);
   float chirp_sample=uz_wavegen_chirp_sample(chirp_instance);
}

The function uz_wavegen_chirp_reset() resets the chirp such that it can be started again from the start frequency. A subsequent call of uz_wavegen_chirp() will start the chirp function from \(t=0\) again.

Description#

Outputs one sample of a configurable chirp for each function call based on the global system time. The parameters for configuration are the amplitude, the start and end frequency, the duration for the chirp and a delay for the start of the chirp wave. After the duration of the chirp wave, the function uz_wavegen_chirp_sample() will return a normal sine wave with the end_frequency_Hz. For the input arguments a struct is required.

Figure made with TikZ

Fig. 270 chirp wave