Programmable controller

Abstract: A programmable controller comprises two memories (5a, 5b) which can be accessed by the same addresses, a sequence processor (3) which executes a user program stored in one of the two memories (5a, 5b), a control processor (1) which accesses and updates a user program stored in the other memory (5b, 5a) while the sequence processor (3) is not using a bus arrangement, and a memory selecting means (6) which selects one of the two memories (5a, 5b) for access by the sequence processor and by the control processor.

Description: DETAILED DESCRIPTION OF THE INVENTION: Industrial Field of Utilization: The present invention relates to a programmable controller and a method therefor adapted to update the contents of a user program during program execution. Prior Art: Programmable controllers with an ability to update the contents of a user program while the program is being executed have become commonplace. Such a prior art programmable controller is disclosed by Japanese Patent Laid-open No. 63-214806. This programmable controller comprises a first memory containing a user program A to be executed by a sequence processor and a second memory containing a user program B, the contents of the second memory being transferred to the first memory by an update instruction so that the sequence processor may execute the user program B instead of the program A. A disadvantage of this prior art is that when the user programs are switched for execution by the sequence processor, it takes time to transfer the new user program from the second memory to the first. During the program transfer, the sequence processing must come to a halt. The suspension of the processing entails significant inconveniences especially where large-size user programs are involved. One way to circumvent the problem above is to provide a function for directly updating part of the user program in the first memory to be accessed by the sequence processor. But there can be complications: If a wrong part of the user program is updated, e.g., if an added jump instruction is not matched with its destination, the update is invalid while the sequence processor executing the user program successively in the first memory makes it difficult to activate a verification program concurrently for check. With the prior art, such update errors cannot be detected and countered properly. DE-A-36 10 155 discloses a multi-processor system which is adapted to simultaneously read and write application programs into alternating memories by means of two processors, wherein a switching between said two alternating memories is possible. From US-A-4 257 095 a multi-processor system is known in which a bus controller circuit controls access of processors via a bus system to a memory. J.D. Foley et al., "Computer Graphics Principles and Practice", Addison-Wesley, Reading, US, 1990, p. 858 and 859 discloses a multi-processor system comprising two memories in which the data of one memory are read out while the data of the further memory are computed. SUMMARY OF THE INVENTION: It is the object of the present invention to provide a programmable controller and a method therefor capable to update user programs easily and quickly. This object is met by a programmable controller according to claim 1 and a method according to claim 5. Preferred embodiments are disclosed in the depending claims. According to the invention, there are provided two memories to be accessed by the sequence processor using the same addresses. While the sequence processor is executing a user program in one of the memories, the other memory is accessed so that another user program stored therein may be edited or otherwise handled. Because the editing takes place by use of the other memory, a verification program may be run concurrently to check the program in the first memory. If user programs are to be switched, the new memory to be accessed by the sequence processor is selected instead of the programs being transferred between the memories. This makes it possible to perform the sequence processing uninterrupted. BRIEF DESCRIPTION OF THE DRAWINGS: Fig. 1 is a block diagram of the programmable controller as the preferred embodiment of the present invention; Fig. 2 is a view describing how two memories are to be selected by register set points; Fig. 3 is a view depicting one instruction cycle of the sequence processor used in the embodiment; and Fig. 4 is a flowchart illustrating the procedure for switching user programs to be executed. Preferred Embodiment: A preferred embodiment of the present invention will now be described by referring to the accompanying drawings. Fig. 1 is a block diagram of a programmable controller embodying the present invention. In Fig. 1, a CPU module 15 of the programmable controller is connected to input modules 12a, 12b, ..., and to output modules 13a, 13b, ..., by an PI/O bus 14. The CPU module 15 comprises a program executing microcomputer 3 which is a sequence processor, a PI/O bus controller 7 to which the PI/O bus 14 is connected, two user program memories 5a and 5b which are accessed by the microcomputer 3 using the same addresses, and a sequencer bus 9 which interconnects these parts. The CPU module 15 also contains a program controlling microcomputer 1 for verifying and controlling user programs, a memory 2 containing the system program for the program controlling microcomputer 1, and a microcomputer bus 8 which connects the microcomputer 1 with the memory 2. The sequencer bus 9 is connected to the microcomputer bus 8 via a bus interface 4. Furthermore, the CPU module 15 comprises a memory selecting register 6 which selects either of the user program memories 5a and 5b using selection signals 11a and 11b and connects the selected memory to the sequencer bus 9. The memory selecting register 6 admits a memory access signal 10a from the program controlling microcomputer 1, a memory access signal 10b from the program executing microcomputer 3, and a set point signal also from the microcomputer 1. The output from the register 6 is the selection signals 11a and 11b. The user programs stored in the memories 5a and 5b will be called the user programs #1 and #2, respectively, in the description that follows. In this embodiment, four set point signals shown in Fig. 2 are used. With set point "1" placed in the register 6, the memory 5a is selected by the selection signal 11a if the access signals 10a and 10b come from the microcomputers 1 and 3. With set point "2" placed in the register 6, the memory 5b is selected by the selection signal 11b if the access signals 10a and 10b come from the microcomputers 1 and 3. With set point "3" placed in the register 6, the memory 5a is selected by the output of the selection signal 11a from the register 6 if the access signal 10b comes from the program executing microcomputer 3; if the access signal 10a comes from the program controlling microcomputer 1, the memory 5b is selected by the output of the selection signal 11b from the register 6. With set point "4" placed in the register 6, the memory 5b is selected by the output of the selection signal 11b from the register 6 if the access signal 10b comes from the program executing microcomputer 3; if the access signal 10a comes from the program controlling microcomputer 1, the memory 5a is selected by the output of the selection signal 11a from the register 6. Fig. 3 is a view showing an instruction cycle of the program executing microcomputer 3. One instruction cycle of the microcomputer 3 comprises an instruction fetch operation "a," a decode operation "b," an address computation "c," an I/O access operation "d," and execution "e." The sequencer bus 9 is monopolized during the instruction fetch operation "a" and 1/0 access operation "d." When the microcomputer 3 is in a decode operation "b," address computation "c" or execution "e," the sequencer bus 9 is free. During this bus free period, the program controlling microcomputer 1 may use the sequencer bus 9. The programmable controller whose construction was described above works as follows. When the program controlling microcomputer 1 sets a "1" to the register 6, the program executing microcomputer 3 outputs the access signal 10b to the register 6 and places an address signal onto the sequencer bus 9 in order to read a user program instruction from memory. Because the memory 5a is already selected by the register 6, the address signal causes the user program #1 in the memory 5a to be accessed. The program executing microcomputer 3 fetches and executes the suitable instruction. If the program controlling microcomputer 1 reads out the user program #1 being executed so as to duplicate it in an external memory, the access signal 10a is output to the register 6 and the address signal is placed on the microcomputer bus 8 in the cycle in which the program executing microcomputer 3 is not using the sequencer bus 9. Because the memory 5a is selected by the selection signal 11a from the register 6, the address signal is placed on the sequencer bus 9 via the bus interface 4. This causes the user program #1 to be read out of the memory 5a. If the user program being executed is stored in the memory 5b, a "2" is set in the register 6, and the subsequence process is the same as described above. If it is desired to modify the user program #1 being executed while stored in the memory 5a, a "3" is set in the register 6. The program executing microcomputer 3 continues reading the user program #1 from the memory 5a for execution, which allows the program controlling microcomputer 1 to access the memory 5b. This makes it possible to update the user program #1 that was moved to the external memory as described above and to have the program controlling microcomputer 1 store the updated user program #2 into the memory 5b. The updating may be carried out by an external programming device and the updated program may be checked for error thereafter. The user program may also be checked by the program controlling microcomputer 1 after being stored into the memory 5b. Where no external programming device is used, the user program #1 may be copied into the memory 5b in which the user program may be updated by the program controlling microcomputer 1. If the user program #2 is to be updated while being executed, a "4" is set in the register 6, and the subsequence process is the same as described above. What follows is a procedure for replacing the user program #1 being executed with the user program #2 for new execution. As indicated, a "3" is set in the register 6 so that the program executing microcomputer 3 executes the user program #1. This in turn allows the program controlling microcomputer 1 to access the memory 5b. The microcomputer 1 stores the user program #2 into the memory 5b, and waits for the program executing microcomputer 3 to end its scanning of the user program #1. At the scan end, the program executing microcomputer 3 attempts to interrupt the program controlling microcomputer 1. The microcomputer 1 accepts the interruption and illustratively sets a "4" in the memory selecting register 6. After this, the address signal coming from the program executing microcomputer 3 allows the user program #2 to be accessed in the memory 5b. In this manner, the user program #1 may be replaced with the user program #2 for execution by the program executing microcomputer 3 switching the memories to be accessed. The user programs are switched without the microcomputer 3 either becoming aware of the switch or interrupting the sequence processing. Effects of the Invention: According to the invention, user programs are switched without interruption of the sequence processing. The invention also allows the newly selected user program to be verified before its execution.

