初学者
10 分钟

使用Teseo-LIV3FL和ATmega328P提供准确的位置信息

准确、可靠、始终如一

GNSS 6 Click with Arduino UNO Rev3

已发布 6月 27, 2024

点击板

GNSS 6 Click

开发板

Arduino UNO Rev3

编译器

NECTO Studio

微控制器单元

ATmega328P

确定并为诸如导航和地图制作等应用提供准确的位置信息。

A

A

硬件概览

它是如何工作的?

GNSS 6 Click 基于 STMicroelectronics 的 Teseo-LIV3FL,这是一款微型低功耗 GNSS 模块。它支持所有的 GNSS 星座,并且用户可以在固件配置中选择活动星座。默认情况下,活动的 GNSS 星座是 GPS 和 Glonass。该模块支持 SBAS 作为提供差分 GPS 校正数据的系统。它还支持改进位置精度的差分 GPS。其他功能包括辅助 GNSS、ST 辅助 GPS、预测性 AGNSS、实时 AGPS 等等。此外,该模块配备了一个嵌入式闪存,可用于数据记录和固件升级。GNSS 6 Click 配备了 SMA 天线连接器,

可连接适当的活动天线以提高范围和接收信号强度。为了改善接收效果,除了滤波器外,还配备了 BGA824N6,这是来自英飞凌的硅锗低噪声放大器,用于 GNSS。此放大器的射频输出内部匹配到 50 欧姆。可以通过来自德州仪器的 TPS22943,一款低输入电压电流限制负载开关,关闭天线。Teseo-LIV3FL 模块在此 Click board™ 上具有备用供电选项,可通过板载 VCC 输入或通过硬币电池实现。GNSS 6 Click 使用标准的 2 线 UART 接口与主机 MCU 进行通信,支持行业标准 16C650 

UART 的大部分功能。此外,模块包括一个 I2C 接口,支持正常和快速速度,时钟频率高达 400kHz。两个接口都支持 NMEA 协议。时间输出脉冲可作为 PPS LED 指示和通过 PPS 引脚输出。您可以通过 WUP 引脚从软件待机状态唤醒模块,而 RST 引脚是 GNSS 模块的标准复位引脚。该 Click board™ 只能在 3.3V 逻辑电压电平下操作。在使用具有不同逻辑电平的 MCU 之前,板子必须执行适当的逻辑电压电平转换。此外,它配备有一个包含函数和示例代码的库,可用作进一步开发的参考。

GNSS 6 Click hardware overview image

功能概述

开发板

Arduino UNO 是围绕 ATmega328P 芯片构建的多功能微控制器板。它为各种项目提供了广泛的连接选项,具有 14 个数字输入/输出引脚,其中六个支持 PWM 输出,以及六个模拟输入。其核心组件包括一个 16MHz 的陶瓷谐振器、一个 USB 连接器、一个电

源插孔、一个 ICSP 头和一个复位按钮,提供了为板 子供电和编程所需的一切。UNO 可以通过 USB 连接到计算机,也可以通过 AC-to-DC 适配器或电池供电。作为第一个 USB Arduino 板,它成为 Arduino 平台的基准,"Uno" 符号化其作为系列首款产品的地

位。这个名称选择,意为意大利语中的 "一",是为了 纪念 Arduino Software(IDE)1.0 的推出。最初与 Arduino Software(IDE)版本1.0 同时推出,Uno 自此成为后续 Arduino 发布的基础模型,体现了该平台的演进。

Arduino UNO Rev3 double side image

微控制器概述 

MCU卡片 / MCU

default

建筑

AVR

MCU 内存 (KB)

32

硅供应商

Microchip

引脚数

28

RAM (字节)

2048

你完善了我!

配件

Click Shield for Arduino UNO 具有两个专有的 mikroBUS™ 插座,使所有 Click board™ 设备能够轻松与 Arduino UNO 板进行接口连接。Arduino UNO 是一款基于 ATmega328P 的微控制器开发板,为用户提供了一种经济实惠且灵活的方式来测试新概念并构建基于 ATmega328P 微控制器的原型系统,结合了性能、功耗和功能的多种配置选择。Arduino UNO 具有 14 个数字输入/输出引脚(其中 6 个可用作 PWM 输出)、6 个模拟输入、16 MHz 陶瓷谐振器(CSTCE16M0V53-R0)、USB 接口、电源插座、ICSP 头和复位按钮。大多数 ATmega328P 微控制器的引脚都连接到开发板左右两侧的 IO 引脚,然后再连接到两个 mikroBUS™ 插座。这款 Click Shield 还配备了多个开关,可执行各种功能,例如选择 mikroBUS™ 插座上模拟信号的逻辑电平,以及选择 mikroBUS™ 插座本身的逻辑电压电平。此外,用户还可以通过现有的双向电平转换电压转换器使用任何 Click board™,无论 Click board™ 运行在 3.3V 还是 5V 逻辑电压电平。一旦将 Arduino UNO 板与 Click Shield for Arduino UNO 连接,用户即可访问数百种 Click board™,并兼容 3.3V 或 5V 逻辑电压电平的设备。

Click Shield for Arduino UNO accessories 1 image

GNSS L-Band Active Antenna (LBAND01D-S6-00) 是来自 Inpaq Technology 的一款主动贴片 50Ω 天线,支持 GNSS L-Band(频率范围从 1525MHz 至 1559MHz)应用。它具有高增益和高效率,为跟踪、车队管理、导航和许多其他跟踪应用提供了出色的性能。该天线采用磁性安装类型,尺寸为 37.5x34.5x12.5mm,通过一根长达 3m 的电缆与设备连接,带有 SMA PLUG 雄性连接器。当与需要高度准确的定位能力的 Click board™(如 RTK)配合使用时,它提供了卓越的性能。

