Beginner
10 min

Provide advanced and real-time motion detection capabilities with PD-V10-G5 and PIC18F4680

Improve your space with Doppler-driven motion detection!

Microwave 5 Click with EasyPIC v8

Published Nov 01, 2023

Click board™

Microwave 5 Click

Dev Board

EasyPIC v8

Compiler

NECTO Studio

MCU

PIC18F4680

Enhance your environment with our Doppler-based solution, a smart and sophisticated way to heighten awareness through intelligent and responsive motion sensing.

A

A

Hardware Overview

How does it work?

Microwave 5 Click is based on the PD-V10-G5, a miniature X-band microwave transceiver from Ningbo Pdlux Electronic Technology. This microwave solution is housed in a metal can and features a dielectric resonator stabilized oscillator, providing a stable operation over a broad temperature range in either CW or low-duty cycle pulse mode and an integrated homodyne receiver for enhanced sensitivity and reliability. The Microwave 5 Click detects the frequency shift between a transmitted and a received signal reflected from a moving object within the field of view of the transceiver. The standard antenna has 5dBi of gain and a minimum power output of

5dBm with -84dBm of sensitivity for a 10dB signal-to-noise ratio. The produced low-level output is amplified over the MCP6022, a rail-to-rail input/output 10MHz operational amplifier from Microchip. The amplified output goes to the ADC SEL jumper, which allows you to read the data over an analog pin of the mikroBUS™ socket or the MCP3221, a low-power 12-bit A/D converter from Microchip. The jumper is set to an analog pin by default. If the option is the ADC, you can count up to 22.3 ksps in I2C fast mode. As mentioned, the Microwave 5 Click uses an analog AN pin of the mikroBUS™ socket or a standard 2-Wire I2C interface of the MCP3221 to communicate with

the host MCU. The I2C of the ADC supports standard (100KHz) and fast (400KHz) modes. Depending on the ADC of the host MCU, the onboard 12-bit ADC could be a better choice. Worth noting is that the microwave sensor works on 5V. This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the VCC SEL jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. Also, this Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used as a reference for further development.

Microwave 5 Click hardware overview image

Features overview

Development board

EasyPIC v8 is a development board specially designed for the needs of rapid development of embedded applications. It supports many high pin count 8-bit PIC microcontrollers from Microchip, regardless of their number of pins, and a broad set of unique functions, such as the first-ever embedded debugger/programmer. 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, EasyPIC v8 provides a fluid and immersive working experience, allowing access anywhere and under any

circumstances at any time. Each part of the EasyPIC 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 DEVICE, and CAN are also included, including the well-established mikroBUS™ standard, two display options (graphical and character-based LCD), and several different DIP sockets. These sockets cover a wide range of 8-bit PIC MCUs, from the smallest PIC MCU devices with only eight up to forty pins. EasyPIC 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.

EasyPIC v8 horizontal image

Microcontroller Overview

MCU Card / MCU

PIC18F4680

Architecture

PIC

MCU Memory (KB)

64

Silicon Vendor

Microchip

Pin count

40

RAM (Bytes)

3328

Used MCU Pins

mikroBUS™ mapper

Analog Output
RA2
AN
NC
NC
RST
NC
NC
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
NC
NC
INT
NC
NC
TX
NC
NC
RX
I2C Clock
RC3
SCL
I2C Data
RC4
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Click board™ Schematic

Microwave 5 Click Schematic schematic

Step by step

Project assembly

EasyPIC v8 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the EasyPIC v8 as your development board.

EasyPIC v8 front image hardware assembly
Buck 22 Click front image hardware assembly
MCU DIP 40 hardware assembly
EasyPIC v8 DIP 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 DIP 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

1. Application Output - In Debug mode, the 'Application Output' window enables real-time data monitoring, offering direct insight into execution results. Ensure proper data display by configuring the environment correctly using the provided tutorial.

2. UART Terminal - Use the UART Terminal to monitor data transmission via a USB to UART converter, allowing direct communication between the Click board™ and your development system. Configure the baud rate and other serial settings according to your project's requirements to ensure proper functionality. For step-by-step setup instructions, refer to the provided tutorial.

