基于单片机去皮校准电子秤设计
1454下载地址 https://docs.qq.com/doc/DWEpnR2pOWU91b3p4?pub=1&dver=2.1.0
#include <reg52.h> #include <intrins.h> #include <string.h> bit bdata flag_key; #include "main.h" #include "LCD1602.h" #include "HX711.h" #include "keyboard.h" #include "eeprom52.h" #define uchar unsigned char #define uint unsigned int unsigned long HX711_Buffer = 0; unsigned long Weight_Maopi = 0; unsigned long Weight_Maopi_0 = 0; unsigned int qupi=0; long Weight_Shiwu = 0; //键盘处理变量 unsigned char keycode; unsigned char DotPos; //小数点标志及位置 uint GapValue,GapValue1; unsigned char idata price; //单价,长整型值,单位为分 unsigned char idata money; //总价,长整型值,单位为分 //定义标识 volatile bit FlagTest = 0; //定时测试标志,每0.5秒置位,测完清0 volatile bit FlagKeyPress = 0; //有键按下标志,处理完毕清0 //校准参数 //因为不同的传感器特性曲线不是很一致,因此,每一个传感器需要矫正这里这个参数才能使测量值很准确。 //当发现测试出来的重量偏大时,增加该数值。 //如果测试出来的重量偏小时,减小改数值。 //该值可以为小数 //#define GapValue 349 sbit LED=P1^1; volatile bit ClearWeighFlag = 0; //传感器调零标志位,清除0漂 /******************把数据保存到单片机内部eeprom中******************/ void write_eeprom() { SectorErase(0x1000);