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:
figure 1
The 485 interface circuit inside the s7-200 described in other materials is shown in Figure 2:
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:
Figure 3: RS232 waveform
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.
Previous article:About MCU soft reset
Next article:Infrared decoding principle and procedure
- Popular Resources
- Popular amplifiers
- Learn ARM development(14)
- Learn ARM development(15)
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Micropython wireless device command line tool upydev
- Are there any netizens doing embedded research in Shenyang?
- Timing Constraint Training.rar
- Today at 10:00 AM, live broadcast with prizes: The best assistant in human-machine interaction interface and machine vision applications—Renesas Electronics
- DSP digital anti-noise module for airborne communication equipment
- (Transfer) Bluetooth BLE GATT complete analysis and application
- Why do OEMs like to specify Ethernet connectors?
- "Play Board" + Shared Bicycle Control Panel 1
- Wire harness disc abnormal noise test
- Mid-Autumn Festival and Teachers' Day are coming together. I heard that there are only three times in a century.