This application is based on Japanese Patent Application No. 2013-270477 filed with the Japan Patent Office on Dec. 26, 2013, the entire contents of which are incorporated herein by reference.
The present invention relates to a control system including a controller which periodically executes a user program and more particularly to a control system which is communicably connected to a server device.
Machines or facilities to be used at many production sites are typically controlled by a control system configured mainly by a control device such as a programmable logic controller (hereinafter referred to as a “PLC”) or the like. Such a control system can verify failures occurring in system configurations or operations afterwards.
The PLC described in Japanese Unexamined Patent Publication No. 2011-39643 as the prior art related to the control device is configured by a CPU and one or more extension units connected to the CPU, and functions as an FTP (File transfer Protocol) client in file transfer. The PLC accepts an input of set data which causes the PLC to function as the FTP client, and stores the set data which is accepted to be input. The PLC stores function assignment information including flag information about whether a predetermined function is assigned to the FTP client or not, and writes the flag information every predetermined function. In the case in which the PLC detects the write of the flag information, it executes the file transfer based on the stored set data.
In the PLC to be used in the control of production facilities, the FTP client function is used in a scene in which data on the production facilities is transmitted to a server device (an FTP server). In this case, a user changes a value of set information to be used in utilization of the FTP. For example, a user can change various variables to be file transfer targets (a directory name, a file name and the like), various variables for designating a transfer destination (an IP address of the FTP server, a directory name of the FTP server, a user ID and a password) and the like.
Referring to the Japanese Unexamined Patent Publication No. 2011-39643, it is necessary to prestore these set information to be changing targets and to connect a dedicated personal computer, thereby changing the setting in the change of the set information. In the case in which the change is carried out by using a dedicated tool, moreover, a system or a unit should be reset or initialized and the change cannot be carried out during an operation of a control program. In order to carry out the setting, furthermore, it is necessary to use the dedicated tool. If there is no dedicated tool or there is no skill for carrying out the setting by the dedicated tool, inconvenience is given to a user.
In consideration of the problems, it is an object of the invention to provide a control device capable of changing a set information value to be used in utilization of a communication protocol such as an FTP also during execution of a control program, and a communication control method in the control device.
According to an aspect of the invention, a control device controls a predetermined apparatus by communicating with a server device and executing a control program. The control device includes an executing unit configured to execute the control program, an acquiring unit configured to acquire data based on the control from the predetermined apparatus, a first communicating unit configured to communicate with the server device by using a predetermined communication protocol, and a memory configured to store a variable to be used in utilization of the communication protocol and a value of the variable correspondingly to each other. The control program includes an instruction for transmitting the data to the server device with the variable as an input variable. The data is transmitted to the server device based on the value of the variable when the instruction is started in order to execute the control program.
It is preferable that the control device should further include a second communicating unit configured to communicate with a programmable display unit and a setting unit configured to set the value of the variable based on a command sent from the programmable display unit.
It is preferable that the setting unit should set the value of the variable also during execution of the control program.
It is preferable that the control program should include description for setting the value of the variable.
It is preferable that the variable should include a name of data. The first communicating unit transmits, to the server device, data having a name of data designated by the variable based on an execution result of the control program with respect to the input.
It is preferable that the control device should further include a managing unit configured to manage the data by classifying the acquired data into a plurality of data groups having different names from each other in accordance with predetermined rules. The managing unit manages the data groups as files. The communication protocol is a file transfer protocol.
According to another aspect of the invention, a communication control method is executed in a control device for controlling a predetermined apparatus by communicating with a server device and executing a control program. The communication control method includes the steps of causing a processor of the control device to execute the control program, causing the processor to acquire data based on the control from the predetermined apparatus, and causing the processor to communicate with the server device by using a predetermined communication protocol. The control device stores a variable to be used in utilization of the communication protocol and a value of the variable correspondingly to each other. The control program includes an instruction for transmitting the data to the server device with the variable as an input variable. The communication control method further includes the step of transmitting the data to the server device based on the value of the variable when the instruction is started in order to execute the control program.
According to the invention, it is possible to make the change during the execution of the control program or after creation of the user program, that is, causing a user to create a set information value which is to be used in utilization of a communication protocol such as an FTP. Moreover, the user can create such a program as to be changeable following the set information.
An embodiment according to the invention will be described in detail with reference to the drawings. The same or corresponding portions in the drawings have the same reference numbers and description thereof will not be repeated.
First, a system configuration of a control system according to the embodiment will be described. In the embodiment, the description will be given of a programmable logic controller (PLC) configured to control a control target such as a machine or a facility, as a typical example of a control device. However, the control device according to the invention is not restricted to the PLC but can be applied to various control devices.
The PLC 100 communicates with the server device 400 via a communication based on an FTP (a file transfer protocol), which will be described below in detail. In other words, the PLC 100 has an FTP client function and functions as an FTP client. Moreover, the server device 400 has an FTP server function and functions as an FTP server.
The PLC 100 executes the following user program periodically or on an event basis. The user program is created by a user of the PLC 100. The user can create a program (a source program) including an access instruction by operating a support device (not shown), for example. The support device converts the source program into an executable format in the PLC 100 and transmits the converted user program to the PLC 100. The support device offers functions such as setting of various parameters, programming, monitoring or debugging together with the PLC 100. Typically, the PLC 100 and the support device are communicably configured in accordance with USB (Universal Serial Bus) standards.
The PLC 100 executes the user program and communicates with the server device 400 in accordance with an instruction included in the user program. In other words, the PLC 100 and the server device 400 are configured to exchange data through a network 112 such as Ethernet (registered trademark). The details of the processing will be described later.
The PLC 100 includes a CPU 104 configured to execute a control operation and at least one IO (Input/Output) unit 106. These units are configured to exchange data each other through a PLC system bus 108. Moreover, a power having a proper voltage is supplied to these units by a power supply unit 102.
In the control system 1, the PLC 100 exchanges data together with various field apparatuses through the IO unit 106 (connected through the PLC system bus 108) and/or a field bus 110. These field apparatuses include an actuator configured to perform some processing over a control target, a sensor configured to acquire various information from the control target, and the like. In
The programmable display unit 300 is communicably connected to the PLC 100 through a connection cable 114. The programmable display unit 300 displays, on a screen, various type of information acquired from the PLC 100. Moreover, the user operates the programmable display unit 300, thereby enabling change of the input variable values stored in the PLC 100, which will be described below in detail.
(b1. Hardware Configuration)
The processor 120 and the chip set 122 are typically configured according to a general-purpose computer architecture. In other words, the processor 120 interprets and executes an instruction code supplied sequentially from the chip set 122 in accordance with an internal clock. The chip set 122 exchanges internal data together with various components which are connected thereto, and furthermore, generates a necessary instruction code for the processor 120. The system clock 124 generates a system clock in a predetermined cycle and offers the system clock to the processor 120. The chip set 122 has a function for caching data obtained as a result of execution of arithmetic processing in the processor 120 or the like.
The CPU 104 has a main memory 126 and a nonvolatile memory 128 as storage units. The main memory 126 is a volatile storage area, and holds various programs to be executed by the processor 120 and is also used as a working memory in execution of the various programs. The nonvolatile memory 128 holds an OS (Operating system), a system program, a user program, log information and the like in a nonvolatile manner.
The Ethernet connector 130 is an interface configured to connect the programmable display unit 300 to the CPU 104. A USB connector (not shown) is an interface configured to connect a support device to the CPU 104. Typically, an executable program transferred from the support device or the like is fetched into the CPU 104 through the USB connector.
The CPU 104 has, as communicating units, a PLC system bus controller 140, a field bus controller 150, and a host communication controller 160. These communication circuits transmit and receive data.
The PLC system bus controller 140 controls data exchange through the PLC system bus 108. More specifically, the PLC system bus controller 140 includes a buffer memory 142, a PLC system bus control circuit 144, and a DMA (Dynamic Memory Access) control circuit 146. The PLC system bus controller 140 is connected to the PLC system bus 108 through a PLC system bus connector 148.
The field bus controller 150 includes a buffer memory 152, a field bus control circuit 154, and a DMA control circuit 156. The field bus controller 150 is connected to the field bus 110 through a field bus connector 158. The host communication controller 160 includes a buffer memory 162, a host communication control circuit 164, and a DMA control circuit 166. The host communication controller 160 is connected to the network 112 through a host communication connector 168.
The memory card interface 170 connects a memory card 172 which can be attached to and removed from the CPU 104, and the processor 120.
(b2. Software Configuration)
With reference to
The OS 180 offers a basic execution environment for the processor 120 to execute the system program 188 and the user program 186.
The system program 188 is a software group for offering a basic function of the PLC 100. Specifically, the system program 188 includes a sequence instruction program 190, an FTP processing program 192, an input/output processing program 194, a Tool interface processing program 196, and a scheduler 198.
On the other hand, the user program 186 is optionally created in response to a control purpose for a control target. In other words, the user program 186 is optionally designed depending on the target to be controlled by the control system 1.
The user program 186 implements a control purpose of a user in cooperation with the sequence instruction program 190. In other words, a programmed operation is implemented by utilizing an instruction, a function, a function module and the like offered by the sequence instruction program 190. For this reason, the user program 186 and the sequence instruction program 190 will also be referred to as the “control program 181”.
When a predetermined event occurs with the execution of the system program 188 and the user program 186, information about the occurring event is stored in a working log 184 in relation to time information. In other words, various information about the execution of the system program 188 and/or the user program 186 are stored as a log (history information) in the working log 184.
Each program will be described below in more detail.
The sequence instruction program 190 includes an instruction code group for calling an entity of a sequence instruction designated in the user program 186 with the execution of the user program 186 and implementing a content of the instruction.
The input/output processing program 194 serves to manage acquirement of input data and transmission of output data together with the IO unit 106 or various field apparatuses.
The Tool interface processing program 196 offers an interface for data exchange together with the support device.
The scheduler 198 generates a thread or a procedure for executing a control program in accordance with a predetermined priority, a value of a system timer, or the like.
The user program 186 is created depending on the control purpose of the user as described above. The user program 186 typically takes an object program format which can be executed in the processor 120 of the CPU 104. The user program 186 is generated by compiling a source program described in a ladder format or a function block format in the support device or the like. Then, the generated user program 186 in the object program format is transferred from the support device to the CPU 104 and is stored in the nonvolatile memory 128 or the like.
The FTP processing program 192 includes an instruction code group for implementing necessary processing for communicating with the server device 400 with the execution of the user program 186. The FTP processing program 192 includes an execution code corresponding to an instruction which can be designated in the user program 186.
The touch screen 318 has a display 381 and a touch panel 382 disposed to cover the display 381. The communication interface 319 has an IF (InterFace) for Ethernet (registered trademark) 391, an IF for serial 392, and an IF for USB (Universal Serial Bus) 393.
The CPU 311 expands a program stored in the flash ROM 314 into the RAM 313 or the like and executes the expanded program. The ROM 312 generally stores a program of an OS (Operating System) or the like. The RAM 313 is a volatile memory which is used as a work memory.
The IF for Ethernet 391 supports a communication protocol of the Ethernet and performs a data communication together with the PLC 100. The IF for serial 392 supports a serial communication protocol and performs a data communication together with a PC (Personal Computer), for example. The IF for USB 393 supports a USB communication protocol and performs a data communication together with a USB memory, for example.
Each component configuring the programmable display unit 300 shown in
With reference to
The server device 400 further includes a keyboard 410 and a mouse 412 which accept an operation from a user, and a monitor 414 configured to present information to the user. In addition, the server device 400 includes a communication interface (IF) 418 configured to perform a communication with the PLC 100 (the CPU 104) or the like. The server device 400 is communicably connected to the PLC 100 by the communication IF 418.
The PLC 100 has the FTP client function as described above, and can transfer (upload) a file in the memory card 172 from the PLC 100 serving as an FTP client to the server device 400 serving as an FTP server in an intranet by using an FTP client communication instruction. Moreover, it is also possible to transfer (download) the file from the server device 400 to the PLC 100.
Names of instructions (FTP client communication instructions) for implementing the file list acquiring function of the FTP server, the file uploading function to the FTP server, the file downloading function from the FTP server, the file deleting function of the FTP server, and the directory deleting function of the FTP server will also be referred to as an “FTPGetFileList instruction”, an “FTPGetFile instruction”, an “FTPPutFile instruction”, an “FTPRemoveFile instruction”, and an “FTPRemoveDir instruction”, respectively.
Each of the “FTPGetFileList instruction”, the “FTPGetFile instruction”, the “FTPPutFile instruction”, the “FTPRemoveFile instruction”, and the “FTPRemoveDir instruction” is offered as a function block. The user can include the respective instructions in the user program 186. The PLC 100 executes the user program 186, thereby implementing the FTP client function.
Referring to the user program 186 shown in
With reference to
With reference to
With reference to
“LocalDirName” representing a local directory name is an input variable for designating a directory (a directory of the PLC 100) storing a file to be uploaded to the FTP server. “FileName” representing a file name is an input variable for designating a file name of a file to be uploaded. A wild card can also be used for designating the file name.
“ExecOption” representing an FTP execution option is an input variable for designating an option related to FTP execution. For example, the “ExecOption” includes an input variable “OverWrite” for designating whether overwrite is permitted or not (see
With reference to
When each field apparatus is controlled by executing the control program 181 (in detail, an instruction other than the FTP client communication instruction), the acquiring part 1050 periodically acquires data based on the control from the field apparatus.
The data managing part 1060 writes the data acquired by the acquiring part 1050 to the memory card 172. In detail, the data managing part 1060 sequentially writes the data sequentially acquired by the acquiring part 1050 to a predetermined file stored in the memory card 172. In more detail, the data managing part 1060 classifies the acquired data into a plurality of files (data groups) having different names from each other in accordance with predetermined rules, thereby managing the data. These can be implemented by description in a user program created by the user.
The variable memory 1030 stores a variable referred to in the user program. The variable memory 1030 stores a plurality of input variables to be used in the utilization of the FTP (input variables for FTP setting) and values of the respective input variables correspondingly to each other. Specifically, the variable memory 1030 stores the input variable “ConnectSvr”, “SvrDirName”, “LocalDirName”, “FileName” or the like and a value of the input variable. The “value” is an expression which relates to a variable to be noted and corresponds to a thing indicated by the variable. In other words, the value includes not only the numeric value, but also a character string other than a numeric value. In the embodiment, an IP address of the FTP server is utilized as the input variable “ConnectSvr”.
The variable memory 1030 may include a variable having an attributes which is browsed and released to external apparatuses and a variable having an attributes to be used in an inner part.
The control program executing part 1040 executes the control program 181. The control program executing part 1040 executes an FTP communication instruction included in the user program 186 of the control program 181, and other instructions included in the control program 181. In that case, the control program 181 includes, as an input variable, the variable stored in the variable memory 1030 as shown in
The communicating part 1070 is an interface for communicating with the server device 400 to be the FTP server. The communicating part 1070 executes processing corresponding to the execution result of the control program executing part 1040. For example, the communicating part 1070 executes Put processing based on the FTPPutFile instruction (transfer of a file to the FTP server (upload)), Get processing based on the FTPGetFile instruction (acquirement of a file from the FTP server (download)), and Ls processing based on the FTPGetFileList instruction (acquirement of a file list from the FTP server).
In the Put processing, the communicating part 1070 transfers (transmits) a file designated by the input variable “FileName” in the directory of the memory card 172 specified by the input variable “SvrDirName”, to a directory designated by the input variable “SvrDirName” of the FTP server (the server device 400 in the embodiment) specified by the input variable “ConnectSvr” based on the execution result of the control program 181 obtained in the input of the value of the input variable stored in the variable memory 1030. Thus, the PLC 100 transmits data to the server device 400 based on the value of the variable when an instruction is started in order to execute the control program 181.
In the Ls processing, the communicating part 1070 acquires, from the FTP client, a file list included in the directory designated by the input variable “SvrDirName” of the FTP client specified by the input variable “ConnectSvr” (the server device 40 in the embodiment) based on the execution result of the control program 181 with respect to the value of the input variable stored in the variable memory 1030.
The communicating part 1010 is an interface for communicating with the programmable display unit 300. The setting part 1020 sets (updates) the value of the input variable stored in the variable memory 1030 based on a command sent from the programmable display unit 300 with a user operation.
According to the structure described above, the PLC 100 can transmit the data acquired from the field apparatus as a file to the server device 400 by the FTP with the value of the variable used in the FTP as the input variable of the control program. According to the PLC 100, therefore, it is possible to change the value of the variable used in the utilization of the FTP also during the execution of the control program 181.
(f1. Referring to Option Processing)
Next, the following processing is carried out in the case in which overwrite processing is prohibited in the input variable “ExexOption” in the FTPPutFile instruction (
The control program executing part 1040 determines, based on the file list acquired from the server device 400, whether a file having the same name as a name given by the data managing part 1060 is present in the server device 400 or not by the communication with the server device 400 through the communicating part 1070. In detail, the control program executing part 1040 utilizes the file list acquired based on the FTPGetFileList instruction, thereby determining whether a file overlapping with the file included in the directory designated by the input variable “LocalDirName” of the FTPPutFile instruction is present in the directory specified by the input variable “SvrDirName” of the FTPPutFile instruction (the directory of the server device 400) or not.
The communicating part 1070 transmits, to the server device 400, any of the files which is stored in the memory card 172 and is not determined to have the file with the same name based on the execution result of the control program with respect to an input. In detail, the communicating part 1070 transfers, to the directory designated by the input variable “SvrDirName” of the server device 400, any of the files included in the directory specified by the input variable “LocalDirName” which has no file with the same name in the directory designated by the input variable “SvrDirName”.
(f2. Example of Value of Input Variable)
With reference to
Moreover, a file name to be transferred is designated by using the wild card. Specifically, a value of the file name to be transferred represents text data (“*.txt”) included in the value (“”) of the input variable “LocalDirName”.
The value of the input variable “Overwrite” is “False” for prohibiting the overwrite. In the case in which the overwrite is permitted, the value of the input variable “Overwrite” is “True”.
With reference to
In step S104, the processor 120 starts the execution of the FTPPutFile instruction. In step S106, the processor 120 acquires, from the memory card 172, a file list of the files included in the directory (hereinafter referred to as a “directory DT”) designated by the input variable “LocalDirName”.
In step S108, the processor 120 sets a value of a predefined variable i to be “1”. In step S110, the processor 120 determines, based on the two acquired file lists, whether a file having a coincident file name with an i-th file included in the directory DT is present in the directory DS of the server device 400 or not.
If it is determined that the file is not present (NO in step S110), the processor 120 executes file transfer processing (Put processing) through the FTP in step S112. In step S114, the processor 120 outputs a file name of a transferred file as a value of the output variable “PutFileResult” representing an uploaded file result. If it is determined that the file is present (YES in step S110), the processor 120 outputs a file name of a transfer failure file as a value of the output variable “PutFileResult” in step S120.
In step S116, the processor 120 increments the variable i. In other words, the processor 120 increases a value of i by one. In step S118, the processor 120 determines whether the processing for outputting file names of all files included in the directory DT of the memory card 172 is ended or not. In other words, the processor 120 determines whether the execution of the FTPPutFile instruction is ended or not. If the processor 120 determines that the execution is not ended (NO in step S118), it returns the processing to step S110. If the processor 120 determines that the execution is ended (YES in step S118), it ends the serial processing.
Specifically, the PLC 100 previously recognizes the IP address of the FTP server configuring a network. For this reason, the processor 120 determines whether the FTP server designated by the input variable “ConnectSvr” is present or not depending on whether the recognized IP address is input or not. If the FTP server is present, moreover, the processor 120 determines whether the directory designated by the input variable “SvrDirName” is present in the FTP server or not. Furthermore, the processor 120 determines whether the directory designated by the input variable “LocalDir” is present in the memory card 172 or not. Moreover, the processor 120 determines whether the file designated by the input variable “Filename” is present in the directory designated by the input variable “LocalDir” or not.
If it is determined that the value is proper (YES in step S204), the processor 120 executes file transfer processing in step S206 and ends the serial processing. If it is determined that the value is not proper (NO in step S204), the processor 120 ends the serial processing.
With reference to
With reference to
The user inputs the value to each of the input boxes 821 to 823 and then selects the set button 828, thereby enabling setting (update) of the value of the variable stored in the variable memory 1030 (
With reference to
The user inputs the value to each of the input boxes 831 to 833 and then selects a set button 838, thereby enabling setting (update) of the value of the variable stored in the variable memory 1030 (
The value of the variable is set (updated) by the setting part 1020 of the PLC 100. The value of the variable is set (updated) also during the execution of the control program 181 as described above. Consequently, the user can change the FTP client communication instruction without interrupting the execution of the control program.
With reference to
In other words, the user program 186 further utilizes, as an input, a name of a file (hereinafter referred to as a “second file”) other than any of the files which is not determined to have a file with the same name in the directory designated by the server device 400 (which will be hereinafter referred to as a “first file”). Moreover, the control program executing part 1040 shown in
As described above, the PLC 100 automatically determines whether the transfer (transmission) failure file can be transferred again or not. For this reason, the user does not need to set the file name of the transfer failure file as the value of the input variable “FileName”.
It is also possible to rewrite a value of each input variable through the user program 186 configuring the control program 181.
With reference to
As described above, the PLC 100 can use, as the value of the input variable of the FTP client communication instruction, the output variable of the function block which is different from the function block of the FTP client communication instruction.
Although the description has been given by taking the FTP as an example of the communication protocol to be used in the communication between the PLC 100 and the server device 400, the invention is not restricted thereto. The invention can be applied to various communication protocols to be used in a data communication between the PLC 100 and the server device 400.
The embodiment disclosed herein is only illustrative in all respects and should not be construed to be restrictive. The scope of the invention is designated by the appended claims instead of the above description, and it is intended that all changes are contained in the claims and equivalent meanings and ranges.
Number | Date | Country | Kind |
---|---|---|---|
2013-270477 | Dec 2013 | JP | national |