中级
20 分钟

使用Mosaic-x5和STM32G474RE在不同地区和条件下提高全球定位的准确性和可靠性

紧凑型全球导航卫星系统(GNSS)接收器

Mosaic Click with Nucleo 64 with STM32G474RE MCU

已发布 11月 08, 2024

点击板

Mosaic Click

开发板

Nucleo 64 with STM32G474RE MCU

编译器

NECTO Studio

微控制器单元

STM32G474RE

通过多频段和多星座 GNSS 卫星信号跟踪,实现高质量的全球定位,提供精确的导航和基于位置的应用。

A

A

硬件概览

它是如何工作的?

Mosaic Click 基于 Mosaic-X5,这是 Septentrio 的一款紧凑型 GNSS 接收器。该接收器在多个频段和卫星星座(如 GPS、GLONASS、北斗、Galileo 和 NavIC)上提供厘米级精度。它集成了 AIM+ 技术,用于先进的干扰抑制和防欺骗,提供无与伦比的可靠性和精度。这项技术可以中和各种信号干扰,从简单的连续窄带信号到复杂的宽带和脉冲干扰。专为机器人和自动化技术等大众市场应用设计,这一解决方案不仅确保低功耗,还提供多种接口选项并支持 RTK 定位。Mosaic-X5 与主 MCU 之间的通信通过 UART 接口进行,使用标准的 UART RX 和 TX 引脚以及硬件流控制引脚 (CTS/RTS)。模块默认以 115200bps 通信,允许高效的数据交换。此 Click board™ 还包含一个复位引脚 (RST) 以直接复位模块,以及一个状态指示器 (RDY),通过逻辑高(激活)或低(待机或复位)状态信号指示模块的操作状态。此外,该模块支持设备模

式下的 USB 连接,符合 USB 2.0 标准以进行高速数据传输(高达 480Mbps)。它包括通过 LDO(MCP1826)或备用电源开关(TPS22965)实现的 USB 供电选项,每种方式均确保模块正常操作所需的 3.3V。除了 USB 接口外,它还配备一个 microSD 卡插槽用于外部数据记录,可以通过一个 LOG 按钮进行控制。此按钮可以切换 SD 卡记录并管理卡的挂载状态,挂载状态可以通过标记为 LOG 的绿色 LED 指示灯监控。如果 LOG 按钮按下 100ms 到 5 秒之间,它会切换 SD 卡记录开关。按住此按钮超过 5 秒然后释放会卸载已挂载的 SD 卡,反之亦然。绿色 LOG LED 指示灯可以检查 SD 卡的挂载状态。除了 LOG LED,板上还配有一个通用的用户可配置红色 LED、一个黄色 PPS(每秒脉冲)LED 和四个测试点。TP1 和 TP2 是两个事件定时器,可以用于对外部事件进行时间标记,时间分辨率为 20ns,而 TR3 和 TP4 

则具有与开/关和复位功能相同的功能。还可以使用 ON/OFF 按钮关闭模块电源,并在激活和待机模式之间切换。然而,这种突然的电源中断可能会在记录外部 SD 卡数据时导致数据丢失。电路板配有一个 u.Fl 连接器用于 GNSS 天线,例如 MIKROE 提供的 GNSS Active External Antenna,结合 IPEX-SMA 电缆以实现灵活高效的连接选项。此外,用户可以通过 VANT SEL 跳线在 3.3V 和 5V 之间选择外部天线的电源供应。此 Click board™ 可以在 3.3V 和 5V 逻辑电压水平下工作,通过 VCC SEL 跳线选择。鉴于 Mosaic-X5 模块在 3.3V 下工作,还使用了 TXB0106 逻辑电平转换器,以确保正常操作和精确的信号电平转换。这样,3.3V 和 5V 兼容的 MCU 都可以正确使用通信线路。此外,此 Click board™ 配备了一个包含易于使用的函数和示例代码的库,可用作进一步开发的参考。

Mosaic Click hardware overview image

功能概述

开发板

Nucleo-64 搭载 STM32G474R MCU 提供了一种经济高效且灵活的平台,供开发者探索新想法并原型设计他们的项目。该板利用 STM32 微控制器的多功能性,使用户能够为他们的项目选择最佳的性能与功耗平衡。它配备了 LQFP64 封装的 STM32 微控制器,并包含了如用户 LED(同时作为 ARDUINO® 信号)、用户和复位按钮,以及 32.768kHz 晶体振荡器用于精确的计时操作等基本组件。Nucleo-64 板设计考虑到扩展性和灵活性,它特有的 ARDUINO® Uno

V3 扩展连接器和 ST morpho 扩展引脚头,提供了对 STM32 I/O 的完全访问,以实现全面的项目整合。电源供应选项灵活,支持 ST-LINK USB VBUS 或外部电源,确保在各种开发环境中的适应性。该板还配备了一个具有 USB 重枚举功能的板载 ST-LINK 调试器/编程器,简化了编程和调试过程。此外,该板设计旨在简化高级开发,它的外部 SMPS 为 Vcore 逻辑供电提供高效支持,支持 USB 设备全速或 USB SNK/UFP 全速,并内置加密功能,提升了项目的功效