Claims: A programmable controller comprising two memories (5a, 5b) each for storing an application program; a program executing microcomputer (3) for executing the application programs stored in said two memories (5a, 5b), said program executing microcomputer using the same addresses to access said two memories; a program controlling microcomputer (1) for controlling access to contents of said two memories (5a, 5b); and memory selecting means (6) for selecting access to one of said two memories (5a, 5b) on the basis of setpoint signals supplied from said program controlling microcomputer (1); wherein on a first setpoint signal supplied to said memory selecting means (6) from said program controlling microcomputer (1), said program controlling microcomputer is allowed to modify the application program stored in a first one (5b) of said two memories while said program executing microcomputer (3) executes the application program fetched from a second one (5a) of said memories, and wherein on a second setpoint signal supplied to said memory selecting means (6) from said program controlling microcomputer (1) after the execution of said application program fetched from said second memory (5a) is finished by said program executing microcomputer (3), said program executing microcomputer is allowed to fetch the modified application program from said first memory (5b). The programmable controller according to claim 1, further comprising a sequencer bus (9) connected to said two memories (5a, 5b), said program executing microcomputer (3) and said program controlling microcomputer (1), said sequencer bus being alternately used by said program executing microcomputer and said program controlling microcomputer to access to said two memories. The programmable controller according to claim 2, wherein one instruction cycle of said program executing microcomputer (3) comprises an instruction fetch operation, a decoding operation, an address computation, an I/O access operation and an execution and wherein said sequencer bus (9) is monopolised by said program executing microcomputer (3) during said instruction fetch operation and said I/O access operation. The programmable controller according to claim 2 or 3, further comprising a microcomputer bus (8) which connects said program controlling microcomputer (3) via a bus interface (4) to said sequencer bus (9). A method for modifying an application program during program execution, running on a programmable controller comprising two memories (5a, 5b) each for storing an application program, a program executing microcomputer (3) for executing the application programs stored in said two memories (5a, 5b), said program executing microcomputer using the same addresses to access said two memories, a program controlling microcomputer (1) for controlling access to contents of said two memories (5a, 5b) and memory selecting means (6) for selecting access to one of said two memories (5a, 5b) on the basis of setpoint signals supplied from said program controlling microcomputer (1); said method comprising the steps of modifying the application program stored in a first one (5b) of said two memories while the program executing microcomputer (3) executes the application program fetched from a second one (5a) of said two memories in response to a first setpoint signal supplied to said memory selecting means (6) from said program controlling microcomputer (1); and switching said program executing microcomputer (3) to said first memory (5b) to fetch the modified application program therefrom in response to a second setpoint signal supplied to said memory selecting means (6) from said program controlling microcomputer (1) after the execution of said application program fetched from said second memory (5a) is finished by said program executing microcomputer (3). The method according to claim 5, wherein said modifying step comprises the steps of reading out said application program stored in said first memory (5b) by said program controlling microcomputer (1), updating said application program and restoring said updated application program into said first memory (5b) by said program controlling microcomputer (1). The method according to claim 6, wherein said modifying step comprises a further step of checking the updated application program for errors. The method according to any of claims 5 to 7, wherein said switching step comprises the steps of supplying an interrupt signal from said program executing microcomputer (3) to said program controlling microcomputer (1) after the execution of said application program fetched from said second memory (5a) is finished by said program executing microcomputer (3) and supplying said second setpoint signal to said memory selecting means (6) from said program controlling microcomputer (1) in response to said interrupt signal. The method according to any of claims 5 to 8, wherein one instruction cycle of said program executing microcomputer (3) comprises an instruction fetching operation, a decoding operation, an address computation, an I/O access operation and an execution and wherein a sequencer bus (9) connected to said two memories (5a, 5b), said program executing microcomputer (3) and said program controlling microcomputer (1) is monopolised by said program executing microcomputer (3) during said instruction fetch operation and said I/O access operation.

Inventors: ITOH ATSUSHI, SUNAGA TSUTOMU, ITOH, ATSUSHI, SUNAGA, TSUTOMU
Applicants: HITACHI LTD, HITACHI, LTD.
Application year: 1990
Main classification: G06F9
IPC codes: G06F9, G05B19