Square wave#

float uz_wavegen_square(float amplitude, float frequency_Hz, float duty_cycle)#

Returns one sample of a square wave.

Parameters:
  • amplitude – Amplitude for the square wave

  • frequency_Hz – Frequency for the square wave in Hz. Only positive values are permitted

  • duty_cycle – Duty Cycle for the square wave. Only values 0.0 <= DutyCycle <= 1.0 is permitted

Returns:

Returns one sample for current system time

Example#

Listing 73 Example function call to square wave generator#
1#include "uz_wavegen.h"
2int main(void) {
3   float amplitude = 6.0f;
4   float frequency_Hz = 20.0f;
5   float duty_cycle = 0.5f;
6   float output = uz_wavegen_square(amplitude, frequency_Hz, duty_cycle);
7}

Description#

This function calculates a square wave based on the global system time.

Figure made with TikZ

Fig. 276 square wave