Intermediate
30 min

Make hands-free control with VC-02 and PIC32MZ1024EFF144

Control your device using speech

SpeakUp 3 Click with Fusion for PIC32 v8

Published Feb 27, 2023

Click board™

SpeakUp 3 Click

Development board

Fusion for PIC32 v8

Compiler

NECTO Studio

MCU

PIC32MZ1024EFF144

Pure offline speech recognition solution

A

A

Hardware Overview

How does it work?

SpeakUp 3 Click is based on the VC-02, an offline voice recognition AI module from Ai-Thinker Technology, characterized by high reliability and robust versatility. The VC-02 module uses an integrated voice chip US516P6 from Unisound, which continuously optimizes and innovates algorithms in speech recognition technology. The offline recognition algorithm is deeply integrated with the chip architecture, providing customers with an ultra-low-cost offline voice recognition solution. This board can be widely and quickly applied to all smart small household appliances and products requiring voice control. The US516P6 chip uses a 32-bit RSIC architecture core, running at 240MHz, and incorporates a DSP instruction explicitly set for signal processing and speech recognition, an FPU arithmetic unit that supports floating-point operations, and an FFT accelerator (support 1024-point complex FFT/IFFT operations, or 2048-point real FFT/IFFT operations). What makes this module unique are features like

offline identification of 150 local instructions and self-learning of wake-up words, RTOS lightweight system, 90% recognition rate in a far field distance from 1 up to 5m, firmware update feature, as well as the selection of the communication method with the module. This Click board™ comes with a configurable host interface allowing communication with MCU using the chosen interface. The VC-02 can communicate with MCU using the UART interface, a default communication interface with commonly used UART RX and TX pins, and a default baud rate of 115200bps. Users can also use other interfaces, such as SPI and I2C, to configure the module and write the library by themselves. At the center of the SpeakUp 3 Click, an additional unpopulated header offers full support for debugging and programming capabilities. The Ai-Thinker has provided its users with a VC series development page. With a simple registration, they can create

their own command list/SDK/firmware for this module quickly and easily for free. With this header, the user can use a JTAG interface, in addition to the UART interface, for programming and debugging available through the JTAG interface pins (TCK and TMS). For more information and help when creating custom firmware, you can contact their help center. A special addition to this Click board™ are connectors, marked as MIC and SPK, for an analog omnidirectional microphone and 8Ω 2W cavity speaker from Shenzhen Anxinke Technology. These parts can be found in the same package as the Click board or can be acquired as a solo version in our shop. This Click board™ can only be operated with a 3.3V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. However, the Click board™ comes equipped with a library containing functions and an example code that can be used as a reference for further development.

SpeakUp 3 Click top side image
SpeakUp 3 Click lateral side image
SpeakUp 3 Click bottom side image

Features overview

Development board

Fusion for PIC32 v8 is a development board specially designed for the needs of rapid development of embedded applications. It supports a wide range of Microchip's PIC32 microcontrollers regardless of their number of pins and a broad set of unique functions, such as the first-ever embedded debugger/programmer over WiFi. The development board is well organized and designed so that the end-user has all the necessary elements, such as switches, buttons, indicators, connectors, and others, in one place. Thanks to innovative manufacturing technology, Fusion for PIC32 v8 provides a fluid and immersive working experience, allowing access anywhere and under any circumstances at any time. Each part of the

Fusion for PIC32 v8 development board contains the components necessary for the most efficient operation of the same board. In addition to the advanced integrated CODEGRIP programmer/debugger module, which offers many valuable programming/debugging options and seamless integration with the Mikroe software environment, the board also includes a clean and regulated power supply module for the development board. It can use a wide range of external power sources, including a battery, an external 12V power supply, and a power source via the USB Type-C (USB-C) connector. Communication options such as USB-UART, USB HOST/DEVICE, CAN (on the MCU card, if

supported), and Ethernet is also included. In addition, it also has the well-established mikroBUS™ standard, a standardized socket for the MCU card (SiBRAIN standard), and two display options for the TFT board line of products and character-based LCD. Fusion for PIC32 v8 is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

Fusion for PIC32 v8 horizontal image

Microcontroller Overview

MCU Card / MCU

default

Type

8th Generation

Architecture

PIC32

MCU Memory (KB)

1024

Silicon Vendor

Microchip

Pin count

144

RAM (Bytes)

262144

You complete me!

Accessories

