天天看點

畢業設計 stm32單片機的智能微波爐設計0 前言1 簡介2 主要器件3 實作效果4 設計原理5 部分核心代碼6 最後

0 前言

🔥 這兩年開始畢業設計和畢業答辯的要求和難度不斷提升,傳統的畢設題目缺少創新和亮點,往往達不到畢業答辯的要求,這兩年不斷有學弟學妹告訴學長自己做的項目系統達不到老師的要求。

為了大家能夠順利以及最少的精力通過畢設,學長分享優質畢業設計項目,今天要分享的是

🚩 畢業設計 stm32單片機的智能微波爐設計

🥇學長這裡給一個題目綜合評分(每項滿分5分)

  • 難度系數:3分
  • 工作量:3分
  • 創新點:5分

🧿 選題指導, 項目分享:

https://gitee.com/dancheng-senior/project-sharing-1/blob/master/%E6%AF%95%E8%AE%BE%E6%8C%87%E5%AF%BC/README.md

1 簡介

說到微波爐大家并不陌生,很早之前一部分家庭都備有微波爐,尤其是在一些公司企業裡都會有,而在這個共享經濟火熱的時期裡,共享微波爐也加入到共享經濟的行列中。共享微波爐主要是給室外的從業人員以及企業的辦公人員加熱食物用的,尤其是在冬天用的很多。而這種家電共享化的嘗試,将會成為未來共享經濟爆發的下一個風口。結合國産軟硬體的計算不斷提高,全套系統使用國有硬體和軟體基本上已經沒有阻礙。本項目是将原有的底層控制更換,采用國有資源項目架構設計。

2 主要器件

  • 中科藍訊的AB32VG1單片機
  • RT-Thread物聯網作業系統
  • 上位機: android 工控系統
  • 繼電器

3 實作效果

畢業設計 stm32單片機的智能微波爐設計0 前言1 簡介2 主要器件3 實作效果4 設計原理5 部分核心代碼6 最後

4 設計原理

硬體設計

本項目使用的開發闆為中科藍訊AB32VG1,使用到闆子的序列槽通訊子產品,闆子作為下位機和上位機使用序列槽通訊。

AB32VG1主要MCU

AB32VG1是一顆基于RISC-V的MCU,成本效益非常高,不管是開發闆還是晶片,都比較便宜,具體參數如下:

畢業設計 stm32單片機的智能微波爐設計0 前言1 簡介2 主要器件3 實作效果4 設計原理5 部分核心代碼6 最後

