Design of direct communication network between PCA82C250 and MCU
[Copy link]
Abstract: After analyzing the similarities and differences between RS-485 bus and CAN, taking PCA82C250 interface circuit as an example, it is proposed to use CAN bus communication physical layer interface circuit to replace the circuit in RS-485 bus interface and directly connect with single-chip microcomputer for communication network design, thus forming a high-performance, low-cost, data communication safe and reliable distributed measurement and control system. Keywords: Communication physical interface RS-485 bus CAN bus MCU 1 Overview The communication physical layer interface used for data communication between multiple machines is the working basis for data sharing in distributed measurement and control systems. Traditional distributed multi-machine measurement and control systems with single-chip microcomputers as the core mostly use current loops or RS-485/RS-422 buses to simplify the communication physical layer. The current loop form has basically withdrawn from the historical stage due to the reasons such as the complicated wiring compared with the RS-485/RS-422 bus form. The RS-485 bus wiring form has fewer two-pole communication lines and enhanced anti-interference ability compared with the RS-422 bus wiring form, making the wiring form simpler and cheaper. Therefore, the RS-485 bus basically dominates the application of the communication physical layer of the distributed multi-machine measurement and control system with the single-chip microcomputer as the core. However, with the development of science and technology, the shortcomings of the RS-485 bus, such as low bus efficiency, poor system real-time performance, low communication reliability, high later maintenance cost, complex network engineering debugging, unsatisfactory transmission distance, few single bus nodes, and inflexible application, have gradually been 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, which is of great significance to improving the reliability of the distributed measurement and control system with multi-machine interconnection. Compared with other fieldbuses, CAN has obvious advantages in communication capability, reliability, real-time performance, flexibility, ease of use, transmission distance and cost, and has become one of the most promising fieldbuses in control and other fields. For the physical layer interface of CAN bus, most of the existing CAN bus communication networks are composed of CAN bus physical layer interface circuits connected with CAN bus controllers. The author's in-depth analysis and practice have proved that the CAN bus physical layer interface circuit (in accordance with ISO11898 standard) can also be directly connected with a single-chip microcomputer to form a highly reliable, low-cost, simple and practical, multi-machine interconnected distributed measurement and control system. 2 Comparison of CAN and RS-485 physical layer characteristics The CAN bus has a dedicated interface circuit at the physical layer, and this type of interface circuit has its own characteristics. The similarities between the physical layer characteristics of the CAN bus and the RS-485 bus are: Two-wire, half-duplex serial communication; Differential transmission, balanced reception; The transmission medium is twisted pair; ·Terminal matching resistor is required; The communication circuit can work under 5V power supply condition. Compared with RS-485 bus, CAN bus communication physical layer interface circuit (taking PCA82C250 as an example) has the following advantages: Fully compliant with ISO11898 international standards; Long data transmission distance (up to 10km/5kb/s); High data transmission rate (up to 1Mb/s/40m); The bus values in the CAN bus are two complementary logic "dominant" or "recessive" bit values; It can realize multi-master communication network design, and the signal can realize non-destructive bus arbitration through "wired AND" on the bus; No sending and receiving conversion control pins; ·It has the bus protection capability against transient pulse interference (-150V<Vpulse<+100V); ·It has a higher bus voltage (-8V~+18V) tolerance than RS-485 bus; ·With transmit pulse slope control, it can reduce radio frequency interference; Differential receivers can resist a wider range of common-mode interference; ·With short circuit protection between bus, power supply and ground; ·With anti-bus short circuit protection capability; ·Under certain single-line conditions, the bus can still be protected to work normally; ·With low current standby mode; The bus is equipped with a resistor network inside, and no external upper and lower resistors are required; Unpowered nodes have no impact on the bus; At least 110 nodes can be connected. It can be seen that using the CAN bus physical layer dedicated interface circuit to replace the RS-485 bus interface circuit to form a hybrid mode multi-machine interconnection distributed measurement and control system communication network can overcome the inherent defects of the RS-485 bus and make full use of the advantages of the CAN bus physical layer. A highly competitive distributed measurement and control system can be constructed in a simple form, at a low price and with high performance.
Figure 2
3 PCA82C250 Introduction There are many CAN bus physical layer dedicated interface circuits that fully comply with the ISO11898 international standard. Here we only take the CAN bus universal interface circuit PCA82C250 as an example to illustrate this type of interface chip. The pin diagram of PCA82C250 is shown in Figure 1. The functional pins are as follows: Pin 1: Input terminal for sending data; Pin 2: power ground; Pin 3: power supply terminal; Pin 4: Output terminal for receiving data; Pin 5: output terminal of reference voltage; Pin 6: low level CAN bus input/output terminal; Pin 7: high level CAN bus input/output terminal; Pin 8: Bus pulse slope control resistor connection terminal. PCA82C250 can provide differential transmission capability for bus data and differential reception capability for communication bus data. Its pin 8 is quite special. This pin is used to select the circuit's own working mode; high speed, slope control and standby. When this pin is grounded, PCA82C250 works in high-speed communication mode; after connecting a resistor of a certain resistance value and then to ground, it is used to control the rising and falling slopes 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 mode, the transmitter is turned off and the receiver switches to low-current operation, but the receiver can still make a "dominant" bit 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 Atmal AT89C55 microcontroller as an example, the comparative connection diagram between AT89C55 and RS-485 bus interface circuit and AT89C55 and CAN bus physical layer dedicated interface circuit is shown in Figure 2. From the comparison in Figure 2, it can be seen that the hardware connection between PCA82C250 and AT89C55 is simpler than that between MAX485 and AT89C55, because the communication process of PCA82C250 does not require hardware conversion control of receiving and sending, but is only controlled by software. When the CAN bus is floating, it shows a "hidden" bit value, that is, CANH and CANL are suspended (VCAHN≈CANL≈VCC/2, equivalent to shutting down the bus), which provides network security for systems with "sleep" function; when the TXD terminal input 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), and CANL outputs a low level (about 1.5V, when Vcc is 5V). Obviously, under multi-host conditions, the introduction of "dominant" and "hidden" bits can realize non-destructive bus arbitration on the bus to determine which master device should be the next device to occupy the bus. Since the output value of the PCA82C250 reference voltage is not used, the 5th pin of the PCA82C250 can be left floating, and the resistor RS connected to the 8th pin is used to control the slope of the rising and falling edges of the output pulse of the CAN bus 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, the PCA82C250 enters a communication state of slope control of the rising and falling edges of the CAN bus output pulse, and the slope is proportional to the voltage on RS. In Figure 2, the software of the two communication systems is almost the same. When PCA82C250 is used as the bus interface to replace the original MAX485, the changes made in the software are: first, the communication direction control instruction part of the RS-485 bus can be cancelled, because the CA7402097N bus interface no longer needs this function; second, when the RS-485 bus is sending, the sending and receiving control ends are connected together, which automatically turns off the bus data receiving function, while the CAN bus interface is receiving bus data while sending bus data (the CAN bus interface does not provide separate control functions for communication receiving and sending data), so this should be considered in software design. Of course, this provides conditions for software identification and arbitration of bus data conflicts in multi-machine communication systems. When 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 physical layer dedicated interface circuit of the CAN bus to achieve electrical isolation between the MCU and the communication network. 5 Conclusion The actual application system test proves that the use of CAN bus physical layer dedicated interface circuit (such as PCA82C250, etc.) to replace RS-485 bus dedicated interface circuit to form a mixed mode multi-machine interconnected distributed measurement and control system communication network can largely overcome the inherent defects of RS-485 bus, and only a few modifications are made to the software, or even the original RS-485 bus communication software is not modified to adapt to the new system work. If necessary, multi-host multi-machine data communication can be realized by modifying the original RS-485 bus communication software, 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 in a simple form, at a lower price and with higher performance, so that the communication network performance of the distributed measurement and control system with multiple machines interconnected can be improved, ensuring the safe and reliable operation of the communication system under harsh working conditions.
|