Communication between MCU and PLC: About 485 interface

Publisher:传邮万里Latest update time:2016-09-08 Source: eefocusKeywords:MCU  PLC Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Origin of RS485 interface

Smart instruments developed with the maturity of single-chip microcomputer technology in the early 1980s. Now the world's instrument market is basically monopolized by smart instruments. The reason is the need for enterprise informatization. One of the necessary conditions for enterprises to select instruments is to have a network communication interface. Initially, the data analog signal output was a simple process quantity. Later, the instrument interface was the RS232 interface, which can realize point-to-point communication, but this method cannot realize the networking function. The subsequent RS485 solved this problem.

 

Electrical characteristics of RS485 interface

RS485 uses differential signal (positive?) logic, +2V~+6V represents "1", -6V~-2V represents "0", this level is compatible with TTL level and can be easily connected to TTL circuit. In many cases, when connecting RS-485 communication link, a pair of twisted pair wires is used to connect the "A" and "B" ends of each interface (choose common ground according to the situation).

 

S7-200 485 interface pin definition

     The pin definition of the 485 interface in the S7-200 manual is shown in Figure 1:

 

Communication between MCU and PLC: About 485 interface - Guozi - Guozi's Blog

 

 

figure 1

 

The 485 interface circuit inside the s7-200 described in other materials is shown in Figure 2:

Communication between MCU and PLC: About 485 interface - Guozi - Guozi's Blog

 

 

figure 2

 

The definitions of the 485 interface 3 and 8 pins in the two figures are completely opposite. When doing a communication test, first connect according to the definition in Figure 1, and the PLC receives data incorrectly; then connect according to the definition in Figure 2, and the PLC receives data normally.

         Based on actual usage, it is assumed that the 485 interface 3 of s7-200 is used as A and 8 as B.

 

Communication between MCU and PLC

The MCU uses RS232 serial port while the PLC uses RS485 interface. The pin definitions and logic levels of the two are different, so other devices are needed to perform conversion and adjustment to complete the communication between the two.

1. PC/PPI cable

Connect the microcontroller and s7-200 via PC/PPI cable, and the data communication is correct;

2. RS232 - RS485 adapter

 

Question 1: Is the connection cable between the RS232 serial port of the microcontroller and the RS232 serial port of the adapter a straight line or a cross line?

The RS232 interface in the adapter description is DCE mode, which can be directly connected to the serial port of the DTE terminal device. A crossover cable is required to connect to the DCE device.

A simple distinction between using a crossover cable or a straight-through cable for serial device connection:

If the cable has one male and one female connector at each end, use a straight cable;

If both ends of the cable are male or female, use a crossover cable.

 

Question 2: About the labels on the 232-485 adapter and its matching wiring terminals

RS232 data signal is negative logic, RS485 data signal is positive logic, the waveform of transmitting the same data is shown in the figure:

Communication between MCU and PLC: About 485 interface - Guozi - Guozi's Blog

 

 

Figure 3: RS232 waveform

 

Communication between MCU and PLC: About 485 interface - Guozi - Guozi's Blog

 

 

Figure 4: RS485 waveform

Measure the waveform results according to the instructions on the converter:

① The input and output waveforms of the converter are consistent, and data transmission is performed using negative logic;

② The D+ and D- on the conversion head and the wiring terminal are cross-marked. If the waveform is measured according to the markings on the wiring terminal, the input and output waveforms on the conversion head and the wiring terminal are reversed.

According to the waveform measured by the oscilloscope, the circuit part between the converter head and sp485e converted the logic level of the RS232 signal. The RS485 end of the converter connector deliberately reversed the D+/D- to achieve transparent transmission of serial port data. The terminal block "set things right" in terms of marking so that the correct signal was transmitted to the PLC.

During the experiment, the terminals were directly removed and the serial port line was soldered by the user to connect the adapter and the PLC serial port, resulting in incorrect communication (there were also issues with the power supply of the adapter and the definition of the PLC serial port pins).

Summary: Communication is not smooth. Measure the waveform of each node based on the data link to determine the link where the problem occurs.

In addition, the pin markings on the device are for reference only; the actual definition needs to be determined by referring to the chip data sheet and circuit.

 

3. MAX3485 chip

The signal between the microcontroller and PLC is directly converted and transmitted through the 485 chip.

 

Whether it is the PC/PPI cable or the adapter, in essence they all use the 485 chip to complete the data conversion between the 232 interface and the 485 interface. Therefore, from a cost perspective, the 485 chip must ultimately be used to complete the communication between the microcontroller and the PLC.

Keywords:MCU  PLC Reference address:Communication between MCU and PLC: About 485 interface

Previous article:About MCU soft reset
Next article:Infrared decoding principle and procedure

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号