初学者
10 分钟

使用 G6D-1A-ASI 和 PIC32MZ2048EFH100 保持研究和实验的理想条件

您可信赖的全环境温度计

Thermostat 2 Click with Flip&Click PIC32MZ

已发布 6月 25, 2024

点击板

Thermostat 2 Click

开发板

Flip&Click PIC32MZ

编译器

NECTO Studio

微控制器单元

PIC32MZ2048EFH100

使用我们的温度测量技术,提前预防潜在的健康风险,该技术旨在为关键环境中的温度波动提供早期预警。

A

A

硬件概览

它是如何工作的?

Thermostat 2 Click设计时没有主要IC;它允许使用外部连接的热传感器。它可以与使用1-Wire®通信的DS1820兼容传感器接口。Click board™配备了一个3针母插座,可以用于安装TO-92封装的DS1820兼容传感器。还配有一个3极螺钉端子,如果传感器需要安装在远程位置(例如加热组件上),则可以使用该端子。螺钉端子与插座共享其线路。通过mikroBUS™的PWM引脚与主机MCU进行1-Wire®通信。根据通过1-Wire®接口获得的温度信息,主机MCU可以采取必要的操作:它可以打开或关闭继电器的触点。Click board™使用了来自欧姆龙的G6D系列PCB电源继电器。这个高质量继电器可以在没有负载连接的情况下承受惊人的大量机械循环。然而,当其输出连接有显著负载时,微电弧会随着时间的推移导致触点磨损。最大负载电流为5A时,它可以承受高达70,000次

循环。其触点由银合金制成,具有出色的最大100mΩ的ON电阻。继电器通过低压侧内置线圈产生的磁场激活。线圈由主机MCU激活。线圈激活的电压为5V,线圈的电流为40mA。MCU无法直接驱动线圈,因此需要添加一个NPN晶体管。其基极由主机MCU控制,允许线圈从5V mikroBUS™电源轨吸取足够的电流。晶体管的基极被路由到Click board™的CS引脚。晶体管在同一外壳中打包了两个偏置电阻,因此可以直接在MCU引脚上使用,而无需外部偏置电阻。标记为ACTIVE的红色LED用于指示晶体管处于打开状态,并且电流正在通过继电器线圈。当线圈(或任何其他电感器)中的电流突然改变时,将产生反电动势,反对电流的变化。这有时会导致控制电路损坏:在这种情况下,晶体管将变为反向极化。为了防止这种情况的发生,在线圈两端添加了一个续流二

极管。在正常操作期间,该二极管不导通任何电流。然而,当线圈关闭时,反向极化将导致电流以最小阻力通过该二极管。这防止了反向(续流)电压的建立,从而保护了晶体管。输出上的触点可能连接到较高电压,并且可能会通过较大的电流。为防止这种情况下的高电压瞬变,续流二极管并不是可行的选择。因此,Thermostat 2 Click使用了压敏电阻(VDR)。当电压升高超过其额定钳位电压时,该组件会迅速降低其电阻。由于它将成为最小阻力的电流路径,因此过量的电压瞬变将通过VDR。在正常操作期间,当电压低于额定钳位电压时,VDR具有非常高的电阻,因此电流通过电路运行。Click board™的工作电压可以通过VCC SEL跳线选择。此跳线允许从mikroBUS™选择3.3V或5V。所选电压将应用于连接的DS1820传感器的VCC引脚。

Thermostat 2 Click hardware overview image

功能概述

开发板

Flip&Click PIC32MZ 是一款紧凑型开发板,设计为一套完整的解决方案,它将 Click 板™的灵活性带给您喜爱的微控制器,使其成为实现您想法的完美入门套件。它配备了一款板载 32 位 PIC32MZ 微控制器,Microchip 的 PIC32MZ2048EFH100,四个 mikroBUS™ 插槽用于 Click 板™连接,两个 USB 连接器,LED 指示灯,按钮,调试器/程序员连接器,以及两个与 Arduino-UNO 引脚兼容的头部。得益于创

新的制造技术,它允许您快速构建具有独特功能和特性的小工具。Flip&Click PIC32MZ 开发套件的每个部分都包含了使同一板块运行最高效的必要组件。此外,还可以选择 Flip&Click PIC32MZ 的编程方式,使用 chipKIT 引导程序(Arduino 风格的开发环境)或我们的 USB HID 引导程序,使用 mikroC、mikroBasic 和 mikroPascal for PIC32。该套件包括一个通过 USB 类型-C(USB-C)连接器的干净且调

