打破传统 发表于 2021-3-7 23:54

【测评SGP40】3、uart控制测试

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线">&nbsp; &nbsp; &nbsp; 今天来学习一下Sensirion_Gas_Sensors_SEK-SVM40_UART_Interface_Description_D1和</span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线">Sensirion_Gas_Sensors_SEK-SVM40_Technical_Description_D1因为下面我们将串口通信部分代码移植到我的Zynq平台</span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线">官网</span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线"><a href="https://www.sensirion.com/cn/environmental-sensors/evaluation-kit-sek-environmental-sensing/evaluation-kit-sek-svm40/" style="color:#0563c1; text-decoration:underline">https://www.sensirion.com/cn/environmental-sensors/evaluation-kit-sek-environmental-sensing/evaluation-kit-sek-svm40/</a></span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线">页面下载</span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线">Sensirion_Gas_Sensors_SEK-SVM40_UART_Interface_Description_D1和</span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线">Sensirion_Gas_Sensors_SEK-SVM40_Technical_Description_D1</span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线">&nbsp; &nbsp; &nbsp; &nbsp; SEK-SVM40平台提供两种获取传感器信息的接口一种是I2C一种是串口,在这里我们先只讨论一下串口,以后再研究I2C接口。</span></span></p>

<p style="text-align:justify">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-size:10.5pt"><span style="font-family:等线">硬件接口如图,通过sel脚悬空或上拉选择UART,通过接地选择I2C。</span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;串口设置在Sensirion_Gas_Sensors_SEK-SVM40_UART_Interface_Description_D1中Table 1</span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;接下来是协议,SEK-SVM40平台在UART的基础上封装一层SHDLC协议,输出为MOSI帧,输入为MISO帧,帧结构如图:</span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;首先是起始和停止位:由一个字节0x7E表示,如果0x7E出现在其他位置必须被替换成其他两个字节,0x7D、0x11、0x13也是</span></span></p>

<p style="text-align:justify">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="font-size:10.5pt"><span style="font-family:等线">一个字节地址位:从设备地址是0</span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;一个字节主命令位:MOSI中是告诉从设备用传输的数据做什么,MISO则是单纯返回接受的的命令</span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;一个字节长度位:表示比特替换之前的长度</span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;一个字节状态位:只在MISO帧中,指示通信和执行错误信息</span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0到255字节数据位:比特替换前的数据总量,传输数据是按大端在前的方式传输,注意第一个字节作为子命令字节使用!</span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;校验和:开始位和停止位之间的字节数、取结果的最低有效字节取反</span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;最后是UART命令,总共13条,详细说明见文档Sensirion_Gas_Sensors_SEK-SVM40_UART_Interface_Description_D1第6页</span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;接下来我们连接SEK-SVM40平台跟电脑,在设备管理器中找到串口端号,打开串口调试工具</span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线">&nbsp; &nbsp; &nbsp; 串口调试工具设置如下图:</span></span></p>

<p style="text-align:justify">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="font-size:10.5pt"><span style="font-family:等线">打开串口,发送svm40_start_measurement命令7E 00 00 01 00 FE 7E&nbsp;</span></span><span style="font-size:10.5pt"><span style="font-family:等线">返回如图:</span></span></p>

<p style="text-align:justify">&nbsp; &nbsp; &nbsp;<span style="font-size:10.5pt"><span style="font-family:等线">接下来根据Sensirion_Gas_Sensors_SEK-SVM40_Technical_Description_D1来看看如何让SEK-SVM40平台输出我们想要的信号。</span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线">&nbsp; &nbsp; &nbsp;传感器上电后最大100ms进入idle模式,此时SVM40准备好接收主设备的命令。</span></span><span style="font-size:10.5pt"><span style="font-family:等线">接下来进行测量,svm40_start_measurement命令是进入测量模式,svm40_stop_measurement或svm40_device_reset是退出测量模式命令,在测量模式期间SVM40每秒钟进行一次测量,进入测量模式等待一个特定的延时后用svm40_get_signals或r svm40_get_raw_signals命令,再另一个特定延时后读到返回的数据。使用svm40_get_signals命令,一个标准的测量过程如图所示:</span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线">&nbsp; &nbsp; &nbsp; 原始信号的测量过程如图:</span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线">&nbsp; &nbsp; &nbsp; 使用温度偏移补偿RHT测量过程如图:</span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线">&nbsp; &nbsp; &nbsp; VOC算法的可调节性过程:</span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线">&nbsp; &nbsp; &nbsp; 将输入的参数存储到非易性存储器过程:</span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线">&nbsp; &nbsp; &nbsp; VOC算法的可记忆性过程:</span></span></p>

<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:等线">SEK-SVM40平台Uart控制测试就到这里,下一章移植到zynq开发板</span></span></p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify">&nbsp;</p>

<p style="text-align:justify">&nbsp;</p>

Jacktang 发表于 2021-3-8 20:25

<p>uart控制是基本功能测试,看来和其他板子区别不大</p>
页: [1]
查看完整版本: 【测评SGP40】3、uart控制测试