中级
30 分钟

使用MCP4361和MK64FN1M0VDC12为电压控制带来前所未有的精度和多功能性

无限电阻的可能性

DIGI POT 5 click with Clicker 2 for Kinetis

已发布 6月 24, 2024

点击板

DIGI POT 5 click

开发板

Clicker 2 for Kinetis

编译器

NECTO Studio

微控制器单元

MK64FN1M0VDC12

用我们的数字替代品替换笨重的机械电位器,提高可靠性、耐久性,并实现高级自动化。

A

A

硬件概览

它是如何工作的?

DIGI POT 5 Click基于Microchip的MCP4361,这是一款非常多功能的四通道数字电位器,通过SPI接口进行控制。该设备有四个集成的数字电位器部分,由串联连接的一串电阻和数字控制的模拟开关组成,用于连接擦除器端位置。擦除器位置值0x000h对应于电阻阶梯的下端,而0x100h对应于上端。这些值可以写入易失性擦除器寄存器,每个擦除器都有一个地址。四个擦除器可以以多种方式进行控制。直接将数据写入易失性擦除器寄存器将擦除器移动到指定位置。如果擦除器未锁定且擦除器寄存器值不为0x000h(防止进一步减小)或大于0x100h(防止进一步增加),则可以通过将数据写入递增或递减寄存器来递增或递减擦除器值。如果擦除器寄存器设置为大于0x100h的值,则将忽略增加和减少命令。如果必须增加或减少擦除器位置,递增和递减寄存器可以减少开销,使其易于与旋转编码器应用进行接口。MCP4361还具有WiperLock™功

能,可防止擦除器位置进一步改变,有效地将擦除器锁定在原位。必须将CS引脚拉到预定义的电压阈值(8.5V至12.5V)以上才能启用此功能。当发生这种情况时,设备进入高电压通信模式(HV模式),并且可以访问WiperLock™功能。点击板有一个专用的高压输入引脚(VIHH),当需要HV模式时,它可以用适当的电压水平驱动CS引脚。电阻阶梯网络可以通过写入终端控制寄存器完全关闭。这有效地将电位器端子与电路断开连接,降低了MCP4361的功耗以及IC所用的电路的功耗。终端控制寄存器可以分别切换擦除器端子和两个电阻端子。还使用STATUS寄存器存储各种与状态相关的信息,例如WiperLock™状态,EEPROM写入以保护状态等。即使在断电后,EEPROM存储器也可以保存擦除器数据。在重新启动或上电后,将几个(五个)通用9位地址和4个NV擦除器寄存器地址复制到擦除器寄存器地址,以允许设备从先前存储的状态恢复

擦除器位置。默认情况下,数据寄存器被清零,而NV擦除器寄存器保持擦除器的中间位置。DIGI POT 5 Click有一个2x10引脚标准,2.54mm间距的排针,连接四个电位器端子。板上有三个SMD跳线: 标记为WP的SMD跳线用于设置MCP4361的WP引脚状态。WP引脚用作硬件EEPROM写保护和状态寄存器的软件WP位(仅在HV模式下可写入)。硬件WP引脚和软件WP位必须设置为禁用模式才能写入EEPROM。标记为PWR SEL的SMD跳线选择电源电压 - 3.3V或5V。这也会影响SPI通信使用的逻辑电压电平。标记为CS SEL的SMD跳线选择CS引脚电压电平。如果需要HV模式,则应将此跳线移至VIHH位置,以便外部连接的8.5V至12.5V电源拉高CS引脚。如果不需要HV模式,则此SMD跳线应保持在默认位置(CS)。请注意,在HV模式下,CS引脚的使用方式与常规SPI通信相同,逻辑电平有所不同 - HV模式逻辑高至少为8.5V。

DIGI POT 5 click hardware overview image

功能概述

开发板

Clicker 2 for Kinetis 是一款紧凑型入门开发板,它将 Click 板™的灵活性带给您喜爱的微控制器,使其成为实现您想法的完美入门套件。它配备了一款板载 32 位 ARM Cortex-M4F 微控制器,NXP 半导体公司的 MK64FN1M0VDC12,两个 mikroBUS™ 插槽用于 Click 板™连接,一个 USB 连接器,LED 指示灯,按钮,一个 JTAG 程序员连接器以及两个 26 针头用于与外部电子设备的接口。其紧凑的设计和清晰、易识别的丝网标记让您能够迅速构建具有独特功能和特性

的小工具。Clicker 2 for Kinetis 开发套件的每个部分 都包含了使同一板块运行最高效的必要组件。除了可以选择 Clicker 2 for Kinetis 的编程方式,使用 USB HID mikroBootloader 或外部 mikroProg 连接器进行 Kinetis 编程外,Clicker 2 板还包括一个干净且调节过的开发套件电源供应模块。它提供了两种供电方式;通过 USB Micro-B 电缆,其中板载电压调节器为板上每个组件提供适当的电压水平,或使用锂聚合物 电池通过板载电池连接器供电。所有 mikroBUS™ 本

身支持的通信方法都在这块板上,包括已经建立良好的 mikroBUS™ 插槽、重置按钮和几个用户可配置的按钮及 LED 指示灯。Clicker 2 for Kinetis 是 Mikroe 生态系统的一个组成部分,允许您在几分钟内创建新的应用程序。它由 Mikroe 软件工具原生支持,得益于大量不同的 Click 板™(超过一千块板),其数量每天都在增长,它涵盖了原型制作的许多方面。

Clicker 2 for Kinetis dimensions image

微控制器概述 

MCU卡片 / MCU

default

建筑

