初学者
10 分钟

使用MCP609和TM4C1299NCZAD实现精确可靠的电压测量

电压揭示:用我们的电压表解决方案实现测量革命!

Voltmeter Click with Fusion for Tiva v8

已发布 6月 26, 2024

点击板

Voltmeter Click

开发板

Fusion for Tiva v8

编译器

NECTO Studio

微控制器单元

TM4C1299NCZAD

体验我们电压表技术的新精度水平,旨在提供实时电压数据,确保您在电气项目中拥有所需的洞察力。

A

A

硬件概览

它是如何工作的?

Voltage Click基于MCP609,这是Microchip的一款微功耗CMOS运算放大器。它是一款增益稳定、偏移电压低的运算放大器,包括轨到轨输出、摆动能力和低输入偏置电流。在Voltage Click上,MCP609被设置为带有缓冲输出的差分放大器。通过螺丝端子的电流流过一排四个电阻。最后两个电阻产生与输入电荷成比例的电压。然后,这个电压被发送到进一步增强两个输入(+/-)之间差异的差分放大器。MCP609上的结果电荷正好是实际测量电压的33倍低。这个Click板™特性有

MCP3201,这是Microchip的一款带有SPI串行接口的12位AD转换器。MCP3201提供单个伪差分输入,具有芯片上采样和保持功能,最大采样率高达100ksps等。作为参考电压,MCP3201从MAX6106获取2.048V,MAX6106是Analog Devices的一款低成本、微功耗、低压降、高输出电流的电压参考。Voltmeter Click使用MCP3201的3线SPI串行接口与主机MCU通信,支持高时钟频率和SPI 0.0以及SPI 1.1模式。通过MCP609放大的电压可以直接通过mikroBUS™插座的AN引脚监

测,这一点非常有用,如果主机MCU具有更高的ADC分辨率的话。主机MCU上的固件应设置为乘以ADC值,以便从SPI接口获取实际电压。这个Click板™可以通过PWR SEL跳线选择使用3.3V或5V逻辑电压水平操作。这样,既可以3.3V也可以5V的MCU都可以正确使用通信线。此外,这个Click板™还配备了一个包含易于使用的功能和示例代码的库,可用作进一步开发的参考。

Voltmeter Click top side image
Voltmeter Click bottom side image

功能概述

开发板

Fusion for TIVA v8 是一款专为快速开发嵌入式应用的需求而特别设计的开发板。它支持广泛的微控制器,如不同的32位ARM® Cortex®-M基础MCUs,来自Texas Instruments,无论它们的引脚数量如何,并且具有一系列独特功能,例如首次通过WiFi网络实现的嵌入式调试器/程序员。开发板布局合理,设计周到,使得最终用户可以在一个地方找到所有必要的元素,如开关、按钮、指示灯、连接器等。得益于创新的制造技术,Fusion for TIVA v8 提供了流畅而沉浸式的工作体验,允许在任何情况下、任何地方、任何

时候都能访问。Fusion for TIVA v8开发板的每个部分都包含了使同一板块运行最高效的必要组件。一个先进的集成CODEGRIP程序/调试模块提供许多有价值的编程/调试选项,包括对JTAG、SWD和SWO Trace(单线输出)的支持,并与Mikroe软件环境无缝集成。此外,它还包括一个干净且调节过的开发板电源供应模块。它可以使用广泛的外部电源,包括电池、外部12V电源供应和通过USB Type-C(USB-C)连接器的电源。通信选项如USB-UART、USB HOST/DEVICE、CAN(如果MCU卡支持的话)和以

太网也包括在内。此外,它还拥有广受好评的 mikroBUS™标准,为MCU卡提供了标准化插座(SiBRAIN标准),以及两种显示选项,用于TFT板线产品和基于字符的LCD。Fusion for TIVA v8 是Mikroe快速开发生态系统的一个组成部分。它由Mikroe软件工具原生支持,得益于大量不同的Click板™(超过一千块板),其数量每天都在增长,它涵盖了原型制作和开发的许多方面。

Fusion for Tiva v8 horizontal image

微控制器概述 

MCU卡片 / MCU

default

类型

8th Generation

建筑

ARM Cortex-M4

MCU 内存 (KB)

1024

硅供应商

Texas Instruments

引脚数

212

RAM (字节)

262144

使用的MCU引脚

mikroBUS™映射器

Analog Output
PE3
AN
NC
NC
RST
SPI Chip Select
PE7
CS
SPI Clock
PA2
SCK
SPI Data OUT
PA5
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
NC
NC
SCL
NC
NC
SDA
Power Supply
5V
5V
Ground
GND
GND
1

“仔细看看!”

Click board™ 原理图

Voltmeter Click Schematic schematic

一步一步来

项目组装

Fusion for PIC v8 front image hardware assembly