3. Plot Output - The Plot feature offers a powerful way to visualize real-time sensor data, enabling trend analysis, debugging, and comparison of multiple data points. To set it up correctly, follow the provided tutorial, which includes a step-by-step example of using the Plot feature to display Click board™ readings. To use the Plot feature in your code, use the function: plot(*insert_graph_name*, variable_name);. This is a general format, and it is up to the user to replace 'insert_graph_name' with the actual graph name and 'variable_name' with the parameter to be displayed.

Software Support

Library Description

This library contains API for Microwave 5 Click driver.

Key functions:

  • microwave5_read_raw_adc - Microwave 5 read raw ADC value function.

  • microwave5_read_voltage - Microwave 5 read voltage level function.

  • microwave5_set_vref - Microwave 5 set vref function.

Open Source

Code example

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.

/*!
 * @file main.c
 * @brief Microwave 5 Click Example.
 *
 * # Description
 * This example demonstrates the use of the Microwave 5 Click board™ 
 * by reading and displaying the results of AD conversion and motion detection.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * The initialization of I2C or ADC module and log UART.
 * After driver initialization, the app calculates the reference ADC value.
 *
 * ## Application Task
 * The demo application reads the ADC results, takes an ADC sample, 
 * compares the difference between the taken samples and the ADC reference value, 
 * and reports the movement if the difference is higher/lower than the selected threshold value.
 * Results are being sent to the UART Terminal, where you can track their changes.
 *
 * @author Nenad Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "microwave5.h"

#define MICROWAVE5_THRESHOLD    0.5f
#define MICROWAVE5_FLAG_CLEAR   0
#define MICROWAVE5_FLAG_SET     1

static microwave5_t microwave5;   /**< Microwave 5 Click driver object. */
static log_t logger;              /**< Logger object. */
static float reference = 0, voltage = 0;
static uint8_t flag = MICROWAVE5_FLAG_CLEAR;

void application_init ( void )
{
    log_cfg_t log_cfg;                /**< Logger config object. */
    microwave5_cfg_t microwave5_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.
    microwave5_cfg_setup( &microwave5_cfg );
    MICROWAVE5_MAP_MIKROBUS( microwave5_cfg, MIKROBUS_1 );
    err_t init_flag = microwave5_init( &microwave5, &microwave5_cfg );
    if ( ( ADC_ERROR == init_flag ) || ( I2C_MASTER_ERROR == init_flag ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    log_printf( &logger, " Calibrating the sensor...\r\n" );
    log_printf( &logger, " There must be no movement near the sensor!\r\n" );
    log_printf( &logger, "----------------------------------\r\n" );
    Delay_ms( 3000 );
    
    if ( MICROWAVE5_OK == microwave5_read_voltage( &microwave5, &reference ) )
    {
        log_printf( &logger, " The sensor has been calibrated!\r\n" );
        log_printf( &logger, " Detector AN Voltage : %.3f[V]\r\n", reference );
        log_printf( &logger, "----------------------------------\r\n" );
        Delay_ms( 100 );
    }
    else
    {
        log_error( &logger, " Communication error." );
        for ( ; ; );
    }
    
    log_printf( &logger, "The motion detector unit is ready.\r\n" );
    log_printf( &logger, "----------------------------------\r\n" );
    Delay_ms( 100 );
}

void application_task ( void ) 
{
    if ( MICROWAVE5_OK == microwave5_read_voltage( &microwave5, &voltage ) )
    {
        if ( ( ( voltage + MICROWAVE5_THRESHOLD ) < reference ) || 
             ( ( voltage - MICROWAVE5_THRESHOLD ) > reference ) )
        {
            if ( MICROWAVE5_FLAG_SET == flag )
            {
                log_printf( &logger, " Motion detected!\r\n" );
                log_printf( &logger, " Detector AN Voltage : %.3f[V]\r\n", voltage );
                log_printf( &logger, "----------------------------------\r\n" );
                flag = MICROWAVE5_FLAG_CLEAR;
                Delay_ms( 100 );
            }
        }
        else
        {
            flag = MICROWAVE5_FLAG_SET;
        }
    }
}

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.