初学者
10 分钟

使用MAX-F10S和PIC32MZ2048EFM100即使在复杂的城市环境中也能提供准确的卫星定位数据

L1/L5双频专业级GNSS接收器

GNSS MAX 2 Click with Curiosity PIC32 MZ EF

已发布 10月 21, 2024

点击板

GNSS MAX 2 Click

开发板

Curiosity PIC32 MZ EF

编译器

NECTO Studio

微控制器单元

PIC32MZ2048EFM100

支持依赖准确位置信息的应用,例如导航、地图绘制和增强现实

A

A

硬件概览

它是如何工作的?

GNSS MAX 2 Click 基于 u-blox 的 MAX-F10S,这是一款专业级的 L1/L5 双频 GNSS 接收器,设计用于即使在具有挑战性的城市环境中也能实现米级精度。该板基于 u-blox F10 GNSS 技术,利用 L1 和 L5 GNSS 频段以提高精度。双频能力使 MAX-F10S 能够减轻多径效应,利用 L1 和 L5 频段的信号提供比单频接收器更显著的定位精度提升。此 Click board™ 非常适合各种需要在城市环境中进行可靠精确定位的应用,如车辆跟踪、车队管理、微出行解决方案等,即使使用小型天线也能提供显著优势。作为一个并发 GNSS 接收器,MAX-F10S 可以同时跟踪多个 GNSS 星座,包括 GPS、Galileo 和北斗系统,并启用了 SBAS,确保在复杂城市地区的可靠表现。其射频前端架构设计为能够同时接收双频信号,提供高灵敏度

和更高的准确性。为了进一步增强其可靠性,该模块包括两个内部 SAW 滤波器和一个低噪声放大器 (LNA),可以保护接收器免受附近蜂窝调制解调器引起的射频干扰。其高效的电源管理系统还允许接收器仅使用一部分 GNSS 星座,降低功耗的同时保持高精度。GNSS MAX 2 Click 通过 UART 接口与主 MCU 通信,使用标准的 UART RX 和 TX 引脚。默认通信速度设置为 9600bps,确保高效数据交换。它还提供了 I2C 接口,用于与主 MCU 以 I2C 快速模式通信。但需注意的是,I2C 接口只能在从属模式下运行。除了接口引脚外,该 Click board™ 还集成了一个复位引脚 (RST),用于直接复位模块,以及一个外部中断信号 (EXI),可以编程用于各种功能,如唤醒模块。此外,GNSS 17 Click 包含一个红色 PPS LED 指示

灯,它每秒发出一次与 MAX-F10S 同步的脉冲信号。PPS 功能默认启用,当模块达到 3D 定位时将输出 PPS 信号。此 Click board™ 还配备了一个 50Ω 阻抗的 SMA 天线连接器,兼容 MIKROE 提供的各种天线,如 Active GPS 天线,以增强其连接性。此外,在主电源失效的情况下,模块可以使用从连接电池中获取的备用电源,使得您可以将 Click board™ 用作独立设备。此 Click board™ 只能使用 3.3V 逻辑电压级运行。在使用其他逻辑电压级的 MCU 之前,必须进行适当的逻辑电压级转换。此外,它还配备了一个包含函数库和示例代码的库,可作为进一步开发的参考。

GNSS MAX 2 Click hardware overview image

功能概述

开发板

Curiosity PIC32 MZ EF 开发板是一个完全集成的 32 位开发平台,特点是高性能的 PIC32MZ EF 系列(PIC32MZ2048EFM),该系列具有 2MB Flash、512KB RAM、集成的浮点单元(FPU)、加密加速器和出色的连接选项。它包括一个集成的程序员和调试器,无需额外硬件。用户可以通过 MIKROE 

mikroBUS™ Click™ 适配器板扩展功能,通过 Microchip PHY 女儿板添加以太网连接功能,使用 Microchip 扩展板添加 WiFi 连接能力,并通过 Microchip 音频女儿板添加音频输入和输出功能。这些板完全集成到 PIC32 强大的软件框架 MPLAB Harmony 中,该框架提供了一个灵活且模块化的接口

来应用开发、一套丰富的互操作软件堆栈(TCP-IP、USB)和易于使用的功能。Curiosity PIC32 MZ EF 开发板提供了扩展能力,使其成为连接性、物联网和通用应用中快速原型设计的绝佳选择。

Curiosity PIC32MZ EF double side image

微控制器概述 

MCU卡片 / MCU

default

建筑

PIC32

MCU 内存 (KB)

2048

硅供应商

Microchip

引脚数

100

RAM (字节)

524288

你完善了我!

配件

主动 GPS 天线旨在增强您的 GPS 和 GNSS Click 板™ 的性能。这款外置天线结构坚固,适用于各种天气条件。凭借 1575.42MHz 的频率范围和 50Ohm 的阻抗,它确保了可靠的信号接收。天线在较宽的角度范围内提供大于 -4dBic 的增益,确保超过 75% 的覆盖率。± 5MHz 的带宽进一步保证了精确的数据采集。天线采用右旋圆极化 (RHCP),提供稳定的信号接收。其紧凑的尺寸为 48.5×39×15mm,配有 2 米长的电缆,安装方便。磁性天线类型与 SMA 公连接器确保了安全便捷的连接。如果您需要为定位设备提供可靠的外置天线,我们的主动 GPS 天线是完美的解决方案。

