Background
The numerical control system of the machine tool is a digital machine tool control system, and converts a macro motion instruction describing the relative motion of a cutter and a workpiece into a periodic servo system control instruction; the numerical control system controls the servo to realize the movement of the machine tool feed shaft dragged by the driving motor so as to realize the relative movement of the cutter and the workpiece and realize the workpiece processing. Generally, a machine tool numerical control system has a set of I/O control system besides a motion control function, and the system manages all the operations except servo control, such as limit and origin of each shaft, a tool magazine, a machine tool keyboard, electro-hydraulic and pneumatic switch control and the like, so that the system is a key for safe and stable operation of a machine tool and is an important component of the numerical control system.
I/O control systems for numerically controlled machine tools have undergone several generations of development as technology advances.
Relay logic system
Early I/O logic control of cnc machines was independent of the nc system and was implemented entirely by separate relay elements. If the relay is electrified and attracted to be 1 and the power-off release to be 0 or the contact is closed to be 1 and disconnected to be 0, the relay can be used for forming various logic gate circuits to play a logic control function.
1. NOT gate circuit
When the relay input signal A is equal to 1, the relay K1 is closed, the contact K1-1 is disconnected, and the output Y is equal to 0; when the input signal a is equal to O, the relay K1 is released, the contact K1-1 is closed, and the output is 1. The inverter circuit composed of relays is shown in fig. 1 as the inverter circuit composed of relays.
2. AND gate circuit
When the relay input signal A is 1, B is 1 and C is 1, the relays K1, K2 and K3 are attracted, the corresponding contacts K1-1, K1-2 and K1-3 are all closed, and Y is output to be 1; if one or more input signals are 0, the contact will cut off the positive power supply loop, and the output is 0. The logic of the AND gate formed by the relays is shown in the 'AND gate formed by the relays' in FIG. 2.
3. OR gate circuit
And connecting the normally open contacts of the relay in parallel to obtain OR logic. As long as one of the relays is energized (a ═ 1, or B ═ 1, or C ═ 1), the corresponding contact is closed, and the output Y ═ 1. The relay-based OR gate is shown in FIG. 3 as "Relay-based OR gate".
Second, industrial PLC system
As shown in fig. 4, an industrial PLC system generally includes a logic operation processing core module CPU and a peripheral I/O module, where the CPU is responsible for the collection, logic operation and output of I/O, and the I/O module is only used as a physical input/output interface of signals.
The industrial PLC is used for carrying out multipoint centralized control, and the method has the advantages of mature technology, good stability and high control efficiency, has the defects of difficult butt joint with a numerical control system, difficult cooperative work with the numerical control system and frequent increase of the design complexity of the system, thereby bringing other unstable factors.
Three, soft PLC system
As shown in fig. 5, the soft PLC system generally adopts a hardware structure of a general-purpose computer and an extended I/O, core control operations are completed on the computer, and are generally integrated in a numerical control system, which has the obvious advantage of overcoming the isolation of the relay logic system and the PLC system, and integrating the I/O control function under the main system, so that the system can work in cooperation with other components well, although the system is not as high in reliability as the hard PLC system, the stability and control efficiency of the soft PLC system are continuously improved today with the technical level of software and hardware being continuously improved.
The soft PLC system is divided into a centralized structure and a dispersed structure according to a hardware structure. The centralized structure, i.e. all the expanded I/O nodes are relatively centralized, and basically are I/O boards inserted into the main board of the main control computer, so that the centralized power supply is realized, the processor is directly accessed through the internal bus of the main control computer, and the software directly controls the processor. The distributed structure, i.e. the I/O nodes (input/output nodes) are distributed to each part of the machine tool, and the serial communication interface is accessed to the main control computer, and the communication content is I/O node information; after the information from the input node is gathered to the main control computer, the main control computer still realizes control logic operation, and sends a control result to the output node through the serial communication interface to realize control behavior.
The centralized structure has the advantages of direct interaction with a processor, good real-time performance, but the peripheral I/O nodes are limited by a computer interface, are not easy to expand and are far away from a control field, so that the loss of original input information and final output information can be caused, and the wiring cost is increased. The advantage of the decentralized structure is that the cost of wiring is saved, and the disadvantage is that the communication link causes the delay of the system, has reduced the real-time of the system. Although the hardware organization structure of the centralized structure and the distributed structure is different, the control modes are the same, namely, the processing cores of the logic operation are all from the main control computer.
Disclosure of Invention
The soft and hard PLC system has a fatal problem, namely control operation is centralized, and once a control core fails, the whole system is paralyzed. The invention provides a method for overcoming the defects, which can ensure that the safety switches such as shaft limit, emergency stop and the like of a numerical control machine tool can still work normally under the condition that a control operation core is paralyzed, and can locally and obviously improve the logic control efficiency. The I/O control method of the numerical control system of the machine tool can improve the I/O control efficiency of the machine tool, greatly reduce the control response time and obviously improve the control safety and stability of the numerical control machine tool.
In order to achieve the aim, the invention provides a safety logic control system with a centralized control function and a distributed control function in machine tool numerical control, which comprises a numerical control subsystem and a logic control subsystem for information interaction; the logic control subsystem is connected with the intelligent module and the I/O module managed by the main controller through a serial communication bus;
the logic control subsystem comprises a control resource manager, a control logic program editor, a control logic program compiler, an intelligent module program downloader and a master control program interpretation executor; wherein,
the control resource manager is used for controlling resources; the resources comprise I/O management and are used for distinguishing the I/O module managed by the main controller from the I/O locked by the branch controller of the intelligent module, so that the file compiled by the control logic program compiler is sent to the main control program interpretation executor to be executed or sent to the intelligent module to be used;
the control logic program editor is used for designing the main control program and the programs of the intelligent module sub-controllers, provides the functions of compiling and compiling the control logic program for the intelligent module, and directly generates the executive program of the intelligent module in the IDE environment.
The control logic program compiler is used for compiling the main control program into an operation file identified by the main control program interpretation executor of the main controller; meanwhile, a program compiler of the intelligent module is also carried, and the program of the intelligent module sub-controller is compiled into a target file for module identification and execution;
the intelligent module program downloader is used for downloading the generated intelligent module sub-control program file to a target module in the intelligent module;
the main control program interpretation executor is used for loading the compiled main control program and executing the main control program to realize the execution function of the main controller;
the intelligent module is used for receiving and executing the program of the sub-controller, and the program of the sub-controller is a control logic program; the system comprises a sub-control program receiver and a sub-control program interpretation executor; wherein,
the sub-control program receiver is used for receiving a program of the sub-controller loaded by an upper computer, and writing the program of the sub-controller into a nonvolatile storage area of the intelligent module after confirming the validity and the correctness of the receiving;
and the sub-control program interpretation executor is responsible for loading and executing the program downloaded from the sub-control device.
The execution steps of the system are as follows:
s1, opening a logic control integrated development environment, confirming hardware control resources, and planning the use and controlled party of the I/O module under the control resource manager according to a control logic program design scheme; the controlled party comprises the main control program interpretation executor and a sub-control program interpretation executor of the intelligent module;
s2, writing the main control program or the program of the intelligent module sub-controller in the control logic program editor according to the design scheme of the control logic program;
s3, calling the control logic program compiler to compile the main control program and the programs of the intelligent module sub-controllers respectively and generate control logic execution files of the main control program interpretation executor and the sub-control program interpretation executor of the intelligent module respectively;
and S4, loading the main control program into the main control program interpretation executor, downloading the sub-control program execution file to the intelligent module through the program downloader of the intelligent module, and loading the sub-control program interpretation executor into the intelligent module.
The invention can ensure that the safety switches such as shaft limit, emergency stop and the like of the numerical control machine can still work normally under the condition that the control operation core is paralyzed, and can obviously improve the logic control efficiency in part, thereby improving the I/O control efficiency of the machine tool, greatly reducing the control response time and obviously improving the control safety and stability of the numerical control machine.
Detailed Description
The technical scheme of the invention is as follows: the intelligent I/O module is designed on the basis of a control system with a distributed hardware structure, and is endowed with partial logic operation capability, so that the module manages own I/O points without depending on an upper computer, can perform basic logic operation to form a relatively independent sub-control system, the intelligent module is still monitored by a main controller, I/O resources not occupied by the sub-controllers in the module can still be used as the I/O resources of the main controller, and information such as occupied I/O resources, working states and intermediate results of the sub-controllers can still be checked by the main controller or used as input signals of the main controller to participate in logic operation and the like of the main controller. The editing and compiling of the intelligent module operation logic program are completely realized in a control logic programming development environment of the upper computer, and only the program is downloaded to the target module before operation, so that the man-machine interaction of system programming and operation is completely consistent with that of a traditional PLC system from the perspective of users, the users can use the control system realized by the invention as the traditional PLC system without any training, and the essential safety and the improvement of the control efficiency are brought to the users.
As shown in fig. 6, the present invention is composed of the following parts:
1. the logic control subsystem integrates a development environment and comprises a logic control resource manager, a logic program editor and a logic program compiler.
a) And the logic control resource manager is responsible for controlling the resources. Resources include I/O management, program and subroutine management, and real-time task management, among others. The primary task of I/O management here is to resolve which I/Os are managed by the primary and which I/Os are locked for use by the secondary of the intelligent module.
b) The control logic program editor is responsible for the design of the programs of the main controller and the intelligent module sub-controller, provides the function of compiling and compiling the control logic program for the intelligent module, and can directly generate the execution program of the intelligent module in the IDE environment.
c) The control logic program compiler is responsible for compiling the main control program into an operation file which can be identified by the program interpretation executor of the main control, and is also provided with the program compiler of the intelligent module, so that the control logic program of the intelligent module can be compiled into an identifiable or executable target file of the module.
d) And the intelligent module program downloader is responsible for downloading the generated intelligent module sub-control program file to the target module.
e) The main control program interpretation executor, which is called a main controller for short, is responsible for loading and executing the compiled main control program and realizes the execution function of the main controller.
2. And the intelligent module is a module which replaces a common I/O module and can receive and execute a simple control logic program. The intelligent module is compatible with all functions of a common I/O module, and also provides two important functions of a sub-control program receiver and a sub-control program interpretation executor, so that a local safe and efficient logic control function is realized.
a) And a sub-control program receiver. The intelligent module is responsible for receiving the sub-control program loaded by the upper computer, confirming the validity and correctness of program receiving, and writing the program into the nonvolatile storage area of the intelligent module for use.
b) And the sub-control program interpretation executor, called a sub-controller for short, is responsible for loading and executing the program downloaded to the intelligent module.
The invention discloses a design method for realizing high-efficiency and high-reliability safety logic control on a numerical control machine tool, which comprises the following overall steps of fig. 7.
The execution steps are as follows:
1. opening a logic control integrated development environment, knowing hardware control resources, and planning the application and controlled party (a controlled main controller or a branch controller of the intelligent module) of the module I/O under a resource manager according to a control logic program design scheme.
2. And compiling the control logic programs of the main controller and the intelligent module sub-controllers in the control program editor according to the control logic program design scheme.
3. And calling a control logic program compiler to respectively compile the main control program and the sub-control program to generate control logic execution files of the main controller and the intelligent module sub-controllers.
4. The main control program is loaded into the main control program interpretation executor, the sub-control program execution file is downloaded to the intelligent module through the intelligent module program downloader, and the sub-control program interpretation executor is loaded by the intelligent module. The sub-control program downloading and receiving process is as shown in FIG. 8:
5. and starting and operating the numerical control logic control subsystem.
Implementation method
The design method of the logic control subsystem provided by the invention has various implementation modes according to different operating systems and development tools selected by the numerical control system. Fig. 9 illustrates one implementation of the present invention.
The numerical control system is composed of numerical control system hardware and numerical control system software.
The numerical control system hardware can be formed by various computer systems, such as an X86PC framework, an ARM processor framework, a DSP processor framework, a singlechip framework and a multi-CPU framework formed by a plurality of the processors. The CPU is connected with other devices through an internal computer bus, including a real-time clock, a servo and I/O device interface, a storage medium, a display device and an input device which are necessary for numerical control. The hardware system adopting the X86PC framework can use the built-in 8253 or a compatible clock system thereof as a real clock; the servo and I/O equipment interface can be realized by an analog quantity output card and a digital quantity input/output card of a PCI bus or ISA bus interface, and for the servo and I/O equipment of a field bus interface, a corresponding field bus communication interface card can be adopted to realize the servo and I/O equipment interface; standard hard disks or SD cards, CF cards can be used as file system storage media.
The numerical control system software can be developed by using an application program development tool supported by a real-time operating system, for example, a GCC development environment supported by an RTLinux operating system, and the numerical control system software is developed in a VC development environment selected from Windows + RTX as the real-time operating system.
The intelligent module, as mentioned above, has the capability of receiving and executing the sub-control program logic in addition to the function of the ordinary I/O module, which requires the intelligent module to have a certain data processing capability, so that the intelligent module can adopt an embedded hardware system, such as an ARM7 series 32-bit MCU, and the currently popular ARMCotexM3M0 series, and even some 8-bit single-chip machines, such as an ATmega series AVR single-chip machine, can also meet the requirements.
The software of the intelligent module is designed according to the actual hardware resource condition, a small real-time system can be embedded to support complex applications, and a more friendly resource use interface is provided; on the other hand, certain tasks can be executed without a system, and module resources can be directly and efficiently used.
The specific implementation method of each part of the numerical control logic control subsystem is as follows (the intelligent module takes an AVR singlechip AT90CAN128 with a CAN controller as an example):
1. an integrated development environment includes a control resource manager, a control logic program editor, and a control logic program compiler. The three parts all work in a non-real-time system and can be realized by using a conventional software development tool (such as VC under Windows), wherein a program compiler needs to call a third-party compiler to realize the compilation of the intelligent module control logic program.
2. The main control logic program executor is a control logic program executing mechanism of the main controller, and needs to run under a real-time system to ensure the quick execution of control logic and the quick response of I/O control.
3. And the intelligent module control logic program downloader is responsible for rapidly and safely downloading the intelligent module control logic program file generated by compiling to the intelligent module. The downloader loads the file first, performs packet processing in binary form to meet the data format requirement of the communication protocol, can perform CRC redundancy check on each packet of data for data security, and designs a data error retransmission mechanism to ensure that the program file is downloaded to the intelligent module without errors. Referring to fig. 10, the downloading steps are as follows:
a) and loading a certain module to execute the file to be downloaded.
b) And packaging the file according to the communication protocol frame segment.
c) Resetting all network devices to restart and load a BootLoader (BootLoader), and completing the receiving work of the program in the BootLoader.
d) And starting the segmented frame downloading, and after receiving the response confirmation, downloading the next segment until all the program segments are downloaded.
e) Returning to the step a) to execute the downloading of the next module execution file. And after all the intelligent module programs are downloaded, informing all the modules to boot loader to load the operation of the application program.
f) The program downloader completes the mission exit.
4. And the program receiver is responsible for completely and faultlessly writing the received control logic program file into the program storage area of the intelligent module. The intelligent module program downloader is matched with an intelligent module program downloader of main system software, and is responsible for splicing the received data blocks together again, restoring the program file and storing the program file into a program storage area of the intelligent module for use by the intelligent module except for completing the matching work of data receiving verification, error retransmission notification and the like. Referring to fig. 10, the matching receiving steps with the intelligent module program downloader are as follows:
a) the module application program receives a node reset instruction of the CAN network in the running process, executes module reset, and is loaded into a boot loader (BootLoder), which CAN be also called a program receiver, by hardware to complete the receiving process of the logic program.
b) And waiting for and receiving the program segments sent to the module, sequentially storing the program segments in a designated program receiving area according to the sequence, and simultaneously returning a receiving confirmation to inform an upper computer that the program segments are successfully received.
c) And after all the segments are received, waiting for a communication instruction of the downloader, and loading the application program for execution.
The following figures are the program receiver operation and interaction flow (based on the CAN bus) of the system program downloader and the intelligent module:
5. the module sub-control logic program executor is responsible for receiving the I/O instruction of the main controller and feeding back the state of external I/O, and what is more important is that the module sub-control logic program executor can load and interpret the execution sub-control logic program and execute the logic instruction quickly and safely according to the written program. The sub-control program actuator has two realization methods: the method has the advantages that firstly, an executor is explained, program codes are compiled into a strip of control instructions in a determined format, the executor needs to translate the instructions into executable codes of modules, and the executable codes of the modules are translated and executed in a strip of order, the efficiency and the execution speed of the method are obviously not high due to the fact that the instruction translation process is added, the method also puts higher requirements on software and hardware environments of the modules, a high-performance MCU is needed to complete a large amount of program explanation work on hardware, and the support of an embedded operating system is generally needed on software to complete complex operation and task management work; the other method is compiling execution, namely a downloaded program file is a compiled program and can be directly operated on the intelligent module, obviously, the method saves the instruction translation process and has the highest efficiency, but the method requires that an upper computer system can realize the compiling work of the intelligent module subprogram, namely the program translation work of the former method is realized by the upper computer, and the intelligent module is required to support the dynamic loading of executable codes. The intelligent module is required to support an operating system to realize the similar program management and calling mechanism of the PC machine to support the dynamic loading of the program; or the intelligent module hardware MCU supports the loading and the guiding of the program, namely the intelligent module MCU has a BootLoader (BootLoader) to support the online programming of the system, and the compiled program can be directly downloaded to the intelligent module to replace the original program to be executed. The implementation of the logic program executor is described below by taking the AT90CAN128 as an example:
the AT90CAN128 is an 8-bit AVR singlechip, has limited operation capability, supports online programming, and CAN finish online downloading and replacement of a program by a start loader, so that the function of a logic program executor module is realized by adopting a compiling and executing mode.
AT90CAN128 runs without OS, the C programming is adopted, the single chip microcomputer starts a main function which jumps to a program to be executed, in the main function, firstly, software and hardware resources are initialized, and a resource initialization sub-function subminit () is designed; then, a main loop is entered, the main loop is a program loop main body of the single chip microcomputer, and the single chip microcomputer always circularly executes tasks in the main loop before the intelligent module is powered off. The tasks of the main loop include a communication function subprogram submscom (), an application function subprogram submsmap (), an input port reading subprogram (), a logic operation subprogram submalogic (), and an output port operation subprogram submenut ().
The main function structure of the program described by the C language is as follows:
the flow chart of the master function is shown in FIG. 11:
from the program framework and the flow chart, we can see that the submalogic () function is the implementation of our logical program executor. The upper computer only needs to convert the ladder diagram for realizing the logic operation of the module into C statements to be embedded into the submalogic function, then calls an AVR compiler to compile the whole single chip microcomputer engineering and then downloads the single chip microcomputer engineering to the intelligent module, and the new logic operation program function can be directly executed when a new program starts to run. For example, the ladder program that inverts the lower 8 bits of the input to the corresponding output is converted into C statement as follows:
the above description is only for the preferred embodiment of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art should be able to cover the technical solutions and the inventive concepts of the present invention within the technical scope of the present invention.