初学者
10 分钟

使用NE555和STM32F031K6实现完美的负载管理方法

设定时间,实现完美控制,迎接能源效率的新纪元

Timer Relay Click with Nucleo 32 with STM32F031K6 MCU

已发布 10月 01, 2024

点击板

Timer Relay Click

开发板

Nucleo 32 with STM32F031K6 MCU

编译器

NECTO Studio

微控制器单元

STM32F031K6

在我们这个受计时器控制的世界中,每次都能准时开启。我们的解决方案与时钟的滴答声保持一致,为各种应用提供无缝可靠的负载管理。

A

A

硬件概览

它是如何工作的?

Timer Relay Click 基于 Diodes Incorporated 的 NE5555,这是一款精密计时器。当触发器处于低逻辑状态时,它会根据阈值开始延迟,然后激活继电器。由德州仪器的 256 级单通道数字电位器 TPL0501 确定阈值。通过在这个数字电位器上设置所需的值,您就可以在 NE5555 上设置延迟的阈

值。当按下板载触发按钮时,您将根据数字电位器设置的延迟激活继电器。Timer Relay Click 使用 TPL0501 的 3 线 SPI 串行接口,使主 MCU 可以设置阈值。除了触发按钮,您还可以通过 mikroBUS™ 插座的 TRG 引脚触发 NE5555。当计时器达到阈值并在延迟后激活继电器时,它还会点亮 TIMER 

LED。继电器本身可以承受高达 10A 和 220VAC/28VDC 的电流。这款 Click board™ 可以通过 VCC SEL 跳线选择使用 3.3V 或 5V 逻辑电压水平。这样,3.3V 和 5V 的 MCU 都可以正确使用通信线路。此外,这款 Click board™ 配备了包含易于使用的功能和示例代码的库,可用于进一步开发。

Timer Relay Click hardware overview image

功能概述

开发板

Nucleo 32开发板搭载STM32F031K6 MCU,提供了一种经济且灵活的平台,适用于使用32引脚封装的STM32微控制器进行实验。该开发板具有Arduino™ Nano连接性,便于通过专用扩展板进行功能扩展,并且支持mbed,使其能够无缝集成在线资源。板载集成

ST-LINK/V2-1调试器/编程器,支持通过USB重新枚举,提供三种接口:虚拟串口(Virtual Com port)、大容量存储和调试端口。该开发板的电源供应灵活,可通过USB VBUS或外部电源供电。此外,还配备了三个LED指示灯(LD1用于USB通信,LD2用于电源

指示,LD3为用户可控LED)和一个复位按钮。STM32 Nucleo-32开发板支持多种集成开发环境(IDEs),如IAR™、Keil®和基于GCC的IDE(如AC6 SW4STM32),使其成为开发人员的多功能工具。

Nucleo 32 with STM32F031K6 MCU double side image

微控制器概述 

MCU卡片 / MCU

default

建筑

ARM Cortex-M0

MCU 内存 (KB)

32

硅供应商

STMicroelectronics

引脚数

32

RAM (字节)

4096

你完善了我!

配件

Click Shield for Nucleo-32是扩展您的开发板功能的理想选择,专为STM32 Nucleo-32引脚布局设计。Click Shield for Nucleo-32提供了两个mikroBUS™插座,可以添加来自我们不断增长的Click板™系列中的任何功能。从传感器和WiFi收发器到电机控制和音频放大器,我们应有尽有。Click Shield for Nucleo-32与STM32 Nucleo-32开发板兼容,为用户提供了一种经济且灵活的方式,使用任何STM32微控制器快速创建原型,并尝试各种性能、功耗和功能的组合。STM32 Nucleo-32开发板无需任何独立的探针,因为它集成了ST-LINK/V2-1调试器/编程器,并随附STM32全面的软件HAL库和各种打包的软件示例。这个开发平台为用户提供了一种简便且通用的方式,将STM32 Nucleo-32兼容开发板与他们喜欢的Click板™结合,应用于即将开展的项目中。

Click Shield for Nucleo-32 accessories 1 image

使用的MCU引脚

mikroBUS™映射器

NC
NC
AN
Reset / ID SEL
PA11
RST
SPI Select / ID COMM
PA4
CS
SPI Clock
PB3
SCK
NC
NC
MISO
SPI Data IN
PB5
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
Timer Trigger
PA12
INT
NC
NC
TX
NC
NC
RX
NC
NC
SCL
NC
NC
SDA
Power Supply
5V
5V
Ground
GND
GND
1

“仔细看看!”

Click board™ 原理图

Timer Relay Click Schematic schematic

一步一步来

项目组装

Click Shield for Nucleo-144 front image hardware assembly

从选择您的开发板和Click板™开始。以Nucleo 32 with STM32F031K6 MCU作为您的开发板开始。

Click Shield for Nucleo-144 front image hardware assembly
Nucleo 144 with STM32L4A6ZG MCU front image hardware assembly
Stepper 22 Click front image hardware assembly
Prog-cut hardware assembly
Stepper 22 Click complete accessories setup image hardware assembly
Nucleo-32 with STM32 MCU 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
STM32 M4 Clicker HA MCU/Select 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

实时跟踪您的结果

应用程序输出

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

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

软件支持

库描述

该库包含 Timer Relay Click 驱动程序的 API。

关键功能:

  • timerrelay_set_wiper_pos - Timer Relay 设置滑动端位置功能。

  • timerrelay_activate_reset - Timer Relay 重置计时器功能。

  • timerrelay_activate_trigger - Timer Relay 激活触发功能。

开源

代码示例

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

/*!
 * @file main.c
 * @brief Timer Relay Click example
 *
 * # Description
 * This example demonstrates the use of the Timer Relay Click board by
 * setting the relay timer to 2 seconds ON time, then holding it OFF for 2 more seconds.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver and performs the click default configuration,
 * then setting the ON time to 2 seconds.
 *
 * ## Application Task
 * This example is activating the trigger every 4 seconds activating the relay timer.
 *
 * @author Stefan Ilic
 *
 */

#include "board.h"
#include "log.h"
#include "timerrelay.h"

static timerrelay_t timerrelay;
static log_t logger;

void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    timerrelay_cfg_t timerrelay_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.
    timerrelay_cfg_setup( &timerrelay_cfg );
    TIMERRELAY_MAP_MIKROBUS( timerrelay_cfg, MIKROBUS_1 );
    if ( SPI_MASTER_ERROR == timerrelay_init( &timerrelay, &timerrelay_cfg ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    if ( TIMERRELAY_ERROR == timerrelay_default_cfg ( &timerrelay ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }
    
    if ( TIMERRELAY_ERROR == timerrelay_set_delay( &timerrelay, 2 ) )
    {
        log_error( &logger, " Value configuration." );
        for ( ; ; );
    }
    
    timerrelay_activate_reset( &timerrelay );
    
    log_info( &logger, " Application Task " );
}

void application_task ( void )
{
    timerrelay_activate_trigger( &timerrelay );
    log_printf( &logger, " Trigger activated. \r\n" );
    Delay_ms( 4000 );
}

void main ( void )
{
    application_init( );

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

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

额外支持

资源

喜欢这个项目吗?

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