用我们的数字替代品替换笨重的机械电位器,提高可靠性、耐久性,并实现高级自动化。
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。
功能概述
开发板
Clicker 4 for STM32F3 是一款紧凑型开发板,作为完整的解决方案而设计,可帮助用户快速构建具备独特功能的定制设备。该板搭载 STMicroelectronics 的 STM32F302VCT6 微控制器,配备四个 mikroBUS™ 插槽用于连接 Click boards™、完善的电源管理功能以及其他实用资源,是快速开发各类应用的理想平台。其核心 MCU STM32F302VCT6 基于高性能
Arm® Cortex®-M4 32 位处理器,运行频率高达 168MHz,处理能力强大,能够满足各种高复杂度任务的需求,使 Clicker 4 能灵活适应多种应用场景。除了两个 1x20 引脚排针外,板载最显著的连接特性是四个增强型 mikroBUS™ 插槽,支持接入数量庞大的 Click boards™ 生态系统,该生态每日持续扩展。Clicker 4 各功能区域标识清晰,界面直观简洁,极大
提升使用便捷性和开发效率。Clicker 4 的价值不仅在于加速原型开发与应用构建阶段,更在于其作为独立完整方案可直接集成至实际项目中,无需额外硬件修改。四角各设有直径 4.2mm(0.165")的安装孔,便于通过螺丝轻松固定。对于多数应用,只需配套一个外壳,即可将 Clicker 4 开发板转化为完整、实用且外观精美的定制系统。
微控制器概述
MCU卡片 / MCU

建筑
ARM Cortex-M4
MCU 内存 (KB)
256
硅供应商
STMicroelectronics
引脚数
100
RAM (字节)
40960
使用的MCU引脚
mikroBUS™映射器
“仔细看看!”
Click board™ 原理图

一步一步来
项目组装
软件支持
库描述
这个库包含 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 ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
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 ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
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 ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
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 ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
log_printf( &console, "****************************************\r\n" );
}
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
额外支持
资源
类别:数字电位计