Microphone with PH2.0 female connector is an analog-type omnidirectional electret microphone, an electrostatic capacitor-based microphone, and is available with a lead terminated in a PH2.0 female connector. This microphone eliminates the need for a polarizing power supply by using permanently-charged material. With operating frequencies ranging from 100 to 20.000Hz, the microphone features sensitivity ratings as low as -40dB (±3) and signal-to-noise ratios from 57 to 70dBA (typical 60dBA). Housed in a compact package with diameters as small as 6mm, this omnidirectional microphone is ideally suited for various high-quality recordings in industrial and outdoor applications where moisture and environmental contaminants are present.

SpeakUp 3 Click accessories 1 image

Speaker with PH2.0 female connector is an 8Ω 2W portable all-in-one passive cavity speaker available in wire-lead mount configuration with a PH2.0 female connector with an operating frequency of 100kHz. This speaker is characterized by a long service life based on excellent build-material and technology, which enhance its service life, making it convenient and reliable. It is also built on strict quality control standards (design improved for more durability) with a low distortion rate, keeping the sound stable (clear sound quality providing superb music reproductions). Housed in a compact package with dimensions of 40×20×5.8mm (LxWxH), this cavity loudspeaker offers stable performance ideally suited for various audio-producing applications in consumer, medical, security, and many more.

SpeakUp 3 Click accessories 2 image

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
NC
NC
RST
NC
NC
CS
SPI Clock
PD1
SCK
SPI Data OUT
PG8
MISO
SPI Data IN
PG7
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
NC
NC
INT
UART TX
PB14
TX
UART RX
PB15
RX
I2C Clock
PA2
SCL
I2C Data
PA3
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Schematic

SpeakUp 3 Click Schematic schematic

Step by step

Project assembly

Fusion for PIC v8 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Fusion for PIC32 v8 as your development board.

Fusion for PIC v8 front image hardware assembly
GNSS2 Click front image hardware assembly
SiBRAIN for PIC32MZ1024EFK144 front image hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
v8 SiBRAIN 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 Compiler Selection Step Image hardware assembly
NECTO Output Selection Step Image hardware assembly
Necto image step 6 hardware assembly
Necto image step 7 hardware assembly
Necto image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Necto PreFlash Image hardware assembly

Track your results in real time

Application Output

After pressing the "FLASH" button on the left-side panel, it is necessary to open the UART terminal to display the achieved results. By clicking on the Tools icon in the right-hand panel, multiple different functions are displayed, among which is the UART Terminal. Click on the offered "UART Terminal" icon.

UART Application Output Step 1

Once the UART terminal is opened, the window takes on a new form. At the top of the tab are two buttons, one for adjusting the parameters of the UART terminal and the other for connecting the UART terminal. The tab's lower part is reserved for displaying the achieved results. Before connecting, the terminal has a Disconnected status, indicating that the terminal is not yet active. Before connecting, it is necessary to check the set parameters of the UART terminal. Click on the "OPTIONS" button.

UART Application Output Step 2

In the newly opened UART Terminal Options field, we check if the terminal settings are correct, such as the set port and the Baud rate of UART communication. If the data is not displayed properly, it is possible that the Baud rate value is not set correctly and needs to be adjusted to 115200. If all the parameters are set correctly, click on "CONFIGURE".

UART Application Output Step 3

The next step is to click on the "CONNECT" button, after which the terminal status changes from Disconnected to Connected in green, and the data is displayed in the Received data field.

UART Application Output Step 4

Software Support

Library Description

This library contains API for SpeakUp 3 Click driver.

Key functions:

  • speakup3_generic_read This function reads a desired number of data bytes by using UART serial interface.

  • speakup3_wait_for_reply This function waits up to @b wait_ms for a reply to the voice command.

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 SpeakUp 3 Click Example.
 *
 * # Description
 * This example demonstrates the use of the SpeakUp 3 click board by reading
 * and displaying the voice commands reply messages.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes driver and logger.
 *
 * ## Application Task
 * Waits for the reply message to a voice command and displays it on the USB UART.
 *
 * ## Additional Function
 * - static void speakup3_display_reply ( void )
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "speakup3.h"

static speakup3_t speakup3;
static log_t logger;

/**
 * @brief SpeakUp 3 display reply function.
 * @details This function displays on the USB UART the reply message for the selected
 * reply instruction code.
 * @param[in] reply_ins : Reply instruction code.
 * @return None.
 * @note None.
 */
