Intermediate
30 min

Embrace the future of potentiometers with AD5206 and STM32F031K6

Simplify voltage adjustments

DIGI POT 8 Click with Nucleo 32 with STM32F031K6 MCU

Published Oct 01, 2024

Click board™

DIGI POT 8 Click

Dev Board

Nucleo 32 with STM32F031K6 MCU

Compiler

NECTO Studio

MCU

STM32F031K6

From audio equipment to industrial automation, our digital potentiometers offer an electronic means to finely tune parameters, enhancing overall system performance and accuracy

A

A

Hardware Overview

How does it work?

DIGI POT 8 Click is based on the AD5206, 6-channel 256-position digitally controlled device that performs the same electronic adjustment function as a potentiometer or variable resistor from Analog Devices. Each channel of the AD5206 contains a fixed resistor with a wiper contact that taps the fixed resistor value of 100kΩ at a point determined by a digital code loaded into the SPI-compatible serial-input register. The resistance between the wiper and either endpoint of the fixed resistor varies linearly concerning the digital code transferred into the variable resistor (VR) latch. The AD5206 also has an internal Power-On preset that places the wiper in a preset midscale condition at the Power-On state. The AD5206 communicates with MCU through the 3-wire

SPI serial interface with a maximum frequency 10MHz. Each VR has its VR latch that holds its programmed resistance value. These VR latches are updated from an internal serial-to-parallel shift register loaded from a standard 3-wire SPI serial-input digital interface. Eleven bits make up the data word clocked into the serial input register. The first three bits are decoded to determine which VR latch is loaded with the last eight bits of the data word when the CS pin of the SPI serial interface returns to a logic high state. In addition to the AD5206 present on the DIGI POT 8, this Click board™ has four 2x3 male headers. Three of them, under the labels A, W, and B, with the appropriate number, represent the corresponding DIGI POT terminal of the AD5206, while

the fourth header, with the label VCC and GND, represents an additional power supply output. Wiper terminal number 6, labeled as W6, also can be used as an auxiliary wiper output, routed to the AN pin of the mikroBUS ™ socket if the wiper back to the mikroBUS™ is required. This Click board™ can be operated only with a 3.3V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. Also, it comes equipped with a library containing functions and an example code that can be used, as a reference, for further development.

DIGI POT 8 Click top side image
DIGI POT 8 Click bottom side image

Features overview

Development board

Nucleo 32 with STM32F031K6 MCU board provides an affordable and flexible platform for experimenting with STM32 microcontrollers in 32-pin packages. Featuring Arduino™ Nano connectivity, it allows easy expansion with specialized shields, while being mbed-enabled for seamless integration with online resources. The

board includes an on-board ST-LINK/V2-1 debugger/programmer, supporting USB reenumeration with three interfaces: Virtual Com port, mass storage, and debug port. It offers a flexible power supply through either USB VBUS or an external source. Additionally, it includes three LEDs (LD1 for USB communication, LD2 for power,

and LD3 as a user LED) and a reset push button. The STM32 Nucleo-32 board is supported by various Integrated Development Environments (IDEs) such as IAR™, Keil®, and GCC-based IDEs like AC6 SW4STM32, making it a versatile tool for developers.

Nucleo 32 with STM32F031K6 MCU double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

ARM Cortex-M0

MCU Memory (KB)

32

Silicon Vendor

STMicroelectronics

Pin count

32

RAM (Bytes)

4096

You complete me!

Accessories

Click Shield for Nucleo-32 is the perfect way to expand your development board's functionalities with STM32 Nucleo-32 pinout. The Click Shield for Nucleo-32 provides two mikroBUS™ sockets to add any functionality from our ever-growing range of Click boards™. We are fully stocked with everything, from sensors and WiFi transceivers to motor control and audio amplifiers. The Click Shield for Nucleo-32 is compatible with the STM32 Nucleo-32 board, providing an affordable and flexible way for users to try out new ideas and quickly create prototypes with any STM32 microcontrollers, choosing from the various combinations of performance, power consumption, and features. The STM32 Nucleo-32 boards do not require any separate probe as they integrate the ST-LINK/V2-1 debugger/programmer and come with the STM32 comprehensive software HAL library and various packaged software examples. This development platform provides users with an effortless and common way to combine the STM32 Nucleo-32 footprint compatible board with their favorite Click boards™ in their upcoming projects.

