Design of Communication Software and Hardware of Field Instrument Using HART Protocol



Due to the many unquestionable advantages of HART, it has become the most widely used field communication protocol in the world and has become a practical standard in the industry. Therefore, for a long period of time in the future, HART protocol products still have a very broad market in China.

Author: Anonymous

1. Introduction to HART protocol

HART (Highway Addressable Remote Transducer), an open communication protocol for an addressable remote sensor high-speed channel, is a communication protocol introduced by Rosemen Company in 1985 for on-site intelligent instruments and control room equipment.

HART devices provide communication with relatively low bandwidth and moderate response time. After more than 10 years of development, HART technology has matured abroad and has become the industry standard for global smart meters.

The HART protocol adopts the FSK frequency shift keying signal based on the Bell202 standard, superimposes the audio digital signal with the amplitude of 0.5mA on the low-frequency 4-20mA analog signal for two-way digital communication, and the data transmission rate is 1.2Mbps. Since the average value of the FSK signal is 0, it does not affect the size of the analog signal transmitted to the control system, ensuring compatibility with the existing analog system.

In HART protocol communication, the main variables and control information are transmitted by 4 ~ 20mA, and when needed, additional measurement, process parameters, device configuration, calibration, and diagnostic information are accessed through the HART protocol.

HART communication adopts the half-duplex communication method.

The HART protocol refers to ISO/OSI (Open System Interconnection Model) and adopts its simplified three-layer model structure, namely the first layer of physical layer, the second layer of data link layer and the seventh layer of application layer.

The first layer: the physical layer. The transmission method and transmission medium of the signal are specified. In order to realize the simultaneous analog communication and digital communication without interfering with each other, the HART protocol adopts the frequency shift keying technology FSK, that is, a frequency signal is superimposed on the 4-20mA analog signal, and the frequency The signal adopts the international standard of Be11202, the transmission baud rate of the digital signal is set to 1200bps, 1200Hz represents logic “0”, 2200Hz represents logic “1”, and the signal amplitude is 0.5A, as shown in Figure 1.

Design of Communication Software and Hardware of Field Instrument Using HART Protocol

The choice of communication medium depends on the transmission distance. Usually, when twisted-pair coaxial cable is used as the transmission medium, the maximum transmission distance can reach 1500m. The total line impedance should be between 230 and 1100Ω.

The second layer: the data link layer. The format of the HART frame is specified, and the functions of establishing, maintaining and terminating link communication are realized. According to the redundant error detection code information, the HART protocol adopts the automatic repeat request sending mechanism to eliminate the data communication errors caused by line noise or other interference, and realize the error-free transmission of communication data.

For field instruments to execute HART instructions, the operands must conform to the specified size. Each individual character includes a start bit, 8 data bits, a parity bit and a stop bit. Since the presence and length of data are not constant, the length of HART data is also different, and the longest HART data contains 25 bytes.

The seventh layer: the application layer. For the HART command set, used to implement HART instructions. Commands are divided into three categories, namely general commands, common commands and special commands.

2. Hardware design of field instrument HART protocol remote communication

The HART protocol part of a field instrument mainly completes the conversion of digital signals to analog current signals, and realizes access to main variables and measurement, process parameters, equipment configuration, calibration and diagnostic information. Figure 2 is a block diagram of the structural design of the HART protocol communication module.

Design of Communication Software and Hardware of Field Instrument Using HART Protocol

The HART communication part is mainly realized by D/A conversion and Bell202 MODEM and its affiliated circuits. Among them, the function of D/A conversion is to directly convert the digital signal into 4-20mA current output to output the main variable. The function of Bell202 MODEM and its auxiliary circuits is to perform band-pass filtering and amplification on the signal superimposed on the 4-20mA loop. If the HART communication unit detects the FSK frequency shift keying signal, the Bell202 MODEM will demodulate the 1200Hz signal as “1”, the 2200Hz signal is demodulated into a “0” digital signal, which is sent to the MCU through serial communication, and the MCU receives the command frame and performs corresponding data processing. Then, the MCU generates the response frame to be sent back. The digital signal of the response frame is modulated by the MODEM into corresponding 1200Hz and 2200Hz FSK frequency shift keying signals. After waveform shaping, it is superimposed on the loop by AD421 and sent out.