节过的电源供应模块。所有 mikroBUS™ 本身支持的 通信方法都在这块板上,包括已经建立良好的 mikroBUS™ 插槽、用户可配置的按钮和 LED 指示灯。Flip&Click PIC32MZ 开发套件允许您在几分钟内创建新的应用程序。它由 Mikroe 软件工具原生支持,得益于大量不同的 Click 板™(超过一千块板),其数量每天都在增长,它涵盖了原型制作的许多方面。

Flip&Click PIC32MZ double image

微控制器概述 

MCU卡片 / MCU

default

建筑

PIC32

MCU 内存 (KB)

2048

硅供应商

Microchip

引脚数

100

RAM (字节)

524288

使用的MCU引脚

mikroBUS™映射器

NC
NC
AN
NC
NC
RST
Relay Control
RA0
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
1-Wire Data
RC14
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™ 原理图

Thermostat 2 Click Schematic schematic

一步一步来

项目组装

Flip&Click PIC32MZ front image hardware assembly

从选择您的开发板和Click板™开始。以Flip&Click PIC32MZ作为您的开发板开始。

Flip&Click PIC32MZ 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
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

软件支持

库描述

该库包含Thermostat 2 Click驱动程序的 API。

关键功能:

  • thermostat2_read_temperature - 该函数读取摄氏温度值。

  • thermostat2_relay_state - 该函数打开/关闭继电器。

开源

代码示例

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

/*!
 * @file main.c
 * @brief Thermostat 2 Click Example.
 *
 * # Description
 * This example demonstrates the use of Thermostat 2 Click board by reading
 * and displaying the temperature in Celsius and turning the relay on/off 
 * depending on the temperature value.
 * DS1820, DS18S20 and DS18B20 chips can be used in this example. 
 * 
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver and performs the Click default configuration.
 *
 * ## Application Task
 * Reads and displays the temperature measured by the Click board on the UART Terminal.
 * If the temperature goes beneath the THERMOSTAT2_TEMPERATURE_LIMIT, 
 * the relay will be turned off while otherwise it will be turned on. 
 * In both cases an appropriate message will be displayed on the terminal. 
 *
 * @author Aleksandra Cvjetićanin 
 *
 */

#include "board.h"
#include "log.h"
#include "thermostat2.h"

static thermostat2_t thermostat2;
static log_t logger;

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    thermostat2_cfg_t thermostat2_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.
    thermostat2_cfg_setup( &thermostat2_cfg );
    THERMOSTAT2_MAP_MIKROBUS( thermostat2_cfg, MIKROBUS_1 );
    if ( ONE_WIRE_ERROR == thermostat2_init( &thermostat2, &thermostat2_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    if ( THERMOSTAT2_ERROR == thermostat2_default_cfg ( &thermostat2 ) )
    {
        log_error( &logger, " Default config." );
        for ( ; ; );
    }
    
    log_info( &logger, " Application Task " );
}

void application_task ( void ) 
{
    static uint8_t relay_state = 0xFF;
    float temperature;
    
    if ( THERMOSTAT2_OK == thermostat2_read_temperature ( &thermostat2, &temperature ) )
    {
        log_printf( &logger, " Temperature: %.2f C\r\n\n ", temperature );
    }
    
    if ( temperature < THERMOSTAT2_TEMPERATURE_LIMIT )
    {
        if ( relay_state != THERMOSTAT2_RELAY_ON )
        {
            log_info( &logger, " Relay is ON.\r\n " );
            thermostat2_relay_state ( &thermostat2, THERMOSTAT2_RELAY_ON );
            relay_state = THERMOSTAT2_RELAY_ON;
        }
    }
    else 
    {
        if ( relay_state != THERMOSTAT2_RELAY_OFF )
        {
            log_info( &logger, " Relay is OFF.\r\n" );
            thermostat2_relay_state ( &thermostat2, THERMOSTAT2_RELAY_OFF );
            relay_state = THERMOSTAT2_RELAY_OFF;
        }
    }
}

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

额外支持

资源

喜欢这个项目吗?

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