从选择您的开发板和Click板™开始。以Fusion for Tiva v8作为您的开发板开始

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

实时跟踪您的结果

应用程序输出

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

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

软件支持

库描述

这个库包含了电压表点击驱动的API。

关键功能:

  • voltmeter_read_raw_data - 这个功能读取原始ADC值

  • voltmeter_calculate_voltage - 这个功能将原始ADC值转换为相应的电压等级。

开源

代码示例

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

/*!
 * \file 
 * \brief Voltmeter Click example
 * 
 * # Description
 * This application reads the voltage measurement and displays the results on the USB UART.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initialization the driver and logger.
 * 
 * ## Application Task  
 * Reads the raw ADC measurement once per second and converts it to the proportional voltage level.
 * All data are being displayed on the USB UART where you can track their changes.
 * 
 * \author MikroE Team
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "voltmeter.h"

// ------------------------------------------------------------------ VARIABLES

static voltmeter_t voltmeter;
static log_t logger;

void application_init ( void )
{
    log_cfg_t log_cfg;
    voltmeter_cfg_t cfg;

    /** 
     * 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.
    voltmeter_cfg_setup( &cfg );
    VOLTMETER_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    voltmeter_init( &voltmeter, &cfg );
    Delay_ms ( 100 );
    
    log_info( &logger, " Application Task " );
}

void application_task ( void )
{
    int16_t adc_value = 0;
    float voltage = 0;

    adc_value = voltmeter_read_raw_data( &voltmeter );
    log_printf( &logger, " ADC Value: %d\r\n", adc_value );

    voltage = voltmeter_calculate_voltage( &voltmeter, adc_value, VOLTMETER_GND_ISO );
    log_printf( &logger, " Voltage  : %.3f V\r\n", voltage );
    log_printf( &logger, "------------------------\r\n");
    Delay_ms ( 1000 );
}

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;
}


// ------------------------------------------------------------------------ END
/*!
 * \file 
 * \brief Voltmeter Click example
 * 
 * # Description
 * This application reads the voltage measurement and displays the results on the USB UART.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initialization the driver and logger.
 * 
 * ## Application Task  
 * Reads the raw ADC measurement once per second and converts it to the proportional voltage level.
 * All data are being displayed on the USB UART where you can track their changes.
 * 
 * \author MikroE Team
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "voltmeter.h"

// ------------------------------------------------------------------ VARIABLES

static voltmeter_t voltmeter;
static log_t logger;

void application_init ( void )
{
    log_cfg_t log_cfg;
    voltmeter_cfg_t cfg;

    /** 
     * 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.
    voltmeter_cfg_setup( &cfg );
    VOLTMETER_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    voltmeter_init( &voltmeter, &cfg );
    Delay_ms ( 100 );
    
    log_info( &logger, " Application Task " );
}

void application_task ( void )
{
    int16_t adc_value = 0;
    float voltage = 0;

    adc_value = voltmeter_read_raw_data( &voltmeter );
    log_printf( &logger, " ADC Value: %d\r\n", adc_value );

    voltage = voltmeter_calculate_voltage( &voltmeter, adc_value, VOLTMETER_GND_ISO );
    log_printf( &logger, " Voltage  : %.3f V\r\n", voltage );
    log_printf( &logger, "------------------------\r\n");
    Delay_ms ( 1000 );
}

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;
}


// ------------------------------------------------------------------------ END
/*!
 * \file 
 * \brief Voltmeter Click example
 * 
 * # Description
 * This application reads the voltage measurement and displays the results on the USB UART.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initialization the driver and logger.
 * 
 * ## Application Task  
 * Reads the raw ADC measurement once per second and converts it to the proportional voltage level.
 * All data are being displayed on the USB UART where you can track their changes.
 * 
 * \author MikroE Team
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "voltmeter.h"

// ------------------------------------------------------------------ VARIABLES

static voltmeter_t voltmeter;
static log_t logger;

void application_init ( void )
{
    log_cfg_t log_cfg;
    voltmeter_cfg_t cfg;

    /** 
     * 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.
    voltmeter_cfg_setup( &cfg );
    VOLTMETER_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    voltmeter_init( &voltmeter, &cfg );
    Delay_ms ( 100 );
    
    log_info( &logger, " Application Task " );
}

void application_task ( void )
{
    int16_t adc_value = 0;
    float voltage = 0;

    adc_value = voltmeter_read_raw_data( &voltmeter );
    log_printf( &logger, " ADC Value: %d\r\n", adc_value );

    voltage = voltmeter_calculate_voltage( &voltmeter, adc_value, VOLTMETER_GND_ISO );
    log_printf( &logger, " Voltage  : %.3f V\r\n", voltage );
    log_printf( &logger, "------------------------\r\n");
    Delay_ms ( 1000 );
}

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;
}


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

额外支持

资源

喜欢这个项目吗?

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