Realizes serial communication between Omron PLC and computer with VB - Database & Sql Blog Articles

RF cable can be customized for other specifications
F380J106MMA original authentic, spot stock brand NICHICON
Electronic scale crystal oscillator 3.2*2.5mm 3225 16M (16.000MHZ) 12PF 10PPM 20PPM 30PPM

1 Introduction In the field of industrial automation, PLCs are widely used as reliable and stable controllers. However, they have limitations in data processing and management, and often lack a user-friendly interface. This is where computers come into play. Computers offer superior data handling capabilities and intuitive interfaces, making them ideal partners for PLC systems. By integrating PLCs with computers, real-time data acquisition, storage, and processing become possible. The key to this integration lies in the communication between the PLC and the computer. This article uses Omron's CPMIA small PLC as an example to explore the principles of PLC-computer communication and how to implement it using PB (Program Builder).

2 Communication Principles and Methods For effective control, the upper computer must monitor the status of the lower device via the PLC. This requires establishing communication between the two. In most industrial settings, RS232C is used for this purpose. The host computer sends a query command to the PLC, which checks the status of input/output terminals and DM areas. Upon receiving the command, the PLC performs an FCS check. If valid, it transmits the data back, including start and end check bytes. Otherwise, it rejects the request. The host computer then verifies the received data and accepts or rejects it accordingly.

Since the CPM1A does not have a serial port, we use its peripheral ports for communication. A special cable, CQM1-CIF01, provided by Omron connects the PLC to the computer. The hardware setup is shown in the diagram below:



3 PLC-Computer Communication Communication occurs in "frames," with the computer having higher priority. It initiates a command frame, and the PLC responds with a response frame. The format of both frames is as follows:

(1) Command Frame Format: The command frame starts with '@', followed by the PLC address, command code, and FCS (Frame Check Sequence). The frame ends with '*' and a carriage return. This ensures accurate data transmission and error detection.

(2) Response Frame Format: The PLC returns a response frame that includes the exception code, indicating whether the command was executed successfully. If there is data to read, the body of the response is returned along with the FCS for verification.

4 Communication Program Design To fully leverage the computer’s data processing power, we use VB (Visual Basic) to develop the communication program. VB provides the MSComm control, which allows serial communication between the computer and the PLC. Key properties include:

  • CommPort: Sets the serial port number.
  • PortOpen: Opens or closes the communication port.
  • Settings: Defines baud rate, parity, data bits, and stop bits.
  • Input/Output: Reads from and writes to the buffer.
  • InBufferCount/OutBufferCount: Tracks incoming and outgoing data.

The initialization process involves setting the correct port, baud rate, and parity. A custom function calculates the FCS using XOR on each character of the input string. This ensures data integrity during communication.

5 Conclusion This communication method has been successfully implemented in a mechatronics system developed by our school’s CIMS research center. After testing, it proved to be stable and efficient. By connecting PLCs to a computer network, we create a system that combines centralized management with decentralized control. Each PLC controls local devices, while the computer manages the overall process. This setup meets modern automation needs, enabling information-based, networked, and intelligent control systems.

UHD Led Display-PJ

As one of most popular cabinet type, Priva LED's PJ series products is much easier for installation, maintenance and transportation. This series of products covers LED Screen from P1.56mm, P1.875mm, P2mm and P2.5mm. PJ series UHD led display support front acccess& back access. Modular design easier for maintenance. Lock for up and down, left and right make installation easier and fast. PJ series UHD led screen packed with modules and cabinet together, It will also speed up the installation and transportation. If more information about this sereries of LED display, Pls contract us!

UHD Video wall, UHD led screen, UHD led display

Shenzhen Priva Tech Co., Ltd. , https://www.privaled.com