Serial Communication between Single Chip Microcomputer and PLC

1 Introduction

With the rapid development of microprocessors, computers and digital communication technologies, computer control has expanded to almost all industrial fields. Among them, PLC and single-chip microcomputer have been widely used in small-scale control systems.

In the automatic temperature control of plastic extruder, S7-200 series PLC is selected as the main control device, PIC16F877 single-chip microcomputer is used as temperature data acquisition and analog-to-digital conversion chip, and the single-chip computer transmits data to PLC through communication port, because RS-485 interface is adopted. Standard, transmission distance up to 1000m. The PLC controls the heating coil after the PID operation to keep the temperature constant. The following is an introduction to the communication implementation of PLC and MCU with examples.

2, hardware composition 2.1, PIC16F877 microcontroller

Microchip's PIC16F877 microcontrollers feature Harvard bus architecture and reduced instruction set technology, featuring low power consumption, high operating speed, high drive capability, and compact external circuitry. The PIC16F877 microcontroller integrates a serial communication module, the universal synchronous/asynchronous transceiver USART module. The main application target is long-distance serial communication between systems. The two pins required by the USART module are RC6 and RC7. As shown in Figure 1, when the transmit enable bit, TXEN, is set, the transmit data can be written to the TXREG register to complete the transfer.

2.2, S7-200 series PLC

The S7-200 series PLC communication port adopts asynchronous serial communication mode. The communication port standard adopts balanced drive and differential acceptance RS485 interface standard, which can form a half-duplex serial communication network to form a distributed system. There can be up to 32 in the system. station. The S7-200 supports a variety of serial communication protocols. With the free port mode, the user-defined communication protocol can be implemented through statement list or ladder diagram programming, which is convenient for connecting smart devices from different manufacturers. In the free port mode, data within 255 bytes can be continuously transmitted or received, which is convenient in bulk data communication.

2.3, MAX485E chip

The MAX485E chip is a standard dedicated communication chip for the RS-485 interface. As shown in Figure 1, the RO pin is a data output pin. It receives the differential mode signal VAB of the RS-485 and converts it to a TTL level output by the RO. The RE pin is the RO. The enable terminal, strobe RO when low level, the output is valid. The DI pin is the data input terminal, which converts the TTL level data into the differential mode signal VAB, and is sent out by the A and B legs. The DE is the DI enable terminal, the high level strobe DI, and the input is valid. Therefore, the two legs A and B are both the RS-485 signal input terminal and the output terminal of the signal. The key is determined by the levels of the enable terminals RE and DE.

2.4, hardware connection diagram

S7-200PLC adopts RS-485 interface standard to receive differential mode signal, while the output of PIC16F877 MCU is TTL level, so the two must be converted first when communicating. This system uses MAX485E chip as conversion chip, hardware connection is shown in Figure 1. Shown. The input or output of data is selected by the RC4 of the PIC16F877 microcontroller.

Serial Communication between Single Chip Microcomputer and PLC

Figure 1 hardware connection diagram

3. Communication protocol

In this project, since the PIC16F877 MCU only sends data, the PLC simply receives data, so it uses simplex serial communication. The PLC adopts the free port mode protocol, and the protocol is implemented by the statement table programming; the single chip uses the asynchronous sending mode of the USART module, and the protocol is implemented by assembly language programming. It can be known from the transmission buffer structure of the PIC16F877 single-chip microcomputer that only two bytes of data can be continuously transmitted at a time, so it is convenient for the PLC to use the character reception completion interrupt. The interface standard adopts RS-485 which is consistent with the PLC side, the connector adopts 9-pin D-shaped connector, the transmission line adopts shielded twisted pair, and the transmission data of the MCU side needs to be converted and then sent.

The format of the character information is: 1 start bit, 8 data bits, no parity, 1 stop bit.

The character information format of asynchronous communication is shown in Figure 2.

Serial Communication between Single Chip Microcomputer and PLC

Figure 2 Character information format

The data bits are sent in the order of the low order and the high order.

HDMI Cable Assembly

8K HDMI Cable, HDMI 2.1 48Gbps High Speed Nylon Braided HDMI Cord with eARC HDR10 4:4:4 HDCP 2.2&2.3, 4K HDMI Cable Compatible with Dolby Atmos Apple Fire LG Samsung TV PS5 PS4 Switch Xbox Roku.

[Ultimate High Speed 8K HDMI 2.1 Cable]Premium and easy-to-use for 8K and 4K devices. UCOAX 8K HDMI cable is the latest HDMI cable according to HDMI 2.1 specification which supports a wide range of higher video resolutions and higher refresh rates including 8K@60Hz and 4K@120Hz, max up to 10K. HDMI 2.1 is also compatible with previous HDMI 2.0b/2.0a/2.0/1.4/1.3/1.2/1.1.


[Wide Compatibility]UCOAX 8K HDMI 2.1 Cable is compatible for your streaming devices, Apple TV 4K, Fire TV, LG TV, Sony 8K UHD TV, Samsung OLED TV, NVIDIA SHIELD TV, amazon portal TV, Tivo, Vizio, CD/DVD/Blu-ray players, Roku Ultra, Wii U, Denon, PS5/4/3, Xbox One/360, Nintendo Switch, Playstation, Computers, Projector, Soundbar or other HDMI-enabled devices. Support Mirror and Extended Mode for you work, study, and entertainment provide the best visual enjoyment.


[Ultra High Speed Cable Extender For Gaming]48Gbps bandwidth super high speed data transfer, quick frame transmission(QFT)and variable refresh rate (VRR) at the same time, lower input lag, provide you better Gaming, and VR experience.


[High Performance For Video Streaming]3D stereo imaging technology, unique dynamic HDR and 12 Bit color processing technology, combined with Dolby Atmos& Dolby Vision, Enhanced audio return channel(eARC) provides high-resolution audio. Quick Media Switching(QMS) provides faster synchronization of images and sound, provide you an immersive audiovisual experience.


[100% Worry-free Money Back Guarantee]We take your great shopping experience as our top priority. We adopt the 24K gold plated connectors, 28AWG high purity copper conductor, nylon braided cable and triple shielding layer shielded to ensure transfer the signals in high speed and low loss. And 100% tested every HDMI cable before sent to avoid any troubles to you. If there is any problem, we also promise 12 months worry-free warranty and 24 hours friendly customer service.


HDMI Cable Assembly,HDMI Cord,8K HDMI cable,HDMI 2.1 Cable,HDMI to USB C Cable

UCOAX , https://www.jsucoax.com