ARM Cortex-M4

MCU 内存 (KB)

1024

硅供应商

NXP

引脚数

121

RAM (字节)

262144

使用的MCU引脚

mikroBUS™映射器

NC
NC
AN
Reset
PB11
RST
SPI Chip Select
PC4
CS
SPI Clock
PC5
SCK
SPI Data OUT
PC7
MISO
SPI Data IN
PC6
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™ 原理图

DIGI POT 5 click Schematic schematic

一步一步来

项目组装

Clicker 2 for PIC32MZ front image hardware assembly

从选择您的开发板和Click板™开始。以Clicker 2 for Kinetis作为您的开发板开始。

Clicker 2 for PIC32MZ front image hardware assembly
GNSS2 Click front image hardware assembly
Prog-cut hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
Micro B Connector Clicker 2 Access - 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
Flip&Click PIC32MZ 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”替换为要显示的参数。

软件支持

库描述

这个库包含 DIGI POT 5 Click 驱动程序的 API。

关键函数:

  • digipot5_generic_write - 通用写入函数

  • digipot5_generic_read - 通用读取函数

  • digipot5_increment_wiper - 增加擦除器函数

开源

代码示例

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

/*!
 * \file main.c
 * \brief DIGI POT 5 Click example
 *
 * # Description
 * This example demonstrates the use of the DIGI POT 5 click board.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes all necessary peripherals and pins used for the DIGI POT 5 click.
 * Also allows the device to be reset and configured to enable all wipers (4).
 * UART console module will be initialized also in this function.
 *
 * ## Application Task
 * Demonstrates the use of click driver functions by performing a control of
 * the all wipers positions. By checking the uart console, user can be informed
 * about the all current wipers positions.
 *
 * *note:*
 * Increment/decrement command can be issued only to volatile wiper locations.
 *
 * \author Nemanja Medakovic
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "digipot5.h"


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

static digipot5_t digipot5;
static log_t console;
static uint8_t i;

// ------------------------------------------------------ APPLICATION FUNCTIONS

void application_init( void )
{
    digipot5_cfg_t digipot5_cfg;
    log_cfg_t console_cfg;

    //  Click initialization.
    digipot5_cfg_setup( &digipot5_cfg );
    DIGIPOT5_MAP_MIKROBUS( digipot5_cfg, MIKROBUS_1 );
    digipot5_init( &digipot5, &digipot5_cfg );
    digipot5_reset( &digipot5 );
    digipot5_default_cfg( &digipot5 );

    /** 
     * 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( console_cfg );
    log_init( &console, &console_cfg );
    log_printf( &console, "***  DIGI POT 5 Initialization Done  ***\r\n" );
    log_printf( &console, "****************************************\r\n" );
}

void application_task( void )
{
    log_printf( &console, "* Setting wiper 0 to zero scale.\r\n" );
    digipot5_generic_write( &digipot5, DIGIPOT5_REG_WIPER0_VOL,
                            DIGIPOT5_RES_ZEROSCALE );
    log_printf( &console, "* Setting wiper 1 to 3k Ohm.\r\n" );
    digipot5_generic_write( &digipot5, DIGIPOT5_REG_WIPER1_VOL,
                            DIGIPOT5_RES_3KOHM );
    log_printf( &console, "* Setting wiper 2 to half scale (5k Ohm).\r\n" );
    digipot5_generic_write( &digipot5, DIGIPOT5_REG_WIPER2_VOL,
                            DIGIPOT5_RES_5KOHM_HALFSCALE );
    log_printf( &console, "* Setting wiper 3 to full scale (10k Ohm).\r\n" );
    digipot5_generic_write( &digipot5, DIGIPOT5_REG_WIPER3_VOL,
                            DIGIPOT5_RES_10KOHM_FULLSCALE );

    Delay_ms( 3000 );
    log_printf( &console, "* Decrementing wiper 3 by 5 steps.\r\n" );
    for ( i = 0; i < 5; i++ )
    {
        digipot5_decrement_wiper( &digipot5, DIGIPOT5_REG_WIPER3_VOL );
    }

    Delay_ms( 3000 );
    log_printf( &console, "* Incrementing wiper 0 by 10 steps.\r\n" );
    for ( i = 0; i < 10; i++ )
    {
        digipot5_increment_wiper( &digipot5, DIGIPOT5_REG_WIPER0_VOL );
    }

    Delay_ms( 3000 );
    log_printf( &console, "* Setting wiper 0 to 2k Ohm.\r\n" );
    digipot5_generic_write( &digipot5, DIGIPOT5_REG_WIPER0_VOL,
                            DIGIPOT5_RES_2KOHM );
    log_printf( &console, "* Setting wiper 1 to 2k Ohm.\r\n" );
    digipot5_generic_write( &digipot5, DIGIPOT5_REG_WIPER1_VOL,
                            DIGIPOT5_RES_2KOHM );
    log_printf( &console, "* Setting wiper 2 to 2k Ohm.\r\n" );
    digipot5_generic_write( &digipot5, DIGIPOT5_REG_WIPER2_VOL,
                            DIGIPOT5_RES_2KOHM );
    log_printf( &console, "* Setting wiper 3 to 2k Ohm.\r\n" );
    digipot5_generic_write( &digipot5, DIGIPOT5_REG_WIPER3_VOL,
                            DIGIPOT5_RES_2KOHM );

    Delay_ms( 3000 );
    log_printf( &console, "****************************************\r\n" );
}

void main( void )
{
    application_init( );

    for ( ; ; )
    {
        application_task( );
    }
}


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

额外支持

资源

喜欢这个项目吗?

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