【安信可UWB室内定位模组NodeMCU-BU01】No.003-应用程序联调
<div class='showpostmsg'><p style="text-indent:24.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:12.0000pt"><span style="font-family:宋体"><font face="宋体">上一篇介绍搭建硬件电路,并进行了简单测试,确认硬件焊接无问题。这一篇主要是介绍应用程序的编写和两板卡测试。</font></span></span></span></span></p><p style="text-indent:24.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:12.0000pt"><span style="font-family:宋体"><font face="宋体">首先展示一下我做好的《超简单测距仪》合体的样子,如下图,左边是基站,只负责发射信号。右边是实际应用实现部分,接收信号和显示结果。</font></span></span></span></span></p>
<p class="imagemiddle" style="text-align: center;"></p>
<p align="center" style="text-indent:24.0000pt; text-align:center"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:12.0000pt"><span style="font-family:宋体"><font face="宋体">图</font><font face="Calibri">1 </font><font face="宋体">超简单测距仪</font></span></span></span></span></p>
<p style="text-indent:24.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:12.0000pt"><span style="font-family:宋体"><font face="宋体">为了不显得特别简陋,我用白纸做了一个蒙皮遮挡一下绿板板。具备</font><font face="Calibri">4</font><font face="宋体">个按键,分别是:</font></span></span></span></span></p>
<p style="text-indent:24.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:12.0000pt"><span style="font-family:宋体"><font face="宋体">测距键,切换模块进入</font><font face="Calibri">TAG</font><font face="宋体">模式并启动测距任务,屏幕上会滚动显示测距结果。</font></span></span></span></span></p>
<p style="text-indent:24.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:12.0000pt"><span style="font-family:宋体"><font face="宋体">基站键,切换模块进入</font><font face="Calibri">Anchor</font><font face="宋体">模式,作为基站发射信号。</font></span></span></span></span></p>
<p style="text-indent:24.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:12.0000pt"><span style="font-family:宋体"><font face="Calibri">XYZ</font><font face="宋体">键,读取模块加速度传感器输出信号,显示到屏幕上,可用于测量水平状态。</font></span></span></span></span></p>
<p style="text-indent:24.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:12.0000pt"><span style="font-family:宋体"><font face="Calibri">TH</font><font face="宋体">键,读取模块温湿度传感器输出信号,滚动显示到屏幕上,用于测量温湿度。</font></span></span></span></span></p>
<p style="text-indent:24.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:12.0000pt"><span style="font-family:宋体"><font face="宋体">下面介绍具体软件设计过程。最先调试的是串口字符串接收程序,具体接收代码如下图。</font></span></span></span></span></p>
<p class="imagemiddle" style="text-align: center;"></p>
<p align="center" style="text-indent:24.0000pt; text-align:center"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:12.0000pt"><span style="font-family:宋体"><font face="宋体">图</font><font face="Calibri">2 </font><font face="宋体">字符串接收</font></span></span></span></span></p>
<p style="text-indent:24.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:12.0000pt"><span style="font-family:宋体"><font face="宋体">由于每一次返回的消息都是以</font></span></span><span style="font-size:12.0000pt"><span style="font-family:Calibri">”</span></span><span style="font-size:12.0000pt"><span style="font-family:宋体"><font face="Calibri">\r\n</font></span></span><span style="font-size:12.0000pt"><span style="font-family:Calibri">”</span></span><span style="font-size:12.0000pt"><span style="font-family:宋体"><font face="宋体">结束,所以我这采用</font></span></span><span style="font-size:12.0000pt"><span style="font-family:Calibri">”</span></span><span style="font-size:12.0000pt"><span style="font-family:宋体"><font face="Calibri">\r</font></span></span><span style="font-size:12.0000pt"><span style="font-family:Calibri">”</span></span><span style="font-size:12.0000pt"><span style="font-family:宋体"><font face="宋体">作为一行的判断依据。返回的消息中存在大量的换行和</font>“<font face="Calibri">OK</font><font face="宋体">”这样不需要显示的字符串,我做了一个筛选规则,凡是小于</font><font face="Calibri">3</font><font face="宋体">个字符的消息全部过滤掉,这样就保存了有用的数据到一个二维数组中</font><font face="Calibri">RxBuffer</font><font face="宋体">。这个数组也是用于显示缓存。显示器是</font><font face="Calibri">128*64</font><font face="宋体">分辨率,每行能显示</font><font face="Calibri">16</font><font face="宋体">个字符,能显示</font><font face="Calibri">4</font><font face="宋体">行,接收时也对字符数做了过滤,每行大于</font><font face="Calibri">16</font><font face="宋体">个字符的部分也丢掉了,实际应用中被丢弃的是重启后初始化时输出的小版本信息,并不影响实际应用。</font></span></span></span></span></p>
<p style="text-indent:24.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:12.0000pt"><span style="font-family:宋体"><font face="宋体">在调试中遇到一个</font><font face="Calibri">STM32</font><font face="宋体">库的</font><font face="Calibri">bug</font><font face="宋体">,就是串口出现溢出后</font><font face="Calibri">HAL</font><font face="宋体">库函数没有处理,导致进入死循环,后来在异常处理中加了清除溢出标志位操作,终于好用了,具体操作代码如下。</font></span></span></span></span></p>
<p class="imagemiddle" style="text-align: center;"></p>
<p align="center" style="text-indent:24.0000pt; text-align:center"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:12.0000pt"><span style="font-family:宋体"><font face="宋体">图</font><font face="Calibri">3 </font><font face="宋体">清除溢出标志位</font></span></span></span></span></p>
<p style="text-indent:24.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:12.0000pt"><span style="font-family:宋体"><font face="宋体">每接收完一行字符串,会置位一次显示刷新标志,显示程序将整个字符串数组刷新到屏幕上,如下图。</font></span></span></span></span></p>
<p class="imagemiddle" style="text-align: center;"></p>
<p align="center" style="text-indent:24.0000pt; text-align:center"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:12.0000pt"><span style="font-family:宋体"><font face="宋体">图</font><font face="Calibri">4 </font><font face="宋体">刷新屏幕</font></span></span></span></span></p>
<p style="text-indent:24.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:12.0000pt"><span style="font-family:宋体"><font face="宋体">四个按键采用</font><font face="Calibri">IO</font><font face="宋体">口直接读取方式,每</font><font face="Calibri">100</font><font face="宋体">毫秒读取一次,连续读取</font><font face="Calibri">2</font><font face="宋体">次一样就生成有效键值。然后等待释放,不释放不会产生新的键值。如下图。</font></span></span></span></span></p>
<p class="imagemiddle" style="text-align: center;"></p>
<p align="center" style="text-indent:24.0000pt; text-align:center"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:12.0000pt"><span style="font-family:宋体"><font face="宋体">图</font><font face="Calibri">5 </font><font face="宋体">按键读取</font></span></span></span></span></p>
<p style="text-indent:24.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:12.0000pt"><span style="font-family:宋体"><font face="宋体">主循环分为三部分,如下图。</font><font face="Calibri">1</font><font face="宋体">、按键键值处理,将状态进行标记和转换。</font><font face="Calibri">2</font><font face="宋体">、按键任务散转处理,具体执行对应按键指向的任务。</font><font face="Calibri">3</font><font face="宋体">、刷新显示任务,标志置位每刷新一次后执行一次本任务。</font></span></span></span></span></p>
<p class="imagemiddle" style="text-align: center;"></p>
<p align="center" style="text-indent:24.0000pt; text-align:center"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:12.0000pt"><span style="font-family:宋体"><font face="宋体">图</font><font face="Calibri">6 </font><font face="宋体">主循环</font></span></span></span></span></p>
<p style="text-indent:24.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:12.0000pt"><span style="font-family:宋体"><font face="宋体">实际操作如下面视频,通过按键直接切换工作模式,对两个模块联调,基本上实现了预期功能。</font></span></span></span></span></p>
<p align="center" style="text-indent:24.0000pt; text-align:center"><iframe allowfullscreen="true" frameborder="0" height="510" src="https://training.eeworld.com.cn/shareOpenCourseAPI?isauto=true&lessonid=32511" style="background:#eee;margin-bottom:10px;" width="700"></iframe><br />
<span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:12.0000pt"><span style="font-family:宋体"><font face="宋体">视频</font><font face="Calibri">1 </font><font face="宋体">操作演示</font></span></span></span></span></p>
<p style="text-indent:24.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:12.0000pt"><span style="font-family:宋体"><font face="宋体">视频上可以看出,由于</font><font face="Calibri">OLED</font><font face="宋体">是不断刷新的,录像或拍照的时候,能看出来在不停地闪烁,但是人眼直接看的时候由于视觉残留作用,则看着是正常的,这个对拍照有些影响,等以后有机会了进行研究下,看看能不能改善。</font></span></span></span></span></p>
<p style="text-indent:24.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:12.0000pt"><span style="font-family:宋体"><font face="宋体">至此,预期要实现的功能都完成,制作成功一台简易的测距仪,下一步进行实地测量,总结测试报告。</font></span></span></span></span></p>
<p style="text-indent:24.0000pt; text-align:justify"> </p>
<p style="text-indent:24.0000pt; text-align:justify"> </p>
<p style="text-indent:24.0000pt; text-align:justify"> </p>
<p style="text-indent:24.0000pt; text-align:justify"> </p>
</div><script> var loginstr = '<div class="locked">查看本帖全部内容,请<a href="javascript:;" style="color:#e60000" class="loginf">登录</a>或者<a href="https://bbs.eeworld.com.cn/member.php?mod=register_eeworld.php&action=wechat" style="color:#e60000" target="_blank">注册</a></div>';
if(parseInt(discuz_uid)==0){
(function($){
var postHeight = getTextHeight(400);
$(".showpostmsg").html($(".showpostmsg").html());
$(".showpostmsg").after(loginstr);
$(".showpostmsg").css({height:postHeight,overflow:"hidden"});
})(jQuery);
} </script><script type="text/javascript">(function(d,c){var a=d.createElement("script"),m=d.getElementsByTagName("script"),eewurl="//counter.eeworld.com.cn/pv/count/";a.src=eewurl+c;m.parentNode.insertBefore(a,m)})(document,523)</script> <p>测距精度怎样</p>
<p>测距精度按楼主的这个方案与什么有关</p>
Jacktang 发表于 2022-2-13 21:59
测距精度怎样
测距精度按楼主的这个方案与什么有关
<p>无遮挡的情况下,精度在20cm左右,比官方宣称的要大一点</p>
<p>有遮挡就不好说,在我家隔3堵墙,就收不到数了</p>
页:
[1]