| The programming device is essential to the Programmable Logic Controller(PLC),Generally,it has programming for hand-held devices and software on the PC-based programming,etc.the PC resource is rich,powerful,use-friendly, and good support for PLC program, such as ladder,instruction list and other characteristics,therefore,PC programming software become the mainstream way of PLC programming.This paper designed a PLC program editing system, which includes PLC programming software,and USB to CAN communication devices.Object-oriented graphical user interface library, MFC multi-document`,multi-view structure, message-driven mechanism and redraw mechanisms, on the VS2010 development platform,developed more humane editing interface of the ladder and instruction list; use standard template library, data structure and algorithm design, used of compiler technology complete the compilation. By studying the USB interface drivers and CAN interface driver, designed USB to CAN communication devices, to complete the communication between PC and PLC.In the research results obtained were as follows:(1)Completed the editing and compilation. Achieved a ladder and instruction list editing functions.The software could create, open, save the file, insert, delete, modify, found and other editing operations. Based support for multi-operand instruction list structural characteristics of the subject of independent design, the use of a dynamic array to store the instruction list, double linked list with multiple-operand instructions are stored in the table data structure; on the subject of self-designed 32-bit instruction encoding, used compiler technology to achieve the basic commands and functions instruction list compiled instruction encoding, while the instruction encoding can recompiled the instruction list, ladder could be converted to the instruction list.(2)Optimized communication devices and communication protocols.Design a circular queue buffer, resolved USB communication with CAN’s speed rate does not match the problem. PC can download the program by developing good communication protocol to the PLC, added the program download error re-transmission mechanism, and a timeout warning mechanisms to improve the download protocol. PLC program could upload through the development of good communication protocol to the PC and automatically converted to the instruction list, showed the instruction table editing interface. The realization of the device’s read function, and real-time display to the monitor screen, PLC stopped state can force the output device function.(3)Through the PLC on-line debugging, the experiment results showed that the PC programming software to correct the implementation of the user program editor and compiler,USB to CAN communication device enables communicate with PLC,it is proved the correctness and feasibility of PLC program editing system. |