Click Shield for Nucleo-32 accessories 1 image

Used MCU Pins

mikroBUS™ mapper

Wiper Output
PA0
AN
NC
NC
RST
SPI Chip Select
PA4
CS
SPI Clock
PB3
SCK
NC
NC
MISO
SPI Data IN
PB5
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
NC
NC
INT
NC
NC
TX
NC
NC
RX
NC
NC
SCL
NC
NC
SDA
NC
NC
5V
Ground
GND
GND
1

Take a closer look

Schematic

DIGI POT 8 Click Schematic schematic

Step by step

Project assembly

Click Shield for Nucleo-144 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Nucleo 32 with STM32F031K6 MCU as your development board.

Click Shield for Nucleo-144 front image hardware assembly
Nucleo 144 with STM32L4A6ZG MCU front image hardware assembly
Stepper 22 Click front image hardware assembly
Prog-cut hardware assembly
Stepper 22 Click complete accessories setup image hardware assembly
Nucleo-32 with STM32 MCU Access MB 1 - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
Necto image step 5 hardware assembly
Necto image step 6 hardware assembly
STM32 M4 Clicker HA MCU/Select Step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware assembly

Track your results in real time

Application Output via Debug Mode

1. Once the code example is loaded, pressing the "DEBUG" button initiates the build process, programs it on the created setup, and enters Debug mode.

2. After the programming is completed, a header with buttons for various actions within the IDE becomes visible. Clicking the green "PLAY" button starts reading the results achieved with the Click board™. The achieved results are displayed in the Application Output tab.

DEBUG_Application_Output

Software Support

Library Description

This library contains API for DIGI POT 8 Click driver.

Key functions:

  • digipot8_write_data - DIGI POT 8 write data function

  • digipot8_set_wiper_1 - DIGI POT 8 set wiper 2 function

  • digipot8_set_wiper_2 - DIGI POT 8 set wiper 3 function

Open Source

Code example

This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.

/*!
 * @file main.c
 * @brief DIGIPOT8 Click example
 *
 * # Description
 * This example demonstrates the use of DIGI POT 8 Click board.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver and makes an initial log.
 *
 * ## Application Task
 * Iterates through the entire wiper range and sets all wipers to 
 * the iterator value each second. 
 * The current wiper position will be displayed on USB UART.
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "digipot8.h"

static digipot8_t digipot8;
static log_t logger;

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    digipot8_cfg_t digipot8_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.

    digipot8_cfg_setup( &digipot8_cfg );
    DIGIPOT8_MAP_MIKROBUS( digipot8_cfg, MIKROBUS_1 );
    err_t init_flag  = digipot8_init( &digipot8, &digipot8_cfg );
    if ( init_flag == SPI_MASTER_ERROR ) 
    {
        log_error( &logger, " Application Init Error. " );
        log_info( &logger, " Please, run program again... " );

        for ( ; ; );
    }

    log_info( &logger, " Application Task " );
}

void application_task ( void ) 
{
    for ( uint8_t cnt = DIGIPOT8_WIPER_POSITION_MIN; cnt < DIGIPOT8_WIPER_POSITION_MAX; cnt += 5 )
    {
        digipot8_set_wiper_1 ( &digipot8, cnt );
        digipot8_set_wiper_2 ( &digipot8, cnt );
        digipot8_set_wiper_3 ( &digipot8, cnt );
        digipot8_set_wiper_4 ( &digipot8, cnt );
        digipot8_set_wiper_5 ( &digipot8, cnt );
        digipot8_set_wiper_6 ( &digipot8, cnt );
        log_printf( &logger, " * All wipers position set to %d *\r\n", ( uint16_t ) cnt );
        
        Delay_ms( 1000 );
    }
}

void main ( void ) 
{
    application_init( );

    for ( ; ; ) 
    {
        application_task( );
    }
}

// ------------------------------------------------------------------------ END

Additional Support

Resources

Love this project?

'Buy This Kit' button takes you directly to the shopping cart where you can easily add or remove products.