static void speakup3_display_reply ( uint8_t reply_ins );

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    speakup3_cfg_t speakup3_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.
    speakup3_cfg_setup( &speakup3_cfg );
    SPEAKUP3_MAP_MIKROBUS( speakup3_cfg, MIKROBUS_1 );
    if ( UART_ERROR == speakup3_init( &speakup3, &speakup3_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    log_info( &logger, " Application Task " );
}

void application_task ( void ) 
{
    uint8_t reply_ins;
    if ( SPEAKUP3_OK == speakup3_wait_for_reply ( &speakup3, &reply_ins, 1000 ) )
    {
        speakup3_display_reply ( reply_ins );
    }
}

void main ( void ) 
{
    application_init( );

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

static void speakup3_display_reply ( uint8_t reply_ins )
{
    log_printf( &logger, " Reply: " );
    switch ( reply_ins )
    {
        case SPEAKUP3_INS_ENTER_WAKE_UP:
        {
            log_printf( &logger, "Hi, how can I help? / Hi, what's up? / Yes, I'm here.\r\n" );
            break;
        }
        case SPEAKUP3_INS_EXIT_WAKE_UP:
        {
            log_printf( &logger, "See you later.\r\n" );
            break;
        }
        case SPEAKUP3_INS_LEARN_MATCH_AC:
        {
            log_printf( &logger, "OK, match the air conditioner.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TURN_ON:
        {
            log_printf( &logger, "OK, turn on the air conditioner.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TURN_OFF:
        {
            log_printf( &logger, "OK, turn off the air conditioner.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_MODE_AUTO:
        {
            log_printf( &logger, "OK, automatic mode.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_MODE_COLD:
        {
            log_printf( &logger, "OK, cold mode.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_MODE_HEAT:
        {
            log_printf( &logger, "OK, heat mode.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_MODE_DRY:
        {
            log_printf( &logger, "OK, dry mode.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_MODE_FAN:
        {
            log_printf( &logger, "OK, fan mode.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_MODE_SLEEP:
        {
            log_printf( &logger, "OK, sleeping mode.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_WIND_AUTO:
        {
            log_printf( &logger, "OK, automatic fan.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_WIND_LOW:
        {
            log_printf( &logger, "OK, low fan.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_WIND_MID:
        {
            log_printf( &logger, "OK, medium fan.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_WIND_HIGH:
        {
            log_printf( &logger, "OK, high fan.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_WIND_INC:
        {
            log_printf( &logger, "OK, higher the fan.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_WIND_DEC:
        {
            log_printf( &logger, "OK, lower the fan.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_16:
        {
            log_printf( &logger, "OK, sixteen centigrade.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_17:
        {
            log_printf( &logger, "OK, seventeen centigrade.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_18:
        {
            log_printf( &logger, "OK, eighteen centigrade.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_19:
        {
            log_printf( &logger, "OK, nineteen centigrade.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_20:
        {
            log_printf( &logger, "OK, twenty centigrade.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_21:
        {
            log_printf( &logger, "OK, twenty one centigrade.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_22:
        {
            log_printf( &logger, "OK, twenty two centigrade.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_23:
        {
            log_printf( &logger, "OK, twenty three centigrade.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_24:
        {
            log_printf( &logger, "OK, twenty four centigrade.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_25:
        {
            log_printf( &logger, "OK, twenty five centigrade.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_26:
        {
            log_printf( &logger, "OK, twenty six centigrade.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_27:
        {
            log_printf( &logger, "OK, twenty seven centigrade.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_28:
        {
            log_printf( &logger, "OK, twenty eight centigrade.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_29:
        {
            log_printf( &logger, "OK, twenty nine centigrade.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_30:
        {
            log_printf( &logger, "OK, thirty centigrade.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_INC:
        {
            log_printf( &logger, "OK, warmer.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_TMP_DEC:
        {
            log_printf( &logger, "OK, cooler.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_SWEPT_ON:
        {
            log_printf( &logger, "OK, start to fan.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_SWEPT_OFF:
        {
            log_printf( &logger, "OK, stop to fan.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_SWEPT_VERT:
        {
            log_printf( &logger, "OK, air swing up and down.\r\n" );
            break;
        }
        case SPEAKUP3_INS_AC_SWEPT_CROSS:
        {
            log_printf( &logger, "OK, air swing left and right.\r\n" );
            break;
        }
        case SPEAKUP3_INS_SET_RESTORE:
        {
            log_printf( &logger, "OK, air conditioner reset.\r\n" );
            break;
        }
        default:
        {
            log_printf( &logger, "Unknown.\r\n" );
            break;
        }
    }
}

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

Additional Support

Resources