基于STM32单片机的电子称称重系统proteus仿真原理图PCB

功能:
0.本系统采用STC89C52作为单片机
1.LCD1602液晶实时显示当前重量和重量报警阈值
2.重量超过报警阈值声光报警
3.按键功能介绍
'上’键——报警阈值加10g
'下’键——报警阈值减10g
4.系统上设计有eeprom芯片,可支持设置的报警阈值掉电不丢失
5.采用DC002作为电源接口可直接输入5V给整个系统供电

原理图:
在这里插入图片描述

PCB :
在这里插入图片描述

主程序:

#define __MIAN_C
#include "main.h"
#include "stdio.h"
#include "stm32f10x.h"
#include "stm32f10x_gpio.h"
#include "bsp_gpio.h"
#include "bsp_clkconfig.h"
#include "bsp_delay.h"
#include "bsp_lcd1602.h"
#include "bsp_key.h"
#include "bsp_GeneralTim.h" 
#include "bsp_display.h"
#include "bsp_hx711.h"
#include "bsp_at24c02.h"

// 局部变量,用于保存转换计算后的电压值 	 
CreatByte Flag;

uint8_t isNewFlag = 0x01;
uint16_t alarmWeight = 5000;
uint8_t alarmWeight_H;
uint8_t alarmWeight_L;
uint16_t alarmWeight_i = 0;
uint16_t alarmWeight_d = 0;
uint16_t alarmWeightBuf = 0;
uint32_t initialWeight = 0; //单位g
float objectWeight = 0; //单位g
uint32_t objectWeight_i = 0; //单位g
uint32_t objectWeight_d = 0; //单位g

int main(void)
{	

    // 使用HSI,SYSCLK = 4M * RCC_PLLMul_x, x:[2,3,...16],最高是64MH
    HSI_SetSysClock(RCC_PLLMul_2); //使用内部8MHz晶振,并设置PLL输出为8MHz

    // 端口初始化
    GPIO_Config();
    GENERAL_TIM_Init();
    Key_GPIO_Config();
    HX711_GPIO_Config();
    EEPROM_Init();
    
    isNewFlag = EEPROM_ReadByte(0x01);
    
    if (isNewFlag != 0x00)
    {
        EEPROM_WriteByte(0x01, 0x00);        
        DelayMs(10);
        EEPROM_WriteByte(0x02, (uint8_t)(alarmWeight>>8));
        DelayMs(10);
        EEPROM_WriteByte(0x03, (uint8_t)(alarmWeight & 0x00FF));
        DelayMs(10);
    }
    isNewFlag = EEPROM_ReadByte(0x01);
    DelayMs(10);
    alarmWeight_H = EEPROM_ReadByte(0x02);
    DelayMs(10);
    alarmWeight_L = EEPROM_ReadByte(0x03);
    DelayMs(10);    
    alarmWeight = ((uint16_t)alarmWeight_H<<8) + (uint16_t)alarmWeight_L;

    LCD_GPIO_Init();
    LCD_Init();
    LCD_Clear();
    DelayMs(200);
    LCD_DispStr(0, 0, "Electronic Scale");
    
    initialWeight = HX711_GetInitialWeight();
    
    DelayMs(1000);
    LCD_Clear();


    while (1)
    {
        if (dispFlag == 1)
        {
            dispFlag = 0;
            DispWeight();
        }

        KeyProcess();
    }
}

/*********************************************END OF FILE**********************/

仿真演示视频:
https://www.bilibili.com/video/BV18D4y1k7FN/

实物演示视频:
https://www.bilibili.com/video/BV1R34y1E7Bd/

  • 0
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值