Electronic
Design of Distributed Communication Network Based on AT89C55 MCU and PCA82C250

Design of Distributed Communication Network Based on AT89C55 MCU and PCA82C250

The communication physical layer interface used for data communication between multiple machines is the working basis for data sharing of distributed measurement and control systems. Traditional distributed multi-machine measurement and control systems with single-chip microcomputers as the core mostly use current loop or RS-485/RS-485/ RS-422 bus.

Author: Wang Mingshun; He Lihong

1 Overview

The communication physical layer interface used for data communication between multiple machines is the working basis for data sharing of distributed measurement and control systems. Traditional distributed multi-machine measurement and control systems with single-chip microcomputers as the core mostly use current loop or RS-485/RS-485/ RS-422 bus.

The current loop form has basically withdrawn from the historical stage due to the reason that the connection is more complicated than the RS-485/RS-422 bus form. Compared with the RS-422 bus, the RS-485 bus connection form has fewer two-pole communication lines and enhanced anti-interference ability, so that the connection form is simpler and the cost is lower. Therefore, the RS-485 bus basically dominates the single-chip microcomputer. It is the application of the communication physical layer of the distributed multi-machine measurement and control system as the core. However, with the development of science and technology, the RS-485 bus has low bus efficiency, poor system real-time performance, low communication reliability, high post-maintenance cost, complicated network engineering debugging, unsatisfactory transmission distance, few nodes that can be connected to a single bus, and poor application. The shortcomings such as flexibility are gradually exposed. Therefore, it is urgent to find a new, simple and effective communication physical layer interface chip to replace the RS-485 bus physical layer interface circuit for network communication. The reliability of the measurement and control system is of great significance.

Design of Distributed Communication Network Based on AT89C55 MCU and PCA82C250

Compared with other fieldbuses, CAN has obvious advantages in communication capability, reliability, real-time, flexibility, ease of use, transmission distance and cost, and has become the most promising fieldbus in control and other fields. one. For the physical layer interface of the CAN bus, most of the existing CAN bus communication networks are formed by connecting the physical layer interface circuit of the CAN bus and the CAN bus controller. The author’s in-depth analysis and practice have proved that the CAN bus physical layer interface circuit (in accordance with the ISO11898 standard) can also be directly connected with the single-chip microcomputer to form a distributed measurement and control system with high reliability, low cost, simple and practical, and multi-machine interconnection.

2 CAN and RS-485 physical layer characteristics comparison

The CAN bus has a dedicated interface circuit at the physical layer, and this type of interface circuit has its own characteristics. The physical layer characteristics of the CAN bus and the RS-485 bus have the same characteristics:

Design of Distributed Communication Network Based on AT89C55 MCU and PCA82C250

Compared with the RS-485 bus, the CAN bus communication physical layer interface circuit (taking PCA82C250 as an example) has the following advantages:

Design of Distributed Communication Network Based on AT89C55 MCU and PCA82C250

It can be seen that the use of the physical layer dedicated interface circuit of the CAN bus instead of the RS-485 bus interface circuit forms a communication network of a mixed-mode multi-machine interconnection distributed measurement and control system, which can overcome the inherent defects of the RS-485 bus and make full use of the CAN bus. The advantage of bus physical layer can construct a highly competitive distributed measurement and control system with simple form, lower price and higher performance.

Design of Distributed Communication Network Based on AT89C55 MCU and PCA82C250

3 Introduction to PCA82C250

There are many kinds of CAN bus physical layer dedicated interface circuits that fully comply with the ISO11898 international standard. Here, only the CAN bus general interface circuit PCA82C250 is used as an example to illustrate this type of interface chip. The pin diagram of PCA82C250 is shown in Figure 1. The function pins are as follows:

Design of Distributed Communication Network Based on AT89C55 MCU and PCA82C250

