waveform  2.0.0.0
Main Page

Waveform click

Waveform Click is a precise sine/triangle/square waveform generator, capable of reproducing frequencies up to 12MHz.

click Product page


Click library

  • Author : MikroE Team
  • Date : Dec 2019.
  • Type : SPI type

Software Support

We provide a library for the Waveform Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly form compilers IDE(recommended way), or downloaded from our LibStock, or found on mikroE github account.

Library Description

This library contains API for Waveform Click driver.

Standard key functions :

Example key functions :

  • Freqency function

    void waveform_write_freqency ( waveform_t *ctx, uint32_t f );

  • Triangle output function

    void waveform_triangle_output ( waveform_t *ctx, uint32_t f );

  • Square output function

    void waveform_square_output ( waveform_t *ctx, uint32_t f );

Examples Description

This program outputs wave forms.

The demo application is composed of two sections :

Application Init

Initialize the communication interface and configure the click board.

{
log_cfg_t log_cfg;
// Logger initialization.
LOG_MAP_USB_UART( log_cfg );
log_cfg.level = LOG_LEVEL_DEBUG;
log_cfg.baud = 115200;
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
// Click initialization.
WAVEFORM_MAP_MIKROBUS( cfg, MIKROBUS_1 );
waveform_init( &waveform, &cfg );
waveform_square_output( &waveform, freq );
freq = 0;
}

Application Task

Predefined characters are inputed from the serial port. Depending on the character sent the signal frequency, waveform or amplitude will be changed.

{
uint8_t rx_len = log_read ( &logger, rx_data_buffer, 1 );
if ( rx_len > 0 )
{
switch( rx_data_buffer[ 0 ] )
{
case '+': {
waveform_digipot_inc( &waveform );
log_printf( &logger, "Increasing amplitude of the current wave.\r\n" );
break;
}
case '-': {
waveform_digipot_dec( &waveform );
log_printf( &logger, "Decreasing amplitude of the current wave.\r\n" );
break;
}
case 'S': {
log_printf( &logger, "Increasing frequency of the sine wave.\r\n" );
break;
}
case 's': {
log_printf( &logger, "Decreasing frequency of the sine wave.\r\n" );
break;
}
case 'T': {
log_printf( &logger, "Increasing frequency of the triangle wave.\r\n" );
break;
}
case 't': {
log_printf( &logger, "Decreasing frequency of the triangle wave.\r\n" );
break;
}
case 'Q': {
log_printf( &logger, "Increasing frequency of the square wave.\r\n" );
break;
}
case 'q': {
log_printf( &logger, "Decreasing frequency of the square wave.\r\n" );
break;
}
default :{
break;
}
}
rx_data_buffer[ 0 ] = 0;
rx_len = 0;
}
}

The full application code, and ready to use projects can be installed directly form compilers IDE(recommneded) or found on LibStock page or mikroE GitHub accaunt.

Other mikroE Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Waveform

Additional notes and informations

Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all Mikroelektronika compilers, or any other terminal application of your choice, can be used to read the message.


application_init
void application_init()
Definition: main.c:99
WAVEFORM_SINE_OUT
#define WAVEFORM_SINE_OUT
Definition: waveform.h:93
waveform_digipot_dec
void waveform_digipot_dec(waveform_t *ctx)
Decrement function.
WAVEFORM_MAP_MIKROBUS
#define WAVEFORM_MAP_MIKROBUS(cfg, mikrobus)
Definition: waveform.h:54
frequency_increment
void frequency_increment(uint8_t output_mode)
Definition: main.c:78
waveform_digipot_inc
void waveform_digipot_inc(waveform_t *ctx)
Increment function.
waveform_cfg_setup
void waveform_cfg_setup(waveform_cfg_t *cfg)
Config Object Initialization function.
waveform_aprox_freqcalculation
uint32_t waveform_aprox_freqcalculation(float freqency)
Definition: main.c:51
application_task
void application_task()
Definition: main.c:123
waveform_square_output
void waveform_square_output(waveform_t *ctx, uint32_t f)
Square output function.
frequency_decrement
void frequency_decrement(uint8_t output_mode)
Definition: main.c:86
waveform_init
WAVEFORM_RETVAL waveform_init(waveform_t *ctx, waveform_cfg_t *cfg)
Initialization function.
waveform_cfg_t
Click configuration structure definition.
Definition: waveform.h:126
WAVEFORM_TRIANGLE_OUT
#define WAVEFORM_TRIANGLE_OUT
Definition: waveform.h:94
WAVEFORM_SQUARE_OUT
#define WAVEFORM_SQUARE_OUT
Definition: waveform.h:95