To develop communication program between microcomputer and OMRON PLC with VC++ - Database & Sql Blog Articles

Programmable Package SG-8018CA(SG7050C) 0.67M~170M
RF cable can be customized for other specifications

1. Introduction A programmable controller is an electronic system designed for digital operations, specifically tailored for use in industrial environments. It utilizes programmable memory to store internal programs and execute user-defined instructions such as logic operations, sequence control, timing, counting, and arithmetic functions. These controllers manage various types of machinery through digital or analog input and output signals during production processes. The design of programmable controllers and their associated external devices ensures seamless integration into industrial control systems and allows for easy expansion of functionality. Early PLCs were primarily based on digital sequencing and provided limited communication capabilities, such as RS232, RS485, and Modbus protocols. However, modern PLCs have evolved significantly, offering advanced features like A/D and D/A conversion, numerical calculations, data processing, and analog control. With the expansion of PLC capabilities, they now support communication networking functions. For example, OMRON PLC models C200HX/HG/HE include a CPU with an RS-232C port that supports communication with programming devices, personal computers, and other peripherals. This includes one-to-one (1:1) communication with PCs and NT link communication with programmable terminals equipped with an NT interface. This topic focuses on the communication between a host computer and an OMRON PLC using the Host Computer Link protocol, implemented in VC++.

2. OMRON PLC Communication Protocol As PLC technology advances, more manufacturers are integrating computer communication features, often using serial ports for connectivity. This paper uses the C200HE PLC as an example and explains the Host Computer Link communication protocol used in this study. The protocol involves exchanging command and response frames between the host computer and the PLC. Each command frame consists of up to 131 characters and follows a specific format. It begins with the '@' symbol, followed by the node number, a two-character command code, the register address, and parameters such as the starting address and number of words. A Frame Check Sequence (FCS) is included, calculated using XOR over all data before the FCS. The frame ends with a '*' and a carriage return (CR). Response frames depend on the received command and include an end code indicating whether the operation was successful or if an error occurred. Examples of end codes include '00' for normal completion, '13' for FCS errors, and '15' for invalid command codes. If the response exceeds 132 characters, it must be split into multiple frames using CR as the delimiter. Example commands include reading from IR0100 of a PLC with node 1, formatted as @01RR0100000141*+CR, and writing to the same register, represented as @01WR0100000171*+CR.

3. System Architecture The following diagram illustrates the communication structure between the host computer and multiple PLCs. To connect the host computer to multiple PLCs, an RS232/422 level converter is required. RS422 supports balanced transmission, offering long-distance communication, strong noise immunity, and multi-point connectivity, allowing up to 32 PLCs to be connected. Each PLC must be equipped with a COM06 unit for RS422 connection, and all communications follow the Host Computer Link protocol. 3.1 Hardware Setup The RS232/422 converter should be set to 422 mode, and the COM06 communication board on the OMRON PLC should also be configured for 422 and four-wire operation. 3.2 Parameter Configuration Both the host and PLC should be set to a baud rate of 9600, with a data format of E, 7, 2 (even parity, 7 data bits, 2 stop bits). 3.3 Node Assignment The node numbers in the DC6558 unit of the PLC should be set from 00 (default) to 31 (configured nodes). 4. Writing Serial Communication Programs in Visual C++ 6.0 The host computer link communication program is developed using Visual C++ 6.0, leveraging its built-in communication controls. The process involves creating a dialog-based application using MFC AppWizard (exe), adding necessary controls, and configuring the Microsoft Communications Control. When setting up the communication properties, the CommPort is set to 1, InputMode to text, RThreshold to 1, and the settings to 9600, E, 7, 2. These configurations ensure proper data transmission and reception. 5. Code Implementation In the program, additional code is added to handle communication functions. Variables and response functions are defined using ClassWizard, including text boxes for different memory areas (DM, LR, HR, IR), a response frame display, and a send command button. The communication port is initialized and configured accordingly.

High Speed Connector

High Speed 6PIN Female Connecor for Cable,High Speed GT32 4 PIN Female Connector,High Speed Connetor

Dongguan Zhuoyuexin Automotive Electronics Co.,Ltd , https://www.zyx-fakra.com

Posted on