The D/A converter adopts AD421, which is a single-chip high-performance digital-to-analog converter introduced by ADI Company in the United States. It is powered by the loop, and the 16-bit digital signal is input in serial mode, which can directly convert the digital signal into 4~ 20mA current output. It provides a high-precision, fully integrated, low-power solution in 16-pin DIP, TSSOP, SOIC packages, enabling low-cost remote intelligent industrial control. AD421 includes serial input 16-bit D/A (digital/current) conversion, in addition to its own power consumption, it also provides a selectable (5V, 3.3 V or 3 V) regulated output for power consumption by other parts of the transmitter.

The HART MODEM adopts the HT2012 of Smar Company, which is a half-duplex modem conforming to the Bell202 standard, and realizes the encoding or decoding of the digital communication stipulated by the HART protocol. The chip is specially designed for HART instruments, and integrates modulators, demodulators, clock and timing circuits, and detection control circuits that conform to the BELL202 standard. High cost performance, 16-pin DIP and 28-pin PLCC package, working current 80μA when +5V power supply. The HT2012 exchanges digital signals with the microcontroller and interfaces with the AD421 for analog signals. On the one hand, it communicates serially with the asynchronous serial communication port of the MCU, on the other hand, it modulates the input non-return-to-zero digital signal into an FSK signal, and then superimposes it on the 4-20mA loop through AD421 for output, or converts the loop signal through the After band-pass filtering, amplification and shaping, the FSK signal is taken out and demodulated into a digital signal, thereby realizing HART communication.

For the input clock required by the HART MODEM, a 7.3728MHz crystal oscillator is used to divide the frequency by 4 twice through two counters 74LS161 to obtain a clock divided by 16.

Due to the requirements of HART digital communication, a sine wave current signal of 0.5mA is superimposed on the 4mA current, so the entire hardware circuit must be guaranteed to work normally below 3.5mA, so it is very important to realize the low power consumption design of the system.

Figure 3 and Figure 4 are the peripheral circuit diagrams of AD421 and HT2012 used respectively.

Design of Communication Software and Hardware of Field Instrument Using HART Protocol

3. Communication software design

The HART communication program is also the software realization of the HART protocol data link layer and application layer, which is the key to the design of the entire field instrument software.

In the HART communication process, the host computer (host computer) sends a command frame. After the field instrument receives the command frame through the serial port interrupt, the MCU performs corresponding data processing to generate a response frame. The MCU triggers the sending interrupt and sends a response frame. This completes a command exchange.

First, after power-on or watchdog reset, the main program should initialize the communication part, including baud rate setting, serial port working mode setting, clearing the communication buffer, and opening interrupts.

After the initialization is completed, the communication part is always in the ready-to-receive state. Once the host computer sends a command, the carrier detection port OCD of the HT2012 becomes low level, triggers an interrupt, starts receiving, and the program enters the receiving part. Then complete the interpretation of the host command and perform the corresponding operation according to the command, and finally generate the response frame according to a certain format and send it into the communication buffer, start the transmission, and close the SCI after completion.

FIG. 5 is a flow chart of a program of serially receiving a request frame and replying to a reply frame.

Design of Communication Software and Hardware of Field Instrument Using HART Protocol

After sending the acknowledgment frame, it enters the wait state again and waits for the next host command.

4. Conclusion

Practice has proved that the above method has the characteristics of simple structure and reliable operation, fully conforms to the HART protocol, and has good generality.

Due to the many unquestionable advantages of HART, it has become the most widely used field communication protocol in the world and has become a practical standard in the industry. Therefore, for a long period of time in the future, HART protocol products still have a very broad market in China.

The Links:   M185XTN010 FP35R12KT4