当前位置:网站首页>【小型物体测速仪】只有原理,无代码
【小型物体测速仪】只有原理,无代码
2022-07-24 05:23:00 【喜暖知寒】
项目来源:Arduino ESP8266 电磁炮测速仪&OLED显示器

本项目有几个问题不懂。
不知道作者为何引用Adafruit_ssd1306syp 这个库。
- 没有在 Arduino 管理库中找到此库。
- 在 GitHub 上貌似是找到此库,但是没有说明:ssd1306syp
- 在本地引入此库后导致出现了 byte is ambiguous 错误
- 将 Adafruit_ssd1306syp 库更改为 Adafruit_ssd1306 库后错误没有了。
故,本项目按照作者代码没有复刻成功,在此不做代码过多分析。
原理

智能小车玩过没有?有个测速模块!就是那个东西。找了一个测速模块的图片(如下图)

槽中无物体档光时,接收管导通,G14\G13 检测为低电平。而有物体遮挡光时,接收管不导通。此时,最希望单片机能够读到高电平。故 G14\G13 应该设置为上拉输入。在此逻辑下,才有无挡光物体检测为低电平,有挡光物体时检测为高电平。那这样,透明物体就不好检测了。
怎么判断速度呢? 由于物体要依次通过两个光电开关,那么就会有时间延时。通过两光电开关之间的距离即可求得速度。
设两光电开关距离(中心到中心的距离)为 L ,延时时间为 T ,那么速度 V = L÷T 。
由于 ESP32 for Arduino 有一个能读微妙单位时间的函数:micros() 。可记录下通过两光电开关的相对时间进行求速度。
要比较准确的计算,最好是用到中断函数,并且应该设置为上升沿触发!
因为有物体遮挡时 G14/G13 端口会检测到高电平,由低电平到高电平的瞬间记录比较准确。
算物体的动能也很简单,只要输入物体的质量就可以了。反正用的 ESP8266 ,直接网页输入。
动能: E = m×V×V×0.5
然后就是规定的比动能 1.8 焦耳每平方厘米!这就除面积就好了啊 ~
代码
下面写一个伪代码进行操作,仅仅写出计算时间、速度的部分
ICACHE_RAM_ATTR void G13_InterFunction() //中断函数
{
G13time = micros();
G13flag = 1;
}
ICACHE_RAM_ATTR void G14_InterFunction()
{
G14time = micros();
G14flag = 1;
}
void setup()
{
attachInterrupt(G13, G13_InterFunction, RISING); // 上升沿触发
attachInterrupt(G14, G14_InterFunction, RISING); // 上升沿触发
}
void loop()
{
if(G13flag == 1 && G14flag == 1)
{
if(G13time>G14time)
time = G13time - G14time;
else
time = G14time - G13time;
G13flag = 0;
G14flag = 0;
}
} 总结
根据原作者的 ESP8266 版本的项目代码没复刻出来还是听沮丧的!但是更改代码可以做出来。
暂时还不知道哪里出来问题,后期再看吧!
项目资料
后续再放代码吧,先弄好为啥有问题。
啊啊啊啊!遇到挫折好难过!!!

边栏推荐
- Remember 20 classic interview questions of performance test in three minutes
- JSP tag 02
- Wasm vs EVM, Boca's choice predicts the future of the public chain
- [222] memory overflow and location
- RAID5和LVM组合使用
- Windows下Mysql5.7忘记root密码解决方法
- How to build a website full of ritual sense and publish it on the public website 2-2
- Go environment construction and start
- Login page + summary
- MySQL batch modifies the data table code and character set to utf8mb4
猜你喜欢
随机推荐
How to build a website full of ritual sense and publish it on the public website 1-2
Leetcode does not add, subtract, multiply, divide, and calculate the number of 1 in binary
自定义zabbix agent rpm包
Promise (try to implement a promise by yourself) more detailed comments and other interfaces are not completed yet. Let's continue next time.
Write blog at leisure ~ briefly talk about let, VaR and Const
使用自定义zabbix包(4.0.5版本)安装agent和proxy
Windows下bat脚本备份MySQL数据库
OpenSSL version upgrade
Leetcode sword finger offer jz42 maximum sum of continuous subarrays
Common commands and package management of go language
Top 10 vulnerability assessment and penetration testing tools
API process and code structure
United Nations agricultural products data analysis
Flink production environment configuration recommendations
Leetcode sword finger offer jz23: the entry node of the link in the linked list
Maximum value of jz47 gifts (dynamic planning ideas)
Leetcode sword finger offer jz25 merges two sorted linked lists
Grid layout
ES10 subtotal flat and flatmap
Sed command

![[no need for public IP] configure a fixed public TCP port address for remote desktop raspberry pie](/img/85/dec6a66dd10c35e2519bd240c05de1.png)






![[214] what is an automation framework](/img/bb/24c35613c49357258876ce3f1611ee.jpg)