GNSS MAX 2 Click accessories 1 image

使用的MCU引脚

mikroBUS™映射器

NC
NC
AN
Reset
RA9
RST
ID COMM
RPD4
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
External Interrupt
RPE8
PWM
Time Pulse Signal
RF13
INT
UART TX
RPD10
TX
UART RX
RPD15
RX
I2C Clock
RPA14
SCL
I2C Data
RPA15
SDA
NC
NC
5V
Ground
GND
GND
1

“仔细看看!”

Click board™ 原理图

GNSS MAX 2 Click Schematic schematic

一步一步来

项目组装

Curiosity PIC32MZ EF front image hardware assembly

从选择您的开发板和Click板™开始。以Curiosity PIC32 MZ EF作为您的开发板开始。

Curiosity PIC32MZ EF front image hardware assembly
GNSS2 Click front image hardware assembly
Prog-cut hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
Board mapper by product7 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
Curiosity PIC32 MZ EF MCU 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

实时跟踪您的结果

应用程序输出

1. 应用程序输出 - 在调试模式下,“应用程序输出”窗口支持实时数据监控,直接提供执行结果的可视化。请按照提供的教程正确配置环境,以确保数据正确显示。

2. UART 终端 - 使用UART Terminal通过USB to UART converter监视数据传输,实现Click board™与开发系统之间的直接通信。请根据项目需求配置波特率和其他串行设置,以确保正常运行。有关分步设置说明,请参考提供的教程

3. Plot 输出 - Plot功能提供了一种强大的方式来可视化实时传感器数据,使趋势分析、调试和多个数据点的对比变得更加直观。要正确设置,请按照提供的教程,其中包含使用Plot功能显示Click board™读数的分步示例。在代码中使用Plot功能时,请使用以下函数:plot(insert_graph_name, variable_name);。这是一个通用格式,用户需要将“insert_graph_name”替换为实际图表名称,并将“variable_name”替换为要显示的参数。

软件支持

库描述

该库包含 GNSS MAX 2 Click 驱动程序的 API。

关键功能:

  • gnssmax2_generic_read - 此函数使用 UART 或 I2C 串行接口读取所需数量的数据字节。

  • gnssmax2_parse_gga - 此函数从读取的响应缓冲区中解析 GGA 数据。

  • gnssmax2_reset_device - 此函数通过切换 RST 引脚来重置设备。

开源

代码示例

完整的应用程序代码和一个现成的项目可以通过NECTO Studio包管理器直接安装到NECTO Studio 应用程序代码也可以在MIKROE的GitHub账户中找到。

/*!
 * @file main.c
 * @brief GNSS MAX 2 Click Example.
 *
 * # Description
 * This example demonstrates the use of GNSS MAX 2 click by reading and displaying
 * the GNSS coordinates.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver and logger.
 *
 * ## Application Task
 * Reads the received data, parses the NMEA GGA info from it, and once it receives 
 * the position fix it will start displaying the coordinates on the USB UART.
 *
 * ## Additional Function
 * - static void gnssmax2_clear_app_buf ( void )
 * - static void gnssmax2_log_app_buf ( void )
 * - static err_t gnssmax2_process ( gnssmax2_t *ctx )
 * - static void gnssmax2_parser_application ( uint8_t *rsp )
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "gnssmax2.h"

// Application buffer size
#define APP_BUFFER_SIZE             500
#define PROCESS_BUFFER_SIZE         200

static gnssmax2_t gnssmax2;
static log_t logger;

static uint8_t app_buf[ APP_BUFFER_SIZE + 1 ] = { 0 };
static int32_t app_buf_len = 0;
static uint8_t i2c_data_ready = 0;

/**
 * @brief GNSS MAX 2 clearing application buffer.
 * @details This function clears memory of application buffer and reset its length.
 * @note None.
 */
static void gnssmax2_clear_app_buf ( void );

/**
 * @brief GNSS MAX 2 log application buffer.
 * @details This function logs data from application buffer to USB UART.
 * @note None.
 */
static void gnssmax2_log_app_buf ( void );

/**
 * @brief GNSS MAX 2 data reading function.
 * @details This function reads data from device and concatenates data to application buffer. 
 * @param[in] ctx : Click context object.
 * See #gnssmax2_t object definition for detailed explanation.
 * @return @li @c  0 - Read some data.
 *         @li @c -1 - Nothing is read.
 * See #err_t definition for detailed explanation.
 * @note None.
 */
static err_t gnssmax2_process ( gnssmax2_t *ctx );

/**
 * @brief GNSS MAX 2 parser application.
 * @details This function logs GNSS data on the USB UART.
 * @param[in] rsp Response buffer.
 * @return None.
 * @note None.
 */
