中级
30 分钟

使用MIC74和PIC32MZ2048EFM100实现风扇速度的魔法控制

空气的掌控者

Fan 3 click with Curiosity PIC32 MZ EF

已发布 7月 22, 2025

点击板

Fan 3 click

开发板

Curiosity PIC32 MZ EF

编译器

NECTO Studio

微控制器单元

PIC32MZ2048EFM100

创新与最佳冷却性能相结合。

A

A

硬件概览

它是如何工作的?

Fan 3 Click基于MIC74,这是Microchip的串行到并行I/O扩展器和风扇控制器,以及MIC29152,这是Microchip的高电流、高精度、低压降稳压器。最高的四位输出可以用来实现风扇速度控制。该设备使用I2C通信协议来设置专用内部寄存器。CLK和DATA引脚连接到mikroBUS™ I2C引脚。此外,这些引脚已经通过点击板上的4k7电阻上拉,因此不需要使用额外的上拉电阻。最高的三位输出配有电阻,连接到MIC29152的反馈输入(ADJ)。该稳压器用于输出风扇的稳定电压,该电压由ADJ引脚

上的反馈电压确定。当选择最大速度时,稳压器的输出被设定为12V。推荐的输入电压应最多为12V,因为在这种情况下,调节效率将不会是最佳的,并且多余的功率将会作为热量散发出去。电压稳压器具有内部功率限制逻辑,可以保护其在输出过载的情况下不受损坏。MIC74的各个开漏输出位根据内部状态机的控制有选择地接地或浮动,因此MIC29152稳压器的反馈路径所看到的等效电阻被提高或降低,以此来改变输出电压。第四位被设置为SHDN,当I2C选择风扇模式时,通过其EN引脚使电压稳压器

工作。设置此位将激活电压稳压器,并且风扇将以MIC74寄存器定义的速度开始旋转。Fan 3 click可以在几个不同的I2C地址上使用,可通过ADD SEL跳线选择。这些跳线用于直接设置MIC74的A0到A2地址选择引脚。所有地址引脚默认接地,将从设备I2C地址设置为0x20h。该点击板配有两个连接器。一个连接器连接到馈送给稳压器输入的外部电压源。另一个连接器用于连接负载-通常是一个与额定电压为12V的电动机连接的负载,并且其转子上附有风扇叶片。

Fan 3 click hardware overview image

功能概述

开发板

Curiosity PIC32 MZ EF 开发板是一个完全集成的 32 位开发平台,特点是高性能的 PIC32MZ EF 系列(PIC32MZ2048EFM),该系列具有 2MB Flash、512KB RAM、集成的浮点单元(FPU)、加密加速器和出色的连接选项。它包括一个集成的程序员和调试器,无需额外硬件。用户可以通过 MIKROE 

mikroBUS™ Click™ 适配器板扩展功能,通过 Microchip PHY 女儿板添加以太网连接功能,使用 Microchip 扩展板添加 WiFi 连接能力,并通过 Microchip 音频女儿板添加音频输入和输出功能。这些板完全集成到 PIC32 强大的软件框架 MPLAB Harmony 中,该框架提供了一个灵活且模块化的接口

来应用开发、一套丰富的互操作软件堆栈(TCP-IP、USB)和易于使用的功能。Curiosity PIC32 MZ EF 开发板提供了扩展能力,使其成为连接性、物联网和通用应用中快速原型设计的绝佳选择。

Curiosity PIC32MZ EF double side image

微控制器概述 

MCU卡片 / MCU

default

建筑

PIC32

MCU 内存 (KB)

2048

硅供应商

Microchip

引脚数

100

RAM (字节)

524288

使用的MCU引脚

mikroBUS™映射器

NC
NC
AN
NC
NC
RST
NC
NC
CS
NC
NC
SCK
NC
NC
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
I2C Clock
RPA14
SCL
I2C Data
RPA15
SDA
NC
NC
5V
Ground
GND
GND
1

“仔细看看!”

Click board™ 原理图

Fan 3 click Schematic schematic

一步一步来

项目组装

Curiosity PIC32MZ EF front image hardware assembly

从选择您的开发板和Click板™开始。以Curiosity PIC32 MZ EF作为您的开发板开始。

Curiosity PIC32MZ EF front image hardware assembly
GNSS2 Click front image hardware assembly
Prog-cut hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
Board mapper by product7 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
Curiosity PIC32 MZ EF 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

软件支持

库描述

这个库包含Fan 3 Click驱动程序的API。

关键函数:

  • fan3_set_speed - 设置风扇速度

开源

代码示例

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

/*!
 * \file 
 * \brief Fan3 Click example
 * 
 * # Description
 * This application controls the fan speed.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initializes the Click device.
 * 
 * ## Application Task  
 * Cycles through different fan speeds, including 0 - stopped.
 * 
 * \author MikroE Team
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "fan3.h"

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

static fan3_t fan3;
static log_t logger;

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

void application_init ( void )
{
    log_cfg_t log_cfg;
    fan3_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.

    fan3_cfg_setup( &cfg );
    FAN3_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    fan3_init( &fan3, &cfg );

    log_printf( &logger, ">>> Initialized...\r\n" );
}

void application_task ( )
{
    log_printf( &logger, "Speed 1...\r\n" );
    fan3_set_speed( &fan3, FAN3_SPEED1 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    log_printf( &logger, "Speed 3...\r\n" );
    fan3_set_speed( &fan3, FAN3_SPEED3 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    log_printf( &logger, "Speed 5...\r\n" );
    fan3_set_speed( &fan3, FAN3_SPEED5 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    log_printf( &logger, "Speed 7...\r\n" );
    fan3_set_speed( &fan3, FAN3_SPEED7 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    log_printf( &logger, "Stopped...\r\n" );
    fan3_set_speed( &fan3, FAN3_STOPPED );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    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

额外支持

资源

喜欢这个项目吗?

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