和安全性。通过外部 SMPS 实验的专用连接器、 用于 ST-LINK 的 USB 连接器以及 MIPI® 调试连接器,提供了更多的硬件接口和实验可能性。开发者将通过 STM32Cube MCU Package 提供的全面免费软件库和示例得到广泛支持。这些,加上与多种集成开发环境(IDE)的兼容性,包括 IAR Embedded Workbench®、MDK-ARM 和 STM32CubeIDE,确保了流畅且高效的开发体验,使用户能够充分利用 Nucleo-64 板在他们的项目中的能力。

Nucleo 64 with STM32G474RE MCU double side image

微控制器概述 

MCU卡片 / MCU

STM32G474RE front image

建筑

ARM Cortex-M4

MCU 内存 (KB)

512

硅供应商

STMicroelectronics

引脚数

64

RAM (字节)

128k

你完善了我!

配件

Click Shield for Nucleo-64 配备了两个专有的 mikroBUS™ 插座,使得所有的 Click board™ 设备都可以轻松地与 STM32 Nucleo-64 开发板连接。这样,Mikroe 允许其用户从不断增长的 Click boards™ 范围中添加任何功能,如 WiFi、GSM、GPS、蓝牙、ZigBee、环境传感器、LED、语音识别、电机控制、运动传感器等。您可以使用超过 1537 个 Click boards™,这些 Click boards™ 可以堆叠和集成。STM32 Nucleo-64 开发板基于 64 引脚封装的微控制器,采用 32 位 MCU,配备 ARM Cortex M4 处理器,运行速度为 84MHz,具有 512Kb Flash 和 96KB SRAM,分为两个区域,顶部区域代表 ST-Link/V2 调试器和编程器,而底部区域是一个实际的开发板。通过 USB 连接方便地控制和供电这些板子,以便直接对 Nucleo-64 开发板进行编程和高效调试,其中还需要额外的 USB 线连接到板子上的 USB 迷你接口。大多数 STM32 微控制器引脚都连接到了板子左右边缘的 IO 引脚上,然后连接到两个现有的 mikroBUS™ 插座上。该 Click Shield 还有几个开关,用于选择 mikroBUS™ 插座上模拟信号的逻辑电平和 mikroBUS™ 插座本身的逻辑电压电平。此外,用户还可以通过现有的双向电平转换器,使用任何 Click board™,无论 Click board™ 是否在 3.3V 或 5V 逻辑电压电平下运行。一旦将 STM32 Nucleo-64 开发板与我们的 Click Shield for Nucleo-64 连接,您就可以访问数百个工作于 3.3V 或 5V 逻辑电压电平的 Click boards™。

Click Shield for Nucleo-64 accessories 1 image

GNSS Active External Antenna 是来自 u-blox 的一种独特多频段天线,非常适合需要高精度定位功能(如 RTK)的高精度 GNSS 应用。ANN-MB-00 是一款多频段(L1, L2/E5b/B2I)有源 GNSS 天线,配有 5 米电缆和 SMA 连接器。该天线支持 GPS、GLONASS、Galileo 和北斗系统,包含高性能多频段 RHCP 双馈补丁天线元件、内置高增益 LNA 和 SAW 预过滤器,配有 5 米天线电缆和 SMA 连接器,并且防水。

Mosaic Click accessories 1 image

使用的MCU引脚

mikroBUS™映射器

NC
NC
AN
Module Reset / ID SEL
PC12
RST
UART CTS / ID COMM
PB12
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Module Ready Indicator
PC8
PWM
UART RTS
PC14
INT
UART TX
PA3
TX
UART RX
PA2
RX
NC
NC
SCL
NC
NC
SDA
Power Supply
5V
5V
Ground
GND
GND
1

“仔细看看!”

Click board™ 原理图

Mosaic Click Schematic schematic

一步一步来

项目组装

Click Shield for Nucleo-64 accessories 1 image hardware assembly

从选择您的开发板和Click板™开始。以Nucleo 64 with STM32G474RE MCU作为您的开发板开始。

Click Shield for Nucleo-64 accessories 1 image hardware assembly
Nucleo 64 with STM32G474RE MCU front image hardware assembly
LTE Cat.1 6 Click front image hardware assembly
Prog-cut hardware assembly
LTE Cat.1 6 Click complete accessories setup image hardware assembly
Nucleo-64 with STM32GXXX MCU Access MB 1 Micro B Conn - 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 image step 6 hardware assembly
Clicker 4 for STM32F4 HA 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

实时跟踪您的结果

应用程序输出

此款Click板可通过两种方式进行接口连接和监控:

  • Application Output - 在调试模式下,使用“Application Output”窗口进行实时数据监控。按照本教程正确设置它。

软件支持

库描述

该库包含 Mosaic Click 驱动程序的 API。

