当前位置:网站首页>Ultrasonic distance meter based on 51 single chip microcomputer
Ultrasonic distance meter based on 51 single chip microcomputer
2022-07-04 14:28:00 【toyjis】
The project is based on HC-SR04 Range finder of ultrasonic sensor , Use digital tube to display distance . The ranging range is 2cm-400cm, Use timer 0 Interrupt setting the sensor measurement frequency , Every time 200ms Refresh the data once .
HC-SR04 It is a common ultrasonic sensor , It is often used in the ranging of smart cars , Avoiding obstacles , Blind crutches and other fields ; This module directly integrates the ultrasonic transmitter 、 Receiver and control circuit , You can work directly by plugging it in , There is no need to connect the drive circuit .
HC-SR04 How it works :
1、 Use a pin of the MCU to send at least 10us High level TTL Pulse signal to module Trig Pin , Used to trigger the operation of the module ( The code is embodied as the start ranging function ).
2、 After the module detects the trigger signal , Will automatically send 8 individual 40khz The square wave , Then automatically switch to monitoring mode , Monitor whether there is signal return .
3、 If a signal returns , By module Echo The pin will output a high level , The duration of the high level is the time from the ultrasonic wave is emitted to the time it returns ( The code is embodied in the function of getting distance ).
This design does not use a simple delay function , Instead, the timer interrupt is used to control the frequency of ranging , This ensures that the sensor has enough time to receive data 、 Processing data .
The simulation diagram of the system is as follows :
It's still drawn PCB Territory , This drawing is for in-line devices PCB, The patch device version will be added later , In this way, it can be made into a small range finder .

Part of the code is shown below , Code according to HC-SR04 Instructions for writing
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+1; // Measured cm
if(flag==1||(s>700))
{
flag=0;
s=0;
return s;
}
return s;
}
void main()
{
init();
while(1)
{
display(distance);
}
}
** Resources include :keilC The language code +Proteus Simulation schematic +ad Schematic diagram PCB+ Product specification **
边栏推荐
- MySQL的触发器
- Map of mL: Based on Boston house price regression prediction data set, an interpretable case is realized by using the map value to the LIR linear regression model
- 产业互联网则具备更大的发展潜能,具备更多的行业场景
- opencv3.2 和opencv2.4安装
- Digi XBee 3 RF: 4个协议,3种封装,10个大功能
- 一文概览2D人体姿态估计
- 如何游戏出海代运营、游戏出海代投
- 聊聊保证线程安全的 10 个小技巧
- 数据中台概念
- Nowcoder reverse linked list
猜你喜欢

Oppo find N2 product form first exposure: supplement all short boards

SqlServer函数,存储过程的创建和使用

No servers available for service: xxxx

【信息检索】链接分析

Practical puzzle solving | how to extract irregular ROI regions in opencv
![Incremental ternary subsequence [greedy training]](/img/92/7efd1883c21c0e804ffccfb2231602.png)
Incremental ternary subsequence [greedy training]

Leetcode 61: 旋转链表

leetcode:6110. 网格图中递增路径的数目【dfs + cache】

What is the difference between Bi financial analysis in a narrow sense and financial analysis in a broad sense?

富文本编辑:wangEditor使用教程
随机推荐
leetcode:6110. 网格图中递增路径的数目【dfs + cache】
数据仓库面试问题准备
Gorm read / write separation (rotation)
opencv3.2 和opencv2.4安装
Practical puzzle solving | how to extract irregular ROI regions in opencv
ML之shap:基于boston波士顿房价回归预测数据集利用Shap值对LiR线性回归模型实现可解释性案例
[MySQL from introduction to proficiency] [advanced chapter] (V) SQL statement execution process of MySQL
MySQL的存储过程练习题
R language dplyr package summary_ If function calculates the mean and median of all numerical data columns in dataframe data, and summarizes all numerical variables based on conditions
关于miui12.5 红米k20pro用au或者povo2出现问题的解决办法
GCC [6] - 4 stages of compilation
一种架构来完成所有任务—Transformer架构正在以一己之力统一AI江湖
Remove duplicate letters [greedy + monotonic stack (maintain monotonic sequence with array +len)]
Rich text editing: wangeditor tutorial
Fs4059c is a 5V input boost charging 12.6v1.2a. Inputting a small current to three lithium battery charging chips will not pull it dead. The temperature is 60 ° and 1000-1100ma is recommended
实战解惑 | OpenCV中如何提取不规则ROI区域
R language ggplot2 visualization: gganimate package creates dynamic line graph animation (GIF) and uses transition_ The reveal function displays data step by step along a given dimension in the animat
PyTorch的自动求导机制详细解析,PyTorch的核心魔法
sql优化之查询优化器
基于51单片机的超声波测距仪