利用RT-Thread Studio(https://www.rt-thread.org/page/studio.html)進行開發。此外,需要安裝Bluetrum開發闆支援以及RISC-V-GCC編譯器,如圖:

畢業設計 stm32單片機的智能微波爐設計0 前言1 簡介2 主要器件3 實作效果4 設計原理5 部分核心代碼6 最後

AB32VG1:充當主要,使用其SDIO接口,用于讀取SD的内容。還使用其序列槽,用于連結Wi-Fi模組。

軟體設計

軟體有兩部分組成:

  • 下位機:使用RT-Thread
  • 上位機: android 工控系統

繼電器吸合開始加熱,斷開停止加熱 (LED 模拟繼電器)

實驗步驟

1.打開RT-Thread Studio 安裝資源包

畢業設計 stm32單片機的智能微波爐設計0 前言1 簡介2 主要器件3 實作效果4 設計原理5 部分核心代碼6 最後

2.安裝riscv 的工具鍊(編譯使用)

畢業設計 stm32單片機的智能微波爐設計0 前言1 簡介2 主要器件3 實作效果4 設計原理5 部分核心代碼6 最後

3.建立項目

畢業設計 stm32單片機的智能微波爐設計0 前言1 簡介2 主要器件3 實作效果4 設計原理5 部分核心代碼6 最後

選擇 基于開發闆,然後選擇 AB32VG1-AB-PROUGEN

畢業設計 stm32單片機的智能微波爐設計0 前言1 簡介2 主要器件3 實作效果4 設計原理5 部分核心代碼6 最後

等待項目建立

4.編譯模闆項目

畢業設計 stm32單片機的智能微波爐設計0 前言1 簡介2 主要器件3 實作效果4 設計原理5 部分核心代碼6 最後

5.下載下傳模闆項目

畢業設計 stm32單片機的智能微波爐設計0 前言1 簡介2 主要器件3 實作效果4 設計原理5 部分核心代碼6 最後

使用downloader 下載下傳固件到開發闆,如果燒寫成功,闆子上的LED燈閃速,說明燒寫成功。

6.勾選UART1

畢業設計 stm32單片機的智能微波爐設計0 前言1 簡介2 主要器件3 實作效果4 設計原理5 部分核心代碼6 最後

7.建立序列槽程式修改波特率

畢業設計 stm32單片機的智能微波爐設計0 前言1 簡介2 主要器件3 實作效果4 設計原理5 部分核心代碼6 最後

修改為9600

8.連接配接android 工控機發送指令

  • 序列槽發送0 輸出低電平,關閉繼電器
  • 序列槽發送1 輸出高電平,打開繼電器

5 部分核心代碼

/*
 * Copyright (c) 2020-2020, BLUETRUM Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include "ab32vg1_hal.h"

#ifdef HAL_UART_MODULE_ENABLED

enum
{
    UARTxCON = 0x00,
    UARTxCPND,
    UARTxBAUD,
    UARTxDATA,
};

/**
 * @brief Set the UART baud rate.
 *
 * @param uartx This parameter can be UARTxN where x can be (0.2).
 * @param baud Baud rate.
 */
void hal_uart_setbaud(hal_sfr_t uartx, uint32_t baud)
{
    uint32_t baud_cfg;

    uartx[UARTxCON] |= UART_CLK_SRC1;
    baud_cfg = (26000000/2)/baud;
    uartx[UARTxBAUD] = (baud_cfg << 16) | baud_cfg;
}

/**
 * @brief Set the UART misc paramter.
 *
 * @param uartx This parameter can be UARTxN where x can be (0.2).
 * @param param uart config paramter pointer.
 */
void hal_uart_setparam(hal_sfr_t uartx, struct uart_init *param)
{
    switch (param->word_len)
    {
    case UART_WORDLENGTH_8B:
        uartx[UARTxCON] &= ~UART_BIT9_ENABLE;
        break;
    case UART_WORDLENGTH_9B:
        uartx[UARTxCON] |= UART_BIT9_ENABLE;
        break;
    default:
        break;
    }

    switch (param->stop_bits)
    {
    case UART_STOPBITS_1:
        uartx[UARTxCON] &= ~UART_SB2_ENABLE;
        break;
    case UART_STOPBITS_2:
        uartx[UARTxCON] |= UART_SB2_ENABLE;
        break;
    default:
        break;
    }

    if (param->mode & UART_MODE_1LINE)
    {
        uartx[UARTxCON] |= UART_1LINE_ENABLE;
    }
    else
    {
        uartx[UARTxCON] &= ~UART_1LINE_ENABLE;
    }
}
/**
 * @brief Initialize the UART mode.
 *
 * @param huart UART handle.
 * @return hal_error_t
 */
hal_error_t hal_uart_init(struct uart_handle *huart)
{
    if (huart == HAL_NULL) {
        return -HAL_ERROR;
    }

    hal_uart_mspinit(huart);
    uart_config_all(huart);

    return HAL_EOK;
}

/**
 * @brief DeInitialize the UART peripheral.
 *
 * @param uartx This parameter can be UARTxN where x can be (0.2).
 */
void hal_uart_deinit(hal_sfr_t uartx)
{
    uartx[UARTxCON] = 0;
}

/**
 * @brief Initialize the UART MSP.
 *
 * @param huart UART handle.
 */
WEAK void HAL_UART_MspInit(struct uart_handle *huart)
{}

/**
 * @brief Control the UART peripheral.
 *
 * @param uartx This parameter can be UARTxN where x can be (0.2).
 * @param cntl
 *      @arg UART_MODULE_ENABLE
 *      @arg UART_BIT9_ENABLE
 *      @arg UART_RXIT_ENABLE
 *      @arg UART_TXIT_ENABLE
 *      @arg UART_SB2_ENABLE
 *      @arg UART_CLK_SRC1
 *      @arg UART_1LINE_ENABLE
 *      @arg UART_RX_ENABLE
 * @param param
 *      @arg HAL_DISABLE
 *      @arg HAL_ENABLE
 */
void hal_uart_control(hal_sfr_t uartx, uint32_t cntl, uint32_t param)
{
    if (param == HAL_ENABLE) {
        uartx[UARTxCON] |= (cntl);
    } else {
        uartx[UARTxCON] &= ~(cntl);
    }
}

/**
 * @brief Send a character
 *
 * @param uartx This parameter can be UARTxN where x can be (0.2).
 * @param data The characters that need to be sent
 */
void hal_uart_write(hal_sfr_t uartx, uint8_t data)
{
    uartx[UARTxDATA] = data;
}

/**
 * @brief Receive a character.
 *
 * @param uartx This parameter can be UARTxN where x can be (0.2).
 * @return uint8_t Received character.
 */
uint8_t hal_uart_read(hal_sfr_t uartx)
{
    return (uartx[UARTxDATA] & 0xff);
}

/**
 * @brief Get the UART flag.
 *
 * @param uartx This parameter can be UARTxN where x can be (0.2).
 * @param flag
 *      @arg UART_FLAG_RXPND
 *      @arg UART_FLAG_TXPND
 * @return uint32_t
 */
uint32_t hal_uart_getflag(hal_sfr_t uartx, uint32_t flag)
{
    uint32_t ret = uartx[UARTxCON] & flag;
    return ret;
}

/**
 * @brief Clear the UART flag.
 *
 * @param uartx This parameter can be UARTxN where x can be (0.2).
 * @param flag
 *      @arg UART_FLAG_RXPND
 *      @arg UART_FLAG_TXPND
 */
void hal_uart_clrflag(hal_sfr_t uartx, uint32_t flag)
{
    uartx[UARTxCPND] |= flag;
}

/**
 * @brief Configure the UART peripheral.
 *
 * @param huart UART handle.
 */
void uart_config_all(struct uart_handle *huart)
{
    hal_uart_control(huart->instance, UART_MODULE_ENABLE, HAL_DISABLE);

    CLKCON1 |= BIT(14);
    if (huart->instance == UART0_BASE) {
        hal_rcu_periph_clk_enable(RCU_UART0);
    } else if (huart->instance == UART1_BASE) {
        hal_rcu_periph_clk_enable(RCU_UART1);
    } else if (huart->instance == UART2_BASE) {
        hal_rcu_periph_clk_enable(RCU_UART2);
    } else {
        return; /* Not support! */
    }

    hal_uart_deinit(huart->instance);
    hal_uart_setbaud(huart->instance, huart->init.baud);
    hal_uart_setparam(huart->instance, &huart->init);

    if (huart->init.mode != UART_MODE_TX) {
        hal_uart_control(huart->instance, UART_RX_ENABLE, HAL_ENABLE);
    }
    hal_uart_control(huart->instance, UART_MODULE_ENABLE, HAL_ENABLE);
}

#endif

           

6 最後