关键功能:

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

  • mosaic_enable_nmea_output - 此函数根据选定的消息参数和输出间隔启用 NMEA 输出。

  • mosaic_parse_gga - 此函数从读取响应缓冲区解析 GGA 数据

开源

代码示例

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

/*!
 * @file main.c
 * @brief Mosaic Click Example.
 *
 * # Description
 * This example demonstrates the use of Mosaic click by reading and displaying
 * the GNSS coordinates.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver, reads the NMEA version, and enables the NMEA output.
 *
 * ## 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 mosaic_clear_app_buf ( void )
 * - static void mosaic_log_app_buf ( void )
 * - static err_t mosaic_process ( mosaic_t *ctx )
 * - static err_t mosaic_wait_prompt ( mosaic_t *ctx )
 * - static void mosaic_parser_application ( uint8_t *rsp )
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "mosaic.h"

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

static mosaic_t mosaic;
static log_t logger;

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

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

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

/**
 * @brief Mosaic data reading function.
 * @details This function reads data from device and concatenates data to application buffer. 
 * @param[in] ctx : Click context object.
 * See #mosaic_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 mosaic_process ( mosaic_t *ctx );

/**
 * @brief Mosaic wait prompt function.
 * @details This function waits for a "COM1>" prompt string to appear on UART which indicates
 * the device is ready to receive commands.
 * @param[in] ctx : Click context object.
 * See #mosaic_t object definition for detailed explanation.
 * @return @li @c  0 - Prompt (COM1>) read successfully.
 *         @li @c -2 - Timeout error.
 * See #err_t definition for detailed explanation.
 * @note None.
 */
static err_t mosaic_wait_prompt ( mosaic_t *ctx );

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

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    mosaic_cfg_t mosaic_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.
    mosaic_cfg_setup( &mosaic_cfg );
    MOSAIC_MAP_MIKROBUS( mosaic_cfg, MIKROBUS_1 );
    if ( UART_ERROR == mosaic_init( &mosaic, &mosaic_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    if ( MOSAIC_OK != mosaic_wait_prompt( &mosaic ) )
    {
        log_error( &logger, " No connection prompt detected." );
        for ( ; ; );
    }
    mosaic_log_app_buf( );
    mosaic_clear_app_buf( );
    Delay_ms ( 100 );

    mosaic_send_cmd( &mosaic, MOSAIC_CMD_GET_NMEA_VERSION );
    mosaic_wait_prompt( &mosaic );
    mosaic_log_app_buf( );
    mosaic_clear_app_buf( );
    Delay_ms ( 100 );

    mosaic_enable_nmea_output( &mosaic, MOSAIC_SNO_MESSAGES_GGA, MOSAIC_SNO_INTERVAL_SEC1 );
    mosaic_wait_prompt( &mosaic );
    mosaic_log_app_buf( );
    mosaic_clear_app_buf( );
    Delay_ms ( 100 );
    
    log_info( &logger, " Application Task " );
}

void application_task ( void ) 
{
    mosaic_process( &mosaic );
    if ( app_buf_len > ( sizeof ( MOSAIC_NMEA_GGA ) + MOSAIC_GGA_ELEMENT_SIZE ) ) 
    {
        mosaic_parser_application( app_buf );
    }
}

int main ( void ) 
{
    application_init( );
    
    for ( ; ; ) 
    {
        application_task( );
    }

    return 0;
}

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

static void mosaic_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 ] );
    }
    log_printf( &logger, "\r\n" );
}

static err_t mosaic_process ( mosaic_t *ctx ) 
{
    uint8_t rx_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
    int32_t overflow_bytes = 0;
    int32_t rx_cnt = 0;
    int32_t rx_size = mosaic_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 ] ) 
            {
                app_buf[ app_buf_len++ ] = rx_buf[ rx_cnt ];
            }
        }
        return MOSAIC_OK;
    }
    return MOSAIC_ERROR;
}

static err_t mosaic_wait_prompt ( mosaic_t *ctx )
{
    uint32_t timeout_cnt = 0;
    uint32_t timeout = 120000;
    mosaic_process( ctx );
    while ( 0 == strstr( app_buf, MOSAIC_PROMPT_CMD ) )
    {
        mosaic_process( ctx );
        if ( timeout_cnt++ > timeout )
        {
            mosaic_clear_app_buf( );
            return MOSAIC_ERROR_TIMEOUT;
        }
        Delay_ms( 1 );
    }
    return MOSAIC_OK;
}

static void mosaic_parser_application ( uint8_t *rsp )
{
    uint8_t element_buf[ 100 ] = { 0 };
    if ( MOSAIC_OK == mosaic_parse_gga( rsp, MOSAIC_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 ) );
            mosaic_parse_gga( rsp, MOSAIC_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 ) );
            mosaic_parse_gga( rsp, MOSAIC_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++;
        }
        mosaic_clear_app_buf(  );
    }
}

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

额外支持

资源

喜欢这个项目吗?

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