PCA82C250 can provide differential transmission capability for bus data and differential reception capability for communication bus data. Its pin 8 is special, this pin is used to select the working mode of the circuit itself; high speed, slope control and standby. When this pin is grounded, PCA82C250 works in high-speed communication mode; it is connected to a resistor with a certain resistance and then grounded to control the rising and falling slope of the transmitted data pulse (the slope is proportional to the current value on pin 8), to Reduce radio frequency interference; when this pin is connected to a high level, the circuit enters a low-current standby state. In this way, the transmitter is turned off and the receiver goes to low current operation, but the receiver can still do “dominant” bits on the CAN bus. If the PCA82C250 is at the network terminal of the communication bus, a matching resistor of about 120Ω needs to be added to the bus.

4 Application Examples

Taking the Atmal AT89C55 single-chip microcomputer as an example, the comparative connection diagram of AT89C55 and RS-485 bus interface circuit and AT89C55 and CAN bus physical layer dedicated interface circuit is shown in Figure 2.

It can be seen from the comparison in Figure 2 that the hardware connection between PCA82C250 and AT89C55 is simpler than the hardware connection between MAX485 and AT89C55, because the communication process of PCA82C250 does not require hardware conversion control of receiving and sending, and only software controls the floating time. , the CAN bus shows a “recessive” bit value, that is, CANH and CANL are suspended (VCAHN≈CANL≈VCC/2, which is equivalent to closing the bus), which provides network security for systems with “sleep” function; when When the input of the TXD terminal is low, the CAN bus shows a “dominant” bit value (transmitting valid data bits to the bus), that is, CANH outputs a high voltage (about 3.5V, when VCC is 5V), CANL outputs a low level ( about 1.5V when Vcc is 5V). Obviously, in the multi-master condition, the introduction of “dominant” and “recessive” bits enables non-destructive bus arbitration on the bus to decide which master device should be the next device to occupy the bus. Since the output value of the reference voltage of PCA82C250 is not used, pin 5 of PCA82C250 can be left floating, and the resistor RS connected to pin 8 is used to control the slope of the rising and falling edges of the output pulse of the CAN bus, so as to reduce the radio frequency interference of the bus. . When the resistance on RS is greater than 0.75CC, the PCA82C250 chip enters a low-power standby state; when the voltage on RS is less than 0.3Vcc, the PCA82C250 enters a high-speed communication state; when the voltage on RS is between 0.4Vcc and 0.6Vcc, PCA82C250 enters the communication state of the slope control of the rising and falling edges of the CAN bus output pulse, and its slope is proportional to the voltage on RS.

In Figure 2, the software of the two communication systems is almost the same. When the PCA82C250 is used as the bus interface to replace the original MAX485, the software changes are as follows: First, the communication direction control command part of the RS-485 bus can be cancelled, because the CA7402097N bus interface no longer needs this function; secondly, When the RS-485 bus is sending the bus, because the sending and receiving control terminals are connected together, the bus data receiving function is automatically turned off, and the CAN bus interface is also receiving the bus data while the bus data is being sent (CAN bus interface). It does not provide separate control functions for communication receiving and sending data), therefore, this should be considered in software design. Of course, this provides conditions for software identification and arbitration of bus data conflicts in a multi-computer communication system.

When the electrical isolation between the MCU and the communication network is required, two optoelectronic isolation devices (such as 6N137 optoelectronic isolation circuit) can be added between the MCU and the dedicated interface circuit of the physical layer of the CAN bus to realize the connection between the MCU and the communication network. electrical isolation.

5 Conclusion

It has been proved by the test of the actual application system that the special interface circuit of the physical layer of the CAN bus (such as PCA82C250, etc.) is used to replace the special interface circuit of the RS-485 bus to form a communication network of a mixed-mode multi-machine interconnected distributed measurement and control system. To a large extent, the inherent defects of the RS-485 bus are overcome, and only a few software modifications are made, and even the communication software of the original RS-485 bus can be adapted to the new system work. If necessary, the multi-master multi-machine data communication can be realized by modifying the communication software of the original RS-485 bus, making full use of the advantages of the CAN bus physical layer. In terms of hardware, a highly competitive distributed measurement and control system can be constructed with a simple form, lower price, and higher performance, so that the communication network performance of the multi-machine interconnected distributed measurement and control system can be improved. Safe and reliable operation of the communication system under severe working conditions.

The Links:   NL2432HC22-45A AA065VB08