static void gnssmax2_parser_application ( uint8_t *rsp );

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    gnssmax2_cfg_t gnssmax2_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.
    gnssmax2_cfg_setup( &gnssmax2_cfg );
    GNSSMAX2_MAP_MIKROBUS( gnssmax2_cfg, MIKROBUS_1 );
    if ( GNSSMAX2_OK != gnssmax2_init( &gnssmax2, &gnssmax2_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    log_info( &logger, " Application Task " );
}

void application_task ( void ) 
{
    if ( GNSSMAX2_OK == gnssmax2_process( &gnssmax2 ) ) 
    {
        gnssmax2_parser_application( app_buf );
    }
}

int main ( void ) 
{
    /* Do not remove this line or clock might not be set correctly. */
    #ifdef PREINIT_SUPPORTED
    preinit();
    #endif
    
    application_init( );
    
    for ( ; ; ) 
    {
        application_task( );
    }

    return 0;
}

static void gnssmax2_clear_app_buf ( void ) 
{
    memset( app_buf, 0, app_buf_len );
    app_buf_len = 0;
}

static void gnssmax2_log_app_buf ( void )
{
    for ( int32_t buf_cnt = 0; buf_cnt < app_buf_len; buf_cnt++ )
    {
        log_printf( &logger, "%c", app_buf[ buf_cnt ] );
    }
}

static err_t gnssmax2_process ( gnssmax2_t *ctx ) 
{
    uint8_t rx_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
    int32_t overflow_bytes = 0;
    int32_t rx_cnt = 0;
    int32_t rx_size = 0;
    
    if ( ( GNSSMAX2_DRV_SEL_I2C == ctx->drv_sel ) && ( !i2c_data_ready ) )
    {
        uint16_t pps_wait_log_cnt = 0;
        while ( !gnssmax2_get_pps_pin ( ctx ) )
        {
            if ( ++pps_wait_log_cnt > 5000 )
            {
                log_printf( &logger, " Waiting for the position fix (PPS signal)...\r\n\n" );
                pps_wait_log_cnt = 0;
            }
            Delay_ms ( 1 );
        }
        i2c_data_ready = 1;
        Delay_ms ( 200 );
    }
    rx_size = gnssmax2_generic_read( ctx, rx_buf, PROCESS_BUFFER_SIZE );
    if ( ( rx_size > 0 ) && ( rx_size <= APP_BUFFER_SIZE ) ) 
    {
        if ( ( app_buf_len + rx_size ) > APP_BUFFER_SIZE ) 
        {
            overflow_bytes = ( app_buf_len + rx_size ) - APP_BUFFER_SIZE;
            app_buf_len = APP_BUFFER_SIZE - rx_size;
            memmove ( app_buf, &app_buf[ overflow_bytes ], app_buf_len );
            memset ( &app_buf[ app_buf_len ], 0, overflow_bytes );
        }
        for ( rx_cnt = 0; rx_cnt < rx_size; rx_cnt++ ) 
        {
            if ( rx_buf[ rx_cnt ] && ( GNSSMAX2_DUMMY != rx_buf[ rx_cnt ] ) ) 
            {
                app_buf[ app_buf_len++ ] = rx_buf[ rx_cnt ];
            }
        }
        return GNSSMAX2_OK;
    }
    return GNSSMAX2_ERROR;
}

static void gnssmax2_parser_application ( uint8_t *rsp )
{
    uint8_t element_buf[ 200 ] = { 0 };
    if ( GNSSMAX2_OK == gnssmax2_parse_gga( rsp, GNSSMAX2_GGA_LATITUDE, element_buf ) )
    {
        static uint8_t wait_for_fix_cnt = 0;
        if ( strlen( element_buf ) > 0 )
        {
            log_printf( &logger, "\r\n Latitude: %.2s degrees, %s minutes\r\n", element_buf, &element_buf[ 2 ] );
            memset( element_buf, 0, sizeof( element_buf ) );
            gnssmax2_parse_gga( rsp, GNSSMAX2_GGA_LONGITUDE, element_buf );
            log_printf( &logger, " Longitude: %.3s degrees, %s minutes\r\n", element_buf, &element_buf[ 3 ] );
            memset( element_buf, 0, sizeof( element_buf ) );
            gnssmax2_parse_gga( rsp, GNSSMAX2_GGA_ALTITUDE, element_buf );
            log_printf( &logger, " Altitude: %s m\r\n", element_buf );
            wait_for_fix_cnt = 0;
        }
        else
        {
            if ( wait_for_fix_cnt % 5 == 0 )
            {
                log_printf( &logger, " Waiting for the position fix...\r\n\n" );
                wait_for_fix_cnt = 0;
            }
            wait_for_fix_cnt++;
        }
        gnssmax2_clear_app_buf(  );
        i2c_data_ready = 0;
    }
}

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

额外支持

资源

喜欢这个项目吗?

'购买此套件' 按钮会直接带您进入购物车,您可以在购物车中轻松添加或移除产品。