I/O PROCESSOR FOR PROGRAMMABLE SEQUENCE CONTROLLER

Abstract: Data processing between selected I/O terminals (6a - 6n, 7a - 7n) is switched between processing by direct access to the I/O terminals and processing by indirect access through an image memory (41) having a one-to-one correspondence to the I/O terminals.

Description: BACKGROUND OF THE INVENTION FIELD OF THE INVENTION The present invention relates to a programmable sequence controller in accordance with the precharacterizing part of claim 1. Such a programmable sequence controller is known from US-A-4 172 289. DESCRIPTION OF THE PRIOR ART A sequence control system for controlling a number of equipments has been known as a programmable sequence controller which uses a microcomputer. An example of such controller is shown in Fig. 1. In Fig. 1, a sequence processing procedure is written by a user in a user program memory 1. A CPU 3 sequentially sends addresses a for the user program memory 1 to a program counter 2 so that a desired sequence processing procedure is read from the user program memory 1 to a memory data bus b . The data format thus sequentially read to the memory data bus b is shown in Fig. 2. It comprises an operation code field 100 in which the sequence processing procedure is stored and an operand field 101 in which an object number to be processed is stored. The operand field 101 of the memory data is supplied to an I/O controller 4, which designates the controlled object corresponding to the address designated by the operand field and reads therefrom and writes data therein through an input unit 6 and an output unit 7 which are interfaces to external. On the other hand, the operation code field 100 of the memory data is supplied to the CPU 3 and processing corresponding to the operation code is executed. The data of the corresponding controlled object is read or written through the I/O controller 4 as required. In such a programmable sequence controller, the CPU 3 usually operates in a process flow shown in Fig. 3. When the programmable sequence controller is powered on (60), the CPU 3 carries out initial processing (61) including checks to determine validity of the user-written program, and then it starts processing. In the processing, the program counter which points to the address of the user program is set to "0" (62) so that the user program is started from the beginning, an instruction is fetched (63) and executed (64). Thus, one step of operation is completed. The program counter is incremented (65) to execute the next step, and the next instruction is fetched. When the program counter is incremented, whether the instruction is the lost one or not is checked (66), and if it is not the last one, the process returns to the step 63. If it is the last one, final processing (67) to be described later is carried out and the program counter is set to "0" (62) so that the program is executed from the beginning. Thus, the programmable sequence controller sequentially and cyclically executes the user-written program. Fig. 4 illustrates this. One scan time (cyclic time) consists of a series of instruction processing (50) and final processing (51), and the instruction processing (50) is aggregation of one-step processings (500). One of important specifications required for the programmable sequence controller is an I/O response. It is a big problem to assure a high I/O response speed. If the response speed is high, a higher response to the data from the controlled object is assured and a control command is more rapidly issued as a result, a control precision is improved and the types of the controlled machines can be increased. In the prior art programmable sequence controller, the following approaches A and B have been adapted. A. The total scan time is reduced so that the response speed is increased. In this approach, as shown in Fig. 5, an I/O image memory 41 is provided in the I/O controller 4, and the processing by the CPU 3 in each scan time is carried out in a manner shown in Fig. 6, in which the content of the final processing (51) is exchanged between an external device and the image memory 41 through the input unit 6 and the output unit 7. On the other hand, the content of the instruction processing (50) is the aggregation (500) of the one-step processings (63), (64), (65), and the I/O data are read and written only between the image memory 41 and the CPU 3. In the approach A, the data exchange with the external devices through the input unit 6 and the output unit 7 is carried out in the final processing (51) collectively for several data, and in the processing of those data, the image memory 41 is sequentially accessed. As a result, the time required for each step is reduced, the total scan time is reduced and the response speed is increased. The reason for the reduction of the scan time is explained below. As shown in Fig. 7(a), units 1 - 4 which include the CPU 3 is usually physically spaced from the input unit 6 and the output unit 7 and they are coupled by a relatively long cable. Accordingly, a noise environment is bad. Therefore, if the CPU 3 without the image memory 41 accesses the data one by one to the external device, it is necessary that the time from the output of the address to the read or write time of the data (access time) is sufficiently long as shown in Fig. 10(c) is order to avoid the influence by the noise. As a result, the long access time is required for each step and the sum of them appears in one scan time. Thus, the total scan time is long. The program of the programmable sequence controller is usually written in a manner shown in Fig. 8(a) and executed in a manner shown in Fig. 8(b). The sequence controller has many external inputs/outputs, and it often has more than 256 inputs/outputs. Accordingly, each time they appear in the sequence program, the access times therefor are added. In the approach A, the external inputs/outputs are not transferred one by one but they are transferred collectively for a plurality of (usually 16) inputs/outputs in the final processing (51). Accordingly, the total time is much shorter than the sum of the access times and the overall scan time is reduced. However, in the approach A, the frequency of control to the external devices cannot be shorter than one scan time. In this approach, the external inputs are collectively read and processed, and then the results are collectively outputted. As a result, the response frequency is not shorter than one scan time. This may be an innegligible shortcoming to a particular controlled object and a range of application is narrow. B. One instruction is executed a plurality of times in one scan time. This approach is a contrast to the approach A. The I/O data are read and written when each instruction is executed. In this approach, an output instruction may be written immediately after an input instruction has been executed, and several such instructions are repeatedly written in the program. As a result, an apparent scan time is reduced and the I/O response is improved. However, in the approach B, since one instruction is executed a plurality of times in one scan time, the total number of steps increases and the total scan time increases. The programmable sequence controller by the approach B is disclosed in JP-A-58-121405. The programmable sequence controller known from US-A-4 172 289 scans a predetermined I/O device by immediate instruction at a higher rate than a basic scan rate. However the exchange of data between the I/O device and a processor is always carried out through an I/O image memory (I/O image table). The operations of the immediate instructions, represented by XCF, XOF and OEF which are set separately from ordinary instructions take additionally time in processing for the transfer of data through the I/O image table. Furthermore, since the immediate instructions are set anew separately from the ordinary instructions, these immediate instructions additionally occupy storage areas in a mapping table and a macro-instruction execution routine stored in a ROM. As a result the memory space becomes large. It is an object of the present invention to provide an I/O processor of a programmable sequence controller which attains sufficient reduction of a total scan time and sufficient high response speed to a controlled object. The above object is solved in accordance with the invention by the features characterized in claim 1. Further dependent claims 2 to 8 characterize advantageous developments thereof. By the progammable sequence controller according to the invention, the current status signal of the data I/O terminal can be read without routing the I/O image memory while maintaining the advantage of the approach A, and the result of the CPU can be immediately sent to the data output terminal. Thus, the response speed to the data to which the immediate I/O instruction is directly programmed is increased. BRIEF DESCRIPTION OF THE DRAWINGS Fig. 1 is a block diagram of a typical prior art sequence controller, Fig. 2 shows a format of a user program used in the prior art, Fig. 3 shows a flow chart of an operation of the sequence controller shown in Fig. 1, Fig. 4 shows an execution status of a known user program, Fig. 5 shows a block diagram of a typical prior art sequence controller, Fig. 6 shows an execution status of one scan time of a known user program, Fig. 7 shows connection between a main part of the sequence controller and an I/O interface, Fig. 8 shows a sequence ladder, Fig. 9 shows a block diagram of an embodiment of a sequence controller of the present invention, Fig. 10 shows an operation of the sequence controller of the present invention, Fig. 11 shows an flow chart of an operation of the sequence controller of Fig. 9, and Figs. 12 and 13 show execution status of the user program shown in Fig. 8. DESCRIPTION OF THE PREFERRED EMBODIMENTS An I/O processing method in the programmable sequence controller of the present invention is now explained with reference to the embodiments. Fig. 9 shows an embodiment of the present invention. Numeral 31 denotes an instruction decoder provided in a CPU 3, numeral 42 denotes a data selector provided in an I/O controller 4, and numeral 43 denotes a flip-flop provided in the I/O controller 4. The other numerals are identical to those shown in Figs. 1 and 5. In Figs. 1 and 5, a plurality of data input terminals 6a, 6b, ..., 6n connected to the interface 6 and a plurality of data output terminals 7a, 7b, ..., 7n connected to the interface 7 are omitted. When a direct I/O set instruction D s and a direct I/O reset instruction D r as shown in Fig. 10(a) are applied to the CPU 3, control lines (set line S ℓ and reset line R ℓ ) connected to the outputs of the instruction decoder 31 change depending on the instructions. In the I/O controller 4, the set line and the reset line are connected to a set input and a reset input of the flip-flop 43. Each time the direct I/O set instruction D s or the direct I/O reset instruction D r appears, the output of the flip-flop 43 changes and it is supplied to the data selector 42. Thus, the data selector 42 selects one of an external I/O data directly supplied from the input interface 6 and the output interface 7 and a data from the I/O image memory 41, and supplies the selected data to the CPU 3. The operation of the present embodiment is now explained. Let us assume that none of the direct I/O set instruction D s and the direct I/O reset instruction D r shown in Fig. 10 is contained in the program stored in the user program memory 1. In this case, the data selector 42 keeps selecting the image memory 41, and the processing for each step is executed by reading or writing data from or to the image memory 41. This is the same as the operation of the approach A and the control is attained with a sufficiently short total scan time. Let us assume that there is an external device which requires a special high response speed, and an I/O pair therefor are X₁₀ (input) and Y₁₀₀ (output). In this case, as shown in Fig. 10(a), an instruction set which comprises an instruction CG to the I/O pair X₁₀ and Y₁₀₀ sandwitched by the direct I/O set instruction D s and the direct I/O reset instruction D r is included a plurality of times in a series of programs and the control is attained by executing the programs. Thus, each time the program step encounters the instruction set CG, the flip-flop 43 is set by the direct I/O set instruction D s and the data selector 42 switches the CPU 3 from the image memory 41 to the direct access to the interfaces 6 and 7. Under this condition, the X₁₀ and Y₁₀₀ are executed, and the flip-flop 43 is again reset by the direct I/O reset instruction D r and the data selector 42 again selects the image memory 41. This operation is repeated a plurality of times in one scan time. In this case, the control to the input X₁₀ and the output Y₁₀₀ is of high response, and the control interval is much shorter than one scan time as shown in Fig. 10(b). The one scan time under this condition is shown in Fig. 10(c). The data exchange for the instructions of the program other than the instruction set CG is collectively done as is done in the approach A. Accordingly, the total scan time is sufficiently reduced. In Fig. 10, the instruction set CG appears two times in the series of programs. If it appears more frequently, the control interval will be more shortened. Even if the instruction set CG appears only one time, the output response speed for the instruction set CG is improved over the approach A and the scan time is shortened than that in the approach B. Fig. 11 shows a flow chart of the operation of the present embodiment. Only a difference from the flow shown in Fig. 3 is explained here. In the flow of Fig. 11, after the initial processing 61, the data status at the data input terminals 6a, 6b, ..., 6n and the data output terminals 7a, 7b, ..., 7n are read into the I/O image memory 41, a plurality of status at a time, from the input interface 6 and the output interface 7, in a step 61a. In a step 61b, whether all of the data status of the data input terminals and the data output terminals have been read into the I/O image memory 41 or not is checked. If the decision is NO, the process returns to the step 61a, and if the dicision is YES, the process proceeds to a step 62 and the steps 62 and 63 are carried out in the manner shown in Fig. 3. The step 64 in Fig. 3 corresponds to three steps 64a, 64b and 64c in Fig. 11. In the step 64a, whether the one-step instruction read in the step 63 includes the direct I/O set instruction D s or not is checked. It is checked by the instruction decoder 31. If the direct I/O instruction D s is included, the flip-flop 43 is set to the first state (64d) and the data selector causes the CPU 3 to read the data directly from the I/O interfaces 6 and 7. If the instruction read in the step 63 is not the direct I/O instruction D s , the process proceeds to a step 64b. In the step 64b, whether the one-step instruction read in the step 63 includes the direct I/O reset instruction D r or not is checked by the instruction decoder 31. If the decision is YES, the flip-flop 43 is set to the second state (64e) and the data selector 42 causes the CPU 3 to connect with the I/O image memory 41. If the reset instruction is not present, the process proceeds to the following step 64c. In the step 64c, the essentially same operation as that of the step 64 in Fig. 3 is carried out. The CPU 3 reads in the data from the I/O interfaces 6 and 7 or the I/O image memory 41, and performs logical operations based on the read-in data. In steps 67a and 67b, the data in the I/O image memory 4l are sent, a plurality of data at a time, to the data output terminals 7a, 7b, ..., 7n. In the step 67b, whether all data have been sent or not is checked. Fig. 12 shows a time sequence chart of the program structure described above. A big difference in Fig. 12 from Fig. 4 is that a signal read-in step 61a' is prior to the instruction processing step 50. Fig. 13 shows an operation where the direct I/O set instruction D s is included in S₆ of the instruction processing step 50 and the direct I/O reset instruction D r is included in S₉. In steps S₁ - S₅, the data of the I/O image memory is read into the CPU 3 and the operation result of the CPU 3 is supplied to the I/O image memory. The same operation is carried out in steps S₁₀ - S n . In steps S₆ - S₉, the data at the data input terminals are directly read into the CPU 3, and the operation result of the CPU 3 is directly sent to the data output terminals. In the present embodiment, the I/O image memory reads in the data at the data output terminals through the data selector. Alternatively, the data may be directly supplied from the CPU. The direct input instruction may be effective only when the data is read from the data I/O interface, or direct output instruction may be effective only when the data is sent to the data output interface.

