描述
<div class="document">
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">1、项目功能介绍</h3>
<hr class="horizontal-splitline normal-bold-2">
<p><span style="font-family: 宋体;">本设计的目的是改进光电探测仪的设备,使其更加轻便、操作简单,同时增加智能化读取功能和数据记录功能,提高测量的准确度并实现数据可视化。</span></p>
<p><span style="font-family: 宋体;">可以做到</span><span style="font-family: 宋体;">如下</span><span style="font-family: 宋体;">特点</span><span style="font-family: 宋体;">:</span></p>
<p><span style="font-family: 宋体;">设备轻便便携:重新设计光电探测仪的结构,采用轻便材料,使设备更加便携。</span></p>
<p><span style="font-family: 宋体;">操作简单:优化探测仪的操作界面,简化操作流程,使操作更加直观、易于上手。</span></p>
<p><span style="font-family: 宋体;">智能化读取功能:添加</span>mcu<span style="font-family: 宋体;">芯片,实现对测量数据的智能化读取,自动进行多次测量并排除粗大误差,提高测量的准确度。</span></p>
<p><span style="font-family: 宋体;">数据记录功能:设计数据记录模块,能够记录每一次的实验数据,并实现将所测量的数据转化成图表,方便用户进一步分析和使用。</span></p>
<p><span style="font-family: 宋体;">数据可视化:通过图表展示实验数据,直观地显示光强度的变化,提供更直观的观察和分析方式。</span></p>
<p><span style="font-family: 宋体;">通过以上设计,可以大大改善原有光电探测仪的问题,使其更加便携、操作简单,同时提高测量的准确度和数据分析的方便性,提升实验效果和用户体验。</span></p>
<p><strong><span style="font-family: 宋体;">基本原理</span></strong></p>
<p><span style="font-family: 宋体;">本实验利用外光电效应器件将光信号转变为电信号。首先,将光电效应器件与电路相连接,其中光电效应器件是由光电池和光电二极管组成。光电池是一种将光能转化为电能的器件,而光电二极管是一种将光信号转化为电信号的器件。</span></p>
<p><span style="font-family: 宋体;">光信号经过光电效应器件转变为电信号后,需要经过一系列的电路处理。首先,经过放大电路对电信号进行放大,以增加信号的强度。接着,经过限幅电路对电信号进行限制,以确保输出信号在一定范围内。</span></p>
<p><span style="font-family: 宋体;">处理后的电信号经过</span><span style="font-family: Calibri;">ADC</span><span style="font-family: 宋体;">(模数转换器)测量后,传递给</span><span style="font-family: Calibri;">MCU</span><span style="font-family: 宋体;">(微控制单元)。</span><span style="font-family: Calibri;">MCU</span><span style="font-family: 宋体;">内部的算法对原始数据进行多次测量,并排除误差,以提高测量的准确度。测量到的数据会被记录下来,并存放在数组中。</span></p>
<p><span style="font-family: 宋体;">最后,通过描点、曲线拟合等算法,将数据在</span><span style="font-family: Calibri;">TFT</span><span style="font-family: 宋体;">屏幕上显示出来。这样,可以直观地观察到实验数据的变化,从而分析光强度的变化情况。</span></p>
<p><span style="font-family: 宋体;">在偏正光实验中,我们可以利用上述原理,使用光电探测仪来测量光的偏振状态,验证马吕斯定律,并通过布儒斯特定律测定介质的折射率。通过测量不同角度下的光强度,可以得到光的偏振角和折射率等相关信息。</span></p>
<p><span style="font-family: 宋体;">工作过程如下图所示:</span></p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="//image.lceda.cn/pullimage/7tgQJqyOQxUGcw6jWRplcpYuzcvMKq8eiG5kqF0b.png" alt="" width="202" height="383"></p>
<p> </p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">以下是一些本工程使用到的部分物理、算法、传感器原理</p>
<p><strong><span style="font-family: Calibri;">1</span><span style="font-family: 宋体;">、外光电效应</span></strong><span style="font-family: 宋体;">:亦称为光电子发射效应,当物质受到光线照射时,电子得到了足够的光能后从物质表面上放射出来的现象,称为外光电效应。发射出来的电子称为光电子,可以发射光电子的物体称为光电发射体。光电子形成的电流即为光电流。</span></p>
<p><span style="font-family: 宋体;">对于给定的物质,照射光都有一个能够产生光电效应的极限频率。只有当照射光的频率大于极限频率时,才能产生光电效应。反之,不论光的强度</span>(<span style="font-family: 宋体;">亦称辐照度</span><span style="font-family: Calibri;">)</span><span style="font-family: 宋体;">多大和照射时间多长,都不会引起光电效应。对于单色光照射,当光频率大于极限频率时,光电流就与照射光的强度成正比,光强越强,光电流越大。</span></p>
<p><strong><span style="font-family: Calibri;">2</span><span style="font-family: 宋体;">、外光电效应过程</span></strong><span style="font-family: 宋体;">:光电发射是一种体效应,其过程分三个步骤:</span></p>
<p><span style="font-family: 宋体;">第一步:体内电子吸收光子能量被激发跃迁到高能级;</span></p>
<p><span style="font-family: 宋体;">第二步:被激发的电子向表面运动,运动过程中会与其它电子或晶格碰撞,失去部分能量;</span></p>
<p><span style="font-family: 宋体;">第三步:克服表面势垒的束缚逸出表面。表面势垒的产生:金属中存在大量自由电子。在通常条件下,可能会有一部分电子克服原子核的库仑力作用逸出表面。但这些逸出电子对金属有感应作用,使金属中的电荷重新分布,在表面出现与电子等量的正电荷。逸出电子受到这种正电荷作用,动能减小,不能远离金属。在金属表面形成偶电层,阻碍电子向外逸出,即表面势垒。在半导体中,表面势垒是由于半导体缺陷和表面晶格不连续产生的,与电子亲和力有关。实际含义与光电子谱相同。但较直接地表示外光电效应。这里着重介绍光电子发射到真空前的物理过程。由于光子在固体中的平均自由程较长,发射光电子的始发原子可位于远离固体表面的深处,因此光电子进入真空之前还须经历固体内的输运以及渡越表面这两个阶段,所以整个光电发射过程按经典模型描述时,称为三步模型,用来定量处理发射的强度。原子的光电发射几率相对稳定,用量子力学可精确计算不同光子能量对各个电子轨道的偶极跃迁矩阵元。其次确定始发光电子输运到表面处的存活几率,这种非弹性散射一般具有指数衰减的规律,以特征散射几率表征其衰减长度。最后,光电子穿越表面逸入真空时还须克服表面势垒。为此引入逃逸几率,它是光电子动能的函数。利用三步模型可较好地对光电发射作定量分析。与此相对的是一步模型,把电子统一看作某种本征波函数,包括原子内轨道电子的初态以及偶极跃迁至较高能量的光电子末态</span><span style="font-family: Calibri;">(</span><span style="font-family: 宋体;">通常具有平面波形式</span><span style="font-family: Calibri;">)</span><span style="font-family: 宋体;">,再处理各种势场</span><span style="font-family: Calibri;">(</span><span style="font-family: 宋体;">由原子形成的,包括表面势垒</span><span style="font-family: Calibri;">)</span><span style="font-family: 宋体;">所形成的散射。由于是微观处理,无须借助于实验得出的宏观能量。然而确定固体的内部势决非易事,须作各种近似。由于非弹性散射的光电子会从能谱中的主峰位置弛豫到伴峰中去。这些过程统称多体效应。此光电子与其它粒子</span><span style="font-family: Calibri;">(</span><span style="font-family: 宋体;">或准粒子</span><span style="font-family: Calibri;">)</span><span style="font-family: 宋体;">相互作用而形成不同的系统组态。光电子由此具有不同的能态</span><span style="font-family: Calibri;">(</span><span style="font-family: 宋体;">不同的伴峰</span><span style="font-family: Calibri;">)</span><span style="font-family: 宋体;">。伴峰的存在给定量分析带来困难,但通过伴峰的考察可获得各种有用的信息。</span></p>
<p><strong><span style="font-family: Calibri;">3</span><span style="font-family: 宋体;">、</span></strong><strong><span style="font-family: 宋体;">光电倍增管</span></strong><strong><span style="font-family: 宋体;">:</span></strong></p>
<p><span style="font-family: 宋体;">一种真空光电发射器件。基本原理为</span></p>
<p>1)<span style="font-family: 宋体;">光子透过入射窗口入射在光电阴极上;</span></p>
<p>2<span style="font-family: 宋体;">)光电阴极上的电子受光子激发,离开表面发射到真空中;</span></p>
<p>3<span style="font-family: 宋体;">)光电子通过电场加速和电子光学系统聚焦入射到第一倍增级上,倍增级将发射出比入射电子数目更多的二次电子。入射电子经</span><span style="font-family: Calibri;">N</span><span style="font-family: 宋体;">级倍增级倍增后,光电子就放大</span><span style="font-family: Calibri;">N</span><span style="font-family: 宋体;">次;</span></p>
<p>4<span style="font-family: 宋体;">)经过倍增后的二次电子由阳极收集,形成阳极光电流。</span></p>
<p align="center"> </p>
<p><strong><span style="font-family: Calibri;">4</span><span style="font-family: 宋体;">、提高准确度算法</span></strong><span style="font-family: 宋体;">:由于测量时实验理论上存在着近似性,方法上难以很完善,实验仪器灵敏度和分辨能力有局限性,周围环境不稳定等因素的影响,待测量的真值是不可能测得的,</span><a href="https://baike.baidu.com/item/%E6%B5%8B%E9%87%8F%E7%BB%93%E6%9E%9C?fromModule=lemma_inlink" target="_blank"><span style="font-family: 宋体;">测量结果</span></a><span style="font-family: 宋体;">和被测量真值之间总会存在或多或少的偏差,这种偏差就叫做测量值的误差。常见误差主要分为三大类:</span><a href="https://baike.baidu.com/item/%E7%B3%BB%E7%BB%9F%E8%AF%AF%E5%B7%AE?fromModule=lemma_inlink" target="_blank"><span style="font-family: 宋体;">系统误差</span></a><span style="font-family: 宋体;">、</span><a href="https://baike.baidu.com/item/%E9%9A%8F%E6%9C%BA%E8%AF%AF%E5%B7%AE?fromModule=lemma_inlink" target="_blank"><span style="font-family: 宋体;">随机误差</span></a><span style="font-family: 宋体;">、</span><a href="https://baike.baidu.com/item/%E7%B2%97%E5%A4%A7%E8%AF%AF%E5%B7%AE?fromModule=lemma_inlink" target="_blank"><span style="font-family: 宋体;">粗大误差</span></a><span style="font-family: 宋体;">。为了尽可能减少测量误差,提高测量的精确度,我们通常使用多次测量排除粗大误差后取平均值的方法可以有效的减少</span><a href="https://baike.baidu.com/item/%E9%9A%8F%E6%9C%BA%E8%AF%AF%E5%B7%AE?fromModule=lemma_inlink" target="_blank"><span style="font-family: 宋体;">随机误差</span></a><span style="font-family: 宋体;">和</span><a href="https://baike.baidu.com/item/%E7%B2%97%E5%A4%A7%E8%AF%AF%E5%B7%AE?fromModule=lemma_inlink" target="_blank"><span style="font-family: 宋体;">粗大误差</span></a><span style="font-family: 宋体;">同时也能够减少部分因素导致的系统误差从而提高测量的准确度。</span></p>
<p><strong><span style="font-family: Calibri;">5</span><span style="font-family: 宋体;">、曲线拟合</span></strong><span style="font-family: 宋体;">:实际工作中,变量间未必都有线性关系,如服药后血药浓度与时间的关系;疾病疗效与疗程长短的关系;毒物剂量与致死率的关系等常呈曲线关系。曲线拟合是指选择适当的曲线类型来拟合观测数据,并用拟合的</span><a href="https://baike.baidu.com/item/%E6%9B%B2%E7%BA%BF%E6%96%B9%E7%A8%8B/4413057?fromModule=lemma_inlink" target="_blank"><span style="font-family: 宋体;">曲线方程</span></a><span style="font-family: 宋体;">分析两变量间的关系。</span></p>
<p><strong><span style="font-family: Calibri;">6</span><span style="font-family: 宋体;">、</span><span style="font-family: Calibri;">TEMT6000</span><span style="font-family: 宋体;">:</span></strong><span style="font-family: 宋体;">它由镜片、光敏二极管、滤波器、封装材料以及和一个</span><span style="font-family: Calibri;">Op-Amp</span><span style="font-family: 宋体;">放大器组成,</span><span style="font-family: 宋体;">其内部工作原理可以分为以下几个步骤:</span></p>
<p><span style="font-family: Calibri;">1</span><span style="font-family: 宋体;">)</span><span style="font-family: 宋体;">光线进入芯片</span></p>
<p><span style="font-family: 宋体;">当光线照射到</span>TEMT6000<span style="font-family: 宋体;">芯片上时,它们会</span><span style="font-family: 宋体;">经过镜片、滤波器,</span><span style="font-family: 宋体;">穿过芯片的顶部,并在一个受控的微小空间内收集。</span></p>
<p><span style="font-family: Calibri;">2</span><span style="font-family: 宋体;">)</span><span style="font-family: 宋体;">光电二极管转换</span></p>
<p><span style="font-family: 宋体;">收集到的光线会被芯片内置的光电二极管吸收并转换为电信号</span><span style="font-family: 宋体;">,其转换原理可以参考上述的外光电效应和外光电效应过程,当光线照射到</span><span style="font-family: Calibri;">TEMT6000</span><span style="font-family: 宋体;">的光敏元件上时,元件中的电子将通过</span><span style="font-family: Calibri;">PN</span><span style="font-family: 宋体;">结移动,从而产生电流。该电流幅度与被测光源的强度成正比</span><span style="font-family: 宋体;">。</span></p>
<p><span style="font-family: Calibri;">3</span><span style="font-family: 宋体;">)</span><span style="font-family: 宋体;">对电信号放大</span></p>
<p><span style="font-family: 宋体;">芯片内部的晶体管会将光电二极管转换出的电信号放大</span><span style="font-family: 宋体;">,工作思想可参考光电倍增管,由于</span><span style="font-family: 宋体;">光电二极管转换出</span><span style="font-family: 宋体;">的电信号非常的小必须借助放大器才能被</span><span style="font-family: Calibri;">MCU</span><span style="font-family: 宋体;">有效读取</span><span style="font-family: 宋体;">。</span></p>
<p><span style="font-family: 宋体;">注:参考文献</span></p>
<p><span style="font-family: 宋体;">《普通物理学》(第六版)(程守洙,江之永</span> <span style="font-family: 宋体;">著)</span></p>
<p align="justify"><span style="font-family: 宋体;">《</span><span style="font-family: 宋体;">中国中学教学百科全书</span><span style="font-family: Times New Roman;">·</span><span style="font-family: 宋体;">物理卷</span><span style="font-family: 宋体;">》(</span><span style="font-family: 宋体;">阎金铎</span> <span style="font-family: 宋体;">著)</span></p>
<p align="justify"><span style="font-family: 宋体;">《电气测量》(陈立波</span> <span style="font-family: 宋体;">著)</span></p>
<p align="justify"><span style="font-family: 宋体;">《光电子传感器技术与应用》(李宏毅、汤小军</span> <span style="font-family: 宋体;">著)</span></p>
<p align="justify"><a href="https://xueshu.baidu.com/usercenter/paper/show?paperid=2cbf5cd936d17b25ecaa6acbc84da102&tn=SE_baiduxueshu_c1gjeupa&ie=utf-8&site=baike" target="_blank"> <span style="font-family: 宋体;">透射式蓝延伸</span>GaAs<span style="font-family: 宋体;">光电阴极的光电发射特性研究</span> </a><span style="font-family: 宋体;">石峰,赵静,程宏昌,张益军等</span> <span style="font-family: 宋体;">《</span>CNKI;WanFang<span style="font-family: 宋体;">》</span> 2012<span style="font-family: 宋体;">。</span></p>
<p align="justify"><a href="https://xueshu.baidu.com/usercenter/paper/show?paperid=69c772ddb6c27365d75d914a5038db42&tn=SE_baiduxueshu_c1gjeupa&ie=utf-8&site=baike" target="_blank"><span style="font-family: 宋体;">三代微光像增强器制管工艺对阴极光电发射性能的影响</span> </a><span style="font-family: 宋体;">徐江涛</span> <span style="font-family: 宋体;">《应用光学》</span> 2004<span style="font-family: 宋体;">。</span></p>
<p align="justify"><span style="font-family: 宋体;">《</span>The Art of Electronics<span style="font-family: 宋体;">》(</span><span style="font-family: Times New Roman;">Horowitz, P., & Hill, W. </span><span style="font-family: 宋体;">著)</span></p>
<p align="justify"><span style="font-family: 宋体;">《</span>Analog Circuit Design: A Tutorial Guide to Applications and Solutions<span style="font-family: 宋体;">》(</span><span style="font-family: Times New Roman;">Bob Dobkin, Jim Williams </span><span style="font-family: 宋体;">著)</span></p>
<p align="justify"><span style="font-family: 宋体;">《</span>Practical Electronics for Inventors, Fourth Edition<span style="font-family: 宋体;">》(</span><span style="font-family: Times New Roman;">Paul Scherz, Simon Monk </span><span style="font-family: 宋体;">著)</span></p>
<p align="justify"><span style="font-family: 宋体;">这里也包括了在理论探讨时也参考的部分文献,可能论述中没有具体呈现。</span></p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">2、项目属性</h3>
<hr class="horizontal-splitline normal-bold-2">
<p><span style="font-family: 宋体;">本项目为原创,同时加过</span><span style="font-family: Calibri;">2023</span><span style="font-family: 宋体;">年第二十届江苏省高校大学生物理与实验科技作品创新竞赛,比赛名次尚未知。</span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"> </p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"> 3、开源协议</h3>
<hr class="horizontal-splitline normal-bold-2">
<p><span style="font-family: 宋体;">本项目</span><span style="font-family: 宋体;">使用</span>GPL3.0<span style="font-family: 宋体;">开源协议</span><span style="font-family: 宋体;">,所有模块均为原创,软件代码也均为原创,参考书籍和论文见附件。</span></p>
<p> </p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">4、硬件部分</h3>
<hr class="horizontal-splitline normal-bold-2">
<p><span style="font-family: 宋体;">硬件部分</span><span style="font-family: 宋体;">主要</span><span style="font-family: 宋体;">分</span><span style="font-family: 宋体;">为</span><span style="font-family: 宋体;">三大部分:传感器部分、电路电源部分、结果呈像部分;</span></p>
<p>一、 <span style="font-family: 宋体;">传感器部分</span></p>
<p>TEMT6000X01<span style="font-family: 宋体;">输入电压是</span><span style="font-family: Times New Roman;">3.3v</span><span style="font-family: 宋体;">,输出电压</span><span style="font-family: Times New Roman;">0</span><span style="font-family: 宋体;">~</span><span style="font-family: Times New Roman;">3.3</span><span style="font-family: 宋体;">,光强和电压线性相关,能接收</span><span style="font-family: Times New Roman;">0</span><span style="font-family: 宋体;">~</span><span style="font-family: Times New Roman;">1000lux</span><span style="font-family: 宋体;">的光强</span><span style="font-family: 宋体;">,可以满足日常的测光强范围。当我们的仪器接收到外界光源时,先在</span>TEMT6000X01<span style="font-family: 宋体;">环境光传感器</span><span style="font-family: 宋体;">中进行光强转成电信号,并通过其内部放大电路将其电信号放大,用排母将传感器连接到总电路中。</span></p>
<p><strong><span style="font-family: Times New Roman;">1</span></strong><span style="font-family: 宋体;">、光照传感器</span></p>
<p align="center"><img src="//image.lceda.cn/pullimage/tO3lZjTQFlQCGreIZAA6JJI3LlquDdB3I1EKf3Og.jpeg" alt="" width="312" height="408"></p>
<p>2、<span style="font-family: 宋体;">排母(连接电路)</span></p>
<p style="text-align: center;"> </p>
<p style="text-align: center;"><img style="display: block; margin-left: auto; margin-right: auto;" src="//image.lceda.cn/pullimage/CUNCY7wsXCZW1P270JFRPwEtB5rH9fQUJa82qO4W.jpeg"></p>
<p>二、 <span style="font-family: 宋体;">电路电源部分</span></p>
<p><span style="font-family: Times New Roman;">AMS1117</span><span style="font-family: 宋体;">是一个正向低压降稳压器,固定输出电压为</span><span style="font-family: Times New Roman;">3.</span>3v, <span style="font-family: Times New Roman;">AMS1117</span><span style="font-family: 宋体;">刚好满足</span>TEMT6000X01<span style="font-family: 宋体;">需要的</span><span style="font-family: 宋体;">输入电压</span><span style="font-family: 宋体;">。此部分电路为总电路提供稳定电源,是整个仪器的总开关,起保护电路的作用。</span></p>
<p><span style="font-family: Calibri;">1</span><span style="font-family: 宋体;">、电源供电电路</span></p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="//image.lceda.cn/pullimage/n1IaHoFOFQKkdgFW3pzZNVWiecILd9MNQDlJ2piB.jpeg"></p>
<p>2<span style="font-family: 宋体;">、</span>USB<span style="font-family: 宋体;">和按键</span></p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="//image.lceda.cn/pullimage/Jslg3q4hERVWR6FexrGf2wyoRZJLqUOCc7ATZfvG.jpeg"></p>
<p><span style="font-family: Calibri;">3</span><span style="font-family: 宋体;">、滤波电路和螺母</span></p>
<p><span style="font-family: 宋体;"> 滤波是电路不可或缺的一部分,滤波电路作用是尽可能减小脉动的直流电压中的交流成分,保留其直流成分,使输出电压纹波系数降低,波形变得比较平滑,也可以减小静电对电路的影响,保护电路元器件。</span></p>
<p><span style="font-family: 宋体;">本设计中也存在许多滤波电路,如复位按键的</span>MCU<span style="font-family: 宋体;">、</span><span style="font-family: Times New Roman;">AMS1117</span><span style="font-family: 宋体;">、</span><span style="font-family: Times New Roman;">TYPE_C</span><span style="font-family: 宋体;">等电路部分都有滤波电容的存在,下面其他电路中也有滤波电路的存在。</span></p>
<p><span style="font-family: 宋体;"> 滤波电容在画</span>pcb<span style="font-family: 宋体;">时因都尽可能的靠近需要滤波的管脚,如果离的太远那么滤波效果可能也就甚微</span></p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://image.lceda.cn/pullimage/6WOUZEjcrrxRkHip3FvZqJ4MDnVz11qyp9oTlcrD.png" alt="6WOUZEjcrrxRkHip3FvZqJ4MDnVz11qyp9oTlcrD.png" width="539" height="315"></p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="//image.lceda.cn/pullimage/eIlDxpO2ZMMOSCDW11zjYKIKwZIZJPQrDBFsbPqW.jpeg"></p>
<p><span style="font-family: 宋体;">三、结果呈像部分</span></p>
<p><span style="font-family: 宋体;"> 将传感器部分输出的电信号输入到</span><span style="font-family: Times New Roman;">M</span>CU<span style="font-family: 宋体;">中,</span>MCU <span style="font-family: 宋体;">中带</span><span style="font-family: Times New Roman;"> 12 </span><span style="font-family: 宋体;">位</span><span style="font-family: Times New Roman;"> ADC </span><span style="font-family: 宋体;">的</span><span style="font-family: Times New Roman;"> ch1 </span><span style="font-family: 宋体;">通道将</span><span style="font-family: Times New Roman;">TEMT6000X01 </span><span style="font-family: 宋体;">传过来的模拟信号转换成数字量</span><span style="font-family: 宋体;">,并读取数据;读取到的数据,按我们写入程序的计算公式处理计算数据,计算出</span><span style="font-family: 宋体;">同一光强,在通过</span><span style="font-family: Calibri;">0</span><span style="font-family: 宋体;">°</span><span style="font-family: Calibri;">~360</span><span style="font-family: 宋体;">°偏振片时的光强数据及其形成的图像,</span><span style="font-family: 宋体;">通过</span><span style="font-family: Calibri;">TFT</span><span style="font-family: 宋体;">屏幕直观的显示出来,电路中蜂鸣器起语音提示功能。</span></p>
<p>1、 <span style="font-family: Calibri;">MCU</span><span style="font-family: 宋体;">核心电路</span></p>
<p align="center"><img style="display: block; margin-left: auto; margin-right: auto;" src="//image.lceda.cn/pullimage/DyOIFAu9hwtyAsvINdkMZSyejlEB274Erzc803yt.jpeg"></p>
<p><span style="font-family: Calibri;">2</span><span style="font-family: 宋体;">、</span><span style="font-family: Calibri;">TFT</span><span style="font-family: 宋体;">屏幕</span></p>
<p align="center"><img style="display: block; margin-left: auto; margin-right: auto;" src="//image.lceda.cn/pullimage/aWBdvsgQ2AlVI6OQto49y1flOLMOjEXVSPcqxAdQ.jpeg"></p>
<p align="center"> </p>
<p><span style="font-family: Calibri;">3</span><span style="font-family: 宋体;">、usb、复位、蜂鸣器、滤波电容等其他电路</span></p>
<p><span style="font-family: 宋体;">USB:选用的是</span>USBType-C<span style="font-family: 宋体;">接口(简称</span><span style="font-family: Times New Roman;">Type-C</span><span style="font-family: 宋体;">)是一种通用串行总线(</span><span style="font-family: Times New Roman;">USB</span><span style="font-family: 宋体;">)的硬件接口形式,其规范由</span><span style="font-family: Times New Roman;">USB</span><span style="font-family: 宋体;">开发者论坛(</span><span style="font-family: Times New Roman;">USB-IF</span><span style="font-family: 宋体;">)发布。它的特点在于更加纤薄的设计、更快的传输速度(</span><span style="font-family: Times New Roman;">USB3.1</span><span style="font-family: 宋体;">最高</span><span style="font-family: Times New Roman;">10Gbps</span><span style="font-family: 宋体;">)以及更强悍的电力传输(最高</span><span style="font-family: Times New Roman;">100W</span><span style="font-family: 宋体;">),更重要的是</span><span style="font-family: Times New Roman;">Type-C</span><span style="font-family: 宋体;">插接口支持</span><span style="font-family: Times New Roman;">USB</span><span style="font-family: 宋体;">接口双面插入,正式解决了</span><span style="font-family: Times New Roman;">“USB</span><span style="font-family: 宋体;">永远插不准</span><span style="font-family: Times New Roman;">”</span><span style="font-family: 宋体;">的世界性难题。在</span><span style="font-family: Times New Roman;">USBType-C</span><span style="font-family: 宋体;">规范发布后,许多新款的</span><span style="font-family: Times New Roman;">Android</span><span style="font-family: 宋体;">移动设备、笔记本电脑、台式机甚至是游戏机等</span><span style="font-family: Times New Roman;">3C</span><span style="font-family: 宋体;">设备开始使用这种连接端口。</span></p>
<p><span style="font-family: 宋体;">但是本电路中</span>TYPE_C<span style="font-family: 宋体;">只是用来供电,所以在此选用了</span><span style="font-family: Times New Roman;">6pin</span><span style="font-family: 宋体;">的</span><span style="font-family: Times New Roman;">type_c</span><span style="font-family: 宋体;">母座。</span></p>
<p><span style="font-family: 宋体;">复位电路:当NRST引脚上出现低电平(外部复位) 将产生系统复位。</span></p>
<p><span style="font-family: 宋体;">蜂鸣器:采样PNP型二极管激发,在电路中起到了提升按键按下的作用。</span></p>
<p><span style="font-family: 宋体;">滤波电容在上面有较为详细的阐述,这里不再重复,包括BL1117功能和AMS117一样也不再重复。</span></p>
<p align="center"> </p>
<p align="center"><img style="display: block; margin-left: auto; margin-right: auto;" src="//image.lceda.cn/pullimage/DKzkL7N8rn2Hy6RhtBikwAOKNMfyESkV5crqImfS.jpeg"></p>
<p style="text-align: left;" align="center">注:参考文献</p>
<p style="text-align: left;" align="center">此处部分论述参考本人开源工程https://oshwhub.com/wuxieeda/dian-zi-shi-zhong-xun-lian-ying</p>
<p style="text-align: left;" align="center">Nation《电路设计指南》</p>
<p style="text-align: left;" align="center">正点原子精英版电路原理图 </p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">5、软件部分</h3>
<hr class="horizontal-splitline normal-bold-2">
<p><strong><span style="font-family: 宋体;">完整代码参考附件,这里只阐述两个关键算法的理论和验证</span></strong></p>
<p><strong><span style="font-family: 宋体;">减少误差相关计算:</span></strong></p>
<p><span style="font-family: 宋体;">由于随机误差的有界性,在一定的测量条件下,随机误差的绝对值不会超过一定界限,超过的误差一般都是人为原因造成的,所以称为疏忽误差。疏忽误差不存在</span><span style="font-family: 宋体;">“消除”的问题,而是在发现后加以剔除。在测量数据中,凡是其剩余误差大过方均根误差即标准差的估计值三倍以上的数据,都认为是属于疏忽误差的数据,应予以剔除。3б也称为误差极限。</span></p>
<p><span style="font-family: 宋体;">但应注意,在测量列中剔除了有疏忽误差的数据后,应重新计算它的算术平均值,重新计算每个数据的方均根误差,并重新判断剩下的数据中有无疏忽误差,直至全部数据的值不超过</span><span style="font-family: 宋体;">3б为止。</span></p>
<p align="justify"><span style="font-family: 宋体;">计算详见附件:减少误差</span><span style="font-family: Calibri;">c</span><span style="font-family: 宋体;">语言代码</span></p>
<p><strong><span style="font-family: 宋体;">曲线拟合相关计算及其步骤:</span></strong></p>
<p><span style="font-family: Calibri;">1</span><span style="font-family: 宋体;">、</span><span style="font-family: 宋体;">绘制</span><a href="https://baike.baidu.com/item/%E6%95%A3%E7%82%B9%E5%9B%BE?fromModule=lemma_inlink" target="_blank"><span style="font-family: 宋体;">散点图</span></a><span style="font-family: 宋体;">,选择</span><span style="font-family: 宋体;">幂函数的标准式形式为</span><span style="font-family: 宋体;">的</span><span style="font-family: 宋体;">曲线拟合</span></p>
<p align="justify"><span style="font-family: Calibri;">2</span><span style="font-family: 宋体;">、</span><span style="font-family: 宋体;">进行变量变换</span>Y’=f(Y),X’=g(X)<span style="font-family: 宋体;">使变换后的两个变量呈直线关系。</span></p>
<p align="justify"><span style="font-family: Calibri;">3</span><span style="font-family: 宋体;">、</span><span style="font-family: 宋体;">按</span><a href="https://baike.baidu.com/item/%E6%9C%80%E5%B0%8F%E4%BA%8C%E4%B9%98%E6%B3%95?fromModule=lemma_inlink" target="_blank"><span style="font-family: 宋体;">最小二乘法</span></a><span style="font-family: 宋体;">原理求</span><a href="https://baike.baidu.com/item/%E7%BA%BF%E6%80%A7%E6%96%B9%E7%A8%8B?fromModule=lemma_inlink" target="_blank"><span style="font-family: 宋体;">线性方程</span></a><span style="font-family: 宋体;">和</span><a href="https://baike.baidu.com/item/%E6%96%B9%E5%B7%AE%E5%88%86%E6%9E%90?fromModule=lemma_inlink" target="_blank"><span style="font-family: 宋体;">方差分析</span></a></p>
<p align="justify"><span style="font-family: Calibri;">4</span><span style="font-family: 宋体;">、</span><span style="font-family: 宋体;">将直线化</span><a href="https://baike.baidu.com/item/%E6%96%B9%E7%A8%8B?fromModule=lemma_inlink" target="_blank"><span style="font-family: 宋体;">方程</span></a><span style="font-family: 宋体;">转换为关于原变量</span>X<span style="font-family: 宋体;">、</span><span style="font-family: Times New Roman;">Y</span><span style="font-family: 宋体;">的函数表达式</span></p>
<p align="justify"><span style="font-family: 宋体;">计算详见附件:曲线拟合</span><span style="font-family: Calibri;">c</span><span style="font-family: 宋体;">语言代码</span></p>
<p align="justify"><strong><span style="font-family: 宋体;">电压与光强关系相关计算:</span></strong></p>
<p align="justify">TEMT6000<span style="font-family: 宋体;">环境光传感器</span><span style="font-family: 宋体;">将光强转换为电流形式,并且光照强度与电流成正比,可以连接该传感器的基极到模拟电压输入,通过检测电压值就可以判断当前的光照强度。</span></p>
<p align="justify"><span style="font-family: 宋体;">光照强度计算公式为</span></p>
<p align="center"><span style="font-family: Calibri;">I=ADC/4.09</span></p>
<p><span style="font-family: 宋体;">其中</span><span style="font-family: Calibri;">I</span><span style="font-family: 宋体;">为光照强度单位为</span><span style="font-family: Calibri;">LUX</span></p>
<p><span style="font-family: Calibri;">ADC</span><span style="font-family: 宋体;">为</span><span style="font-family: Calibri;">stm32f103</span><span style="font-family: 宋体;">内部</span><span style="font-family: Calibri;">ADC</span><span style="font-family: 宋体;">转换得到的值,取值范围是</span><span style="font-family: Calibri;">0~4095</span></p>
<p><span style="font-family: 宋体;">其中</span><span style="font-family: Calibri;">4.09</span><span style="font-family: 宋体;">是由环境光传感器读数</span><span style="font-family: Calibri;">N=4096/1000(</span><span style="font-family: 宋体;">传感器有效取值</span><span style="font-family: Calibri;">1~1000LUX)</span></p>
<p><span style="font-family: 宋体;">具体计算方式见附件</span><span style="font-family: Calibri;">c</span><span style="font-family: 宋体;">语言代码</span></p>
<p><span style="font-family: 宋体;">下面是对部分算法的验证</span></p>
<p><span style="font-family: 宋体;">减小误差程序:</span></p>
<p><span style="font-family: 宋体;">这里是给定了</span><span style="font-family: Calibri;">18</span><span style="font-family: 宋体;">组数据</span></p>
<p><span style="font-family: Calibri;">#include <stdio.h></span></p>
<p><span style="font-family: Calibri;">#include <stdlib.h></span></p>
<p><span style="font-family: Calibri;">#define N 18</span></p>
<p><span style="font-family: Calibri;">#define M 6</span></p>
<p><span style="font-family: Calibri;">float sqrts(float x)</span></p>
<p><span style="font-family: Calibri;">{</span></p>
<p> <span style="font-family: Calibri;">float guess = x / 2.0;</span></p>
<p> <span style="font-family: Calibri;">float prev_guess = 0.0;</span></p>
<p> <span style="font-family: Calibri;">while (guess != prev_guess)</span></p>
<p> <span style="font-family: Calibri;">{</span></p>
<p> <span style="font-family: Calibri;">prev_guess = guess;</span></p>
<p> <span style="font-family: Calibri;">guess = (guess + x / guess) / 2.0;</span></p>
<p> <span style="font-family: Calibri;">}</span></p>
<p> <span style="font-family: Calibri;">return guess;</span></p>
<p><span style="font-family: Calibri;">}</span></p>
<p><span style="font-family: Calibri;">float fabss(float x)</span></p>
<p><span style="font-family: Calibri;">{</span></p>
<p> <span style="font-family: Calibri;">if (x >= 0)</span></p>
<p> <span style="font-family: Calibri;">{</span></p>
<p> <span style="font-family: Calibri;">return x;</span></p>
<p> <span style="font-family: Calibri;">}</span></p>
<p> <span style="font-family: Calibri;">else</span></p>
<p> <span style="font-family: Calibri;">{</span></p>
<p> <span style="font-family: Calibri;">return -x;</span></p>
<p> <span style="font-family: Calibri;">}</span></p>
<p><span style="font-family: Calibri;">}</span></p>
<p><span style="font-family: Calibri;">float data[N][M] = { {1.1, 1.2, 1.3, 1.4, 1.5, 100}, </span></p>
<p> <span style="font-family: Calibri;">{2.1, 2.2, 2.3, 2.4, 2.5, 200}, </span></p>
<p> <span style="font-family: Calibri;">{3.1, 3.2, 3.3, 3.4, 3.5, 300}, </span></p>
<p> <span style="font-family: Calibri;">{4.1, 4.2, 4.3, 4.4, 4.5, 400}, </span></p>
<p> <span style="font-family: Calibri;">{5.1, 5.2, 5.3, 5.4, 5.5, 500}, </span></p>
<p> <span style="font-family: Calibri;">{6.1, 6.2, 6.3, 6.4, 6.5, 600}, </span></p>
<p> <span style="font-family: Calibri;">{7.1, 7.2, 7.3, 7.4, 7.5, 700}, </span></p>
<p> <span style="font-family: Calibri;">{8.1, 8.2, 8.3, 8.4, 8.5, 800}, </span></p>
<p> <span style="font-family: Calibri;">{9.1, 9.2, 9.3, 9.4, 9.5, 900}, </span></p>
<p> <span style="font-family: Calibri;">{10.1, 10.2, 10.3, 10.4, 10.5, 1000}, </span></p>
<p> <span style="font-family: Calibri;">{11.1, 11.2, 11.3, 11.4, 11.5, 1100}, </span></p>
<p> <span style="font-family: Calibri;">{12.1, 12.2, 12.3, 12.4, 12.5, 1200}, </span></p>
<p> <span style="font-family: Calibri;">{13.1, 13.2, 13.3, 13.4, 13.5, 1300}, </span></p>
<p> <span style="font-family: Calibri;">{14.1, 14.2, 14.3, 14.4, 14.5, 1400}, </span></p>
<p> <span style="font-family: Calibri;">{15.1, 15.2, 15.3, 15.4, 15.5, 1500}, </span></p>
<p> <span style="font-family: Calibri;">{16.1, 16.2, 16.3, 16.4, 16.5, 1600}, </span></p>
<p> <span style="font-family: Calibri;">{17.1, 17.2, 17.3, 17.4, 17.5, 1700}, </span></p>
<p> <span style="font-family: Calibri;">{18.1, 18.2, 18.3, 18.4, 18.5, 1800},</span></p>
<p> <span style="font-family: Calibri;">};</span></p>
<p><span style="font-family: Calibri;">int main()</span></p>
<p><span style="font-family: Calibri;">{</span></p>
<p> <span style="font-family: Calibri;">float avg[N]; // </span><span style="font-family: 宋体;">存放平均值的数组</span></p>
<p> <span style="font-family: Calibri;">int dety=0;// </span><span style="font-family: 宋体;">误差个数</span></p>
<p> <span style="font-family: Calibri;">int i,j;</span></p>
<p> <span style="font-family: Calibri;">// </span><span style="font-family: 宋体;">计算每组数据的平均值</span></p>
<p> <span style="font-family: Calibri;">for (i = 0; i < N; i++)</span></p>
<p> <span style="font-family: Calibri;">{</span></p>
<p> <span style="font-family: Calibri;">float sum = data[i][0];</span></p>
<p> <span style="font-family: Calibri;">for (j = 1; j < M; j++)</span></p>
<p> <span style="font-family: Calibri;">{</span></p>
<p> <span style="font-family: Calibri;">sum += data[i][j];</span></p>
<p> <span style="font-family: Calibri;">}</span></p>
<p> <span style="font-family: Calibri;">avg[i] = sum / M;</span></p>
<p> <span style="font-family: Calibri;">}</span></p>
<p> <span style="font-family: Calibri;">// </span><span style="font-family: 宋体;">找到每组数据里面的误差并剔除掉,重新计算平均值</span></p>
<p> <span style="font-family: Calibri;">for (i = 0; i < N; i++)</span></p>
<p> <span style="font-family: Calibri;">{</span></p>
<p> <span style="font-family: Calibri;">dety=0;</span></p>
<p> <span style="font-family: Calibri;">for (j = 0; j < M; j++)//</span><span style="font-family: 宋体;">找到误差</span></p>
<p> <span style="font-family: Calibri;">{</span></p>
<p> <span style="font-family: Calibri;">if(fabss(data[i][j]-avg[i])>2*avg[i])</span></p>
<p> <span style="font-family: Calibri;">{</span></p>
<p> <span style="font-family: Calibri;">data[i][j]=0;</span></p>
<p> <span style="font-family: Calibri;">dety++;//</span><span style="font-family: 宋体;">确定误差个数</span></p>
<p> <span style="font-family: Calibri;">}</span></p>
<p> <span style="font-family: Calibri;">}</span></p>
<p> <span style="font-family: Calibri;">if(dety!=0)</span></p>
<p> <span style="font-family: Calibri;">{</span></p>
<p> <span style="font-family: Calibri;">float sum = data[i][0];</span></p>
<p> <span style="font-family: Calibri;">for (j = 1; j < (M-dety); j++)</span></p>
<p> <span style="font-family: Calibri;">{</span></p>
<p> <span style="font-family: Calibri;">sum += data[i][j];</span></p>
<p> <span style="font-family: Calibri;">}</span></p>
<p> <span style="font-family: Calibri;">avg[i] = sum / (M-dety);</span></p>
<p> <span style="font-family: Calibri;">}</span></p>
<p> <span style="font-family: Calibri;">}</span></p>
<p> <span style="font-family: Calibri;">// </span><span style="font-family: 宋体;">输出消除粗大误差和减小系统误差后的数据</span></p>
<p> <span style="font-family: Calibri;">for (i = 0; i < N; i++)</span></p>
<p> <span style="font-family: Calibri;">{</span></p>
<p> <span style="font-family: Calibri;">printf("%f\n", avg[i]);</span></p>
<p> <span style="font-family: Calibri;">}</span></p>
<p> <span style="font-family: Calibri;">return EXIT_SUCCESS;</span></p>
<p><span style="font-family: Calibri;">}</span></p>
<p><span style="font-family: 宋体;">运行结果如下:</span></p>
<p><img src="//image.lceda.cn/pullimage/rwTaJ9BcuUCnZzRx4AGLOYw8O9thDJq1uPL35axG.png" alt="" width="659" height="417"></p>
<p><span style="font-family: 宋体;">可见,误差(错误)项被消除了。</span></p>
<p><span style="font-family: 宋体;">曲线拟合:</span></p>
<p><span style="font-family: 宋体;">这里是将</span><span style="font-family: Calibri;">19</span><span style="font-family: 宋体;">个点的曲线拟合的代码让它变成</span><span style="font-family: Calibri;">181</span><span style="font-family: 宋体;">个点,在本工程中</span>float x[N]<span style="font-family: 宋体;">是由</span><span style="font-family: Calibri;">ADC</span><span style="font-family: 宋体;">经消除系统和粗大误差程序后传输过来的数据给定的,假设</span>19<span style="font-family: 宋体;">个离散坐标(</span><span style="font-family: Calibri;">0</span><span style="font-family: 宋体;">,</span><span style="font-family: Calibri;">1000</span><span style="font-family: 宋体;">),(</span><span style="font-family: Calibri;">20</span><span style="font-family: 宋体;">,</span><span style="font-family: Calibri;">939</span><span style="font-family: 宋体;">),(</span><span style="font-family: Calibri;">40</span><span style="font-family: 宋体;">,</span><span style="font-family: Calibri;">766</span><span style="font-family: 宋体;">),(</span><span style="font-family: Calibri;">60</span><span style="font-family: 宋体;">,</span><span style="font-family: Calibri;">500</span><span style="font-family: 宋体;">),(</span><span style="font-family: Calibri;">80</span><span style="font-family: 宋体;">,</span><span style="font-family: Calibri;">174</span><span style="font-family: 宋体;">),(</span><span style="font-family: Calibri;">100</span><span style="font-family: 宋体;">,</span><span style="font-family: Calibri;">-174</span><span style="font-family: 宋体;">),(</span><span style="font-family: Calibri;">120</span><span style="font-family: 宋体;">,</span><span style="font-family: Calibri;">-500</span><span style="font-family: 宋体;">),(</span><span style="font-family: Calibri;">140</span><span style="font-family: 宋体;">,</span><span style="font-family: Calibri;">-766</span><span style="font-family: 宋体;">),(</span><span style="font-family: Calibri;">160</span><span style="font-family: 宋体;">,</span><span style="font-family: Calibri;">-939</span><span style="font-family: 宋体;">),(</span><span style="font-family: Calibri;">180</span><span style="font-family: 宋体;">,</span><span style="font-family: Calibri;">-1000</span><span style="font-family: 宋体;">),(</span><span style="font-family: Calibri;">200</span><span style="font-family: 宋体;">,</span><span style="font-family: Calibri;">-939</span><span style="font-family: 宋体;">),(</span><span style="font-family: Calibri;">220</span><span style="font-family: 宋体;">,</span><span style="font-family: Calibri;">-766</span><span style="font-family: 宋体;">),(</span><span style="font-family: Calibri;">240</span><span style="font-family: 宋体;">,</span><span style="font-family: Calibri;">-500</span><span style="font-family: 宋体;">),(</span><span style="font-family: Calibri;">260</span><span style="font-family: 宋体;">,</span><span style="font-family: Calibri;">-174</span><span style="font-family: 宋体;">),(</span><span style="font-family: Calibri;">280</span><span style="font-family: 宋体;">,</span><span style="font-family: Calibri;">174</span><span style="font-family: 宋体;">),(</span><span style="font-family: Calibri;">300</span><span style="font-family: 宋体;">,</span><span style="font-family: Calibri;">500</span><span style="font-family: 宋体;">),(</span><span style="font-family: Calibri;">320</span><span style="font-family: 宋体;">,</span><span style="font-family: Calibri;">766</span><span style="font-family: 宋体;">),(</span><span style="font-family: Calibri;">340</span><span style="font-family: 宋体;">,</span><span style="font-family: Calibri;">939</span><span style="font-family: 宋体;">),(</span><span style="font-family: Calibri;">360</span><span style="font-family: 宋体;">,</span><span style="font-family: Calibri;">1000</span><span style="font-family: 宋体;">)</span></p>
<p><span style="font-family: Calibri;">#include <stdio.h></span></p>
<p><span style="font-family: Calibri;">#include <stdlib.h></span></p>
<p><span style="font-family: Calibri;">#include <math.h></span></p>
<p> </p>
<p><span style="font-family: Calibri;">#define N 19</span></p>
<p> </p>
<p><span style="font-family: Calibri;">// </span><span style="font-family: 宋体;">插值点的数据结构</span></p>
<p><span style="font-family: Calibri;">typedef struct {</span></p>
<p> <span style="font-family: Calibri;">double x;</span></p>
<p> <span style="font-family: Calibri;">double y;</span></p>
<p><span style="font-family: Calibri;">} Point;</span></p>
<p> </p>
<p><span style="font-family: Calibri;">// </span><span style="font-family: 宋体;">样条函数的数据结构</span></p>
<p><span style="font-family: Calibri;">typedef struct {</span></p>
<p> <span style="font-family: Calibri;">double a;</span></p>
<p> <span style="font-family: Calibri;">double b;</span></p>
<p> <span style="font-family: Calibri;">double c;</span></p>
<p> <span style="font-family: Calibri;">double d;</span></p>
<p> <span style="font-family: Calibri;">double x;</span></p>
<p><span style="font-family: Calibri;">} Spline;</span></p>
<p> </p>
<p><span style="font-family: Calibri;">// </span><span style="font-family: 宋体;">三次样条插值函数</span></p>
<p><span style="font-family: Calibri;">Spline* spline(Point points[], int n) {</span></p>
<p> <span style="font-family: Calibri;">int i;</span></p>
<p> <span style="font-family: Calibri;">double *h, *a, *l, *u, *z;</span></p>
<p> <span style="font-family: Calibri;">Spline *spline = (Spline*)malloc(sizeof(Spline) * n);</span></p>
<p> </p>
<p> <span style="font-family: Calibri;">h = (double*)malloc(sizeof(double) * n);</span></p>
<p> <span style="font-family: Calibri;">a = (double*)malloc(sizeof(double) * n);</span></p>
<p> <span style="font-family: Calibri;">l = (double*)malloc(sizeof(double) * n);</span></p>
<p> <span style="font-family: Calibri;">u = (double*)malloc(sizeof(double) * n);</span></p>
<p> <span style="font-family: Calibri;">z = (double*)malloc(sizeof(double) * n);</span></p>
<p> </p>
<p> <span style="font-family: Calibri;">for (i = 0; i < n - 1; i++) {</span></p>
<p> <span style="font-family: Calibri;">h[i] = points[i + 1].x - points[i].x;</span></p>
<p> <span style="font-family: Calibri;">a[i] = 3 * (points[i + 1].y - points[i].y) / h[i] - 3 * (points[i].y - points[i - 1].y) / h[i - 1];</span></p>
<p> <span style="font-family: Calibri;">}</span></p>
<p> </p>
<p> <span style="font-family: Calibri;">l[0] = 1;</span></p>
<p> <span style="font-family: Calibri;">u[0] = 0;</span></p>
<p> <span style="font-family: Calibri;">z[0] = 0;</span></p>
<p> </p>
<p> <span style="font-family: Calibri;">for (i = 1; i < n - 1; i++) {</span></p>
<p> <span style="font-family: Calibri;">l[i] = 2 * (points[i + 1].x - points[i - 1].x) - h[i - 1] * u[i - 1];</span></p>
<p> <span style="font-family: Calibri;">u[i] = h[i] / l[i];</span></p>
<p> <span style="font-family: Calibri;">z[i] = (a[i] - h[i - 1] * z[i - 1]) / l[i];</span></p>
<p> <span style="font-family: Calibri;">}</span></p>
<p> </p>
<p> <span style="font-family: Calibri;">l[n - 1] = 1;</span></p>
<p> <span style="font-family: Calibri;">z[n - 1] = 0;</span></p>
<p> </p>
<p> <span style="font-family: Calibri;">for (i = n - 2; i >= 0; i--) {</span></p>
<p> <span style="font-family: Calibri;">z[i] -= u[i] * z[i + 1];</span></p>
<p> <span style="font-family: Calibri;">spline[i].c = z[i];</span></p>
<p> <span style="font-family: Calibri;">spline[i].b = (points[i + 1].y - points[i].y) / h[i] - h[i] * (spline[i + 1].c + 2 * spline[i].c) / 3;</span></p>
<p> <span style="font-family: Calibri;">spline[i].d = (spline[i + 1].c - spline[i].c) / (3 * h[i]);</span></p>
<p> <span style="font-family: Calibri;">spline[i].a = points[i].y;</span></p>
<p> <span style="font-family: Calibri;">spline[i].x = points[i].x;</span></p>
<p> <span style="font-family: Calibri;">}</span></p>
<p> </p>
<p> <span style="font-family: Calibri;">free(h);</span></p>
<p> <span style="font-family: Calibri;">free(a);</span></p>
<p> <span style="font-family: Calibri;">free(l);</span></p>
<p> <span style="font-family: Calibri;">free(u);</span></p>
<p> <span style="font-family: Calibri;">free(z);</span></p>
<p> </p>
<p> <span style="font-family: Calibri;">return spline;</span></p>
<p><span style="font-family: Calibri;">}</span></p>
<p> </p>
<p><span style="font-family: Calibri;">// </span><span style="font-family: 宋体;">使用样条函数计算插值点的值</span></p>
<p><span style="font-family: Calibri;">double interpolate(Spline spline[], int n, double x) {</span></p>
<p> <span style="font-family: Calibri;">int i;</span></p>
<p> <span style="font-family: Calibri;">for (i = n - 2; i >= 0; i--) {</span></p>
<p> <span style="font-family: Calibri;">if (x >= spline[i].x)</span></p>
<p> <span style="font-family: Calibri;">break;</span></p>
<p> <span style="font-family: Calibri;">}</span></p>
<p> <span style="font-family: Calibri;">double dx = x - spline[i].x;</span></p>
<p> <span style="font-family: Calibri;">return spline[i].a + dx * (spline[i].b + dx * (spline[i].c + dx * spline[i].d));</span></p>
<p><span style="font-family: Calibri;">}</span></p>
<p> </p>
<p><span style="font-family: Calibri;">int main() {</span></p>
<p> <span style="font-family: Calibri;">Point points[N] = {{0,1000},{20,939},{40,766},{60,500},{80,174},{100,-174},{120,-500},{140,-766},{160,-939},{180,-1000},{200,-939},{220,-766},{240,-500},{260,-174},{280,174},{300,500},{320,766},{340,939},{360,1000}};</span></p>
<p> </p>
<p> <span style="font-family: Calibri;">Spline* splines = spline(points, N);</span></p>
<p> </p>
<p> <span style="font-family: Calibri;">int i, j;</span></p>
<p> <span style="font-family: Calibri;">for(i = 0; i < N-1; i++) {</span></p>
<p> <span style="font-family: Calibri;">for(j = 0; j < 10; j++) {</span></p>
<p> <span style="font-family: Calibri;">double x = points[i].x + j*2;</span></p>
<p> <span style="font-family: Calibri;">double y = interpolate(splines, N, x);</span></p>
<p> <span style="font-family: Calibri;">int px = x , py = y;</span></p>
<p> <span style="font-family: Calibri;">printf("(%d, %d)", px, py);</span></p>
<p> <span style="font-family: Calibri;">if(j%10 == 9)</span></p>
<p> <span style="font-family: Calibri;">printf("\n");</span></p>
<p> <span style="font-family: Calibri;">else</span></p>
<p> <span style="font-family: Calibri;">printf(", ");</span></p>
<p> <span style="font-family: Calibri;">}</span></p>
<p> <span style="font-family: Calibri;">}</span></p>
<p> <span style="font-family: Calibri;">free(splines);</span></p>
<p> <span style="font-family: Calibri;">int dx =points[i].x , dy =points[i].x;</span></p>
<p> <span style="font-family: Calibri;">printf("(%d, %d)", dx, dy);</span></p>
<p> <span style="font-family: Calibri;">return 0;</span></p>
<p><span style="font-family: Calibri;">}</span></p>
<p><span style="font-family: 宋体;">程序运行结果下:</span></p>
<p><img src="//image.lceda.cn/pullimage/CZET9CxtbSf9O1y9jCsmVuP1krbkGQYSGgaVK1o0.png" alt="" width="748" height="281"><img src="//image.lceda.cn/pullimage/RmGTHWHWiu2P2PasbRRHWlxt1A8hkZ67nY0aoHzJ.png" alt="" width="749" height="244">输入数据是按照cos变化规律变化的,我们可以随意带入数值验证拟合结果,发现最大误差在0.5%以内。</p>
<p>注:参考文献</p>
<p align="justify"><span style="font-family: 宋体;">《嵌入式系统软件设计中的常用算法》(周航慈</span> <span style="font-family: 宋体;">著)</span></p>
<p><span style="font-family: 宋体;">《嵌入式系统设计</span><span style="font-family: 宋体;">——基于</span><span style="font-family: Times New Roman;">STM32CubeMX</span><span style="font-family: 宋体;">与</span><span style="font-family: Times New Roman;">HAL</span><span style="font-family: 宋体;">库》(漆强 著)</span></p>
<p align="justify"><span style="font-family: 宋体;">《电气测量》(陈立波</span> <span style="font-family: 宋体;">著)</span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height: 1.8;"> </p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">*6、BOM清单</h3>
<hr class="horizontal-splitline normal-bold-2">
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"><img src="//image.lceda.cn/pullimage/4C0tXw3ES0c5RmsO67Te2AAHuzqOrgk7AYOpuDjz.png" alt="" width="1546" height="583"></p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">*7、大赛LOGO验证</h3>
<hr class="horizontal-splitline normal-bold-2">
<p style="line-height: 1.8;"> </p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"><span style="color: #95a5a6; font-size: 14px;">请上传包含大赛logo的项目图片,logo以丝印形式印刷在PCB上面。</span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"><span style="color: #95a5a6; font-size: 14px;">点击zip下载大赛logo标识! <span style="text-decoration: underline;"><a href="https://image.lceda.cn/easyedaResource/images/%E7%AB%8B%E5%88%9B%E7%94%B5%E8%B5%9B%E6%A0%87%E8%AF%86.rar" target="_blank">(大赛标识).zip</a></span></span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"> </p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">* 8、演示您的项目并录制成视频上传</h3>
<hr class="horizontal-splitline normal-bold-2">
<p style="line-height: 1.8;"> </p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"><span style="color: #95a5a6; font-size: 14px;">视频要求:请横屏拍摄,分辨率不低于1280×720,格式Mp4/Mov,单个视频大小限100M内;</span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"><span style="color: #95a5a6; font-size: 14px;">视频标题:立创电赛:{项目名称}-{视频模块名称};如立创电赛:《自动驾驶》-团队介绍。</span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"> </p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"><span style="font-size: 14px;">更多详情:<a href="/posts/15a52db9fd7d40c492eb505280278e45" target="_blank">https://diy.szlcsc.com/posts/15a52db9fd7d40c492eb505280278e45</a></span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"> </p>
</div>
评论(2)