CN104155891B - I<2>C-based networked transmitter and communication implementation method thereof - Google Patents
I<2>C-based networked transmitter and communication implementation method thereof Download PDFInfo
- Publication number
- CN104155891B CN104155891B CN201410318169.1A CN201410318169A CN104155891B CN 104155891 B CN104155891 B CN 104155891B CN 201410318169 A CN201410318169 A CN 201410318169A CN 104155891 B CN104155891 B CN 104155891B
- Authority
- CN
- China
- Prior art keywords
- circuit
- transmitter
- ntssp
- data
- sensor
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired - Fee Related
Links
Landscapes
- Arrangements For Transmission Of Measured Signals (AREA)
Abstract
本发明公开了一种基于I2C的网络化变送器及其通信实现方法,该变送器包括微控制器电路、人机交互模块、变送器电源电路、传感器电源电路、I2C通信电路、模拟输入电路、4~20mA信号输出电路、继电器输出电路、Modbus/RS485通信电路和接线端子排,其中外部模拟传感器和具有I2C接口的智能传感器通过接线端子排与网络化变送器连接,所述传感器电源电路和I2C通信电路根据传感器的不同要求提供对应的电源电压和通信连接。本发明提出一NTSSP协议,NTSSP协议综合应用了变送器广播通信模式、请求‑应答通信模式和发布‑订阅通信模式,提高了通信效率,能方便地自动分配智能传感器的I2C地址,方便使用。本发明具有成本低、即插即用的优点。
The invention discloses an I 2 C-based networked transmitter and a communication realization method thereof. The transmitter includes a microcontroller circuit, a human-computer interaction module, a transmitter power circuit, a sensor power circuit, an I 2 C Communication circuit, analog input circuit, 4~20mA signal output circuit, relay output circuit, Modbus/RS485 communication circuit and wiring terminal block, in which the external analog sensor and the intelligent sensor with I 2 C interface are connected to the network transmission through the terminal block The sensor connection, the sensor power supply circuit and the I 2 C communication circuit provide corresponding power supply voltage and communication connection according to different requirements of the sensor. The present invention proposes an NTSSP protocol. The NTSSP protocol comprehensively applies the broadcast communication mode of the transmitter, the request-response communication mode and the publish - subscribe communication mode, which improves the communication efficiency, and can conveniently and automatically assign the I2C address of the smart sensor, which is convenient use. The invention has the advantages of low cost and plug and play.
Description
技术领域technical field
本发明涉及自动化仪表研究领域,特别涉及一种基于I2C的网络化变送器及其通信实现方法。The invention relates to the field of automatic instrument research, in particular to an I2C - based networked transmitter and a communication realization method thereof.
背景技术Background technique
变送器是一种基础自动化设备,用于把不同传感器送来的物理量信号变换为标准信号制式的测量信号。目前变送器与传感器之间的信号连接主要为模拟信号,由于不同物理量的变换电路不同,因此变送器一般只能实现对一种物理量实现变送功能,针对不同物理量需要重新设计变送器。此外在更换传感器时,往往需要对变送器进行重新校正,由于该过程在应用现场进行,又需要标准样本(如3.5%的甲烷气体),因此校正非常不方便,校正过程工作量非常大。为了使变送器有通用性,IEEE协会制定了智能传感器接口标准IEEE1451,但是该标准复杂,模块划分不合理,模块之间的接口过于专用,没有考虑到微处理器技术和通信技术的快速发展,近20年来,一直未被工业界所接受。Transmitter is a kind of basic automation equipment, which is used to convert physical quantity signals sent by different sensors into measurement signals of standard signal format. At present, the signal connection between the transmitter and the sensor is mainly an analog signal. Because the conversion circuits of different physical quantities are different, the transmitter can generally only realize the transmission function for one physical quantity, and the transmitter needs to be redesigned for different physical quantities. . In addition, when replacing the sensor, it is often necessary to recalibrate the transmitter. Since this process is carried out on the application site and requires a standard sample (such as 3.5% methane gas), the calibration is very inconvenient and the workload of the calibration process is very large. In order to make the transmitter universal, the IEEE Association has formulated the intelligent sensor interface standard IEEE1451, but the standard is complicated, the module division is unreasonable, the interface between the modules is too special, and the rapid development of microprocessor technology and communication technology is not considered. , has not been accepted by the industry for nearly 20 years.
在实际应用中,新型变送器最好能兼容已有的变送器类型,这样才能减少用户投资,有利于推广。现有变送器输出的标准信号一般为4~20mADC电流信号,为了方便与其它自动化仪表构成自动化网络,一些变送器也提供Modbus/RS485通信接口。In practical applications, it is best for the new transmitter to be compatible with existing transmitter types, so as to reduce user investment and facilitate promotion. The standard signal output by existing transmitters is generally a 4-20mADC current signal. In order to facilitate the formation of an automation network with other automation instruments, some transmitters also provide Modbus/RS485 communication interfaces.
数字化和网络化是自动化仪表的发展方向,数字化和网络化不仅可以提高变送器的测量精度,而且可以提供远程诊断、标定和组态等模拟变送器没有的新功能。此外,为了使变送器能单独使用,需要有报警输出,并能在现场通过手操器进行参数和功能配置。Digitization and networking are the development direction of automation instruments. Digitization and networking can not only improve the measurement accuracy of transmitters, but also provide new functions that analog transmitters do not have, such as remote diagnosis, calibration and configuration. In addition, in order for the transmitter to be used alone, it is necessary to have an alarm output, and to be able to configure parameters and functions on site through a handheld operator.
发明内容Contents of the invention
本发明的主要目的在于克服现有技术的缺点与不足,提供一种基于I2C(Inter-Integrated Circuit)的网络化变送器,该变送器兼容现有变送器的大多数功能,可以连接多个智能传感器,不需要进行现场标定,即插即用,使用和更 换方便。The main purpose of the present invention is to overcome the shortcomings and deficiencies of the prior art, and provide a networked transmitter based on I 2 C (Inter-Integrated Circuit), which is compatible with most of the functions of existing transmitters. Multiple smart sensors can be connected without on-site calibration, plug and play, easy to use and replace.
本发明的另一目的在于提供一种基于上述网络化变送器的通信实现方法,该方法综合应用了变送器广播通信模式、请求-应答通信模式和发布-订阅通信模式,提高了通信效率,能方便地自动分配智能传感器的I2C地址,方便使用。Another object of the present invention is to provide a communication implementation method based on the above-mentioned networked transmitter, which comprehensively applies the transmitter broadcast communication mode, request-response communication mode and publish-subscribe communication mode, and improves communication efficiency , can conveniently and automatically assign the I 2 C address of the smart sensor, which is convenient to use.
本发明的目的通过以下的技术方案实现:基于I2C的网络化变送器,包括微控制器电路、人机交互模块、变送器电源电路、传感器电源电路、I2C通信电路、模拟输入电路、4~20mA信号输出电路、继电器输出电路、Modbus/RS485通信电路和接线端子排,其中外部模拟传感器和具有I2C接口的智能传感器通过接线端子排与网络化变送器连接,同时接线端子排还连接24V电源线、继电器输出线、4~20mA信号线和Modbus/RS485通信线;所述传感器电源电路用于在微控制器电路控制下输出每个智能传感器所需要的电压,I2C通信电路通过I2C总线与外部智能传感器连接。The purpose of the present invention is achieved through the following technical solutions: an I 2 C-based network transmitter, including a microcontroller circuit, a human-computer interaction module, a transmitter power circuit, a sensor power circuit, an I 2 C communication circuit, an analog Input circuit, 4 ~ 20mA signal output circuit, relay output circuit, Modbus/RS485 communication circuit and wiring terminal block, in which the external analog sensor and the intelligent sensor with I 2 C interface are connected to the networked transmitter through the terminal block, and at the same time The terminal block is also connected with 24V power line, relay output line, 4-20mA signal line and Modbus/RS485 communication line; the sensor power supply circuit is used to output the voltage required by each smart sensor under the control of the microcontroller circuit, I The 2 C communication circuit is connected with the external smart sensor through the I 2 C bus.
优选的,所述微控制器电路中的微控制器采用STM32L151R8T6单片机,变送器工作参数保存在单片机内部的EEPROM中,单片机外接Flash存储器。Flash存储器低地址的存储空间用于存储16点阵中文字库以用于LCD中文显示,高地址的存储空间用于因Modbus通信故障或者变送器单独使用时存储传感器采集的数据。从而提高数据采集的可靠性。Preferably, the microcontroller in the microcontroller circuit uses a STM32L151R8T6 single-chip microcomputer, the transmitter operating parameters are stored in the EEPROM inside the single-chip microcomputer, and the single-chip microcomputer is externally connected to a Flash memory. The low-address storage space of the Flash memory is used to store the 16-dot matrix Chinese character library for LCD Chinese display, and the high-address storage space is used to store the data collected by the sensor due to Modbus communication failure or when the transmitter is used alone. Thereby improving the reliability of data collection.
优选的,所述网络化变送器除了接线端子排外,其他所有电路均密封在防爆金属壳内,防爆金属壳上设置若干个金属孔,变送器内部的连接线通过金属孔连接接线端子排,金属孔被密封胶密封。Preferably, all circuits of the networked transmitter are sealed in the explosion-proof metal shell except for the terminal block, and several metal holes are arranged on the explosion-proof metal shell, and the connecting wires inside the transmitter are connected to the terminal block through the metal holes. , the metal hole is sealed with a sealant.
优选的,所述人机交互模块包括手操器红外接口电路和液晶显示模块,手操器红外接口电路和液晶显示模块分别与微控制器电路连接。Preferably, the human-computer interaction module includes an infrared interface circuit of a handheld operator and a liquid crystal display module, and the infrared interface circuit of the handheld operator and the liquid crystal display module are respectively connected to a microcontroller circuit.
进一步的,所述防爆金属壳的头部采用透明的有机玻璃。从而可以通过该有机玻璃窗口实现红外手操和LCD显示的人机界面。Further, the head of the explosion-proof metal shell is made of transparent organic glass. Therefore, the man-machine interface of infrared hand operation and LCD display can be realized through the plexiglass window.
优选的,所述手操器红外接口电路包括UART和IrDA收发器,用于接收手操器的操作命令和数据输入。Preferably, the infrared interface circuit of the handheld operator includes a UART and an IrDA transceiver for receiving operation commands and data input of the handheld operator.
优选的,所述液晶显示模块包括带LED背光的点阵黑白液晶屏。Preferably, the liquid crystal display module includes a dot-matrix black-and-white liquid crystal screen with LED backlight.
优选的,所述变送器电源电路通过接线端子排与外部的24V电源相连,变送器电源电路包括DC/DC转换器和LDO稳压器,DC/DC转换器用于将24V电源转换为5V,LDO稳压器用于将5V电源转换为3.3V电源,变送器电源电路输出的5V电源用于供液晶显示模块和继电器输出电路工作,3.3V电源用于供 变送器其它电路工作。Preferably, the transmitter power supply circuit is connected to an external 24V power supply through a terminal block, the transmitter power supply circuit includes a DC/DC converter and an LDO voltage regulator, and the DC/DC converter is used to convert the 24V power supply to 5V , The LDO voltage regulator is used to convert the 5V power supply to 3.3V power supply, the 5V power supply output by the transmitter power circuit is used for the operation of the liquid crystal display module and the relay output circuit, and the 3.3V power supply is used for other circuits of the transmitter.
具体的,所述传感器电源电路包括DC/DC前向通道电路、模拟反馈电路、电压加法电路和传感器工作电源测量电路,其中DC/DC前向通道电路用于将24V输入电压变为传感器所需的工作电压,模拟反馈电路与电压加法电路串联,模拟反馈电路采集DC/DC前向通道电路的输出信号,电压加法电路一端与微控制器电路相连,用于接收微控制器电路发出的反馈控制信号,另一端与DC/DC前向通道电路相连;传感器工作电源测量电路用于将DC/DC前向通道电路的输出信号发送到微控制器电路。用户根据模拟传感器和智能传感器的使用要求,可以通过手操器输入对应的电压值,变送器电源电路、微控制器电路共同作用,可以提供可变输出的电源电压给外部模拟传感器和智能传感器。Specifically, the sensor power supply circuit includes a DC/DC forward channel circuit, an analog feedback circuit, a voltage addition circuit and a sensor working power measurement circuit, wherein the DC/DC forward channel circuit is used to change the 24V input voltage into the sensor required The working voltage of the analog feedback circuit is connected in series with the voltage addition circuit, the analog feedback circuit collects the output signal of the DC/DC forward channel circuit, one end of the voltage addition circuit is connected to the microcontroller circuit, and is used to receive the feedback control from the microcontroller circuit The other end is connected to the DC/DC forward channel circuit; the sensor working power measurement circuit is used to send the output signal of the DC/DC forward channel circuit to the microcontroller circuit. According to the use requirements of analog sensors and smart sensors, the user can input the corresponding voltage value through the hand-held device, and the power supply circuit of the transmitter and the microcontroller circuit work together to provide variable output power supply voltage to the external analog sensors and smart sensors. .
更进一步的,所述模拟反馈电路和传感器工作电源测量电路均为电阻分压电路。Furthermore, both the analog feedback circuit and the sensor working power measurement circuit are resistor divider circuits.
具体的,所述I2C通信电路包括两个I2C总线上拉电阻。Specifically, the I 2 C communication circuit includes two I 2 C bus pull-up resistors.
一种基于上述网络化变送器的通信实现方法,包括步骤:A communication implementation method based on the above-mentioned networked transmitter, comprising steps:
(1)具有I2C接口的智能传感器上电后,根据NTSSP协议(变送器与智能传感器的通信协议),先向变送器发送NTSSP地址请求;所述NTSSP协议由物理层、数据链路层和应用层组成,NTSSP的物理层和数据链路层与I2C标准一致,所述NTSSP协议中的应用层,其数据包结构如下:地址、功能号、数据长度、变量名、变量数值和校验码,其中功能号用于表示数据包的功能,不同的功能号分别表示申请NTSSP地址、分配NTSSP地址、读请求数据、写请求数据、订阅数据、发布数据;(1) After the smart sensor with I 2 C interface is powered on, according to the NTSSP protocol (communication protocol between the transmitter and the smart sensor), it first sends an NTSSP address request to the transmitter; the NTSSP protocol consists of physical layer, data link The physical layer and the data link layer of NTSSP are consistent with the I 2 C standard. The application layer in the NTSSP protocol has the following packet structure: address, function number, data length, variable name, variable Value and check code, where the function number is used to indicate the function of the data packet, and different function numbers represent the application for NTSSP address, allocation of NTSSP address, read request data, write request data, subscribe data, and publish data;
(2)变送器根据智能传感器信息表进行智能传感器ID登记并选择未分配的NTSSP地址(即I2C地址),然后通过广播方式向该ID号的智能传感器发送分配的NTSSP地址;(2) The transmitter registers the smart sensor ID according to the smart sensor information table and selects the unassigned NTSSP address (i.e. I 2 C address), and then sends the assigned NTSSP address to the smart sensor with the ID number by broadcasting;
(3)智能传感器通过该NTSSP地址把自己的工作参数、测量参数报告给变送器;(3) The smart sensor reports its working parameters and measurement parameters to the transmitter through the NTSSP address;
(4)变送器登记好智能传感器的属性参数后,变送器采用订阅模式设定智能传感器的工作参数;(4) After the transmitter registers the attribute parameters of the smart sensor, the transmitter adopts the subscription mode to set the working parameters of the smart sensor;
(5)智能传感器根据这些工作参数工作,并采用发布模式主动向变送器报告测量值和报警情况。(5) The smart sensor works according to these working parameters, and adopts the release mode to actively report the measured value and alarm situation to the transmitter.
本发明在上述实现方法中提出了基于I2C的网络变送器与智能传感器的协议(Network Transmitter and Smart Sensor Protocol,简称NTSSP协议),NTSSP协议是在现有I2C总线协议的基础上增加应用层。NTSSP协议综合应用了变送器广播通信模式、请求-应答通信模式和发布-订阅通信模式,从而可以提高通信效率,充分发挥I2C的多主通信能力。通过增加该应用层,变送器可以自动获取每个智能传感器信息,从而实现即插即用,使用方便。The present invention proposes an I2C - based network transmitter and smart sensor protocol (Network Transmitter and Smart Sensor Protocol, referred to as NTSSP protocol) in the above-mentioned implementation method. The NTSSP protocol is based on the existing I2C bus protocol Add application layer. The NTSSP protocol comprehensively applies the transmitter broadcast communication mode, request-response communication mode and publish-subscribe communication mode, which can improve communication efficiency and give full play to the multi-master communication capability of I 2 C. By adding this application layer, the transmitter can automatically obtain the information of each smart sensor, so as to realize plug-and-play and easy to use.
优选的,所述步骤(1)中的NTSSP协议中的数据链路层只采用了Slave Receiver和Master Transmitter两种机制,是I2C数据链路层的子集,在通信过程中当需要发送数据时采用Master模式,发送完后采用Slave模式,等待数据接收。Preferably, the data link layer in the NTSSP agreement in the described step (1) has only adopted Slave Receiver and Master Transmitter two kinds of mechanisms, is the subset of I 2 C data link layer, when needing to send in communication process The master mode is adopted for the data, and the slave mode is adopted after sending, waiting for the data to be received.
优选的,在智能传感器正常工作时,变送器中传感器电源电路中的DC/DC前向通道电路将24V输入电压变为传感器所需的工作电压,模拟反馈电路采集DC/DC前向通道电路的输出信号后输入到电压加法电路中,同时传感器工作电源测量电路也采集DC/DC前向通道电路的输出信号将信号发送到微控制器电路,微控制器电路根据智能传感器工作电压的设定值、当前的测量值求取电压差,将此电压差输入到电压加法电路中,电压加法电路根据此电压差、当前的测量值输出反馈信号到DC/DC前向通道电路。实现智能传感器的工作电压可以在2.5~5.0V之间变化。Preferably, when the smart sensor is working normally, the DC/DC forward channel circuit in the sensor power supply circuit in the transmitter changes the 24V input voltage into the working voltage required by the sensor, and the analog feedback circuit collects the DC/DC forward channel circuit The output signal is input to the voltage addition circuit, and the sensor working power measurement circuit also collects the output signal of the DC/DC forward channel circuit and sends the signal to the microcontroller circuit. The microcontroller circuit is set according to the working voltage of the smart sensor. value, the current measurement value to obtain the voltage difference, and input the voltage difference into the voltage addition circuit, and the voltage addition circuit outputs a feedback signal to the DC/DC forward channel circuit according to the voltage difference and the current measurement value. Realize the working voltage of the intelligent sensor can change between 2.5- 5.0V.
优选的,所述步骤(5)中,在智能传感器向变送器报告测量值和报警情况时,变送器中I2C接收为地址匹配中断接收,具体如下:Preferably, in the step ( 5 ), when the smart sensor reports the measured value and the alarm situation to the transmitter, the I2C reception in the transmitter is an address matching interrupt reception, specifically as follows:
(5-1)当发生中断后,把接收的数据包暂时保存在输入缓冲区中,同时数据个数计数器加1;(5-1) When an interrupt occurs, the received data packet is temporarily stored in the input buffer, and the data number counter is increased by 1 at the same time;
(5-2)将数据包中的数据长度的字节与数据个数计数器进行比较,判断数据包是否结束,如果结束则执行步骤(5-3),否则,执行步骤(5-7);(5-2) compare the byte of the data length in the data packet with the data number counter, judge whether the data packet ends, if end then execute step (5-3), otherwise, execute step (5-7);
(5-3)计算数据包的校验码;(5-3) Calculate the check code of the data packet;
(5-4)判断校验码是否正确,若正确,则执行步骤(5-5);若不正确,则本次接收无效,执行步骤(5-6);(5-4) Judging whether the check code is correct, if correct, then perform step (5-5); if not, then this reception is invalid, and perform step (5-6);
(5-5)将当前数据包保存到变送器的接收缓冲区中,对数据包进行处理,同时进行数据个数清零,准备下次数据包接收;执行步骤(5-7);(5-5) Save the current data packet in the receiving buffer of the transmitter, process the data packet, and simultaneously reset the number of data to prepare for the next data packet reception; perform step (5-7);
(5-6)数据个数计数器清零;执行步骤(5-7);(5-6) The data number counter is cleared; Execute steps (5-7);
(5-7)中断返回。(5-7) Interrupt return.
本发明与现有技术相比,具有如下优点和有益效果:Compared with the prior art, the present invention has the following advantages and beneficial effects:
1、本发明变送器采用I2C总线代替IEEE1541标准,因此通信不仅标准化, 而且非常容易在普通的微控制器上实现,可以实现多主通信机制,除了可以连接一种模拟传感器外,还可以连接具有I2C接口的多种智能传感器,充分利用通用I2C标准,降低了实现成本。1. The transmitter of the present invention adopts the I 2 C bus instead of the IEEE1541 standard, so the communication is not only standardized, but also very easy to implement on an ordinary microcontroller, and can realize a multi-master communication mechanism. In addition to being able to connect an analog sensor, it can also A variety of smart sensors with I 2 C interfaces can be connected, making full use of the general I 2 C standard and reducing the cost of implementation.
2、本发明变送器还同时具有4~20mADC模拟标准、Modbus/RS485通信接口和继电器开关输出,因此输出可以兼容现有的变送器。2. The transmitter of the present invention also has 4-20mADC analog standard, Modbus/RS485 communication interface and relay switch output, so the output can be compatible with existing transmitters.
3、本发明中设置了人机交互模块,因此具有良好的中文LCD人机界面,同时通过红外手操器可以对变送器的工作方式和工作参数进行配置。另外,变送器中的微控制器电路还具有存储模块,因此具有数据保存能力。3. The human-computer interaction module is set in the present invention, so it has a good Chinese LCD human-machine interface, and at the same time, the working mode and working parameters of the transmitter can be configured through the infrared hand operator. In addition, the microcontroller circuit in the transmitter also has a memory module, so it has data retention capabilities.
4、本发明提出的NTSSP协议是在现有I2C总线协议的基础上增加应用层,由于大多数微处理器集成有I2C接口,即使不含硬件I2C片上外设的单片机,也可以通过集电极开路输出的I/O引脚配合软件来实现,因此该实现方式具有成本低、易于实现的优点。4, the NTSSP agreement that the present invention proposes is to increase application layer on the basis of existing I 2 C bus protocol, because most microprocessors are integrated with I 2 C interface, even do not contain the single-chip microcomputer of hardware I 2 C on-chip peripherals, It can also be realized through the I/O pin of open-collector output and software, so this realization method has the advantages of low cost and easy realization.
5、本发明中的NTSSP协议综合应用了变送器广播通信模式、请求-应答通信模式和发布-订阅通信模式,提高了通信效率,能方便地自动分配智能传感器的I2C地址,从而不需要对变送器和智能传感器进行现场标定,传感器即插即用,非常方便。5. The NTSSP protocol in the present invention comprehensively applies the broadcast communication mode of the transmitter, the request-response communication mode and the publish-subscribe communication mode, which improves the communication efficiency and can conveniently and automatically assign the I 2 C address of the smart sensor, so as not to On-site calibration of the transmitter and smart sensor is required, and the sensor is plug-and-play, which is very convenient.
附图说明Description of drawings
图1是本发明的工作原理示意图。Fig. 1 is a schematic diagram of the working principle of the present invention.
图2是本发明中传感器电源电路工作原理示意图。Fig. 2 is a schematic diagram of the working principle of the sensor power supply circuit in the present invention.
图3是本发明NTSSP协议的结构。Fig. 3 is the structure of NTSSP agreement of the present invention.
图4是图3中应用层数据包结构。Fig. 4 is the application layer data packet structure in Fig. 3 .
图5是本实施例1变送器的工作流程图。Fig. 5 is a working flow diagram of the transmitter in Embodiment 1.
图6是本实施例1中中断程序的流程图。Fig. 6 is a flow chart of the interrupt routine in the first embodiment.
具体实施方式detailed description
下面结合实施例及附图对本发明作进一步详细的描述,但本发明的实施方式不限于此。The present invention will be further described in detail below in conjunction with the embodiments and the accompanying drawings, but the embodiments of the present invention are not limited thereto.
实施例1Example 1
参见图1,基于I2C的网络化变送器包括STM32L单片机电路、手操器红外接口电路、液晶显示模块、继电器输出电路、4~20mA信号输出电路、模拟输 入电路、变送器电源电路、Modbus/RS485通信电路、传感器电源电路、I2C通信电路、接线端子排。接线端子排右边的模拟传感器和多个智能传感器是根据实际测量变量类型选用的传感器模块,通过端子排连接变送器,其中智能传感器具有I2C接口。此外,变送器的外部线也通过接线端子排连接,外接线包括24V电源线、继电器输出线、4~20mA信号线、Modbus/RS485通信线。本实施例中变送器的硬件结构全部密封在防爆金属壳内,变送器内部的连接线通过金属孔连接接线端子排,金属孔被密封胶密封。防爆金属外壳的头部采用透明的有机玻璃密封,通过该有机玻璃窗口实现红外手操和LCD显示的人机界面。See Figure 1, the I2C - based networked transmitter includes STM32L single-chip microcomputer circuit, handheld operator infrared interface circuit, liquid crystal display module, relay output circuit, 4~20mA signal output circuit, analog input circuit, transmitter power supply circuit , Modbus/RS485 communication circuit, sensor power supply circuit, I 2 C communication circuit, terminal blocks. The analog sensor and multiple smart sensors on the right side of the terminal block are sensor modules selected according to the actual measured variable type, and are connected to the transmitter through the terminal block, among which the smart sensor has an I 2 C interface. In addition, the external wires of the transmitter are also connected through the terminal block, and the external wires include 24V power wires, relay output wires, 4-20mA signal wires, and Modbus/RS485 communication wires. In this embodiment, the hardware structure of the transmitter is all sealed in the explosion-proof metal shell, and the connecting wires inside the transmitter are connected to the terminal block through the metal hole, and the metal hole is sealed by the sealant. The head of the explosion-proof metal casing is sealed with transparent plexiglass, and the man-machine interface of infrared manual operation and LCD display is realized through the plexiglass window.
本实施例中,STM32L单片机电路采用STM32L151R8T6单片机作为核心控制芯片,变送器工作参数保存在单片机内部的4KB EEPROM中,单片机外接512KB的Flash存储器AT25DF041A,其低地址的272KB用于存储16点阵中文字库,用于LCD中文显示,高地址的240KB用于因Modbus通信故障或者变送器单独使用时存储传感器采集数据,提高数据采集的可靠性。In this embodiment, the STM32L single-chip microcomputer circuit adopts STM32L151R8T6 single-chip microcomputer as the core control chip. The working parameters of the transmitter are stored in the 4KB EEPROM inside the single-chip microcomputer. The single-chip microcomputer is externally connected to the 512KB Flash memory AT25DF041A. The font library is used for LCD Chinese display, and the high address 240KB is used to store the data collected by the sensor due to Modbus communication failure or when the transmitter is used alone, so as to improve the reliability of data collection.
手操器红外接口电路和液晶显示模块构成人机交互模块,手操器红外接口电路由单片机片上外设UART和IrDA收发器TFDU4101及其相关电路组成,接收手操器的操作命令和数据输入。液晶显示模块由带LED背光的128×64点阵黑白液晶屏LM6059BCW及其相关电路组成,单片机采用PWM方式调节液晶LED背光的亮度。The infrared interface circuit of the handheld operator and the liquid crystal display module constitute the human-computer interaction module. The infrared interface circuit of the handheld operator is composed of the on-chip peripheral UART and IrDA transceiver TFDU4101 and related circuits, and receives the operation command and data input of the handheld operator. The liquid crystal display module is composed of 128×64 dot matrix black and white LCD screen LM6059BCW with LED backlight and its related circuits. The single-chip microcomputer uses PWM to adjust the brightness of the LCD LED backlight.
变送器电源电路把外接的24V电源通过DC/DC转换器CS51412变为5V电源,再通过LDO稳压器SPX1117变为3.3V电源,5V电源用于LCD背光和继电器输出电路工作,3.3V电源用于系统其它电路工作。The transmitter power supply circuit converts the external 24V power supply into a 5V power supply through the DC/DC converter CS51412, and then through the LDO voltage regulator SPX1117 into a 3.3V power supply. The 5V power supply is used for LCD backlight and relay output circuits, and the 3.3V power supply It is used for other circuit work of the system.
模拟输入电路和4~20mA信号输出电路主要用于兼容现有的模拟变送器。模拟输入电路用于对某种类型的传感器信号(如温度等)进行放大,然后再连接单片机的片上ADC。4~20mA信号输出电路把测量变量变为电流信号输出,由单片机片上DAC和XTR111及其外围电路组成。继电器输出电路提供继电器报警输出,由驱动芯片ULN2003和2个继电器ATX209组成。Modbus/RS485通信电路由单片机片上UART和低功耗RS485芯片SP3075E组成,实现变送器的Modbus/RS485通信。The analog input circuit and 4-20mA signal output circuit are mainly used to be compatible with existing analog transmitters. The analog input circuit is used to amplify a certain type of sensor signal (such as temperature, etc.), and then connect to the on-chip ADC of the microcontroller. The 4-20mA signal output circuit converts the measured variable into a current signal output, which is composed of DAC, XTR111 and its peripheral circuits on the single-chip microcomputer. The relay output circuit provides relay alarm output, which is composed of driver chip ULN2003 and two relays ATX209. The Modbus/RS485 communication circuit is composed of the on-chip UART of the single-chip microcomputer and the low-power RS485 chip SP3075E, which realizes the Modbus/RS485 communication of the transmitter.
传感器电源电路提供可变输出电源电压供智能传感器工作,工作原理如图2所示,传感器电源电路包括DC/DC前向通道电路、模拟反馈电路、电压加法电路和传感器工作电源测量电路,其中,DC/DC前向通道电路由核心控制芯片 CS51412及其外围电路组成,用于把24V输入电压变为传感器所需的工作电压,其输出电压反馈电路在原有模拟反馈电路基础上串联了一电压加法电路,通过单片机的DAC输出电压EsControl来改变原来的反馈电压VFB,从而调节Es。模拟反馈电路和传感器工作电源测量电路都为电阻分压电路,传感器工作电源测量电路的输出EsMeasure接单片机片上ADC,单片机根据传感器工作电压的设定值(有多个传感器时,取最大值)与测量值比较求误差,根据此电压差来控制EsControl的大小,实现Es从2.5~5.0V的变化。The sensor power supply circuit provides a variable output power supply voltage for the smart sensor to work. The working principle is shown in Figure 2. The sensor power supply circuit includes a DC/DC forward channel circuit, an analog feedback circuit, a voltage addition circuit and a sensor working power measurement circuit. Among them, The DC/DC forward channel circuit is composed of the core control chip CS51412 and its peripheral circuits. It is used to change the 24V input voltage into the working voltage required by the sensor. The output voltage feedback circuit is based on the original analog feedback circuit. A voltage addition circuit is connected in series. The circuit changes the original feedback voltage VFB through the DAC output voltage EsControl of the microcontroller, thereby adjusting Es. Both the analog feedback circuit and the sensor working power measurement circuit are resistor divider circuits, the output EsMeasure of the sensor working power measurement circuit is connected to the on-chip ADC of the single chip microcomputer, and the single chip microcomputer is based on the set value of the sensor working voltage (when there are multiple sensors, take the maximum value) The measured value is compared to find the error, and the size of EsControl is controlled according to the voltage difference to realize the change of Es from 2.5 to 5.0V.
NTSSP协议如图3所示,由物理层M301、数据链路层M302和应用层M303组成,NTSSP的物理层和数据链路层与I2C标准一致,成本低,接线少。NTSSP的数据链路层只采用了Slave Receiver和Master Transmitter两种机制,是I2C数据链路层的子集,不同的是在通信过程中需要在两种模式中切换,当需要发送数据时变为Master模式,发送完后变为Slave模式,等待数据接收。为了提高了通信效率,充分发挥I2C的多主通信能力,NTSSP协议综合应用了变送器广播通信模式、请求-应答通信模式和发布-订阅通信模式。NTSSP协议的应用层数据包如图4,由地址、功能号、数据长度、变量名、变量数值和校验码组成,功能号表示数据包的功能,如:功能号0为申请NTSSP地址,功能号1为分配NTSSP地址,功能号2为读请求数据,功能号3为写请求数据,功能号12为订阅数据,功能号13为发布数据。As shown in Figure 3, the NTSSP protocol consists of a physical layer M301, a data link layer M302 and an application layer M303. The physical layer and data link layer of NTSSP are consistent with the I 2 C standard, with low cost and few connections. The data link layer of NTSSP only uses two mechanisms of Slave Receiver and Master Transmitter, which is a subset of the I 2 C data link layer. The difference is that it needs to switch between the two modes during the communication process. When sending data Change to Master mode, and change to Slave mode after sending, waiting for data reception. In order to improve the communication efficiency and give full play to the multi-master communication capability of I 2 C, the NTSSP protocol comprehensively applies the transmitter broadcast communication mode, request-response communication mode and publish-subscribe communication mode. The application layer data packet of the NTSSP protocol is shown in Figure 4. It is composed of address, function number, data length, variable name, variable value and check code. The function number indicates the function of the data packet. Number 1 is to allocate NTSSP address, function number 2 is to read request data, function number 3 is to write request data, function number 12 is to subscribe data, and function number 13 is to publish data.
上述基于I2C的网络化变送器,其实现方法如下:根据NTSSP协议,变送器节点的NTSSP地址(即I2C地址)固定为1,广播地址为0,智能传感器的NTSSP地址是在2~127之间临时分配的,但是每个智能传感器包括具有唯一性的12字节ID号。变送器在其内部EEPROM保存有每个传感器的信息表,并由变送器维护。当智能传感器上电后首先向变送器发送NTSSP地址请求,变送器根据智能传感器信息表进行智能传感器ID登记并选择未分配的NTSSP地址,然后通过广播方式向该ID号的智能传感器发送分配的NTSSP地址,此后该智能传感器通过该地址与变送器进行通信。分配地址后,智能传感器把自己的工作电压、测量物理量类型等参数报告给变送器,变送器登记好传感器的属性参数后,变送器采用订阅模式设定传感器的采样周期、报警值等工作参数,之后传感器根据这些工作参数工作,采用发布模式主动向变送器报告测量值和报警情况。The above-mentioned networked transmitter based on I 2 C is implemented as follows: According to the NTSSP protocol, the NTSSP address of the transmitter node (that is, the I 2 C address) is fixed at 1, the broadcast address is 0, and the NTSSP address of the smart sensor is Temporarily assigned between 2 and 127, but each smart sensor includes a unique 12-byte ID number. The transmitter keeps a table of information for each sensor in its internal EEPROM and is maintained by the transmitter. When the smart sensor is powered on, it first sends an NTSSP address request to the transmitter, and the transmitter registers the smart sensor ID according to the smart sensor information table and selects an unassigned NTSSP address, and then sends an allocation to the smart sensor with the ID number by broadcasting NTSSP address for the smart sensor to communicate with the transmitter thereafter. After the address is assigned, the smart sensor reports its operating voltage, measurement type of physical quantity and other parameters to the transmitter. After the transmitter registers the sensor’s attribute parameters, the transmitter adopts the subscription mode to set the sensor’s sampling period, alarm value, etc. After that, the sensor works according to these working parameters, and adopts the release mode to actively report the measured value and alarm situation to the transmitter.
本实施例变送器在工作时由一个主程序和多个中断程序进行控制,中断程 序主要为通信接收中断程序,具有类似的结构,图6给出了I2C的接收数据中断程序。在主程序中配置I2C接收为地址匹配中断接收,当发生中断后,进入M411开始I2C中断程序,在M412中,把接收的数据暂时保存在输入缓冲区中,同时数据个数计数器加1。在M413中,将数据包中的数据长度字节(还需要加3,包括功能号和校验码,地址不计入)与数据个数计数器进行比较来判断数据包是否结束,若还没有结束则进入M418进行中断返回,若结束则进入M414计算数据包的校验码。M415判断校验码是否正确,若错误则本次接收无效,进入M417,数据个数计数器清零;若校验码正确,进入M416把数据包保存到主程序的接收缓冲区中,在主程序中进行处理,同时进行数据个数清零,准备下次数据包接收。The transmitter in this embodiment is controlled by a main program and multiple interrupt programs when it is working. The interrupt program is mainly a communication receiving interrupt program with a similar structure. Figure 6 shows the I 2 C receiving data interrupt program. Configure I 2 C receiving in the main program as address matching interrupt receiving. When an interrupt occurs, enter M411 to start the I 2 C interrupt program. In M412, temporarily save the received data in the input buffer, and at the same time, the data number counter plus 1. In M413, compare the data length byte in the data packet (need to add 3, including the function number and check code, and the address is not counted) with the data number counter to determine whether the data packet is over, if not Then enter M418 to interrupt and return, and if it ends, enter M414 to calculate the check code of the data packet. M415 judges whether the check code is correct, if it is wrong, this reception is invalid, enter M417, and the data number counter is cleared; if the check code is correct, enter M416 to save the data packet in the receiving buffer of the main program, in the main program In the process, the number of data is cleared at the same time to prepare for the next data packet reception.
主程序除了完成通信发送工作外,还根据人机界面或者Modbus通信的数据完成变送器工作参数配置,根据接收到的传感器数据更新4~20mA输出和继电器报警处理和输出。参见图5,包括步骤如下:In addition to completing the communication sending work, the main program also completes the transmitter working parameter configuration according to the man-machine interface or Modbus communication data, and updates the 4-20mA output and relay alarm processing and output according to the received sensor data. See Figure 5, including the following steps:
M400:主程序上电后,进入M401;M400: After the main program is powered on, enter M401;
M401:完成I/O、片上外设、缓冲内存单元(如I2C接收数据个数计数器等)初始化,启动RTC计时,启动UART(红外)、UART(RS485)和I2C通信中断。初始化之后,进入无限循环,顺序完成各个功能模块。M401: Complete the initialization of I/O, on-chip peripherals, and buffer memory units (such as I 2 C received data counters, etc.), start RTC timing, start UART (infrared), UART (RS485) and I 2 C communication interruption. After initialization, it enters an infinite loop and completes each function module in sequence.
M402:完成与手操器的红外通信处理,根据用户要求完成变送器工作参数配置,使得变送器可以不需要进行Modbus/RS485联网也可以单独使用。M402: Complete the infrared communication processing with the handheld device, and complete the configuration of the transmitter's working parameters according to the user's requirements, so that the transmitter can be used alone without Modbus/RS485 networking.
M403:实现中文人机界面,根据变送器工作状态显示测量数据或者设定工作参数。M403: realize the Chinese man-machine interface, display the measurement data or set the working parameters according to the working status of the transmitter.
M404:完成模拟传感器的数据采集,先读片上ADC输出,再根据配置的工作参数转换成测量数据。M404: Complete the data acquisition of the analog sensor, first read the on-chip ADC output, and then convert it into measurement data according to the configured working parameters.
M405:完成I2C的通信处理,保存智能传感器的测量数据。M405: Complete I 2 C communication processing, save the measurement data of the smart sensor.
M406:完成Modbus/RS485的通信处理,发送测量数据,并进行测量数据外部Flash备份,外部Flash的240KB数据存储区由首尾相继的环形数据表组成,实现最新数据的备份,方便手操器读取或者上位机通过Modbus/RS485网络读取历史数据。M406: Complete the communication processing of Modbus/RS485, send the measurement data, and perform external Flash backup of the measurement data. The 240KB data storage area of the external Flash is composed of ring data tables in succession to realize the backup of the latest data, which is convenient for the handheld operator to read Or the host computer reads historical data through the Modbus/RS485 network.
M407:把测量数据通过片上DAC变为4~20mA模拟输出,同时根据设定的报警参数(包括多传感器的联动)进行报警处理和相应的继电器输出,之后进入下一循环。M407: Change the measurement data into 4~20mA analog output through the on-chip DAC, and at the same time carry out alarm processing and corresponding relay output according to the set alarm parameters (including multi-sensor linkage), and then enter the next cycle.
上述实施例为本发明较佳的实施方式,但本发明的实施方式并不受上述实施例的限制,其他的任何未背离本发明的精神实质与原理下所作的改变、修饰、替代、组合、简化,均应为等效的置换方式,都包含在本发明的保护范围之内。The above-mentioned embodiment is a preferred embodiment of the present invention, but the embodiment of the present invention is not limited by the above-mentioned embodiment, and any other changes, modifications, substitutions, combinations, Simplifications should be equivalent replacement methods, and all are included in the protection scope of the present invention.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410318169.1A CN104155891B (en) | 2014-07-03 | 2014-07-03 | I<2>C-based networked transmitter and communication implementation method thereof |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410318169.1A CN104155891B (en) | 2014-07-03 | 2014-07-03 | I<2>C-based networked transmitter and communication implementation method thereof |
Publications (2)
Publication Number | Publication Date |
---|---|
CN104155891A CN104155891A (en) | 2014-11-19 |
CN104155891B true CN104155891B (en) | 2017-02-01 |
Family
ID=51881417
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410318169.1A Expired - Fee Related CN104155891B (en) | 2014-07-03 | 2014-07-03 | I<2>C-based networked transmitter and communication implementation method thereof |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104155891B (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106201952B (en) * | 2016-07-25 | 2019-09-24 | 惠州Tcl移动通信有限公司 | A kind of sensor compatibility processing method and system based on mobile terminal |
DE102019112230A1 (en) * | 2019-05-10 | 2020-11-12 | Stego-Holding Gmbh | Sensor hub, sensor system, method for transmitting sensor signals and computer-readable storage medium |
CN114441092B (en) * | 2022-02-10 | 2024-11-08 | 杭州和利时自动化有限公司 | Pressure transmitter calibration inspection method, system, device and storage medium |
Family Cites Families (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN200944602Y (en) * | 2006-09-12 | 2007-09-05 | 吉林大学 | Ethernet Application Processor |
BRPI0902400A2 (en) * | 2009-07-27 | 2012-03-06 | Lino Gonçalves José | PROGRAMMABLE ELECTRONIC CONTROLLER |
CN201476884U (en) * | 2009-08-14 | 2010-05-19 | 中国电子科技集团公司第三十八研究所 | Networked temperature and humidity sensor transmitter |
CN102645293A (en) * | 2012-04-25 | 2012-08-22 | 无锡商业职业技术学院 | Intelligent pressure transmitter |
CN102778327A (en) * | 2012-07-05 | 2012-11-14 | 西安交通大学 | High-performance intelligent sensor digital transmitting system |
CN103033399B (en) * | 2012-12-24 | 2015-02-04 | 南京埃森环境技术有限公司 | Atmospheric multiparameter transmitter for PM2.5 particulate matter monitor and use method thereof |
-
2014
- 2014-07-03 CN CN201410318169.1A patent/CN104155891B/en not_active Expired - Fee Related
Also Published As
Publication number | Publication date |
---|---|
CN104155891A (en) | 2014-11-19 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN103453985B (en) | Distributed wireless light intensity measuring instrument | |
CN110417649A (en) | A multi-interface intelligent IoT data gateway | |
CN103092115B (en) | Sensor transfer measurement and control system based on miniature universal serial bus (USB) | |
CN104614593A (en) | Self-calibration based high-precision intelligent instrument system and application method thereof | |
CN207337388U (en) | A kind of server serial port function test board | |
CN101309193B (en) | USB-Flexray bus adapter based on micro-processor | |
CN101901058B (en) | Wireless keyboard and mouse receiving and transmitting device | |
CN104155891B (en) | I<2>C-based networked transmitter and communication implementation method thereof | |
CN110162446A (en) | A kind of backboard hard disk ignition method based on BMC | |
CN104102160A (en) | Controller area network (CAN) bus signal transceiving analysis tool | |
CN103064329A (en) | Photovoltaic device data collection system and implementation method based on singlechip | |
CN204270290U (en) | IIC bus experimental device through serial port debugging | |
CN204904026U (en) | Environmental protection data acquisition device | |
CN111026620B (en) | Processing-based data visualization Processing system and method | |
CN210109593U (en) | A control system for TACAN navigation equipment | |
CN201765279U (en) | A power quality analysis instrument based on TFT-LCD display | |
CN105319453B (en) | A kind of environment protection digital Acquisition Instrument test device and system | |
CN110109405A (en) | A kind of control system and implementation method of Tacan navigation equipment | |
CN206133247U (en) | Little control system based on multi -sensor data gathers and transmits | |
CN105243040B (en) | A kind of instrument stored program controlled and method for supporting USBTMC agreement based on PCIe bus | |
CN104698909A (en) | Data collection interface of underwater vehicle control system sensor and configuration method of data collection interface | |
CN209373404U (en) | A kind of data collection system based on LabView | |
CN203982121U (en) | Based on I 2the networking transmitter of C | |
CN204028612U (en) | A kind of CAN signal transmitting and receiving instrument | |
CN208187447U (en) | A kind of pipeline gas parameter measuring instrument |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20170201 |