This application is based on and claims the benefit of priority from Japanese Patent Application No. 2019-220079, filed on 5 Dec. 2019, the content of which is incorporated herein by reference.

BACKGROUND OF THE INVENTION

Field of the Invention

The present invention relates to a controller and an industrial machine.

Related Art

Industrial machines including a machine tool, an industrial robot and the like operate based on signals from controllers such as a numerical control device (CNC) and a robot controller. The controller is, for example, incorporated in the industrial machine and provided together with the industrial machine. The controller that controls the industrial machine stores an operation program for operation of the industrial machine. The operation program is, for example, a machining program in the case of the numerical control device, and is a robot program to control a robot in the case of the robot controller. The machining program includes a command to operate an axis, and numerical calculation, and the machining program is executed to machine a workpiece. Furthermore, the machining program is stored, for example, in a storage area such as a storage medium, and during machining processing, the numerical control device loads the machining program in a cache memory to execute the program. The robot program includes, for example, a command for a joint axis, and the robot program is executed to operate the robot. The robot program is also stored in a storage area such as a storage medium in the same manner as in the machining program, and when the robot is controlled, the robot controller loads the robot program in a cache memory to execute the program.

As an example to load the program in the cache memory, an instruction cache system is known which takes, in advance, instruction data of a program to be executed by a central processing unit from a main storage program memory into an instruction cache, and transfers the instruction data from the instruction cache to the central processing unit, characterized in that the instruction cache is constituted of two faces, the system comprising means for repeating an operation of fetching and executing, by the central processing unit, the instruction data from the instruction cache of one face in parallel with an operation of transferring instruction data of the next program from the main storage program memory to the instruction cache of the other face, and after the execution of the instruction data fetched from the instruction cache of the one face is ended, switching connection of the instruction cache of the one face and the instruction cache of the other face, and performing an operation of fetching and executing, by the central processing unit, the instruction data from the instruction cache of the other face in parallel with an operation of transferring the instruction data of the next program from the main storage program memory to the instruction cache of the one face, thus alternately switching between the one face and the other face of the instruction cache, wherein the program includes a program structure in which the program is divided into program pieces to be fitted within a capacity of one face of the instruction cache, and execution of the program in each program piece is completed without straddling over into another program piece, and each program piece is transferred as a unit to the instruction cache (see Japanese Unexamined Patent Application, Publication No. 2005-266997).Patent Document 1: Japanese Unexamined Patent Application, Publication No. 2005-266997

SUMMARY OF THE INVENTION

Processing of loading a program in a cache memory and erasing the program from the cache memory is processing that requires time. Therefore, a mechanism capable of efficiently using the cache memory is required. Particularly, in a controller that controls an industrial machine such as a numerical control device, there exists a large amount of processing of calling another program in response to a command in a machining program. As an example, subprograms are frequently called in an automatic lathe. Therefore, with the current hardware constitution as it is, a mechanism of efficiently loading the machining program or the like in the cache memory is required.

According to an aspect of the present disclosure, provided is a controller that controls an industrial machine comprising a storage area that stores an operation program for operation of the industrial machine, a cache memory that stores the operation program read from the storage area, a cache control unit that controls writing into the cache memory and discarding, and an analysis unit that analyzes the operation program loaded in the cache memory, the analysis unit comprising an operation load determining section that determines whether an operation load on a CPU in a command included in the operation program is below a prescribed value, a call checking section that pre-reads a command subsequent to the command included in the operation program loaded in the cache memory, and checks whether a subprogram call command is present, in a case where the operation load determining section determines that the operation load is below the prescribed value, a cache control command adding section that adds, to the command, a cache control command for loading of the subprogram into the cache memory in accordance with a predetermined condition, in a case where the call checking section confirms presence of the subprogram call command, and a cache control requesting section that makes a cache control request for the cache memory to the cache control unit, responsive to the cache control command added by the cache control command adding section, the cache control unit comprising a cache control request processing section that loads the subprogram in the cache memory, based on the cache control request by the cache control requesting section.

According to an aspect, a controller and an industrial machine can be provided, which can efficiently perform processing by use of a cache memory.

