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 The programmable controller is an electronic system for digital operation and is designed for application in industrial environments. It uses programmable memory for its internal memory program, performs user-oriented instructions such as logic operations, sequence control, timing, counting, and arithmetic operations, and controls various types of machinery through digital or analog input and output. Production process. Programmable controllers and their associated external devices are designed to be easy to integrate with industrial control systems and easily expand their functionality. The early plc is mainly controlled by the digital sequence, providing a simple slow communication function (only supports RS232, RS485, and Modbus protocol). The current PLC not only has logic operation, sequence control, timing, counting and arithmetic. Operation, but also has A / D, D / A conversion, numerical calculation and data processing functions. It can control the amount of switching or control the analog quantity. With the continuous expansion of the PLC function, it also has the communication networking function. For example, the RS-232C port and peripherals in the CPU of the OMRONPLC of C200HX/HG/HE The port supports communication functions such as communication with programming devices (such as programmers, LSS, or SSS (Chinese version)), host computer link communication with personal computers and other peripherals, and RS-232C with personal computers and other peripherals. 1:1 with other PCs, and NT link communication (1:1, 1:N) with a programmable terminal (PT) equipped with an NT link interface. This topic is based on OMRONPLC link communication (with communication). Protocol), communication between the host computer and PLC developed by VC++.
2, OMRONPLC communication protocol At present, with the rapid development of PLC, more and more PLC manufacturers have developed its communication function with the computer (mainly using the computer serial port for communication), this article takes C200HEPLC as an example, for details Explain that the communication protocol of this paper uses the host computer link communication. The host computer link communication is realized by exchanging commands and responses between the host computer and the PLC. The command and response data transmitted in one exchange is called one frame, and one frame can contain up to 131 data characters.
Command frame format When sending a command from the host computer, arrange the command data in the format shown below.

The @ symbol must be placed at the beginning of each command. The node number is used to identify each PLC node. In this paper, it sets the PLC's DM6558 unit. The identification code sets the two-character command code. Which register unit of the PLC, when reading and writing the IR/SR area, its identification code settings are RR and WR, respectively, and the read and write DM areas are RD and WD, respectively. The body sets the command parameters, including the starting address and number of words of the PLC register unit to be read and written. FCS is a two-character frame check sequence code, which is an 8-bit data converted into two ASCII characters. The 8-bit data is the result of performing an exclusive-OR operation on all data from the beginning of the frame to the end of the text (ie, before the FCS). . The terminator sets "*" and carriage return (CH R$(13)) to indicate the end of the command. Command frames can be up to 131 characters long. A command equal to or greater than 132 characters must be divided into several frames. Command segmentation, using the carriage return delimiter (CH R$(13)).
Response frame format

The identification code and body depend on the received host computer connection command, and the end code indicates the state in which the command is completed (ie, whether an error has occurred). When the response exceeds 132 characters, it must be divided into several frames. The end code is information indicating the PLC response in the response frame. The example end code is 00 for normal end, 13 for FCS error, 14 for format error, 15 for entry code data error, 18 for frame length error, A3 for termination due to FCS error when transmitting data, and A8 for frame for transmitting data A length error caused the termination.
The host computer command frame herein includes commands for reading and writing data in the PLC unit. The read command frame is: @01RR0100000141*+CH R$(13), which means that the upper computer reads the contents of the IR0100 unit in the PLC whose node is 1. The write command frame is: @01WR0100000171*+CH R$(13), which means to write a number to the IR0100 unit of the PLC whose node is 1.
3, system structure diagram The following figure is a system diagram of computer and PLC communication

The host computer communicates with multiple PLCs, and must connect an RS232/422 level converter. RS422 adopts balanced transmission and reception mode. It has long transmission distance, strong anti-interference ability and multi-point communication capability, and can connect up to 32 PLCs. As shown in Figure 1, each PLC must hang a COM06 unit for RS422 connection. All PLC and computer communication uses the PLC host computer link communication protocol.
3.1 Hardware Settings
The setting switch of RS232/422 converter is set to 422 mode, and the COM06 communication board unit on OMRONPLC is also set to 422 mode and four-wire system.
3.2 Parameter setting The communication baud rate of the upper and lower position machine is set to 9600, and the data format is set to E, 7, and 2.
3.3 Node Setting Set the node number 00 (initial value) ~ 31 (number machine) in the DC6558 unit of the PLC.
4, using Visual C + + 6.0 to write serial communication program The host computer link communication program is written in Visual C + + 6.0, mainly using a communication control in VC + + to achieve.
First use MFCAppWizard (exe) to build an application based on a dialog box that supports ActiveX controls and is named Transcomn. Then add some controls to the dialog box, where the phone-shaped control must be the Microsoft CommunicationsControl registered in the system. When communicating with it, first set some of its properties as follows.

Property setting value description
CommPort1 communication protocol is PLC host computer link communication, using the serial port of the microcomputer 1
InputMode0 receives the data type as text
Rthreshold1 generates an event every time it receives a character
Settings9600, E, 7, 2 parameters are baud rate,
Parity data digits, stop bits

5, the program to write in the program to add the following code:
//TranscommDlg.cpp:implementationfile
BOOLCTranscommDlg::OnInitDialog()
{
Finally, add variables and response functions to the ClassWizard as follows.

Control name control ID corresponding variable or function communication address text box ID-ADDRESSm_address
DM area text box ID-DMm_dmbox
LR area text box ID-LRm_lrbox
HR area text box ID-HRm_hrbox
IR area text box ID-IRm_irbox
Response frame text box ID-RESPONSEm_response
Communication Control ID-MSCOMMM-comm.
Send command button ID-SENDOnSend()

//TODO:Addextrainitializationhere
/ / Open communication port 1
m_comm..SetCommPort&n

Lithium Fluorocarbon Battery Of 18650

DADNCELL lithium fluoride battery (Li-(CFx)n) battery is a safe and stable battery system with an energy ratio of up to 2,400 wh/kg because of the positive electrodes used in CFC materials.

Fluorocarbon materials have stable physical and chemical properties and excellent high and low temperature operating properties. ≤600°C does not decompose, low temperature does not crystallize, and stable operation in a high and low-temperature environment at 20~125°C. The battery also has higher safety performance in short circuits, collisions, and compressions, and has explosion-proof and self-burning characteristics. At present, the whole series of products of the company's lithium fluoride batteries have passed the acupuncture test. Also, the lithium fluoride battery discharges only <0.5% per year, and the battery has a storage life of more than 10 years, at which time the battery can be thrown to save 95% of its electricity. There are no heavy metals and other pollutants in the production, use, and scrapping of batteries, which are green and environmentally friendly. All battery materials of DADNCELL batteries are independently developed and produced by the company, which can ensure the complete and long-term stable supply of the supply chain. Lithium fluoride batteries currently developed and produced by the company are applied on a large scale in fields with strict requirements for high and low temperature and high energy density, such as automobile tire pressure gauge (TPMS) batteries, industrial control motherboard batteries, computer motherboard batteries, smart instrument batteries, emergency equipment power supply for oilfield rigs, offshore rescue. Bioflash, implantable medical battery, etc.

The company can formulate DADNCELL lithium fluoride series battery solutions according to customer requirements.

Lithium Fluorocarbon Battery Of 18650,Safety Br18650 For Building Battery Pack,High Temperature Resistance Batteries For Camping,Stable Li Batteries For Medical Devices

Shandong Huachuang Times Optoelectronics Technology Co., Ltd. , https://www.dadncell.com