GNSS 6 Click accessories image

使用的MCU引脚

mikroBUS™映射器

NC
NC
AN
Reset
PD2
RST
ID COMM
PB2
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Module Wake-Up
PD6
PWM
Timepulse Output
PC3
INT
UART TX
PD0
TX
UART RX
PD1
RX
I2C Clock
PC5
SCL
I2C Data
PC4
SDA
NC
NC
5V
Ground
GND
GND
1

“仔细看看!”

Click board™ 原理图

GNSS 6 Click Schematic schematic

一步一步来

项目组装

Click Shield for Arduino UNO front image hardware assembly

从选择您的开发板和Click板™开始。以Arduino UNO Rev3作为您的开发板开始。

Click Shield for Arduino UNO front image hardware assembly
Arduino UNO Rev3 front image hardware assembly
Charger 27 Click front image hardware assembly
Prog-cut hardware assembly
Charger 27 Click complete accessories setup image hardware assembly
Arduino UNO Rev3 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
Arduino UNO 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 6 Click 驱动程序的 API。

关键功能:

  • gnss6_generic_read - 此函数从模块中读取所需数量的数据字节。

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

  • gnss6_parse_gpgga - 此函数从读取的响应缓冲区解析 GPGGA 数据。

开源

代码示例

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

/*!
 * @file main.c
 * @brief GNSS 6 Click example
 *
 * # Description
 * This example demonstrates the use of GNSS 6 click by reading and displaying
 * the GNSS coordinates.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver and resets the click board.
 *
 * ## Application Task
 * Reads the received data, parses the GPGGA info from it, and once it receives the position fix
 * it will start displaying the coordinates on the USB UART.
 *
 * ## Additional Function
 * - static void gnss6_clear_app_buf ( void )
 * - static err_t gnss6_process ( gnss6_t *ctx )
 * - static void gnss6_parser_application ( uint8_t *rsp )
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "gnss6.h"

#define PROCESS_BUFFER_SIZE 300

static gnss6_t gnss6;
static log_t logger;

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

/**
 * @brief GNSS 6 clearing application buffer.
 * @details This function clears memory of application buffer and reset its length and counter.
 * @return None.
 * @note None.
 */
static void gnss6_clear_app_buf ( void );

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

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

void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    gnss6_cfg_t gnss6_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.
    gnss6_cfg_setup( &gnss6_cfg );
    GNSS6_MAP_MIKROBUS( gnss6_cfg, MIKROBUS_1 );
    err_t init_flag = gnss6_init( &gnss6, &gnss6_cfg );
    if ( ( UART_ERROR == init_flag ) || ( I2C_MASTER_ERROR == init_flag ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    log_info( &logger, " Application Task " );
}

void application_task ( void )
{
    if ( GNSS6_OK == gnss6_process( &gnss6 ) )
    {
        if ( PROCESS_BUFFER_SIZE == app_buf_len )
        {
            gnss6_parser_application( app_buf );
        }
    }
}

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

    return 0;
}

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

static err_t gnss6_process ( gnss6_t *ctx ) 
{
    int32_t rx_size = 0;
    uint8_t rx_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
    if ( GNSS6_DRV_SEL_UART == ctx->drv_sel )
    {
        rx_size = gnss6_generic_read( ctx, rx_buf, PROCESS_BUFFER_SIZE );
    }
    else
    {
        if ( GNSS6_OK == gnss6_generic_read( ctx, rx_buf, 1 ) )
        {
            if ( GNSS6_DUMMY != rx_buf[ 0 ] )
            {
                rx_size = 1;
            }
        }
    }
    if ( rx_size > 0 ) 
    {
        int32_t buf_cnt = app_buf_len;
        if ( ( ( app_buf_len + rx_size ) > PROCESS_BUFFER_SIZE ) && ( app_buf_len > 0 ) ) 
        {
            buf_cnt = PROCESS_BUFFER_SIZE - ( ( app_buf_len + rx_size ) - PROCESS_BUFFER_SIZE );
            memmove ( app_buf, &app_buf[ PROCESS_BUFFER_SIZE - buf_cnt ], buf_cnt );
        }
        for ( int32_t rx_cnt = 0; rx_cnt < rx_size; rx_cnt++ ) 
        {
            if ( rx_buf[ rx_cnt ] ) 
            {
                app_buf[ buf_cnt++ ] = rx_buf[ rx_cnt ];
                if ( app_buf_len < PROCESS_BUFFER_SIZE )
                {
                    app_buf_len++;
                }
            }
        }
        return GNSS6_OK;
    }
    return GNSS6_ERROR;
}

static void gnss6_parser_application ( uint8_t *rsp )
{
    uint8_t element_buf[ 100 ] = { 0 };
    if ( GNSS6_OK == gnss6_parse_gpgga( rsp, GNSS6_GPGGA_LATITUDE, element_buf ) )
    {
        static uint8_t wait_for_fix_cnt = 0;
        if ( ( strlen( element_buf ) > 0 ) && ( !strstr ( element_buf, GNSS6_RSP_NO_FIX ) ) )
        {
            log_printf( &logger, "\r\n Latitude: %.2s degrees, %s minutes \r\n", element_buf, &element_buf[ 2 ] );
            gnss6_parse_gpgga( rsp, GNSS6_GPGGA_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 ) );
            gnss6_parse_gpgga( rsp, GNSS6_GPGGA_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++;
        }
        gnss6_clear_app_buf(  );
    }
}

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

额外支持

资源

喜欢这个项目吗?

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