Programmable logic controller
The programmable logic controller system addresses file overwriting and cycle time issues by enabling easy file and folder listing through a list acquisition command, optimizing processing efficiency and reducing exclusive waiting times.
Patent Information
- Application Number
- JP2024024321
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2024-02-21
- Publication Date
- 2025-09-02
AI Technical Summary
PLCs face issues with file overwriting and slower cycle times due to mismatched file names, and the need for easy file and folder listing is unmet, especially when external devices transfer files without fixed names.
A programmable logic controller system that includes a program execution unit, data memory, and a file memory with a file system, enabling the identification and listing of files and folders through a list acquisition command, allowing separate processing of file listing and user program execution to minimize scan time fluctuations.
Facilitates easy file and folder listing, reduces file overwriting risks, and optimizes cycle times by allowing simultaneous processing of file listing and user program execution, enhancing operational efficiency.
Smart Images

Figure 2025127557000001_ABST
Abstract
Description
[Technical Field]
[0001] The present invention relates to a programmable logic controller. [Background technology]
[0002] In factory automation, programmable logic controllers (PLCs) are the core controllers that control industrial machinery. PLCs often collect files that maintain the control history of industrial machinery, image files that capture the operation of industrial machinery, and image files that capture the products (workpieces) manufactured by industrial machinery.
[0003] There are times when you want to rename a file collected by a PLC to a desired name. Patent Document 1 proposes a technique for renaming a file so that data indicating a change in the device's status is included in the file name. In the field of PLCs, a device refers to a memory area where 1 bit of data or 1 word of data is stored. [Prior art documents] [Patent documents]
[0004] [Patent Document 1] Japanese Patent Application Laid-Open No. 2004-302629 Summary of the Invention [Problem to be solved by the invention]
[0005] PLCs are connected to various external devices, such as cameras, and these devices may transfer files to the PLC. If the name of a file already stored in the PLC matches the name of the file the external device is attempting to transfer, the file stored in the PLC will be overwritten by the file being transferred from the external device, resulting in the loss of valuable files. Alternatively, the camera may be configured to treat an existing file with the same name as an error instead of overwriting it. This can result in slower cycle times. To avoid such overwriting, the file stored in the PLC must be renamed. Furthermore, to perform a rename, the PLC must identify the name of the file to be renamed. However, if the file transferred from the external device does not have a fixed name, the PLC cannot identify the file name. Therefore, external devices transfer files with a fixed name known to the PLC, and when the PLC receives a file with a known fixed name, it renames the fixed name to a different name. Thus, when a file is renamed on the PLC side, the external device cannot transfer the next file to the PLC until the rename is complete to avoid overwriting. As a result, the cycle time between the PLC and the external device is slower.
[0006] As file names are necessary to perform certain operations on files, there is a need for PLCs to easily obtain lists of files and folders. Therefore, an object of the present invention is to make it possible to easily obtain lists of files, etc. in a PLC. [Means for solving the problem]
[0007] The present invention is, for example, a program execution unit that executes a user program; a data memory that is accessed by the program execution unit in accordance with the user program executed by the program execution unit, and at least a portion of the memory area of which is refreshed every scan; a file memory formatted with a file system for storing files; The programmable logic controller is characterized in that, when the program execution unit executes a list acquisition command based on the user program, it identifies one or more files that are stored in the file memory and are the target of the list acquisition command, and stores a list of the names of each of the identified one or more files in the data memory. [Effects of the Invention]
[0008] According to the present invention, a list of files and the like in a PLC can be easily obtained. [Brief explanation of the drawings]
[0009] [Figure 1] A diagram explaining a PLC system. [Figure 2] FIG. 2 is a diagram illustrating a basic unit. [Figure 3] FIG. 2 is a diagram illustrating an external device. [Figure 4] 10 is a flowchart illustrating a method for creating a file list. [Figure 5] 10 is a flowchart illustrating a method for creating a file list. [Figure 6] 10 is a flowchart illustrating a method for creating a file list. [Figure 7] A diagram explaining how to create a file table that serves as the basis for a file list. [Figure 8] FIG. 10 is a diagram illustrating a file list acquisition command. [Figure 9] FIG. 10 is a diagram for explaining an instruction for reading multiple rows. [Figure 10] A diagram explaining the directory structure. [Figure 11] FIG. 10 is a diagram illustrating a file list. DETAILED DESCRIPTION OF THE INVENTION
[0010] Hereinafter, the embodiments will be described in detail with reference to the accompanying drawings. Note that the following embodiments do not limit the scope of the invention as claimed, and not all combinations of features described in the embodiments are necessarily essential to the invention. Two or more of the features described in the embodiments may be arbitrarily combined. Furthermore, the same reference numerals are used for the same or similar components, and redundant explanations will be omitted.
[0011] <PLCシステム> FIG. 1 shows an example of a programmable logic controller system (hereinafter referred to as a PLC system 1) according to an embodiment of the present invention. As shown in FIG. 1, this PLC system 1 includes a base unit 2, which is a PLC (programmable logic controller) for comprehensively controlling various control devices installed in a factory or the like, and an expansion unit 3 connected to the base unit 2. One or more expansion units 3 (e.g., I / O unit, analog input unit, analog output unit, communication unit, expansion unit 3, etc.) are connected to the base unit 2. The base unit 2 is sometimes called a CPU unit. An external device 4 is also connected to the base unit 2. The base unit 2 and the expansion unit 3 can communicate with each other via a communication bus. A connector for connecting the communication buses may be provided on the connection surface between the base unit 2 and the expansion unit 3. The base unit 2 and the external device 4 can communicate with each other via a communication cable 9.
[0012] The basic unit 2 has a display unit 5 and an operation unit 6. The display unit 5 is a liquid crystal display or organic electroluminescence (EL) display that displays the operating status of the expansion unit 3. The display unit 5 may switch its display content depending on the operation of the operation unit 6. The display unit 5 typically displays the current values (device values) of devices in the PLC system 1 and error information (whether or not an alarm or warning has occurred) that has occurred within the PLC system 1. A device is a memory area provided for storing device values (device data) and is sometimes called data memory or device memory. Device values are information that indicates the input status from input devices, the output status to output devices, and the status of internal relays (auxiliary relays), timers, counters, data memories, etc. set in the user program. Device values are classified into bit and word types. A bit device stores a 1-bit device value. A word device stores a 1-word device value.
[0013] As an example, the expansion unit 3 may store image data acquired by a camera 10 and transfer the image data to the base unit 2 using file transfer protocol (FTP). The camera 10 is installed, for example, to capture moving images of an industrial robot controlled by the PLC system 1. The base unit 2 may have a memory card 7, and the image data transferred by FTP may be stored in the memory card.
[0014] <Basic unit> FIG. 2 shows the hardware configuration of the basic unit 2. The CPU 11 is a processor that controls the PLC system 1 according to a control program. The CPU 11 writes information to and reads information from the memory 14. The memory 14 includes a random access memory (RAM), a read-only memory (ROM), a hard disk drive (HDD), and a solid state drive (SSD), and may further include a removable memory card 7. A ladder program 21, which is an example of a user program executed by the CPU 11, is stored in the ROM area of the memory 14. The data memory 22 has a device memory 23 and a variable memory 24 as storage areas reserved for executing the ladder program 21. The buffer 26 is a storage area for temporarily storing information.
[0015] The memory card 7 has a file memory 25 formatted by a file system. The memory card 7 is merely one example of a storage (storage device) in which files are stored, and other types of storage devices may be used as long as they are capable of storing files.
[0016] The CPU 11 communicates with the external device 4 via the communication unit 15 and stores image data transmitted from the external device 4 in the file memory 25. For example, the CPU 11 may function as an FTP server by executing an FTP server program. The CPU 11 may also function as an FTP client and write files to a network drive, network attached storage (NAS), or the like.
[0017] The CPU 11 may have multiple CPU cores 12 and 13. For example, the CPU core 12 is a processing circuit that functions as a program execution unit that executes the ladder program 21. The CPU core 12 and the CPU core 13 may be mounted in separate CPU packages that are physically separated from each other.
[0018] Furthermore, the CPU 11 may control the PLC system 1 in accordance with a user's instruction input from the operation unit 6, or may display the execution result of the ladder program 21 on the display unit 5.
[0019] <External device> FIG. 3 shows the structure of the external device 4. The external device 4 has a CPU 31, a memory 32, a communication unit 33, and a camera IF 34 (optional). IF is an abbreviation for interface. The CPU 31 functions as a camera control unit 35 by executing a camera control program 37 stored in the memory 32. The camera control unit 35 controls the camera 10 via the camera IF 34, creates image data 39, and stores it in the memory 32. The CPU 31 functions as an FTP client 36 by executing an FTP client program 38. The FTP client 36 may communicate with an FTP server (basic unit 2) and send the image data 39 to the FTP server.
[0020] <Flowchart> In this embodiment, the CPU 11 stores a list (file list) of file information stored in the memory card 7 of the basic unit 2 in the device memory 23 or the variable memory 24. As a result, the CPU 11 provides information about the files stored in the memory card 7 to the external device 4, the expansion unit 3, etc. The file information is information including, for example, the name of the file and the state of the file (e.g., modification date and time, attributes), etc.
[0021] (1) Single-core CPU case 4 shows a control method executed by the CPU 11. The control method is assumed to be described, for example, in the ladder program 21. The objects to be acquired in the file list are, for example, files and folders (directories) stored in the memory card 7.
[0022] In S1, the CPU 11 sets a setting parameter indicating what kind of file information is required for a command (e.g., a function block) written in the ladder program 21, and executes this command. This command may be called, for example, a file information list acquisition command. Here, the setting parameter may include, for example, the following information: Directory Name: The name of the directory from which file information is to be obtained. Filter file name: The file name to be extracted from the list of files. Sort by: Criteria for sorting multiple file information (file name, file update date and time) ·Sort order: Ascending / Descending Maximum number of files to be retrieved: Maximum number of files to be retrieved · File information acquisition destination: A variable that indicates the storage destination for the file information to be acquired.
[0023] In S2, the CPU 11 opens the directory specified by the setting parameters.
[0024] In step S3, the CPU 11 reads a directory entry from the opened directory. The directory entry contains, for example, the following information: File name: The name of the file File creation date and time, update date and time: The date and time when the file was created or updated File Attributes: Attributes assigned to the file (folder, hidden, archive, etc.) File size: The size of the file. A directory entry exists for each file and folder stored in the directory.
[0025] In S4, the CPU 11 determines whether or not a file (file, folder) exists in the directory based on the read directory entry. If a file exists, the CPU 11 proceeds from S4 to S5. If a file does not exist, the CPU 11 proceeds from S4 to S7.
[0026] In S5, the CPU 11 determines whether the file name included in the directory entry matches the filter file name, which is one of the setting parameters (optional). If the two do not match, the CPU 11 returns from S5 to S3 and reads the next directory entry.
[0027] In S6, the CPU 11 registers the directory entry (file information) in the file list and stores the file list in the buffer 26.
[0028] In S7, the CPU 11 closes the directory specified by the setting parameters.
[0029] In S8, the CPU 11 stores the file list held in the buffer 26 in the data memory 22. For example, the file list may be stored in a series of device memories 23 starting from a specific address. Writing the file list to the data memory 22 may be executed, for example, in the end processing of the ladder program 21.
[0030] In S9, the CPU 11 executes a command completion process. For example, the CPU 11 switches a relay device indicating the completion of a command in a command word (e.g., a function block) written in the ladder program 21 from off to on.
[0031] As a result, a file list is stored in the specified device memory 23 or the like, and based on the file list, it becomes clear what file names are stored in the memory card 7 or the like.
[0032] (2) Multi-core CPU case If a file list acquisition process is executed in parallel with the execution of the ladder program 21 on a single-core CPU, the scan time of the ladder program 21 may be extended. Depending on the type of device controlled by the ladder program 21, it is desirable that the scan time not fluctuate as much as possible.
[0033] Therefore, the CPU core 12 is set as the processor that executes the ladder program 21, and the CPU core 13 is set as the processor that executes the process of acquiring the file list. This reduces the fluctuation in the scan time of the ladder program 21.
[0034] (2-1) Processing performed by CPU core 12 for ladder program execution 5 shows the processing executed by the CPU core 12 in accordance with the ladder program 21. It is assumed that the file information list acquisition command is written in the ladder program 21. In addition, the objects to be acquired in the file list are, for example, files and folders stored in the memory card 7.
[0035] In S11, the CPU core 12 sets a setting parameter that indicates what file information is required for the command (e.g., function block) written in the ladder program 21. The setting parameter is as described in relation to S1.
[0036] In S12, the CPU core 12 sends a command to acquire a file list to the CPU core 13 in accordance with the command word. At this time, the CPU core 13 is also passed setting parameters.
[0037] In S13, the CPU core 12 determines whether there is a write request from the CPU core 13. For example, in the end processing of the ladder program 21, the CPU core 12 determines whether there is a write request from the CPU core 13 to the data memory 22 (e.g., device memory 23, variable memory 24). If there is a write request, the CPU core 12 proceeds from S13 to S14. If there is no write request, the CPU core 12 proceeds from S13 to S16.
[0038] In S14, in response to a write request from the CPU core 13, the CPU core 12 writes the file list held in the buffer 26 into the data memory 22 (for example, the device memory 23 and the variable memory 24).
[0039] In S15, the CPU core 12 sends a completion response indicating that writing of the file list has been completed to the CPU core 13, and then returns to S13. Note that the sending of the completion response may be realized by switching a specific relay device assigned to the completion response from off to on.
[0040] In S16, the CPU core 12 determines whether a completion notification has been received from the CPU core 13. If a completion notification has not been received, the CPU core 12 returns from S16 to S13. If a completion notification has been received, the CPU core 12 proceeds from S16 to S17. Receipt of the completion notification may also be achieved by switching a specific relay device assigned to the completion notification from off to on.
[0041] In S17, the CPU 11 executes a command completion process. For example, the CPU 11 switches a relay device indicating the completion of a command in a command word (e.g., a function block) written in the ladder program 21 from off to on.
[0042] As a result, a file list is stored in the specified device memory 23 or the like, and based on the file list, it becomes clear what file names are stored in the memory card 7 or the like.
[0043] (2-2) Processing performed by the CPU core 13 for peripheral processing FIG. 6 shows the process of obtaining a file list executed by the CPU core 13.
[0044] In S21, the CPU core 13 receives a file information list acquisition command together with the setting parameters from the CPU core 12.
[0045] In S22, the CPU core 13 opens the directory specified by the setting parameters.
[0046] In S23, the CPU core 13 reads a directory entry from the opened directory. The directory entry is as described in relation to S3.
[0047] In S24, the CPU core 13 determines whether a file or folder exists in the directory based on the read directory entry. If a file or folder exists, the CPU core 13 proceeds from S24 to S25. If a file or folder does not exist, the CPU core 13 proceeds from S24 to S27.
[0048] In S25, the CPU core 13 determines whether the file name included in the directory entry matches the filter file name, which is one of the setting parameters. If the two do not match, the CPU core 13 returns from S25 to S23 and reads the next directory entry.
[0049] In S26, the CPU core 13 registers the directory entry (file information) in the file list and stores the file list in the buffer 26.
[0050] In S27, the CPU core 13 closes the directory specified by the setting parameters.
[0051] In S28, the CPU core 13 sends a write request to the CPU core 12 to write the file list held in the buffer 26 to the data memory 22.
[0052] In S29, the CPU core 13 waits for a completion response sent from the CPU core 12. When the completion response is received, the CPU core 13 proceeds from S29 to S30.
[0053] In S30, the CPU core 13 executes the completion process of the instruction.
[0054] As a result, a file list is stored in the specified device memory 23 or the like, and based on the file list, it becomes clear what file names are stored in the memory card 7 or the like.
[0055] <Split file list transfer> As the number of files stored in the memory card 7 increases, the time it takes for the CPU core 12 to write the file list passed from the CPU core 13 increases. As a result, the scan time of the ladder program 21 may become longer.
[0056] The CPU core 12 compares the data size of the file list stored in the buffer 26 with a threshold value. If the data size of the file list exceeds the threshold value, the CPU core 12 divides the file list into multiple sub-data sets and writes each of the multiple sub-data sets sequentially to the data memory 22 in different end processes. This makes it possible to suppress localized delays in scan time.
[0057] <Getting a list of some files> When a large number of files are stored in the memory card 7, the user may wish to obtain a list of N files in file name order. Also, when a large number of files are stored in the memory card 7, the user may wish to reduce the amount of space consumed by the buffer 26 and data memory 22 for storing the file list.
[0058] Therefore, in this embodiment, an upper limit is set for the number of pieces of file information to be acquired. This upper limit may be specified by the CPU core 12 to the CPU core 13 as one of the setting parameters (maximum number of acquisitions), for example. Alternatively, the upper limit may be set in the CPU core 13 in advance.
[0059] 7 shows the procedure for creating file list information (table) executed by the CPU core 13. In this example, for simplicity of explanation, the upper limit value is set to 1000. Tables 701 to 705 show changes over time in the file list information (table). The file list information (table) includes, for example, an index for identifying each piece of file information, a file name, an update date and time, and attributes.
[0060] Table 701 shows an empty table.
[0061] Table 702 shows the state in which the first directory entry is read from the memory card 7. The first directory entry indicates that the file has the file name BBB.csv.
[0062] Table 703 shows the state in which the second directory entry has been read from the memory card 7. The second directory entry indicates that the file has the file name AAA.csv. Here, the CPU core 13 sorts the files in ascending order based on the file names specified by the setting parameters. Therefore, in table 703, AAA.csv is listed above BBB.csv.
[0063] Table 704 shows the state in which the 1000th directory entry has been read from memory card 7. Information on 1000 files from index "0" to index "999" is registered in table 704.
[0064] Here, assume that the 1001st directory entry is the directory entry for AAB.csv. Based on the sorting rules, CPU core 13 inserts AAB.csv between AAA.csv and BBB.csv, and the index of each file after BBB.csv is decremented by one. As a result, table 705 is created. Comparing table 705 with the immediately preceding table 704, it is found that YYY.csv, which was located at the bottom of table 704, is deleted from table 705.
[0065] In this way, when the CPU 11 or CPU core 13 is instructed by the first processor to create a list consisting of a specified number of names, the CPU 11 or CPU core 13 associates the names with indexes up to the specified number so as to satisfy the sorting conditions. When the CPU 11 or CPU core 13 acquires a name that should be ranked higher in the list than a name associated with a certain index, the CPU 11 or CPU core 13 may associate the name associated with the certain index with the index next to the certain index, and associate the other name with the certain index, thereby sorting the names each time the CPU 11 or CPU core 13 acquires a name.
[0066] Here, sorting is performed by file name, but sorting may also be performed based on update date and time or attributes specified by setting parameters. Also, the sorting rule may be descending order instead of ascending order.
[0067] In this way, by setting an upper limit value (maximum number of acquisitions) for file information, the user can acquire only a specific number of file information items. For example, a file list containing information on N files in file name order is created and saved in the data memory 22. Alternatively, a file list containing information on the most recent N files may be created and saved in the data memory 22. The user can acquire a preferred file list by specifying the upper limit value (maximum number of acquisitions) and sorting rules in the setting parameters. This also makes it possible to reduce the amount of data memory 22 consumed.
[0068] <filter> A user may wish to obtain file information about files or folders that meet specific conditions (e.g., a specific extension, a file name / folder name containing specific characters). Therefore, a filter may be set as a configuration parameter. For example, a wildcard character (*) may be used in the filter file name, which is introduced as one of the configuration parameters.
[0069] (1) To get file information for a file with a specific extension (e.g., csv): Filter file name: "*.csv" (2) To get file information for a file whose file name contains a specific character (e.g., 20231001): Filter file name: "20231001*" This example is for a forward match. Depending on the position of the wildcard, it is possible to specify a backward match (e.g. *20231001) or partial match (e.g. *20231001*) filter.
[0070] This allows the CPU 11 and CPU core 13 to create a file list by filtering file information based on the characters specified in the filter file name.
[0071] <Number of files for which file information was obtained> When writing file information obtained from a directory entry to buffer 26 as part of the file list, CPU 11 and CPU core 13 may increment a counter (variable uiResultNum) indicating the number of files for which file information was obtained. CPU 11 and CPU core 13 may output the count value of this counter as a return value (output argument) in response to the file list obtainment command. This allows the user to easily know the number of pieces of file information included in the file list. The number of pieces of file information included in the file list may be stored in a specific device memory 23 or a specific variable memory 24.
[0072] <Examples of commands> FIG. 8 shows an example of a command (for example, a function block 800) that can be written in the ladder program 21 to obtain a file list.
[0073] The input arguments (setting parameters) for this command are as follows:
[0074] DirPath: The directory name for which you want to get a list of files SearchFileName: Search file name (file name for filter) Order: Sort order (ascending / descending) MaxFileListNum: Maximum number of files to retrieve (upper limit) FileList: File list storage location (user variable area) The data type of the FileList may be an array type of a dedicated structure for file information, or may be any type that occupies a predefined data size for file information.
[0075] The output arguments of this command are as follows:
[0076] ResultNum: The number of files for which file information was obtained. Busy: Indicates whether the command is being executed or not Error: Indicates whether an error has occurred. ErroID: Indicates the error identification information FileList: File list storage location (user variable area) In this way, the file information list acquisition command may be realized by the function block 800.
[0077] <Command to read text by specifying the number of lines from a specific text file> Generally, a log data file of a facility contains measured values obtained at different times arranged in chronological order.
[0078] DATA No. DATE TIME Pressure Flow rate ... 0 2023 / 10 / 01 11:20:09 91 653 1 2023 / 10 / 01 11:20:10 94 648 2 2023 / 10 / 01 11:20:11 97 647 3 2023 / 10 / 01 11:20:12 100 640 4 2023 / 10 / 01 11:20:13 103 632 Users may sometimes request to read data from such text files as character strings. Generally, the PLC system 1 is provided with a command to read one line of character string from any position up to the line feed code. For example, to read 1000 lines of character string from the beginning of a text file, this command must be repeated 1000 times. However, this has the following problems:
[0079] To read one line, a read request and a read completion notification are required. This must be repeated 1,000 times. The sending of the read request and the receipt of the completion notification are affected by the scan time of the ladder program 21. Therefore, the longer the scan time, the longer it takes to read the character string.
[0080] Therefore, in this embodiment, the maximum number of lines to be read is added as an input argument to the text read command, which makes it possible to read multiple lines with one command word.
[0081] Note that the number of lines actually read may be added as an output argument, which would allow checking the number of newline characters also contained in the read string if the number of lines read is less than the maximum number of lines read.
[0082] FIG. 9 shows an example of a command (function block 900) for reading text by specifying the number of lines from a specific text file.
[0083] The input arguments (setting parameters) for this command are as follows:
[0084] Path: The file name (with path) of the text file from which the string is read. MaxReadLineNum: Maximum number of lines read from a text file. MaxByteSize: Maximum size of string read from text file (in bytes) ReadPos: The position (in bytes) of the string to be read from the text file. Dst: Destination for the string read from the text file The output arguments of this command are as follows: Note that the explanation of arguments that have already been explained will be omitted.
[0085] ByteSizeRes: The size of the string actually read from the text file (in bytes). ReadLineNum: The number of lines actually read from the text file. EOF: Notification that the end of the file has been detected NoCRLF: Notification that the read string does not contain a line break code By including such a function block 900 in the ladder program 21, a user can read a desired number of lines of text from a desired file using a single command. This makes the time required to read the text less susceptible to the scan time.
[0086] <Example of file list> 10 shows the files and directory structure stored in the file memory 25 of the memory card 7. Under the root, there is a folder with the directory name "test." In test, there are folders with the directory names 0001_OK.csv, 0002_OK.csv, and Dir1_1.
[0087] 11 shows a list of files acquired from the memory card 7 and stored in the device memory 23. In this example, the file information for each file includes the file name and file status. The file status includes information indicating the date and time the file was modified, the file size, attribute information indicating whether the file is read-only, attribute information indicating whether the file is hidden, attribute information indicating whether the file is a system file, attribute information indicating whether the file is a volume label, attribute information indicating whether the file is a folder, attribute information indicating whether the file is archived, and an area reserved for future use.
[0088] At the end of the file list 1100, the number of pieces of file information included in the file list 1100 (e.g., 3 pieces) is stored. In other words, this information indicates the number of pieces of file information that have actually been read from the specified folder.
[0089] <Example> (1) File operations The CPU 11 of the basic unit 2 may perform data logging to record the operating status of the PLC system 1. In this case, the log file is given a file name generated according to a predetermined naming rule. For example, the following file name may be used:
[0090] log(sequential number)_(timestamp).csv (Example: log000_231001134050.csv) In this example, the sequence number is a number that increases by 1 each time a log file is generated, and the timestamp indicates the date and time the log file was generated.
[0091] When file names change dynamically, it is not possible to identify the file to be manipulated. In other words, in order to manipulate a file, it is necessary to identify the file name in some way.
[0092] According to the above-described embodiment, by executing the file information list acquisition command, it is possible to acquire information on a plurality of files and folders stored in a storage device that is the target of list acquisition, such as the memory card 7. In other words, the CPU 11 and the external device 4 connected to the PLC system 1 can acquire the file name that is the target of file operations by referring to the data memory 22.
[0093] (2) Storing the string read from the text file in the device memory As an example, assume that the following string is written in the log file generated by data logging:
[0094] DATA No. DATE TIME Pressure Flow rate ... 0 2023 / 10 / 01 11:20:09 91 653 1 2023 / 10 / 01 11:20:10 94 648 2 2023 / 10 / 01 11:20:11 97 647 3 2023 / 10 / 01 11:20:12 100 640 4 2023 / 10 / 01 11:20:13 103 632 5 2023 / 10 / 01 11:20:14 106 605 6 2023 / 10 / 01 11:20:15 109 580 7 2023 / 10 / 01 11:20:16 112 521 8 2023 / 10 / 01 11:20:17 115 475 9 2023 / 10 / 01 11:20:18 118 419 10 2023 / 10 / 01 11:20:19 121 340 In this case, if "2" is specified as the number of lines to read (eg, MaxReadLineNum) in the command (eg, function block 900) described above, the following read results are obtained:
[0095] DATA No. DATE TIME Pressure Flow rate ... 0 2023 / 10 / 01 11:20:09 91 653 1 2023 / 10 / 01 11:20:10 94 648 By using a command that can specify the number of lines to be read, it is possible to easily read multiple lines of text data. Furthermore, this reduces the user's programming time and improves read performance.
[0096] (3) FTP transfer In FTP transfer, it is necessary to specify a file name. In particular, duplicate file names must be avoided to avoid overwriting existing files at the destination.
[0097] In this embodiment, by using the above-mentioned file information list acquisition command (e.g., function block 800), it is possible to acquire file information stored in the transfer destination (e.g., memory card 7), thereby avoiding duplication of file names and overwriting of files.
[0098] The file list is also useful when reading out specific files by FTP transfer from the memory card 7. For example, by using wildcard characters in a file filter (e.g., SearchFileName), it is possible to obtain a list of file names with specific extensions (e.g., *.csv), and read out only files with the specific extensions by FTP transfer.
[0099] (4) Renaming the file name One possible case is when an image file acquired by an external device 4 (image inspection device) is transferred to the base unit 2, and the base unit 2 adds the serial number of the product inspected by the image inspection device to the file name. Normally, the product serial number is information held by the base unit 2, not the image inspection device. Therefore, it is necessary to rename the image file.
[0100] There is a method to fix the file names created by the image inspection device. In this case, the image inspection device transfers the image file to the basic unit 2, and the image inspection device must wait for the next file to be transferred until the basic unit 2 completes the renaming process. This is to avoid overwriting files.
[0101] Therefore, an exclusive process is required in which the basic unit 2 and the image inspection device do not perform the next process until the basic unit 2 completes the file renaming process, which causes the cycle time of the PLC system 1 to decrease.
[0102] Generally, it is not easy for an image inspection device to obtain a file name from the PLC's data memory in advance. To avoid file overwriting, files created by the image inspection device typically have file names that include a timestamp or a sequential number. Therefore, it is necessary to identify the file name on the PLC side, and the file information list obtain command is useful. Using the file information list obtain command makes it possible to differentiate the name of the file to be transferred from the name of the file stored at the transfer destination. As a result, file overwriting is eliminated and exclusive processing is no longer necessary. For example, by using the file information list obtain command (e.g., function block 800) of this embodiment, the image inspection device can obtain a file name from the data memory 22 in advance, rename the file so that it does not overlap with the original file name, and then transfer the file to the basic unit 2. As a result, exclusive processing between the PLC and the image inspection device is no longer necessary, which may shorten the cycle time.
[0103] When there are multiple files, it would be useful to set the file update date and time as the sorting condition set in the file information list acquisition command (e.g., function block 800). In other words, it becomes possible to identify the newest or oldest file. Sorting also rearranges multiple file names in chronological order. This also makes it possible to associate a serial number with each file name in chronological order.
[0104] <Technical ideas derived from examples> The multiple aspects described below can be combined in any combination unless technically inconsistent.
[0105] [Point 1] The basic unit 2 and the PLC system 1 are examples of a PLC (programmable logic controller). The CPU 11 and CPU core 12 are examples of a program execution unit that executes a user program (e.g., ladder program 21). The memory 14 and data memory 22 are examples of data memory 22 that is accessed by the program execution unit in response to the user program executed by the program execution unit, and at least a portion of the memory area is refreshed with each scan. The memory card 7 and file memory 25 are examples of memory formatted with a file system and that store files. When the program execution unit (e.g., CPU 11, CPU core 12) executes a list acquisition command (e.g., function block 800) based on the user program, it identifies one or more files stored in the file memory that are the target of the list acquisition command and stores a list of the names of the identified one or more files (e.g., file list 1100) in the data memory. This makes it easy to obtain a list of files, etc., in the PLC.
[0106] [Point 2] As described in connection with Figure 11, etc., the names of one or more files included in the list may be stored in a memory area in the data memory allocated for each file (e.g., device memory 23).
[0107] [Point 3] 11, the list may include the names of folders stored in the file memory, which will allow users to grasp information about folders as well as files.
[0108] [Point 4] The files and folders to be listed may be files and subfolders stored in a specified folder. A specific folder may be specified by writing the file name with a full path (including the path name). By making it possible to specify a folder (directory) in this way, it will be possible to efficiently obtain file information about files stored in a specific folder.
[0109] [Point 5] The memory area may be the device memory 23, which is a memory area accessible by a user program, or a memory area that stores variables defined by a user program (e.g., variable memory 24). This is a storage area that can be referenced by the unit devices that make up the PLC system 1 or the external devices 4 connected to the PLC system 1, so it will be possible to easily provide a series of files.
[0110] [Point 6] The program execution unit (e.g., CPU 11, CPU cores 12, 13) may store a list of file names that are prefix matches, suffix matches, or partial matches for a pre-specified name in the data memory 22. In the above embodiment, a filter using wildcards has been mainly described, but it is also possible to achieve prefix matches (e.g., ABC*), suffix matches (e.g., *ABC), or partial matches (*ABC*) depending on the position of the wildcard character (e.g., *).
[0111] [Point 7] The program execution unit (e.g., CPU 11, CPU cores 12, 13) may read the list stored in data memory 22 and rename the files stored in file memory 25 that are included in the list.
[0112] [Point 8] The program execution unit (e.g., CPU 11, CPU cores 12, 13) may store the number of files included in the list in the data memory 22. As shown in Fig. 11, the number of files included in the list is written in the last line of the file list 1100. This makes it easy to know the number of files included in the list.
[0113] [Point 9] 9, the program execution unit (e.g., CPU 11, CPU cores 12, 13) may access a file stored in file memory based on the name of the file included in the list and read a specified number of lines of text from the file, making it possible to read multiple lines with a single command.
[0114] [Point 10] As described in relation to Figure 8, etc., the program execution unit (e.g., CPU 11, CPU cores 12, 13) may generate a list of a pre-specified number of names that conform to pre-specified extraction conditions.
[0115] [Point 11] The program execution unit (e.g., CPU 11) may have a first processor (e.g., CPU core 12) that executes a user program, and a second processor (e.g., CPU core 13) that executes predetermined processing in accordance with instructions from the first processor.
[0116] The first processor may send a list acquisition command to the second processor, and the second processor may access the file memory in accordance with the list acquisition command to generate the list, and store the list in the data memory 22. In this way, by separating the processor that executes the user program from the processor that generates the file list, the execution of the user program and the process of generating the file list are less likely to affect each other.
[0117] [Point 12] The second processor (e.g., CPU core 13) may access the file memory 25 in accordance with the list acquisition command to generate the list, and may notify the first processor (e.g., CPU core 12) of the completion of the list generation. Upon being notified of the completion of the list generation, the first processor (e.g., CPU core 12) may acquire the list from the second processor (e.g., CPU core 13) and store it in the data memory 22 in the end processing of the user program.
[0118] [Point 13] If the size of the list is larger than a predetermined size (e.g., a threshold), the first processor (e.g., CPU core 12) may divide the list into a first list (first part) and a second list (second part), and store the first list in the data memory 22 in a first end process of the user program, and store the second list in the data memory 22 in a second end process of the user program. In this way, by dividing a large file list and storing it in the data memory 22, local increases in scan time may be suppressed.
[0119] [Point 14] The second processor (e.g., CPU core 13) may sort the names of the multiple files included in the list and then store the list in the data memory 22. By sorting in this way, the data memory 22 will store a list of file information arranged in the order desired by the user.
[0120] [Point 15] The second processor (e.g., CPU core 13) may create a list including only the names of the multiple files included in the sorted list that satisfy a predetermined condition (filter), and store the list in the data memory 22. By performing filtering in this manner, the data memory 22 will store a list of file information that satisfies the conditions desired by the user.
[0121] [Point 16] As shown in FIG. 7, when the second processor (e.g., CPU core 13) is instructed by the first processor to create a list consisting of a specified number of names (e.g., MaxFileListNum), it associates the names with indexes up to the specified number so as to satisfy the sorting conditions. When a name that should be ranked higher in the list than a name associated with a certain index is obtained, the second processor associates the name associated with the certain index with the index following the certain index, and associates the new name with the certain index. This sorting of names is performed each time a name is obtained, and a list is created. This allows the file list to be created after sorting the number of file information desired by the user. This method is particularly effective when there are a huge number of files.
[0122] [Point 17] The second processor (e.g., CPU core 13) may retrieve and list names that match the filter criteria set by the first processor, thereby creating a file list containing file information that meets the user's desired criteria.
[0123] The invention is not limited to the above-described embodiment, and various modifications and variations are possible within the scope of the gist of the invention.
Claims
1. a program execution unit that executes a user program; a data memory that is accessed by the program execution unit in accordance with the user program executed by the program execution unit, and at least a portion of the memory area of which is refreshed every scan; a file memory formatted with a file system for storing files; a programmable logic controller, characterized in that when the program execution unit executes a list acquisition command based on the user program, it identifies one or more files that are stored in the file memory and are the target of the list acquisition command, and stores a list of the names of each of the identified one or more files in the data memory.
2. 2. The programmable logic controller according to claim 1, wherein the names of the one or more files included in the list are stored in memory areas in the data memory allocated for each file.
3. 2. The programmable logic controller of claim 1, wherein the list includes names of folders stored in the file memory.
4. 4. The programmable logic controller according to claim 3, wherein the list and the target files and folders are files and subfolders stored in a specified folder.
5. 2. The programmable logic controller according to claim 1, wherein the memory area is a device memory that is a memory area accessible by the user program, or a memory area that stores variables defined by the user program.
6. 2. The programmable logic controller according to claim 1, wherein the program execution unit stores in the data memory a list of file names that start with, end with, or partially match a pre-specified name.
7. 2. The programmable logic controller according to claim 1, wherein the program execution unit reads out the list stored in the data memory and renames files stored in the file memory and included in the list.
8. 2. The programmable logic controller according to claim 1, wherein the program execution unit stores the number of files included in the list in the data memory.
9. 2. The programmable logic controller according to claim 1, wherein the program execution unit accesses a file stored in the file memory based on the name of the file included in the list, and reads a specified number of lines of text included in the file.
10. 2. The programmable logic controller according to claim 1, wherein the program execution unit generates a list of a predetermined number of names that conform to a predetermined extraction condition.
11. The program execution unit a first processor that executes the user program; a second processor that executes a predetermined process in accordance with an instruction from the first processor; the first processor sends the list acquisition command to the second processor; 2. The programmable logic controller according to claim 1, wherein the second processor accesses the file memory in accordance with the list acquisition command to generate the list, and stores the list in the data memory.
12. the second processor accesses the file memory in accordance with the list acquisition command to generate the list, and notifies the first processor of completion of generation of the list; 12. The programmable logic controller according to claim 11, wherein when the first processor is notified of the completion of generation of the list, it acquires the list from the second processor and stores it in the data memory in an end processing of the user program.
13. 12. The programmable logic controller of claim 11, wherein the first processor, when the size of the list is larger than a predetermined size, divides the list into a first list and a second list, stores the first list in the data memory in a first end process of the user program, and stores the second list in the data memory in a second end process of the user program.
14. 12. The programmable logic controller of claim 11, wherein the second processor sorts the names of the plurality of files included in the list before storing the list in the data memory.
15. 15. The programmable logic controller according to claim 14, wherein the second processor creates a list including only names of the plurality of files included in the sorted list that satisfy a predetermined condition, and stores the list in the data memory.
16. 12. The programmable logic controller of claim 11, wherein, when instructed by the first processor to create a list consisting of a specified number of names, the second processor associates the names with indexes up to the specified number so as to satisfy a sorting condition, and when a name that should be ranked higher than a name associated with a certain index is obtained in the list, the second processor associates the name associated with the certain index with the index next to the certain index, and associates the other name with the certain index, thereby sorting the names each time a name is obtained and creating the list.
17. 12. The programmable logic controller according to claim 11, wherein the second processor acquires names that match a filter condition set by the first processor and lists them in the list.
Citation Information
Patent Citations
Information processor, distribution data storing program and recording medium having the program recorded thereon
JP2004302629A