体验一种先进的四象限计数器,旨在通过准确的运动测量提升您的设计水平。
A
A
硬件概览
它是如何工作的?
Counter Click基于LSI计算机系统的LS7366R,这是一个带有串行接口的32位正交计数器。它是一个CMOS计数器,具有直接接口,用于从增量编码器获取正交时钟。它还与增量编码器的索引信号进行接口,以执行各种标记功能。该计数器可以配置为1、2、3或4字节计数器。它还可以编程为在几种计数模式下工作,例如Modulo-N、非循环、范围限制或自由运行模式。这个Click板™具有一个2x5引脚排(2.54mm间距),用于接口LS7366R的输入、VCC和一些GND,基本
上是Click板™本身的电源引脚。VCC和GND引脚可以为正交增量 编码器供电。这个标头还包括ENCA和ENCB,即LS7366R的输入A和B引脚,直接将增量编码器的正交时钟输出应用于它们,并且索引(ENCI)引脚,这是由增量编码器的索引输出直接驱动的可编程输入。LS7366R使用标准的4线SPI串行接口通过mikroBUS™插座与主机MCU进行通信。当EN输入处于高逻辑状态时,计数器被启用;否则,它以低逻辑电平被禁用。此外,这个Click板™还具有通过INT引脚的中断功
能,可以通过LF和DF焊接跳线来配置使用LFLAG或DFLAG,DFLAG默认设置。这样,用户可以选择LFLAG,即开漏锁定输出,或DFLAG,即瞬态推挽输出,从而使用这些输出来标志Carry、Borrow、Compare和Index发生。这个Click板™可以通过PWR SEL跳线选择3.3V或5V逻辑电压电平进行操作。这样,3.3V和5V兼容的MCU都可以正确地使用通信线。此外,这个Click板™配备了一个包含易于使用的函数和示例代码的库,可用作进一步开发的参考。
功能概述
开发板
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™ 原理图

一步一步来
项目组装
软件支持
库描述
这个库包含Counter Click驱动程序的API。
关键函数:
counter_read_cntr- 使用click对象读取CNTR。counter_read_str- 使用click对象读取STR。counter_read_otr- 使用click对象读取OTR。
开源
代码示例
完整的应用程序代码和一个现成的项目可以通过NECTO Studio包管理器直接安装到NECTO Studio。 应用程序代码也可以在MIKROE的GitHub账户中找到。
/*!
* \file
* \brief Counter Click example
*
* # Description
* This application measures the speed and the position of the DC motor shafts.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes driver and configures the Click board.
*
* ## Application Task
* Reads data from the CNTR register and calculates the speed of the motor in Rad/s.
* All data is being displayed on the USB UART terminal where you can track their changes.
* The CNTR is a software configurable 8, 16, 24 or 32-bit up/down counter which
* counts the up/down pulses resulting from the quadrature clocks applied at the
* A and B inputs, or alternatively, in non-quadrature mode, pulses applied at the A input.
*
* ## NOTE
* An appropriate motor with optical encoder needs to be connected to the Click board.
*
* \author MikroE Team
*
*/
// ------------------------------------------------------------------- INCLUDES
#include "board.h"
#include "log.h"
#include "counter.h"
// ------------------------------------------------------------------ VARIABLES
static counter_t counter;
static log_t logger;
static int32_t count;
static int32_t count_old;
static float speed;
// ------------------------------------------------------ APPLICATION FUNCTIONS
void application_init ( void )
{
log_cfg_t log_cfg;
counter_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.
counter_cfg_setup( &cfg );
COUNTER_MAP_MIKROBUS( cfg, MIKROBUS_1 );
counter_init( &counter, &cfg );
counter_default_cfg( &counter );
Delay_ms ( 300 );
}
void application_task ( void )
{
count = counter_read_cntr( &counter );
log_printf( &logger, "Counter: %ld\r\n", count );
speed = ( float ) ( count - count_old ) / 3600.0;
speed *= 6.283185;
log_printf( &logger, "Speed: %.4f Rad/s\r\n", speed );
count_old = count;
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
额外支持
资源
类别:旋转编码器































