毕业设计 stm32单片机的智能微波炉设计

201 篇文章 122 订阅
151 篇文章 42 订阅

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 实现效果

4 设计原理

硬件设计

本项目使用的开发板为中科蓝讯AB32VG1,使用到板子的串口通讯模块,板子作为下位机和上位机使用串口通讯。

AB32VG1主控MCU

AB32VG1是一颗基于RISC-V的MCU,性价比非常高,不管是开发板还是芯片,都比较便宜,具体参数如下:
在这里插入图片描述

利用RT-Thread Studio(https://www.rt-thread.org/page/studio.html)进行开发。此外,需要安装Bluetrum开发板支持以及RISC-V-GCC编译器,如图:

在这里插入图片描述

AB32VG1:充当主控,使用其SDIO接口,用于读取SD的内容。还使用其串口,用于链接Wi-Fi模组。

软件设计

软件有两部分组成:

  • 下位机:使用RT-Thread

  • 上位机: android 工控系统

继电器吸合开始加热,断开停止加热 (LED 模拟继电器)

实验步骤

1.打开RT-Thread Studio 安装资源包

在这里插入图片描述

2.安装riscv 的工具链(编译使用)

在这里插入图片描述

3.新建项目
在这里插入图片描述

选择 基于开发板,然后选择 AB32VG1-AB-PROUGEN
在这里插入图片描述

等待项目建立

4.编译模板项目

在这里插入图片描述

5.下载模板项目
在这里插入图片描述

使用downloader 下载固件到开发板,如果烧写成功,板子上的LED灯闪速,说明烧写成功。

6.勾选UART1
在这里插入图片描述

7.创建串口程序修改波特率
在这里插入图片描述

修改为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 最后

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值