TOP Contributors

  1. MIKROE (2653 codes)
  2. Alcides Ramos (351 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (136650 times)
  2. FAT32 Library (69863 times)
  3. Network Ethernet Library (55901 times)
  4. USB Device Library (46244 times)
  5. Network WiFi Library (41871 times)
  6. FT800 Library (41107 times)
  7. GSM click (28960 times)
  8. PID Library (26403 times)
  9. mikroSDK (26325 times)
  10. microSD click (25341 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
mikroSDK Library

Waveform 3 click

Rating:

0

Author: MIKROE

Last Updated: 2024-04-03

Package Version: 2.1.0.10

mikroSDK Library: 2.0.0.0

Category: Clock generator

Downloaded: 177 times

Not followed.

License: MIT license  

Waveform 3 Click is a compact add-on board that represents a high-performance signal generator. This board features the AD9837, a low-power programmable waveform generator capable of producing sine, triangular, and square wave outputs from Analog Devices.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "Waveform 3 click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "Waveform 3 click" changes.

Do you want to report abuse regarding "Waveform 3 click".

  • Information
  • Comments (0)

mikroSDK Library Blog


Waveform 3 click

Waveform 3 Click is a compact add-on board that represents a high-performance signal generator. This board features the AD9837, a low-power programmable waveform generator capable of producing sine, triangular, and square wave outputs from Analog Devices.

waveform3_click.png

click Product page


Click library

  • Author : Stefan Nikolic
  • Date : jan 2021.
  • Type : SPI type

Software Support

We provide a library for the Waveform3 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 from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on mikroE github account.

Library Description

This library contains API for Waveform3 Click driver.

Standard key functions :

  • waveform3_cfg_setup Config Object Initialization function.

    void waveform3_cfg_setup ( waveform3_cfg_t *cfg );
  • waveform3_init Initialization function.

    WAVEFORM3_RETVAL waveform3_init ( waveform3_t *ctx, waveform3_cfg_t *cfg );
  • waveform3_default_cfg Click Default Configuration function.

    void waveform3_default_cfg ( waveform3_t *ctx );

Example key functions :

  • waveform3_set_mode This function sets output mode, freq and phase channels of AD9837 waveform generator.

    void waveform3_set_mode ( waveform3_t *ctx, uint8_t mode, uint8_t freq_reg, uint8_t phase_reg );
  • waveform3_set_freq This function sets desired frequency ( in Hz ) on desired freq channel.

    uint32_t waveform3_set_freq ( waveform3_t *ctx, uint32_t frequency, uint8_t freq_reg );
  • waveform3_set_phase This function sets desired phase shift ( in degrees ) on desired phase channel.

    uint16_t waveform3_set_phase ( waveform3_t *ctx, float phase, uint8_t phase_reg );

Example Description

This demo app shows the basic capabilities of Waveform 3 click board. First, the sinusoidal wave is incremented to targeted frequency for visually pleasing introduction after which it changes between 4 modes of output.

The demo application is composed of two sections :

Application Init

Application initializes the UART LOG and SPI drivers, resets the device and sets frequency and phase shift to default values. In the end, the mode is set with the preferred freq and phase channel.


void application_init ( void ) {
    log_cfg_t log_cfg;              /**< Logger config object. */
    waveform3_cfg_t waveform3_cfg;  /**< Click config object. */

    /** 
     * Logger initialization.
     * Default baud rate: 115200
     * Default log level: LOG_LEVEL_DEBUG
     * @note If USB_UART_RX and USB_UART_TX 
     * are defined as HAL_PIN_NC, you will 
     * need to define them manually for log to work. 
     * See @b LOG_MAP_USB_UART macro definition for detailed explanation.
     */
    LOG_MAP_USB_UART( log_cfg );
    log_init( &logger, &log_cfg );
    log_info( &logger, " Application Init " );

    // Click initialization.

    waveform3_cfg_setup( &waveform3_cfg );
    WAVEFORM3_MAP_MIKROBUS( waveform3_cfg, MIKROBUS_1 );
    err_t init_flag  = waveform3_init( &waveform3, &waveform3_cfg );
    if ( init_flag == SPI_MASTER_ERROR ) {
        log_error( &logger, " Application Init Error. " );
        log_info( &logger, " Please, run program again... " );

        for ( ; ; );
    }

    waveform3_default_cfg( &waveform3 );
    Delay_ms ( 500 );
    log_info( &logger, " Application Task " );
    waveform3_set_mode( &waveform3, WAVEFORM3_CFG_MODE_SINUSOIDAL, WAVEFORM3_CFG_FREQ_REG0, WAVEFORM3_CFG_PHASE_REG0 );
}

Application Task

Task commences with the start frequency rising up to the targeted one. When it reaches desired frequency, the mode changes every 5 seconds which includes: sinusoidal, triangular, DAC divided by 2 and DAC outputs respectively.


void application_task ( void ) {
    uint8_t cfg_mode_switch;

    if ( start_frequency < target_frequency ) {
        if ( start_frequency / rising_factor < 100 ) {
            start_frequency += rising_factor;
            waveform3_set_freq( &waveform3, start_frequency, WAVEFORM3_CFG_FREQ_REG0 );
            Delay_ms ( 5 );
        } else {
            rising_factor += 10;
        }
    } else {
        for ( cfg_mode_switch = 0 ; cfg_mode_switch < 4 ; cfg_mode_switch++ ) {
        waveform3_set_mode( &waveform3, cfg_mode_switch, WAVEFORM3_CFG_FREQ_REG0, WAVEFORM3_CFG_PHASE_REG0 );
        Delay_ms ( 1000 );
        Delay_ms ( 1000 );
        Delay_ms ( 1000 );
        Delay_ms ( 1000 );
        Delay_ms ( 1000 );
        }
    }
}

Note

Waveform 3 click might not provide a high enough peak to peak signal on higher frequencies. The user can freely implement custom buffer for the output stage.

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on mikroE github account.

Other mikroE Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Waveform3

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.


ALSO FROM THIS AUTHOR

LEM click

6

LEM click carries the LTS 6-NP current transducer and MCP3201 ADC converter. The click can measure AC and DC current with exceptional speed, up to 200 KHz. LEM click is designed to run on either 3.3V or 5V power supply. It communicates with the target microcontroller over SPI interface.

[Learn More]

LED Driver 16 click

0

LED Driver 16 Click is a compact add-on board that simplifies the control of multiple LEDs. This board features the PCA9745B, an SPI-configurable sixteen-channel constant current LED driver from NXP Semiconductors. Each LED output has an 8-bit resolution (256 steps) fixed-frequency individual PWM controller that operates at 31.25kHz with an adjustable duty cycle from 0 to 100% to allow the LED to be set to a specific brightness value. Powered through a selected mikroBUS™ power rail, either 3.3V or 5V, it provides a maximum output current of 57mA per channel and multiple built-in protection functions that protect the circuit during abnormalities.

[Learn More]

LTE IoT 3 click

0

LTE IoT 3 Click is a compact add-on board that contains a Low Power Wide Area (LPWA) Wireless IoT module that allows connections to the LTE CAT-M1, CAT NB1/2, and 2G networks. This board features the EXS82-W, LTE-IoT Wireless Module from Thales that offers a rich set of Internet protocols and industry-standard interfaces such as UART, USB, etc. Global IoT connectivity, integrated GNSS support, SMS support, extended coverage range, and reduced power consumption makes this single IoT module an excellent choice for device makers while ensuring worldwide reliability.

[Learn More]