当前位置:网站首页>基于51单片机的计件器设计
基于51单片机的计件器设计
2022-06-30 15:48:00 【toyjis】
本次的项目是基于51单片机的计件器,项目内容为:实现计件器功能,这对于工厂中的货物计数具有实际意义;系统上电后自动设置检测距离20cm,小于该距离的物体会引起计数变化和蜂鸣器鸣响,每个物体仅能触发一次;使用两个数码管用于显示检测距离和物品个数;使用两个按键用于调整检测距离。
项目使用到了51单片机的四个中断源,分别为:外部中断0,定时器中断0,外部中断1,定时器中断1。基本上使用完了基础51内核的所有中断源,在两个定时器中断之间存在中断嵌套,是一份学习单片机中断的好实例!!
项目采用Proteus进行仿真实验,下图是项目的原理图,超声波传感器采用HC-SR04(SRF04)。
采用ad绘制了原理图PCB,版图大小8*9cm,空间较大,便于焊接。
部分代码如下,项目主要内容是:中断的嵌套使用、传感器的驱动代码、数码管显示代码。
void start()//测距初始化
{
TR=1;
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
TR=0;
}
int getdistance(void)
{
start();
while(!ECHO);
TR1=1;
while(ECHO);
TR1=0;
time=TH1*256+TL1;
TH1=0;
TL1=0;
s=(time*1.7)/100; //测得cm
if(flag==1||(s>700))
{
flag=0;
s=0;
return s;
}
return s;
}
完整项目包括:keilC语言代码+Proteus仿真原理图+ad原理图PCB+产品说明书
边栏推荐
- RT-Thread 堆区大小设置
- Etcd教程 — 第九章 Etcd之实现分布式锁
- Mathematical modeling for war preparation 35 time series prediction model
- 数据挖掘知识点整理(期末复习版)
- Niuke network: longest continuous subarray with positive product
- [bjdctf2020]the mystery of ip|[ciscn2019 southeast China division]web11|ssti injection
- Dart: string replace related methods
- 牛客网:乘积为正数的最长连续子数组
- CGR 21 (D,E,F)
- 2020 Blue Bridge Cup group B - move bricks - (greedy sorting +01 backpack)
猜你喜欢
Etcd tutorial - Chapter 8 compact, watch, and lease APIs for etcd
Hologres shared cluster helps Taobao subscribe to the extreme refined operation
删除有序数组中的重复项 II[双指针--多情况统一]
BC1.2 PD协议
深度学习——(2)几种常见的损失函数
Etcd教程 — 第八章 Etcd之Compact、Watch和Lease API
《网络是怎么样连接的》读书笔记 - 汇总篇
Observation cloud reached in-depth cooperation with tdengine to optimize enterprise cloud experience
【Verilog基础】关于Clock信号的一些概念总结(clock setup/hold、clock tree、clock skew、clock latency、clock transition..)
More dragon lizard self-developed features! Production available Anolis OS 8.6 officially released
随机推荐
Talk about telecommuting | community essay solicitation
CMakeLists 基础
Drug management system plus database, overnight, plus report
微信表情符号写入判决书,你发的OK、炸弹都可能成为“呈堂证供”
Etcd教程 — 第八章 Etcd之Compact、Watch和Lease API
Cmakelists Basics
jspreadsheet/CE JExcel数据字段比给的字段(columns)多会导致空白列的问题解决方案
赛芯电子冲刺科创板:拟募资6.2亿 实控人谭健为美国籍
Mathematical modeling for war preparation 35 time series prediction model
您工厂的MES再不升级,就要被淘汰啦
RTP sending PS stream zero copy scheme
Yunhe enmo won the bid for Oracle maintenance project of Tianjin Binhai rural commercial bank in 2022-2023
Home office discussion on the experience of remote assistance to quickly improve efficiency | community essay solicitation
Halcon knowledge: matrix topic [02]
Lambda表达式_Stream流_File类
【微信小程序】常用组件基本使用(view/scroll-view/swiper、text/rich-text、button/image)
halcon知识:区域专题【07】
OpenCV中LineTypes各枚举值(LINE_4 、LINE_8 、LINE_AA )的含义
Restartprocessifvisible process
RT-Thread 堆區大小設置