Claims: A programmable sequence controller comprising: a user program memory (1) for storing a program; a processor (3) connected to said user program memory for performing logical processing cyclically in accordance with the program; an instruction decoder (31) provided in said processor for detecting an instruction in said program; an I/O controller (4) connected to said processor; a plurality of data input and data output terminals (6a - 6n, 7a - 7n) connected to said I/O controller; and an I/O image memory (41) connected to said I/O controller for storing data status of said data input and data output terminals, wherein said processor (3) performs temporary logic processing with respect to a predetermined one of said data input and data output terminals during the cyclic logical processing; characterized in that said user program memory (1) includes a direct I/O instruction in the sequence processing procedure stored therein for designating a step requiring direct input of data from a selected one or ones of said data input terminals and direct output of the result of the processing by said processing means using the direct-input data as parameters, to said data output terminals; said processor (3) performs said temporary logic processing when said instruction decoder (31) detects said direct I/O instruction; and said I/O controller (4) includes a data selector (42) connected to said processor (3) via a data bus, and switching means (43) connected to said instruction decoder for selectively switching the connection of said data selector (4) such that when said direct I/O instruction is detected by said instruction decoder (31), said data input and data output terminals are connected to said data selector, and when said direct I/O instruction is not detected, said I/O image memory (41) is connected to said data selector (42). A programmable sequence controller according to claim 1 characterized in that said user program memory (1) stores a program containing a direct I/O set instruction and a direct I/O reset instruction; and said switching means (43) connects said data input and data output terminals to said data selector from a time when said instruction decoder detects in said program a step containing said direct I/O set instruction and said switching mans connects said I/O image memory to said data selector when said instruction decoder detects in said program a step containing said direct I/O reset instruction. A programmable sequence controller according to claim 2 wherein said switching means includes a flip-flop provided in said I/O controller and connected to said data selector, said flip-flop being set to a first state when said instruction decoder detects a direct I/O set instruction and to a second state when said instruction decoder means detects a direct I/O reset instruction, wherein said first state of said flip-flop, causes said data selector to be connected to one or more of said data input and output terminals thereby inputting data from one or more of said data input terminals to said processor and outputting results of logical operations performed by said processor to selected one or one of said data output terminals, and wherein said second state of said flip-flop, causes said data selector to be connected to said I/O image memory thereby inputting data from said I/O image memory to said processor and outputting results of logical operations performed by said processor to said I/O image memory. A programmable sequence controller according to claim 1, characterized in that said user program memory (1) stores a program containing a direct I/O set instruction and a direct I/O reset instruction; and said switching means (43) connects data input and data output terminals to said data selector from a time when said instruction decoder detects a step containing said direct I/O set instruction until said instruction decoder detects in said program a step containing said direct I/O reset instruction, and said switching means connects said I/O image memory to said data selector when the step containing said direct I/O set instruction is not detected. A programmable sequence controller according to claim 4 wherein said switching means includes a flip-flop provided in said I/O controller and connected to said data selector, said flip-flop being set to a first state when said instruction decoder detects a direct I/O set instruction and to a second state when said instruction decoder detects a direct I/O reset instruction, wherein said first state of said flip-flop causes said data selector to be connected to one or more of said data input and output terminals thereby inputting data from one or more of said data input terminals to said processor and outputting results of logical operations performed by said processor to selected one or ones of said data output terminals, and wherein said second state of said flip-flop, causes said data selector to be connected to said I/O image memory thereby inputting data from said I/O image memory to said processor and outputting results of logical operations performed by said processor to said I/O image memory. A programmable sequence controller according to claim 1, characterized in that said user program memory (1) stores a program containing a direct output instruction; and said switching means (43) connects said data output terminals to said data selector from a time when said instruction decoder detects in said program a step containing said direct output instruction and said switching means connects said I/O image memory to said data selector when the program step containing said direct output instruction is not detected by said instruction decoder. A programmable sequence controller according to claim 1, characterized in that said user program memory (1) stores a program containing a direct input instruction; and said switching means (43) connects said input terminals to said data selector from a time when said instruction decoder detects in said program a step containing said direct input instruction and said switching means connects said I/O image memory to said data selector when the program step containing said direct input instruction is not detected by said instruction decoder. A programmable sequence controller according to claim 1, characterized in that said user program memory (1) includes an area for storing a direct I/O instruction in said program; and said instruction decoder (31) detects said direct I/O instruction from said area in said user program memory.

Inventors: FUJIWARA, KATSUHIRO, KASAHARA, TOSHIRO, OSHIGA, TAKAYUKI
Applicants: HITACHI, LTD.
Application year: 1986
Main classification: G05B19
IPC codes: G05B19