JP2016110458A - Programmable logic controller, basic unit, control method and program - Google Patents

Programmable logic controller, basic unit, control method and program Download PDF

Info

Publication number
JP2016110458A
JP2016110458A JP2014248402A JP2014248402A JP2016110458A JP 2016110458 A JP2016110458 A JP 2016110458A JP 2014248402 A JP2014248402 A JP 2014248402A JP 2014248402 A JP2014248402 A JP 2014248402A JP 2016110458 A JP2016110458 A JP 2016110458A
Authority
JP
Japan
Prior art keywords
unit
update
data
synchronization
basic unit
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
JP2014248402A
Other languages
Japanese (ja)
Other versions
JP6535459B2 (en
JP2016110458A5 (en
Inventor
知伸 北川
Tomonobu Kitagawa
知伸 北川
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Keyence Corp
Original Assignee
Keyence Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Keyence Corp filed Critical Keyence Corp
Priority to JP2014248402A priority Critical patent/JP6535459B2/en
Publication of JP2016110458A publication Critical patent/JP2016110458A/en
Publication of JP2016110458A5 publication Critical patent/JP2016110458A5/ja
Application granted granted Critical
Publication of JP6535459B2 publication Critical patent/JP6535459B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

PROBLEM TO BE SOLVED: To improve usability for refreshing a device memory in a programmable logic controller (PLC).SOLUTION: A PLC repeatedly executes a user program for every scan. A first update unit 75 refreshes data held by an expansion unit and data held by a basic unit in a refresh period of a scan time. A second update unit 76 refreshes data held by the expansion unit and data held by the basic unit in a fixed period of the scan time.SELECTED DRAWING: Figure 7

Description

本発明は、プログラマブル・ロジック・コントローラ、基本ユニット、制御方法およびプログラムに関する。   The present invention relates to a programmable logic controller, a basic unit, a control method, and a program.

一般にプログラマブル・ロジック・コントローラ(PLC)は基本ユニット(CPUユニットとも呼ぶ)と拡張ユニットを備えている(特許文献1)。基本ユニットと拡張ユニットは、通常のラダープログラムが実行されるタイミングと同期した、リフレッシュ期間と呼ばれる期間においてデータの交換(いわゆるリフレッシュ通信)を行う。   In general, a programmable logic controller (PLC) includes a basic unit (also called a CPU unit) and an expansion unit (Patent Document 1). The basic unit and the expansion unit exchange data (so-called refresh communication) in a period called a refresh period that is synchronized with the timing at which a normal ladder program is executed.

ところで、基本ユニットと拡張ユニットは、ユニット間同期処理によって相互に制御の同期をとることもできる。具体的には、1台又は複数台の拡張ユニットの内部処理と、基本ユニットにおける所定の処理(ラダー実行処理など)とを同期させて実行することもできる。   By the way, the basic unit and the extension unit can also synchronize control with each other by inter-unit synchronization processing. Specifically, internal processing of one or a plurality of expansion units and predetermined processing (such as ladder execution processing) in the basic unit can be executed in synchronization.

一般に、ユニット間同期処理において基本ユニットと拡張ユニットの間でデータ交換を行うためには、ユーザは別途、ユニット間同期用のラダープログラムの中に、ダイレクト通信の命令語を書き込まなければならない。ダイレクト通信の命令語とは、基本ユニットがその命令語を実行したタイミングで、基本ユニットと拡張ユニットの間でデータ交換される命令語である。このダイレクト通信の命令語があることで、毎スキャンで繰り返し実行されるリフレッシュ通信のタイミングを待たなくてもデータ交換されるため、ユニット間同期処理を用いた外部機器の高速制御などのメリットが得られる。   Generally, in order to exchange data between the basic unit and the extension unit in the inter-unit synchronization process, the user must separately write a direct communication command word in the ladder program for inter-unit synchronization. An instruction word for direct communication is an instruction word for exchanging data between the basic unit and the expansion unit at the timing when the basic unit executes the instruction word. This direct communication command allows data to be exchanged without waiting for the timing of refresh communication that is repeatedly executed at each scan, thus providing advantages such as high-speed control of external devices using inter-unit synchronization processing. It is done.

特開2004−052672号公報Japanese Patent Laid-Open No. 2004-052672

しかし、ユニット間同期用のラダープログラム中にダイレクト通信の命令語を逐一記述することは、ユーザにとって煩雑な作業であり、手間が掛かるものである。例えば、ユニット間同期ではない、毎スキャンで繰り返し実行される通常のラダープログラム(いわゆる平場のラダープログラム)の記述の一部または全部をユニット間同期用のラダープログラムに流用する場合であっても、別途、ダイレクト通信の命令語を書き加えなければならず、結局のところ、プログラム変更の作業が必要になる。   However, it is troublesome for the user to write direct communication command words one by one in the ladder program for synchronization between units, which is troublesome. For example, even when part or all of the description of a normal ladder program (so-called flat field ladder program) that is repeatedly executed at every scan, not inter-unit synchronization, is diverted to a ladder program for inter-unit synchronization, Separately, direct communication commands must be added, and eventually, a program change operation is required.

そこで、毎スキャンで繰り返し実行されるリフレッシュ通信と同様に、ユニット間同期用のラダープログラムが実行されるタイミングと同期して、ユニット間同期の対象となっているデータを一括でデータ交換する方法(いわゆるユニット間同期リフレッシュ)が考えられる。このユニット間同期リフレッシュは、毎スキャン実行される通常のリフレッシュとは別概念のものであるため、ユニット間同期リフレッシュの対象となるデバイスとして、通常のリフレッシュの対象となるデバイスとは異なる専用デバイスが用意される。   Therefore, in the same way as the refresh communication repeatedly executed at each scan, a method of exchanging data subject to synchronization between units in batch in synchronization with the timing at which the ladder program for synchronization between units is executed ( So-called inter-unit synchronous refresh) can be considered. This inter-unit synchronous refresh is a different concept from the normal refresh that is executed every scan, so a dedicated device that is different from the device that is the target of normal refresh is used as the device that is subject to the inter-unit synchronous refresh. Be prepared.

しかし、基本ユニットと拡張ユニットとの間で共有すべきデータは数多く存在するため、ユニット間同期リフレッシュの期間でデータのすべてをユニット間で一致するように更新処理(リフレッシュ)を実行しようとすると、上述した専用デバイスを数多く用意しなければならない。その結果、専用デバイスを用いてユニット間同期用のラダープログラムを作成することは、ユーザにとって煩雑な作業であり、手間が掛かるものである。また、上述同様、平場のラダープログラムの記述の一部または全部をユニット間同期用のラダープログラムに流用する場合には、別途、通常のリフレッシュの対象となるデバイスを、ユニット間同期リフレッシュの対象となる専用デバイスに書き換えなければならず、この方法も結局のところ、プログラムの変更作業が必要になる。   However, since there is a lot of data that should be shared between the basic unit and the expansion unit, if you try to execute the update process (refresh) so that all of the data matches between units during the inter-unit synchronous refresh period, Many dedicated devices mentioned above must be prepared. As a result, creating a ladder program for inter-unit synchronization using a dedicated device is a cumbersome operation for the user and takes time and effort. Similarly, as described above, when part or all of the description of the flat ladder program is diverted to the ladder program for inter-unit synchronization, a device that is subject to normal refresh is separately designated as the target of inter-unit synchronous refresh. In the end, this method also requires a program change operation.

また、ユニット間同期リフレッシュの対象となる専用デバイスの数が多い場合、ユニット間同期リフレッシュの期間が長くなってしまう。その結果、外部機器の高速制御などのユニット間同期処理のメリットが相殺されることになってしまう。もしこのようなデータの一部を、ユニット間同期リフレッシュの期間以外の期間で実行できるように選択できれば、リフレッシュ期間の増大を抑制できるであろう。そこで、本発明は、基本ユニットと拡張ユニットとの間で共有すべきデータの更新タイミングを選択可能なデバイスを用意することで、ユニット間同期処理のメリットが低下するのを防ぎながら、プログラムの変更作業の負担を軽減してユーザビリティを向上させることを目的とする。   In addition, when the number of dedicated devices that are subject to inter-unit synchronous refresh is large, the inter-unit synchronous refresh period becomes long. As a result, the merits of inter-unit synchronization processing such as high-speed control of external devices will be offset. If a part of such data can be selected so that it can be executed in a period other than the inter-unit synchronous refresh period, an increase in the refresh period will be suppressed. Therefore, the present invention prepares a device that can select the update timing of data to be shared between the basic unit and the expansion unit, thereby preventing a decrease in the merit of the inter-unit synchronization processing while changing the program. The purpose is to reduce the workload and improve usability.

本発明は、たとえば、
ユーザプログラムをスキャン毎に繰り返し実行する基本ユニットと、前記基本ユニットに接続される拡張ユニットとを有するプログラマブル・ロジック・コントローラであって、
前記拡張ユニットは、
外部機器が接続されるインターフェースと、
前記インターフェースを介した前記外部機器からの入力値または前記インターフェースを介した前記外部機器への出力値に関するデバイス値が格納され、前記基本ユニットとデータ共有するためのデバイスが割り付けられた記憶部と、
クロックを計数して時間を計測する拡張ユニットタイマと、
を備え、
前記基本ユニットは、
クロックを計数して時間を計測する基本ユニットタイマと、
前記拡張ユニットタイマと前記基本ユニットタイマのタイマ値を同期させる同期手段と、
スキャン毎のリフレッシュの期間内で前記拡張ユニットが保持しているデータと前記基本ユニットが保持しているデータとを一致させる第1更新手段と、
前記同期手段により前記拡張ユニットタイマのタイマ値と同期した前記基本ユニットタイマのタイマ値に基づいてスキャン中に定周期で実行される処理の期間内で前記拡張ユニットが保持しているデータと前記基本ユニットが保持しているデータとを一致させる第2更新手段と、
を備え、
前記ユーザプログラムに記述される前記拡張ユニットの前記デバイスは、前記第1更新手段による更新の対象および/または前記第2更新手段による更新の対象として設定可能に構成されることを特徴とするプログラマブル・ロジック・コントローラを提供する。
The present invention is, for example,
A programmable logic controller having a basic unit that repeatedly executes a user program for each scan, and an expansion unit connected to the basic unit,
The expansion unit is
An interface to which an external device is connected;
A storage unit in which a device value related to an input value from the external device via the interface or an output value to the external device via the interface is stored, and a device for sharing data with the basic unit is allocated;
An expansion unit timer that counts the clock and measures time,
With
The basic unit is
A basic unit timer that counts the clock and measures time,
Synchronization means for synchronizing the timer values of the extension unit timer and the basic unit timer;
First update means for matching the data held by the extension unit and the data held by the basic unit within a refresh period for each scan;
Based on the timer value of the basic unit timer synchronized with the timer value of the extension unit timer by the synchronization means, the data held by the extension unit within the period of processing executed at regular intervals during scanning and the basic Second update means for matching the data held by the unit;
With
The programmable unit characterized in that the device of the extension unit described in the user program can be set as an update target by the first update means and / or an update target by the second update means. Provide logic controller.

本発明によればユーザビリティを向上させることが可能になる。   According to the present invention, usability can be improved.

PLCシステムの一例を示す図Diagram showing an example of a PLC system ユーザプログラムの一例を示す図The figure which shows an example of the user program プログラム作成支援装置の一例を示す図The figure which shows an example of a program creation assistance apparatus PLCの一例を示す図The figure which shows an example of PLC スキャンタイムを説明するための図Diagram for explaining scan time スキャンタイムと同期周期との関係を示す図Diagram showing the relationship between scan time and synchronization period 基本ユニットの機能を示す図Diagram showing basic unit functions 拡張ユニットの機能を示す図Diagram showing the functions of the expansion unit プログラム作成支援装置の機能を示す図The figure which shows the function of the program creation support device スキャンタイムにおけるユニット間同期とリフレッシュを含む処理を示すフローチャートFlowchart showing processing including synchronization and refresh between units at scan time 拡張ユニットで実行される同期リフレッシュを示すフローチャートFlowchart showing synchronous refresh performed on expansion unit 同期リフレッシュと内部処理との時間的な関係を示す図Diagram showing the temporal relationship between synchronous refresh and internal processing ダブルバッファ構成と複数の拡張ユニット間でのデータの送受信を示す図Diagram showing data transmission and reception between multiple buffer units and multiple expansion units ユニット間同期のタイミングに沿って実行されるスキャン処理を示すフローチャートFlowchart showing scan processing executed along the timing of synchronization between units ユニット間同期のタイミングに沿って実行されるスキャン処理を示すフローチャートFlowchart showing scan processing executed along the timing of synchronization between units 同期リフレッシュと一括リフレッシュとのいずれかを選択するためのGUIの一例を示す図The figure which shows an example of GUI for selecting either synchronous refresh or batch refresh

以下に本発明の一実施形態を示す。以下で説明される個別の実施形態は、本発明の上位概念、中位概念および下位概念など種々の概念を理解するために役立つであろう。また、本発明の技術的範囲は、特許請求の範囲によって確定されるのであって、以下の個別の実施形態によって限定されるわけではない。   An embodiment of the present invention is shown below. The individual embodiments described below will help to understand various concepts, such as the superordinate concept, intermediate concept and subordinate concept of the present invention. Further, the technical scope of the present invention is determined by the scope of the claims, and is not limited by the following individual embodiments.

はじめにプログラマブル・ロジック・コントローラ(PLC、単にプログラマブルコントローラと呼ばれてもよい)を当業者にとってよりよく理解できるようにするために、一般的なPLCの構成とその動作について説明する。   First, in order to allow a person skilled in the art to better understand a programmable logic controller (PLC, which may be simply referred to as a programmable controller), the configuration and operation of a general PLC will be described.

図1は、本発明の実施の形態によるプログラマブル・ロジック・コントローラシステムの一構成例を示す概念図である。図1に示すように、このシステムは、ラダープログラムなどのユーザプログラムの編集を行うためのプログラム作成支援装置1と、工場等に設置される各種制御装置を統括的に制御するためのPLC(プログラマブル・ロジック・コントローラ)2とを備えている。PLC2は、CPUが内蔵された基本ユニット3と1つないし複数の拡張ユニット4を備えている。基本ユニット3に対して1つないし複数の拡張ユニット4が着脱可能となっている。基本ユニット3はCPUユニットと呼ばれることもある。   FIG. 1 is a conceptual diagram showing a configuration example of a programmable logic controller system according to an embodiment of the present invention. As shown in FIG. 1, this system includes a program creation support apparatus 1 for editing a user program such as a ladder program, and a PLC (programmable) for comprehensively controlling various control apparatuses installed in a factory or the like. -Logic controller 2). The PLC 2 includes a basic unit 3 having a built-in CPU and one or more expansion units 4. One or a plurality of expansion units 4 can be attached to and detached from the basic unit 3. The basic unit 3 may be called a CPU unit.

基本ユニット3には、表示部5及び操作部6が備えられている。表示部5には、基本ユニット3に取り付けられている各拡張ユニット4の動作状況などを表示することができ、表示部5の表示内容は、操作部6を操作することにより切り替えることができる。表示部5には、通常、PLC2内のデバイスの現在値(デバイス値)やPLC2内で生じたエラー情報などが表示される。なお、デバイスとは、デバイス値を格納するために設けられたメモリ上の領域を指す名称であり、デバイスメモリと呼ばれてもよい。デバイス値とは、入力機器からの入力状態、出力機器への出力状態およびユーザプログラム上で設定される内部リレー(補助リレー)、タイマ、カウンタ、データメモリ等の状態を示す情報である。   The basic unit 3 includes a display unit 5 and an operation unit 6. The display unit 5 can display the operation status of each expansion unit 4 attached to the basic unit 3, and the display content of the display unit 5 can be switched by operating the operation unit 6. The display unit 5 normally displays a current value (device value) of a device in the PLC 2 and error information generated in the PLC 2. The device is a name indicating an area on a memory provided for storing a device value, and may be called a device memory. The device value is information indicating an input state from the input device, an output state to the output device, and states of an internal relay (auxiliary relay), a timer, a counter, a data memory, and the like set on the user program.

拡張ユニット4は、PLC2の機能を拡張するために用意されており、基本ユニット3に対して側方から取り付けられる。1つ目の拡張ユニット4は、基本ユニット3に対して側方から直接的に取り付けられる。2つ目以降の拡張ユニット4は、既に取り付けられている拡張ユニット4に対して、側方から直列的に取り付けられる。たとえば、基本ユニット3の右側面と拡張ユニット4の左側面とが連結面になっている。同様に、1つ目の拡張ユニット4の右側面の形状等は基本ユニット3の右側面とほぼ同じであるため、1つ目の拡張ユニット4の右側面に2つ目の拡張ユニット4の左側面が連結される。このような連結方式は、数珠つなぎ方式とかデイジーチェーン方式と呼ばれてもよい。各連結面にはコネクタが設けられており、通信や電力供給を行うためのバスもコネクタを介して連結される。このようにして、基本ユニット3と複数の拡張ユニット4が直列的に取り付けられると、各拡張ユニット4内に備えられた配線(例:バス)を介して、各拡張ユニット4が基本ユニット3に対して通信可能に接続される。各拡張ユニット4には、その拡張ユニット4の機能に対応する被制御装置16(図4)が接続され、これにより、各被制御装置16が拡張ユニット4を介して基本ユニット3に接続される。被制御装置16には、センサなどの入力装置や、アクチュエータなどの出力装置が含まれる。   The extension unit 4 is prepared for extending the function of the PLC 2 and is attached to the basic unit 3 from the side. The first extension unit 4 is directly attached to the basic unit 3 from the side. The second and subsequent expansion units 4 are attached in series from the side with respect to the expansion units 4 that are already attached. For example, the right side surface of the basic unit 3 and the left side surface of the expansion unit 4 are connection surfaces. Similarly, since the shape and the like of the right side surface of the first extension unit 4 are substantially the same as the right side surface of the basic unit 3, the left side of the second extension unit 4 is placed on the right side surface of the first extension unit 4. The faces are connected. Such a connection method may be called a daisy chain method or a daisy chain method. Each connection surface is provided with a connector, and a bus for performing communication and power supply is also connected through the connector. In this way, when the basic unit 3 and the plurality of expansion units 4 are attached in series, each expansion unit 4 is connected to the basic unit 3 via the wiring (eg, bus) provided in each expansion unit 4. To be communicable with each other. Each expansion unit 4 is connected to a controlled device 16 (FIG. 4) corresponding to the function of the expansion unit 4, whereby each controlled device 16 is connected to the basic unit 3 via the expansion unit 4. . The controlled device 16 includes an input device such as a sensor and an output device such as an actuator.

プログラム作成支援装置1は、たとえば、携帯可能ないわゆるノートタイプやタブレットタイプのパーソナルコンピュータであって、表示部7及び操作部8を備えている。PLC2を制御するためのユーザプログラムの一例であるラダープログラムは、プログラム作成支援装置1を用いて作成され、その作成されたラダープログラムは、プログラム作成支援装置1内でニモニックコードに変換される。そして、プログラム作成支援装置1を、USB(Universal Serial Bus)などの通信ケーブル9を介してPLC2の基本ユニット3に接続し、ニモニックコードに変換されたラダープログラムをプログラム作成支援装置1から基本ユニット3に送ると、そのラダープログラムが基本ユニット3内でマシンコードに変換され、基本ユニット3に備えられたメモリ内に記憶される。   The program creation support device 1 is, for example, a portable so-called notebook type or tablet type personal computer, and includes a display unit 7 and an operation unit 8. A ladder program which is an example of a user program for controlling the PLC 2 is created using the program creation support apparatus 1, and the created ladder program is converted into a mnemonic code in the program creation support apparatus 1. Then, the program creation support apparatus 1 is connected to the basic unit 3 of the PLC 2 via a communication cable 9 such as a USB (Universal Serial Bus), and the ladder program converted into the mnemonic code is transferred from the program creation support apparatus 1 to the basic unit 3. The ladder program is converted into a machine code in the basic unit 3 and stored in a memory provided in the basic unit 3.

なお、図1では示していないが、プログラム作成支援装置1の操作部8には、プログラム作成支援装置1に接続されたマウスなどのポインティングデバイスが含まれていてもよい。また、プログラム作成支援装置1は、USB以外の他の通信ケーブル9を介して、PLC2の基本ユニット3に対して着脱可能に接続されるような構成であってもよい。   Although not shown in FIG. 1, the operation unit 8 of the program creation support apparatus 1 may include a pointing device such as a mouse connected to the program creation support apparatus 1. The program creation support device 1 may be configured to be detachably connected to the basic unit 3 of the PLC 2 via a communication cable 9 other than the USB.

図2は、ラダープログラムの作成時にプログラム作成支援装置1の表示部7に表示されるラダー図17の一例を示す図である。図2に示すように、PLC2を制御するためのラダープログラムは、プログラム作成支援装置1の表示部7にマトリックス状に表示される複数のセル18内に仮想デバイスのシンボル19を適宜配置して、視覚的なリレー回路を表すラダー図17を構築することにより作成される。   FIG. 2 is a diagram illustrating an example of a ladder diagram 17 displayed on the display unit 7 of the program creation support apparatus 1 when creating a ladder program. As shown in FIG. 2, the ladder program for controlling the PLC 2 appropriately arranges virtual device symbols 19 in a plurality of cells 18 displayed in a matrix on the display unit 7 of the program creation support apparatus 1. It is created by constructing a ladder diagram 17 representing a visual relay circuit.

ラダー図17には、たとえば、10列×N行(Nは任意の自然数)のセル18が配置されている。そして、各行のセル18内に、図2に示す左側から右側に向かって、時系列的に仮想デバイスのシンボル19を適宜配置することにより、視覚的なリレー回路を作成することができる。作成されるリレー回路は、1行で表される直列的なリレー回路であってもよいし、複数行に並列的に表されたリレー回路を互いに結合することにより作成された、並列的なリレー回路であってもよい。   In the ladder diagram 17, for example, cells 18 of 10 columns × N rows (N is an arbitrary natural number) are arranged. A visual relay circuit can be created by appropriately arranging the virtual device symbols 19 in time series in the cells 18 of each row from the left side to the right side shown in FIG. The created relay circuit may be a serial relay circuit represented by one row, or a parallel relay created by coupling relay circuits represented in parallel in a plurality of rows to each other. It may be a circuit.

図2に示すリレー回路は、入力装置からの入力信号に基づいてオン/オフされる3つの仮想デバイス(以下、「入力デバイス」と呼ぶ。)のシンボル19a,19b,19cと、出力装置の動作を制御するためにオン/オフされる仮想デバイス(以下、「出力デバイス」と呼ぶ。)のシンボル19dとが適宜結合されることにより構成されている。   The relay circuit shown in FIG. 2 includes three virtual devices (hereinafter referred to as “input devices”) 19a, 19b, and 19c that are turned on / off based on an input signal from the input device, and the operation of the output device. And a symbol 19d of a virtual device (hereinafter referred to as an “output device”) that is turned on / off to control the device.

各入力デバイスのシンボル19a,19b,19cの上方に表示されている文字(「R0001」、「R0002」及び「R0003」)は、その入力デバイスのデバイス名(アドレス名)21を表している。各入力デバイスのシンボル19a,19b,19cの下方に表示されている文字(「フラグ1」、「フラグ2」及び「フラグ3」)は、その入力デバイスに対応付けられたデバイスコメント22を表している。出力デバイスのシンボル19dの上方に表示されている文字(「原点復帰」)は、その出力デバイスの機能を表す文字列からなるラベル23である。   The characters (“R0001”, “R0002”, and “R0003”) displayed above the symbols 19a, 19b, and 19c of each input device represent the device name (address name) 21 of the input device. The characters (“flag 1”, “flag 2”, and “flag 3”) displayed below the symbols 19a, 19b, and 19c of each input device represent a device comment 22 associated with the input device. Yes. A character (“origin return”) displayed above the symbol 19d of the output device is a label 23 composed of a character string representing the function of the output device.

図2に示す例では、デバイス名「R0001」及び「R0002」にそれぞれ対応する2つの入力デバイスのシンボル19a,19bが直列的に結合されることにより、AND回路が構成されている。また、これらの2つの入力デバイスのシンボル19a,19bからなるAND回路に対して、デバイス名「R0003」に対応する入力デバイスのシンボル19cが並列的に結合されることにより、OR回路が構成されている。すなわち、このリレー回路では、2つのシンボル19a,19bに対応する入力デバイスがいずれもオンした場合、又は、シンボル19cに対応する入力デバイスがオンした場合にのみ、シンボル19dに対応する出力デバイスがオンされるようになっている。   In the example shown in FIG. 2, two input device symbols 19a and 19b respectively corresponding to device names “R0001” and “R0002” are coupled in series to form an AND circuit. In addition, an OR circuit is configured by parallelly connecting the input device symbol 19c corresponding to the device name “R0003” to the AND circuit including the symbols 19a and 19b of these two input devices. Yes. That is, in this relay circuit, the output device corresponding to the symbol 19d is turned on only when both of the input devices corresponding to the two symbols 19a and 19b are turned on or when the input device corresponding to the symbol 19c is turned on. It has come to be.

図3は、図1のプログラム作成支援装置1の電気的構成について説明するためのブロック図である。図3に示すように、プログラム作成支援装置1には、CPU24、表示部7、操作部8、記憶装置25及び通信部26が備えられている。表示部7、操作部8、記憶装置25及び通信部26は、それぞれCPU24に対して電気的に接続されている。記憶装置25は、少なくともRAMを含む構成であり、ラダープログラム記憶部25aと、編集ソフト記憶部25bとを備えている。   FIG. 3 is a block diagram for explaining the electrical configuration of the program creation support apparatus 1 of FIG. As shown in FIG. 3, the program creation support apparatus 1 includes a CPU 24, a display unit 7, an operation unit 8, a storage device 25, and a communication unit 26. The display unit 7, the operation unit 8, the storage device 25, and the communication unit 26 are electrically connected to the CPU 24, respectively. The storage device 25 includes at least a RAM, and includes a ladder program storage unit 25a and an editing software storage unit 25b.

ユーザは、編集ソフト記憶部25bに記憶されている編集ソフトをCPU24に実行させて、操作部8を通じてラダープログラムを編集する。ここで、ラダープログラムの編集には、ラダープログラムの作成及び変更が含まれる。編集ソフトを用いて作成されたラダープログラムは、ラダープログラム記憶部25aに記憶される。また、ユーザは、必要に応じてラダープログラム記憶部25aに記憶されているラダープログラムを読み出し、そのラダープログラムを、編集ソフトを用いて変更することができる。通信部26は、通信ケーブル9を介してプログラム作成支援装置1を基本ユニット3に通信可能に接続するためのものである。   The user causes the CPU 24 to execute editing software stored in the editing software storage unit 25 b and edits the ladder program through the operation unit 8. Here, the ladder program editing includes creation and modification of the ladder program. The ladder program created using the editing software is stored in the ladder program storage unit 25a. Further, the user can read out the ladder program stored in the ladder program storage unit 25a as needed, and change the ladder program using editing software. The communication unit 26 is for connecting the program creation support apparatus 1 to the basic unit 3 through the communication cable 9 so as to be communicable.

図4は、PLC2の電気的構成について説明するためのブロック図である。図4に示すように、基本ユニット3には、CPU10、表示部5、操作部6、記憶装置12及び通信部14が備えられている。表示部5、操作部6、記憶装置12、及び通信部14は、それぞれCPU10に電気的に接続されている。記憶装置12は、RAMやROM、メモリカードなどを含んでもよく、ラダープログラムなどを記憶する。記憶装置12には、プログラム作成支援装置1から入力されたラダープログラムやユーザデータが上書きして記憶される。また、記憶装置12には基本ユニット用の制御プログラムも格納されている。   FIG. 4 is a block diagram for explaining the electrical configuration of the PLC 2. As shown in FIG. 4, the basic unit 3 includes a CPU 10, a display unit 5, an operation unit 6, a storage device 12, and a communication unit 14. The display unit 5, the operation unit 6, the storage device 12, and the communication unit 14 are each electrically connected to the CPU 10. The storage device 12 may include a RAM, a ROM, a memory card, and the like, and stores a ladder program and the like. In the storage device 12, the ladder program and user data input from the program creation support device 1 are overwritten and stored. The storage device 12 also stores a control program for the basic unit.

図5は、本発明の実施の形態に係るプログラマブルコントローラの基本ユニット3でのスキャンタイムの構成を示す模式図である。図5が示すように1つのスキャンタイムTは、入出力のリフレッシュを行うためのユニット間通信201、プログラム実行202、END処理204により構成されている。ユニット間通信201で、基本ユニット3は、ラダープログラムを実行して得られた出力データを基本ユニット3内の記憶装置12から外部機器などに送信するとともに、受信データを含めた入力データを基本ユニット3内の記憶装置12に取り込む。たとえば、基本ユニット3のデバイスに記憶されているデバイス値はリフレッシュによって拡張ユニット4のデバイスに反映される。同様に、拡張ユニット4のデバイスに記憶されているデバイス値はリフレッシュによって基本ユニット3のデバイスに反映される。なお、リフレッシュ以外のタイミングでデバイス値をユニット間で更新する仕組みが採用されてもよい。ただし、基本ユニット3のデバイスは基本ユニット3が随時書き換えており、同様に、拡張ユニット4のデバイスは拡張ユニット4が随時書き換えている。つまり、基本ユニット3のデバイスは基本ユニット3の内部の装置によって随時アクセス可能であり、同様に、拡張ユニット4のデバイスは拡張ユニット4の内部の装置によって随時アクセス可能になっている。基本ユニット3と拡張ユニット4との間では基本的にリフレッシュのタイミングにおいて相互にデバイス値を更新して同期する。プログラム実行202で、基本ユニット3は、更新された入力データを用いてプログラムを実行(演算)する。基本ユニット3はプログラムの実行によりデータを演算処理する。なお、END処理とは、プログラム作成支援装置1や基本ユニット3に接続された表示器(図示せず)等の外部機器とのデータ通信、システムのエラーチェック等の周辺サービスに関する処理全般を意味する。END処理は周辺処理と呼ばれることもある。   FIG. 5 is a schematic diagram showing a scan time configuration in the basic unit 3 of the programmable controller according to the embodiment of the present invention. As shown in FIG. 5, one scan time T is composed of inter-unit communication 201 for executing input / output refresh, program execution 202, and END processing 204. In the inter-unit communication 201, the basic unit 3 transmits output data obtained by executing the ladder program from the storage device 12 in the basic unit 3 to an external device and the like, and also receives input data including received data as the basic unit. 3 is stored in the storage device 12. For example, the device value stored in the device of the basic unit 3 is reflected in the device of the expansion unit 4 by refresh. Similarly, the device value stored in the device of the expansion unit 4 is reflected in the device of the basic unit 3 by refresh. Note that a mechanism for updating device values between units at a timing other than refresh may be employed. However, the device of the basic unit 3 is rewritten as needed by the basic unit 3, and similarly, the device of the expansion unit 4 is rewritten as needed by the expansion unit 4. That is, the device of the basic unit 3 can be accessed at any time by a device inside the basic unit 3, and similarly, the device of the expansion unit 4 can be accessed at any time by a device inside the expansion unit 4. The basic unit 3 and the expansion unit 4 synchronize by updating the device values at the refresh timing basically. In the program execution 202, the basic unit 3 executes (calculates) the program using the updated input data. The basic unit 3 computes data by executing a program. The END processing means general processing related to peripheral services such as data communication with an external device such as a display (not shown) connected to the program creation support apparatus 1 or the basic unit 3, and system error checking. . The END process is sometimes called a peripheral process.

このように、プログラム作成支援装置1はユーザの操作に応じたラダープログラムを作成し、作成したラダープログラムをPLC2に転送する。PLC2は、入出力リフレッシュ、ラダープログラムの実行およびEND処理を1サイクル(1スキャン)として、このサイクルを周期的、すなわちサイクリックに繰り返し実行する。これにより、各種入力機器(センサ等)からのタイミング信号に基づいて、各種出力機器(モータ等)を制御する。よって、PLC2は汎用のパーソナルコンピュータ(PC)とは全く異なる動きをする。   As described above, the program creation support apparatus 1 creates a ladder program according to the user's operation, and transfers the created ladder program to the PLC 2. The PLC 2 executes the input / output refresh, the execution of the ladder program, and the END process as one cycle (one scan), and periodically and cyclically executes this cycle. Thus, various output devices (motors, etc.) are controlled based on timing signals from various input devices (sensors, etc.). Therefore, the PLC 2 moves completely different from a general-purpose personal computer (PC).

<ユニット間同期>
ユニット間同期とは、基本ユニット3の内部処理の制御周期と拡張ユニット4の内部処理の制御周期とを同期させる処理のことである。基本ユニット3と拡張ユニット4はそれぞれタイマを有し、タイマ値に応じて内部処理の開始タイミングなどを決定する。基本ユニット3と拡張ユニット4が同じ周期のタイマを有することにより、両者の制御周期が同期する。なお、基本ユニット3の制御周期を基準として拡張ユニット4の制御周期を同期させる方法と、拡張ユニット4の制御周期を基準として基本ユニット3の制御周期を同期させる方法とがある。いずれにしても拡張ユニット4は、拡張ユニット4の制御周期にしたがって内部処理を実行する。つまり、内部処理の開始タイミングは拡張ユニット4の制御周期の開始タイミングに一致している。なお、同期処理はユーザプログラムであるラダープログラムのスキャンタイム内における特定の期間に実行されてもよいし、ラダープログラムに対して割り込むことで実行されてもよい。ここでは説明の便宜上、一定周期の割り込みによってユニット間同期が実行されるものとして説明する。割り込みを実行するための割り込みモジュールが基本ユニット3に設けられていてもよい。たとえば、図6(A)が示すように、スキャンタイムが5ミリ秒だとすると、ユニット間同期の同期周期は200マイクロ秒(us)に設定されることがある。この場合は、1つのスキャンタイム内で25回のユニット間同期が実行されることになる。なお、スキャンはスキャンモジュールによって制御されており、これとは並行してユニット間同期は同期モジュールによって実行されている。そのため、リフレッシュの期間(ユニット間通信201)、ラダープログラムを実行している期間(プログラム実行202)、END処理を実行している期間(END処理204)のいずれにおいてもユニット間同期が定周期で実行される。
<Inter-unit synchronization>
Inter-unit synchronization is a process of synchronizing the control cycle of internal processing of the basic unit 3 and the control cycle of internal processing of the expansion unit 4. Each of the basic unit 3 and the expansion unit 4 has a timer, and determines the start timing of internal processing according to the timer value. Since the basic unit 3 and the expansion unit 4 have timers having the same cycle, the control cycles of both are synchronized. There are a method of synchronizing the control cycle of the expansion unit 4 with reference to the control cycle of the basic unit 3 and a method of synchronizing the control cycle of the basic unit 3 with reference to the control cycle of the expansion unit 4. In any case, the expansion unit 4 executes internal processing according to the control cycle of the expansion unit 4. That is, the start timing of the internal processing coincides with the start timing of the control cycle of the expansion unit 4. The synchronization process may be executed during a specific period within the scan time of the ladder program that is the user program, or may be executed by interrupting the ladder program. Here, for convenience of explanation, it is assumed that the synchronization between units is executed by interruption with a fixed period. An interrupt module for executing an interrupt may be provided in the basic unit 3. For example, as shown in FIG. 6A, if the scan time is 5 milliseconds, the synchronization period of the inter-unit synchronization may be set to 200 microseconds (us). In this case, 25 inter-unit synchronization is executed within one scan time. Note that the scan is controlled by the scan module, and in parallel with this, the inter-unit synchronization is executed by the synchronization module. Therefore, inter-unit synchronization is performed at a constant cycle in any of the refresh period (inter-unit communication 201), the ladder program execution period (program execution 202), and the END process execution period (END process 204). Executed.

上述した内部処理は内部機能が実行する処理のことである。拡張ユニット4はインターフェースを備え、当該インターフェースを介して外部機器である被制御装置16と接続されている。拡張ユニット4は外部機器から取得したデータに対して演算を実行して入力デバイス値を求め、入力デバイスに格納する。また、拡張ユニット4は出力デバイスのデバイス値に対して演算を実行して出力値を求め、外部機器に出力する。内部処理とはこれらの演算処理などである。なお、演算処理は、数式に基づく算出処理だけでなく、テーブルから値を取得するような処理も含まれる概念である。   The internal processing described above is processing executed by an internal function. The expansion unit 4 includes an interface, and is connected to the controlled device 16 that is an external device via the interface. The expansion unit 4 performs an operation on data acquired from the external device to obtain an input device value and stores it in the input device. Further, the expansion unit 4 performs an operation on the device value of the output device to obtain an output value, and outputs it to an external device. Internal processing includes these arithmetic processes. The arithmetic process is a concept that includes not only a calculation process based on a mathematical expression but also a process of acquiring a value from a table.

<一括リフレッシュと同期リフレッシュ>
図5に示したように入出力リフレッシュは1つのスキャンタイムTにおいて一回だけ実行される(これを一括リフレッシュと呼ぶことにする。)。しかし、1つのスキャンタイムにおいて一回だけのリフレッシュを行うだけでは、十分ではないようなデータも存在する。このようなデータについてはデバイスに割り付けずに、バッファメモリに割り付け、バッファメモリに対してダイレクト通信を行うことで、データを読み書きすることが可能となる。しかし、この場合は、ラダープログラム内でダイレクト通信を実行するための命令を記述しておかなければならない。スキャンタイム(例:5ms)に対してずっと短い周期(例:200us)で更新される必要があるデータについてはラダープログラム内の多数の個所にデータの更新命令を記述しておかねばならず、ユーザビリティにかける面があった。また、「発明が解決しようとする課題」の欄に記述したような問題があった。
<Batch refresh and synchronous refresh>
As shown in FIG. 5, the input / output refresh is executed only once at one scan time T (this will be referred to as batch refresh). However, some data may not be sufficient if only one refresh is performed in one scan time. Such data can be read / written by allocating to the buffer memory without allocating to the device and performing direct communication with the buffer memory. However, in this case, an instruction for executing direct communication must be described in the ladder program. For data that needs to be updated at a much shorter cycle (eg, 200 us) with respect to the scan time (eg, 5 ms), data update instructions must be described in a number of locations in the ladder program. There was a face to put on. In addition, there are problems as described in the column “Problems to be Solved by the Invention”.

ところで、上述したようにユニット間同期(ユニット間同期プログラム)は非常に短い同期周期で繰り返し実行されるように設定されることがある。よって、図6(B)が示すように、ユニット間同期の際にデータをリフレッシュすれば、リアルタイム性の要求されるデータをフレッシュな状態に維持できるようになろう(これを同期リフレッシュと呼ぶことにする)。しかし、一括リフレッシュの対象となっていたすべてのデバイスについて同期リフレッシュを実行してしまうと、ユニット間同期に付随した同期リフレッシュによって平場のラダープログラムが中断される時間が長くなり(別の言い方をすると、同期リフレシュに伴って実行されるユニット間同期プログラムの記述量が制限されることになり)、基本ユニット3が拡張ユニット4を制御する上で不都合が生じる。これは、基本ユニット3がユニット間同期のタイミングでラダープログラムに対して割り込みを発生させ、同期リフレッシュを実行する必要があるからである。なお、リフレッシュの期間(ユニット間通信201)、ラダープログラムを実行している期間(プログラム実行202)、END処理を実行している期間(END処理204)のいずれにおいてもユニット間リフレッシュが定周期の割り込みで実行される。基本ユニット3に対して多数の拡張ユニット4が接続されていれば、その接続台数に概ね比例してリフレッシュ対象のデバイスの数も増加するため、中断時間も増加する。   By the way, as described above, the inter-unit synchronization (inter-unit synchronization program) may be set to be repeatedly executed with a very short synchronization cycle. Therefore, as shown in FIG. 6B, if data is refreshed at the time of synchronization between units, data that requires real-time property can be maintained in a fresh state (this is called synchronous refresh). ). However, if synchronous refresh is executed for all devices that have been subject to batch refresh, the time taken for the ladder program in the flat field to be interrupted by the synchronous refresh accompanying the inter-unit synchronization becomes longer (in other words, Therefore, the amount of description of the inter-unit synchronization program executed with the synchronization refreshing is limited), which causes inconvenience when the basic unit 3 controls the expansion unit 4. This is because the basic unit 3 needs to generate an interrupt to the ladder program at the timing of inter-unit synchronization and execute synchronous refresh. It should be noted that the inter-unit refresh has a fixed period in any of the refresh period (inter-unit communication 201), the ladder program execution period (program execution 202), and the END process execution period (END process 204). It is executed by interruption. If a large number of expansion units 4 are connected to the basic unit 3, the number of devices to be refreshed increases in proportion to the number of connected units, so the interruption time also increases.

そこで、複数あるデバイスをそれぞれ一括リフレッシュの対象とするか、同期リフレッシュの対象とするかを選択できれば、ラダープログラムが中断される時間を削減できるであろう。つまり、基本ユニット3と拡張ユニット4との間で共有すべきデータの更新タイミングを選択可能とすれば、ユーザは自己が共用する範囲の中断時間に収まるように各デバイスについて更新タイミングを選択できるようになり、ユーザビリティが向上することになろう。なお、一部のデバイスは一括リフレッシュの対象として設定可能とされるだけでなく、同期リフレッシュの対象として設定可能であってもよい。   Therefore, if it is possible to select whether a plurality of devices are to be collectively refreshed or synchronously refreshed, the time during which the ladder program is interrupted can be reduced. That is, if the update timing of data to be shared between the basic unit 3 and the expansion unit 4 can be selected, the user can select the update timing for each device so that it falls within the interruption time within the range shared by the user. This will improve usability. Note that some devices may be set not only as a batch refresh target but also as a synchronous refresh target.

なお、これまでユーザプログラムであるラダープログラム内でダイレクト通信によって更新されていたようなバッファメモリについても同期リフレッシュの対象とされてもよい。つまり、同期リフレッシュの対象として選択されたバッファメモリについては、ラダープログラム内ではダイレクト通信のコードを記述する必要がなくなる。つまり、同期リフレッシュの対象として選択されたバッファメモリについては一括リフレッシュの対象とされているデバイスと同様にラダープログラム内で扱うことが可能となる。ラダープログラムの作成が容易になる点でもユーザビリティが向上しよう。また、ラダープログラム内でダイレクト通信により更新されていたデバイスについても同様に同期リフレッシュの対象として選択することが可能となる。   Note that a buffer memory that has been updated by direct communication in the ladder program, which is a user program, may also be subject to synchronous refresh. That is, it is not necessary to write a direct communication code in the ladder program for the buffer memory selected for synchronous refresh. That is, the buffer memory selected as the target of the synchronous refresh can be handled in the ladder program in the same manner as the device that is the target of the batch refresh. Usability will also improve in that it makes it easier to create ladder programs. Similarly, a device that has been updated by direct communication in the ladder program can be selected as a target for synchronous refresh.

<基本ユニットの機能>
図7は基本ユニット3の機能の一例を示すブロック図である。CPU10は制御プログラム77を実行することで様々な機能を実現する。なお、機能の一部はASICなどの論理回路によって実装されてもよい。
<Functions of basic unit>
FIG. 7 is a block diagram illustrating an example of functions of the basic unit 3. The CPU 10 implements various functions by executing the control program 77. Note that some of the functions may be implemented by a logic circuit such as an ASIC.

基本ユニット制御部70は基本ユニット3の各部を統括的に制御する機能である。たとえば、基本ユニット制御部70はスキャンの管理やユニット間リフレッシュなどのための割り込みの管理などを実行する。基本ユニット制御部70はCPU10が制御プログラム77を実行することで実現される機能である。プログラム実行部71は、主にラダープログラム78などを実行する機能である。プログラム実行部71はASICなどにより実装されると、制御の高速化を実現しやすい。デバイス制御部72は、デバイス80に対する読み書きを制御する機能である。デバイス制御部72は、たとえば、同期リフレッシュが実行されている間は、デバイス80の内容が他の手段によって書き換えられたり、読み出されたりしないように、排他・調停処理(禁止処理)を実行する。デバイス制御部72は、第2更新部76が同期リフレッシュを実行している間は、第2更新部76以外の手段による割り込みを禁止してもよい。なお、同期リフレッシュを開始したときにすでに発生している割り込みについては禁止されずに、そのまま実行される。   The basic unit control unit 70 is a function for comprehensively controlling each unit of the basic unit 3. For example, the basic unit control unit 70 executes scan management, interrupt management for inter-unit refresh, and the like. The basic unit control unit 70 is a function realized by the CPU 10 executing the control program 77. The program execution unit 71 is a function that mainly executes a ladder program 78 and the like. If the program execution unit 71 is implemented by an ASIC or the like, it is easy to realize high-speed control. The device control unit 72 is a function that controls reading and writing with respect to the device 80. For example, while the synchronous refresh is being executed, the device control unit 72 executes an exclusion / arbitration process (prohibition process) so that the contents of the device 80 are not rewritten or read by other means. . The device control unit 72 may prohibit interruption by means other than the second update unit 76 while the second update unit 76 is executing synchronous refresh. Note that an interrupt that has already occurred when synchronous refresh is started is not prohibited and is executed as it is.

ユニット間同期部73は、予め定められた同期周期にしたがってユニット間同期プログラムを実行する。ユニット間同期プログラムは、平場のラダープログラムに対して割り込みをかけて実行されるプログラムであり、基本的に平場のラダープログラムよりも短い周期で実行される。ユニット間同期部73は、拡張ユニットタイマ119(図8)のタイマ値と基本ユニットタイマ88のタイマ値とを同期させるタイマ同期を実行する。タイマ同期を実行する機能はタイマ同期部としてユニット間同期部73から独立して設けられていてもよい。これは拡張ユニット4に関しても同様である。タイマ同期の周期はたとえば1000マイクロ秒などである。これにより、基本ユニット3の制御周期に対して拡張ユニット4の制御周期が同期する。一般に、ユニット間同期が実行されない場合、基本ユニット3の制御周期と拡張ユニット4の制御周期が徐々にずれて行き、基本ユニット3が拡張ユニット4を精度よく制御できなくなることがある。そのため、ユニット間同期プログラムを実行することで、基本ユニット3の制御周期と拡張ユニット4の制御周期が位相レベルで一致するようになる。基本ユニットタイマ88はクロックを計数して時間を計測するタイマまたはカウンタである。ユニット間同期部73は、基本ユニットタイマ88のタイマ値を基準とした同期周期にしたがってユニット間同期プログラムを実行する。ユニット間同期部73は、通信部14に接続された拡張バスを介して拡張ユニット4に対して同期タイミングを通知するための同期信号を送信する。通信部14には拡張バスによる通信を行うための通信機能やプログラム作成支援装置1と通信するための通信機能とが含まれているものとする。   The inter-unit synchronization unit 73 executes the inter-unit synchronization program according to a predetermined synchronization cycle. The inter-unit synchronization program is a program that is executed by interrupting the flat ladder program, and is basically executed in a shorter cycle than the flat ladder program. The inter-unit synchronization unit 73 performs timer synchronization that synchronizes the timer value of the extension unit timer 119 (FIG. 8) and the timer value of the basic unit timer 88. The function of executing timer synchronization may be provided as a timer synchronization unit independently from the inter-unit synchronization unit 73. The same applies to the expansion unit 4. The period of timer synchronization is, for example, 1000 microseconds. Thereby, the control cycle of the extension unit 4 is synchronized with the control cycle of the basic unit 3. In general, when inter-unit synchronization is not executed, the control cycle of the basic unit 3 and the control cycle of the expansion unit 4 may gradually shift, and the basic unit 3 may not be able to control the expansion unit 4 with high accuracy. Therefore, by executing the inter-unit synchronization program, the control cycle of the basic unit 3 and the control cycle of the expansion unit 4 coincide with each other in phase level. The basic unit timer 88 is a timer or counter that counts clocks and measures time. The inter-unit synchronization unit 73 executes the inter-unit synchronization program according to the synchronization cycle with the timer value of the basic unit timer 88 as a reference. The inter-unit synchronization unit 73 transmits a synchronization signal for notifying the expansion unit 4 of the synchronization timing via the expansion bus connected to the communication unit 14. It is assumed that the communication unit 14 includes a communication function for performing communication using the expansion bus and a communication function for communicating with the program creation support apparatus 1.

更新部74は、基本ユニット3がデバイスに記憶しているデータと拡張ユニット4がデバイスに記憶しているデータとが一致するように相互に更新する機能である。たとえば、基本ユニット3から拡張ユニット4に転送されるデータは出力デバイスに格納される。拡張ユニット4から基本ユニット3に転送されるデータは入力デバイスに格納される。一般に、複数の出力デバイスはまとめて出力リフレッシュによって更新され、複数の入力デバイスはまとめて入力リフレッシュによって更新される。入力リフレッシュと出力リフレッシュは一括リフレッシュと同期リフレッシュの双方に存在する。第1更新部75は一括リフレッシュを実行する機能である。つまり、第1更新部75はスキャン毎のリフレッシュの期間内で拡張ユニット4が保持しているデータと基本ユニット3が保持しているデータとを一致させる。第2更新部76は同期リフレッシュを実行する機能である。つまり、第2更新部76はユニット間同期部73により拡張ユニットタイマ119のタイマ値と同期した基本ユニットタイマ88のタイマ値に基づいてスキャン中に定周期で実行される処理の期間内で拡張ユニット4が保持しているデータと基本ユニット3が保持しているデータとを一致させる。なお第2更新部76はスキャンタイム内のいずれの期間であっても割り込んで同期リフレッシュを実行しうる。   The update unit 74 is a function of updating the data stored in the device by the basic unit 3 and the data stored in the device by the expansion unit 4 so that they match each other. For example, data transferred from the basic unit 3 to the expansion unit 4 is stored in the output device. Data transferred from the expansion unit 4 to the basic unit 3 is stored in the input device. In general, a plurality of output devices are updated together by output refresh, and a plurality of input devices are updated together by input refresh. Input refresh and output refresh exist in both batch refresh and synchronous refresh. The first update unit 75 is a function for executing batch refresh. That is, the first update unit 75 matches the data held by the extension unit 4 with the data held by the basic unit 3 within the refresh period for each scan. The second update unit 76 has a function of executing synchronous refresh. In other words, the second update unit 76 uses the inter-unit synchronization unit 73 within the period of processing executed at regular intervals during scanning based on the timer value of the basic unit timer 88 synchronized with the timer value of the extension unit timer 119. The data held by 4 and the data held by the basic unit 3 are matched. Note that the second update unit 76 can interrupt and execute synchronous refresh during any period within the scan time.

ユーザプログラムであるラダープログラム78に記述される拡張ユニット4のデバイスは、第1更新部75による更新の対象と第2更新部76による更新の対象とのうち少なくともいずれかの更新対象として設定可能に構成される。基本ユニット制御部70は、第1更新部75による更新の対象となるデータ/デバイスや第2更新部76による更新の対象となるデータ/デバイスを選択する選択手段として機能してもよい。つまり、基本ユニット制御部70はデバイスを更新する更新手段として、第1更新部75および第2更新部76のうち少なくとも一方を選択する選択手段として機能してもよい。たとえば、基本ユニット制御部70は、操作部6からの指示にしたがって各デバイスを一括リフレッシュの対象とするか、それとも同期リフレッシュの対象とするかを選択し、選択結果を設定データ79に保持する。つまり、設定データ79には、同期リフレッシュの対象となるデバイスやバッファメモリを指定する更新対象指定情報が含まれる。なお、一括リフレッシュの対象となるデバイスやバッファメモリについても更新対象指定情報として設定データ79に含まれてもよい。なお、プログラム作成支援装置1においてこのような設定データ79が作成され、ラダープログラム78とともに基本ユニット3に転送されてきてもよい。なお、同期リフレッシュの対象だけが選択可能とされ、一括リフレッシュの対象は選択不可能にされてもよい。また、一括リフレッシュの対象だけが選択可能とされ、同期リフレッシュの対象は選択不可能にされてもよい。   The device of the expansion unit 4 described in the ladder program 78 that is a user program can be set as at least one of the update target by the first update unit 75 and the update target by the second update unit 76. Composed. The basic unit control unit 70 may function as a selection unit that selects data / devices to be updated by the first update unit 75 and data / devices to be updated by the second update unit 76. That is, the basic unit control unit 70 may function as a selection unit that selects at least one of the first update unit 75 and the second update unit 76 as an update unit that updates a device. For example, the basic unit control unit 70 selects whether each device is to be subjected to batch refresh or synchronous refresh according to an instruction from the operation unit 6 and holds the selection result in the setting data 79. That is, the setting data 79 includes update target designation information that designates a device or buffer memory that is a target of synchronous refresh. It should be noted that devices and buffer memories that are targets of batch refresh may also be included in the setting data 79 as update target designation information. Note that such setting data 79 may be created in the program creation support apparatus 1 and transferred to the basic unit 3 together with the ladder program 78. Only the synchronous refresh target may be selectable, and the batch refresh target may be disabled. Further, only the batch refresh target may be selectable, and the synchronous refresh target may be disabled.

記憶装置12には制御プログラム77が記憶されている。制御プログラム77にはスキャンを実行するスキャンプログラムやユニット間同期を実行するユニット間同期プログラム、割り込みを実行する割り込みモジュールなどが含まれている。なお、ユニット間同期プログラムは、ユニット間同期処理によって拡張ユニットタイマ119(図8)のタイマ値と同期した基本ユニットタイマ88のタイマ値に基づいて実行される。記憶装置12はプログラム記憶部としても機能する。スキャンとはスキャンタイム内でユーザプログラムとEND処理とを周期的に繰り返し実行させることをいう。END処理には一括リフレッシュと周辺処理とが含まれる。スキャンタイムTはスキャンに要する時間であり、一定に設定されるケースと可変とされるケースがあるが、本実施形態ではそのどちらのケースにも適用可能である。   A control program 77 is stored in the storage device 12. The control program 77 includes a scan program for executing a scan, an inter-unit synchronization program for executing inter-unit synchronization, an interrupt module for executing an interrupt, and the like. The inter-unit synchronization program is executed based on the timer value of the basic unit timer 88 synchronized with the timer value of the extension unit timer 119 (FIG. 8) by inter-unit synchronization processing. The storage device 12 also functions as a program storage unit. Scanning means that a user program and END processing are repeatedly executed within a scan time. The END processing includes batch refresh and peripheral processing. The scan time T is a time required for scanning, and there are cases where the scan time T is set to be constant and cases where the scan time T is variable.

スキャン制御プログラムや同期プログラムもラダー言語により記述されていてもよい。ユーザプログラムの一種であるラダープログラム78はラダー言語により記述され、基本ユニット3の内部機能や拡張ユニット4の内部機能を制御するためのユーザプログラムである。設定データ79には基本ユニット3や拡張ユニット4の接続順序や内部機能を制御するために必要となるパラメータなどが含まれている。デバイス80は、たとえば、拡張ユニット4の内部機能に割り付けられたデータを機能する記憶領域であり、デバイスメモリと呼ばれることもある。ここではデバイス80は複数のデバイスの集合として記載されている。第1デバイス81は一括リフレッシュの対象として選択されているデバイスである。第2デバイス82は同期リフレッシュの対象として選択されているデバイスである。第1デバイス81の数は一般に第2デバイス82の数よりも多いが、これは逆であってもよい。第3デバイス83は、オプションであり、拡張ユニット4のバッファメモリUGに割り付けられたデバイスメモリである。第3デバイス83については、第1更新部75が一括リフレッシュしてもよいし、第2更新部76が同期リフレッシュしてもよい。第3デバイス83とバッファメモリUGの割り付け関係や、どちらのリフレッシュが適用されるかを示す情報についても設定データ79に保持されている。複数の第3デバイス83が設けられていてもよい。どちらのリフレッシュが適用されるかに応じて、更新部74では、第3デバイス83が第1デバイス81として扱われたり、第2デバイス82として扱われたりすることになる。   The scan control program and the synchronization program may also be described in a ladder language. A ladder program 78, which is a kind of user program, is written in a ladder language, and is a user program for controlling the internal functions of the basic unit 3 and the internal functions of the expansion unit 4. The setting data 79 includes parameters necessary for controlling the connection order and internal functions of the basic unit 3 and the expansion unit 4. The device 80 is a storage area that functions, for example, data assigned to the internal function of the expansion unit 4, and is sometimes called a device memory. Here, the device 80 is described as a set of a plurality of devices. The first device 81 is a device selected as a batch refresh target. The second device 82 is a device selected as a target for synchronous refresh. The number of first devices 81 is generally greater than the number of second devices 82, but this may be reversed. The third device 83 is an optional device memory allocated to the buffer memory UG of the expansion unit 4. For the third device 83, the first update unit 75 may perform batch refresh, or the second update unit 76 may perform synchronous refresh. Information indicating the allocation relationship between the third device 83 and the buffer memory UG and which refresh is applied is also held in the setting data 79. A plurality of third devices 83 may be provided. Depending on which refresh is applied, the update unit 74 treats the third device 83 as the first device 81 or the second device 82.

<拡張ユニットの機能>
図8は拡張ユニットの機能の一例を示すブロック図である。CPU110は記憶装置111に記憶されているシステムプログラム117を実行することで様々な機能を実現する。拡張ユニット制御部113は、第1デバイス118や第2デバイス120に書き込まれる基本ユニット3からの指示に応じて被制御装置16を制御する機能である。記憶装置111は、ROMやRAMなどを有し、記憶装置111における一部のメモリは書き換え可能な不揮発性メモリであってもよい。CPU110は被制御装置16と通信するためのインターフェース123を有している。ユニット間同期部114は、拡張バスおよび通信部112を介して基本ユニット3から送信される同期信号にしたがって拡張ユニット4における内部処理の制御周期を基本ユニット3の制御周期に同期させるものでる。拡張ユニットタイマ119はクロックを計数して時間を計測するタイマまたはカウンタである。ユニット間同期部114は、拡張ユニットタイマ119のタイマ値を基本ユニットタイマ88のタイマ値に一致させるように動作してもよい。なお、ユニット間同期部114は、第2更新部76における更新処理の遅延時間に応じて拡張ユニット4で実行される内部処理の開始を遅延(延期)させる延期部115を備えていてもよい。更新処理が完了していないにもかかわらず、拡張ユニット4が内部処理を開始してしまうと、最新のデバイス値が内部処理に反映されなくなってしまう。そこで、更新処理が完了するまで内部処理の開始タイミングを延期することで、内部処理は最新のデバイス値を利用できるようになる。
<Function of expansion unit>
FIG. 8 is a block diagram showing an example of the function of the expansion unit. The CPU 110 implements various functions by executing the system program 117 stored in the storage device 111. The extension unit control unit 113 has a function of controlling the controlled device 16 in accordance with an instruction from the basic unit 3 written in the first device 118 or the second device 120. The storage device 111 includes a ROM, a RAM, and the like, and a part of the memory in the storage device 111 may be a rewritable nonvolatile memory. The CPU 110 has an interface 123 for communicating with the controlled device 16. The inter-unit synchronization unit 114 synchronizes the control cycle of internal processing in the expansion unit 4 with the control cycle of the basic unit 3 in accordance with the synchronization signal transmitted from the basic unit 3 via the expansion bus and communication unit 112. The expansion unit timer 119 is a timer or counter that counts clocks and measures time. The inter-unit synchronization unit 114 may operate so that the timer value of the extension unit timer 119 matches the timer value of the basic unit timer 88. The inter-unit synchronization unit 114 may include a postponement unit 115 that delays (postpones) the start of internal processing executed by the expansion unit 4 in accordance with the delay time of the update processing in the second update unit 76. If the expansion unit 4 starts internal processing even though the update processing has not been completed, the latest device value is not reflected in the internal processing. Therefore, by delaying the start timing of the internal process until the update process is completed, the internal process can use the latest device value.

記憶装置111にはデバイス値を格納するデバイスやダイレクト通信の対象となるバッファなどの記憶領域が確保される。第1デバイス118は、一括リフレッシュされるデバイスである。第1デバイス118のデバイス値は、基本ユニット3の第1デバイス81と一致するデバイス値が格納される。第2デバイス120は、同期リフレッシュされるデバイスである。第2デバイス120のデバイス値は、基本ユニット3の第2デバイス82と一致するデバイス値が格納される。なお、第1デバイス81や第2デバイス120は複数のバッファにより実現されてもよい。第1バッファ121は、基本ユニット3とデバイス値を交換するためのバッファである。第2バッファ122は、拡張ユニット制御部113がデバイス値を入力したり、出力したりするためのバッファである。バッファ更新部116はオプションのユニットであり、1つのデバイスを複数のバッファにより実現するときに必要となる。第2デバイス120が出力デバイスである場合、バッファ更新部116は、基本ユニット3の第2デバイス82のデバイス値を第1バッファ121に格納し、第1バッファ121に格納されたデバイス値をさらに第2バッファ122に格納する。第2デバイス120が入力デバイスである場合、バッファ更新部116は、内部処理の結果であるデバイス値を第2バッファ122に格納し、第2バッファ122に格納されたデバイス値を第1バッファ121に格納し、第1バッファ121に格納されたデバイス値を基本ユニット3の第2デバイス82に転送する。このように第1バッファ121は同期リフレッシュの際に参照され、第2バッファ121は拡張ユニット4の内部処理によって参照される。このようなダブルバッファ構成を採用することで、第2デバイス120のデバイス値が確定してから、リフレッシュや内部処理に利用されるようになる。つまり、リフレッシュの途中でデバイス値が書き換えられてしまったり、内部処理の途中でデバイス値が書き換えられてしまったりすることが起きにくくなる。デバイス値には、一緒のタイミングで更新される必要がある複数のデバイス値の集合や(同時性)、更新の順序が決まっている複数のデバイス値の集合が存在する(順序性)。また、基本ユニット3と拡張ユニット4との間での伝達遅延時間がそれぞれほぼ同じになることを要求される複数のデバイス値の集合も存在する(伝達遅延時間の一定性)。たとえば、1つ目のデバイスには分母が格納され、2つ目のデバイスには分子が格納されており、この分母と分子とによって制御値が決定されることがある。このような制御値において、拡張ユニット制御部113が分母を取得した後で、分子が同期リフレッシュによって書き換えられてしまうと、分母と分子のペアが破たんし(いわゆる泣き別れ現象)、制御値が異常となる。よって、分母と分子のペアのように同時性を要求されるデバイスに関してはダブルバッファ構成が有効である。バッファ更新部116は、同時性を要求される複数のデバイス値が揃った後で第1バッファ121から第2バッファ122へ、または、第2バッファ122から第1バッファ121へバッファ更新を行うことで、複数のデバイス値の泣き別れを抑制できるようになる。なお、ダブルバッファ構成は順序性や伝達遅延時間の一定性を確保するためにも役立つ。バッファメモリUGは、通常はダイレクト通信によってアクセスされるメモリである。本実施形態では、複数のバッファメモリUGの1つ以上について第3デバイス83に割り付けられうる。第3デバイス83に割り付けられたバッファメモリUGは一括リフレッシュされたり、同期リフレッシュされたりするため、ダイレクト通信による更新が不要となる。   In the storage device 111, storage areas such as a device for storing a device value and a buffer to be subjected to direct communication are secured. The first device 118 is a device that is collectively refreshed. As the device value of the first device 118, a device value that matches the first device 81 of the basic unit 3 is stored. The second device 120 is a device that is synchronously refreshed. As the device value of the second device 120, a device value that matches the second device 82 of the basic unit 3 is stored. The first device 81 and the second device 120 may be realized by a plurality of buffers. The first buffer 121 is a buffer for exchanging device values with the basic unit 3. The second buffer 122 is a buffer for the expansion unit control unit 113 to input and output device values. The buffer update unit 116 is an optional unit and is necessary when one device is realized by a plurality of buffers. When the second device 120 is an output device, the buffer update unit 116 stores the device value of the second device 82 of the basic unit 3 in the first buffer 121, and further stores the device value stored in the first buffer 121. 2 stored in the buffer 122. When the second device 120 is an input device, the buffer update unit 116 stores the device value as a result of the internal processing in the second buffer 122, and stores the device value stored in the second buffer 122 in the first buffer 121. The device value stored in the first buffer 121 is transferred to the second device 82 of the basic unit 3. As described above, the first buffer 121 is referred to during synchronous refresh, and the second buffer 121 is referred to by internal processing of the expansion unit 4. By adopting such a double buffer configuration, the device value of the second device 120 is determined and then used for refresh and internal processing. That is, it is difficult for the device value to be rewritten during the refresh or the device value is rewritten during the internal processing. The device value includes a set of a plurality of device values that need to be updated at the same timing (simultaneity), and a set of a plurality of device values in which the update order is determined (order). There is also a set of a plurality of device values required to have substantially the same transmission delay time between the basic unit 3 and the expansion unit 4 (constancy of transmission delay time). For example, the denominator is stored in the first device and the numerator is stored in the second device, and the control value may be determined by the denominator and the numerator. In such a control value, if the numerator is rewritten by synchronous refresh after the expansion unit control unit 113 acquires the denominator, the denominator-numerator pair is broken (so-called crying phenomenon), and the control value is abnormal. Become. Therefore, the double buffer configuration is effective for devices that require simultaneity, such as a denominator and numerator pair. The buffer update unit 116 performs buffer update from the first buffer 121 to the second buffer 122 or from the second buffer 122 to the first buffer 121 after a plurality of device values for which simultaneity is required are obtained. , It will be possible to suppress the crying of multiple device values. The double buffer configuration is also useful for ensuring the order and the constant transmission delay time. The buffer memory UG is a memory that is normally accessed by direct communication. In the present embodiment, one or more of the plurality of buffer memories UG can be allocated to the third device 83. Since the buffer memory UG allocated to the third device 83 is refreshed collectively or synchronously, it is not necessary to update by direct communication.

<プログラム作成支援装置の機能>
図9はプログラム作成支援装置1のCPU24が編集ソフトウエア86を実行することで実現する機能を示している。編集ソフトウエア86は、ラダープログラム78や設定データ79などをユーザが編集するために使用するプログラムである。
<Functions of the program creation support device>
FIG. 9 shows functions realized by the CPU 24 of the program creation support apparatus 1 executing the editing software 86. The editing software 86 is a program used by a user to edit a ladder program 78, setting data 79, and the like.

CPU24は編集ソフトウエア86を実行することで様々な手段として機能するが、ここでは代表的なものについて説明する。ラダープログラム作成部87は表示部7にラダープログラム78を作成および編集するためのユーザインタフェースを表示し、操作部8から入力される指示にしたがってラダープログラム78を作成し、記憶装置25に書き込む。設定データ作成部84は、設定データ79を作成するためのユーザインタフェースを表示部7に表示し、操作部8から入力される指示にしたがって設定データ79を作成し、記憶装置25に書き込む。たとえば、設定データ作成部84は、基本ユニット3に接続される複数の拡張ユニット4のデバイスを列挙したリストを表示部7に表示し、デバイスごとに一括リフレッシュの対象とするか、同期リフレッシュの対象となるかを選択する。なお、1つの拡張ユニット4あたりのデバイスの数が少ない場合、設定データ作成部84は、拡張ユニット4を単位として、一括リフレッシュの対象とするか、同期リフレッシュの対象となるかを選択してもよい。たとえば、設定データ作成部84は、基本ユニット3に接続される複数の拡張ユニット4を列挙したリストを表示部7に表示し、拡張ユニット4ごとに一括リフレッシュの対象とするか、同期リフレッシュの対象となるかを選択する。このように設定データ79には、各デバイスごとに一括リフレッシュの対象とするか、同期リフレッシュの対象となるかを示す情報が含まれていてもよい。プロジェクト転送部85は、ラダープログラム78および設定データ79などをプロジェクトデータとしてまとめ、通信部26を介して基本ユニット3に転送する。通信部26は、基本ユニット3と通信するためのUSBインターフェースやLANインターフェースを有している。   The CPU 24 functions as various means by executing the editing software 86, but here, representative ones will be described. The ladder program creation unit 87 displays a user interface for creating and editing the ladder program 78 on the display unit 7, creates the ladder program 78 in accordance with instructions input from the operation unit 8, and writes the ladder program 78 in the storage device 25. The setting data creation unit 84 displays a user interface for creating the setting data 79 on the display unit 7, creates the setting data 79 in accordance with an instruction input from the operation unit 8, and writes it in the storage device 25. For example, the setting data creation unit 84 displays a list in which the devices of the plurality of expansion units 4 connected to the basic unit 3 are listed on the display unit 7 and is set as a target of batch refresh for each device or a target of synchronous refresh Select what will be. When the number of devices per one expansion unit 4 is small, the setting data creation unit 84 may select whether to perform batch refresh or synchronous refresh for each expansion unit 4 as a unit. Good. For example, the setting data creation unit 84 displays a list listing a plurality of extension units 4 connected to the basic unit 3 on the display unit 7, and sets each of the extension units 4 as a batch refresh target or a synchronous refresh target. Select what will be. As described above, the setting data 79 may include information indicating whether each device is subject to batch refresh or synchronous refresh. The project transfer unit 85 collects the ladder program 78 and setting data 79 as project data, and transfers them to the basic unit 3 via the communication unit 26. The communication unit 26 has a USB interface and a LAN interface for communicating with the basic unit 3.

<フローチャート>
図10は基本ユニット3が実行する処理を示すフローチャートである。基本ユニット3がメンテナンスモード(プログラミングモード)からランモードに切り替えられると、CPU10は制御プログラム77にしたがって本フローチャートに係る処理を実行する。なお、本実施形態ではランモードにおいてユニット間同期処理が実行されるが、メンテナンスモードにおいてもユニット間同期処理が実行されるようにしてもよい。
<Flowchart>
FIG. 10 is a flowchart showing processing executed by the basic unit 3. When the basic unit 3 is switched from the maintenance mode (programming mode) to the run mode, the CPU 10 executes the processing according to this flowchart according to the control program 77. In this embodiment, the inter-unit synchronization process is executed in the run mode, but the inter-unit synchronization process may be executed in the maintenance mode.

S1でCPU10(第1更新部75)は一括リフレッシュを実行する。たとえば、第1更新部75は複数あるデバイスのうち設定データ79によって一括リフレッシュの対象として選択されているデバイスについて一括リフレッシュを実行する。   In S1, the CPU 10 (first updating unit 75) executes batch refresh. For example, the first updating unit 75 performs batch refresh on a device selected as a batch refresh target by the setting data 79 among a plurality of devices.

S2でCPU10(プログラム実行部71)はユーザプログラムであるラダープログラム78を開始する。以降、プログラム実行部71は、ラダープログラム78が終了するまで、制御プログラム77と並列にラダープログラム78を実行する。   In S2, the CPU 10 (program execution unit 71) starts a ladder program 78 which is a user program. Thereafter, the program execution unit 71 executes the ladder program 78 in parallel with the control program 77 until the ladder program 78 ends.

S3でCPU10(ユニット間同期部73)はユニット間同期をトリガーするイベントが発生したかどうかを判定する。このイベントは割り込みモジュール(ユニット間同期部73または基本ユニット制御部70)などによって所定期間ごとに発生するものとする。たとえば、ユニット間同期部73は基本ユニットタイマ88のタイマ値が所定値増えるごとにユニット間同期を実行してもよい。ユニット間同期の通知は信号線などを通じて拡張ユニット4にも発生する。ユニット間同期のイベントが発生するとS4に進む。ユニット間同期のイベントが発生していなければ、ラダープログラム78が継続され、S8に進む。   In S3, the CPU 10 (inter-unit synchronization unit 73) determines whether an event that triggers inter-unit synchronization has occurred. This event is generated every predetermined period by an interrupt module (inter-unit synchronization unit 73 or basic unit control unit 70). For example, the inter-unit synchronization unit 73 may perform inter-unit synchronization each time the timer value of the basic unit timer 88 increases by a predetermined value. The inter-unit synchronization notification is also generated in the extension unit 4 through a signal line or the like. If an inter-unit synchronization event occurs, the process proceeds to S4. If no inter-unit synchronization event has occurred, the ladder program 78 is continued, and the process proceeds to S8.

S4でCPU10(ユニット間同期部73、プログラム実行部71)は、基本ユニットタイマ88のタイマ値に基づき定周期で発生する同期リフレッシュのための割り込みによってラダープログラムを中断する。たとえば、ユニット間同期部73は基本ユニットタイマ88のタイマ値に基づきプログラム実行部71にラダープログラムを中断するよう指示する。これによりプログラム実行部71はラダープログラムを中断する。なお、割り込み自体が中断の指示として認識されてもよい。   In S <b> 4, the CPU 10 (inter-unit synchronization unit 73, program execution unit 71) interrupts the ladder program by an interrupt for synchronous refresh that occurs at regular intervals based on the timer value of the basic unit timer 88. For example, the inter-unit synchronization unit 73 instructs the program execution unit 71 to interrupt the ladder program based on the timer value of the basic unit timer 88. As a result, the program execution unit 71 interrupts the ladder program. Note that the interrupt itself may be recognized as an interruption instruction.

S5でCPU10(第2更新部76)は同期リフレッシュを実行する。第2更新部76は複数あるデバイスのうち設定データ79によって同期リフレッシュの対象として選択されているデバイスについて一括リフレッシュを実行する。   In S5, the CPU 10 (second update unit 76) executes synchronous refresh. The second update unit 76 performs batch refresh on the devices that are selected as the target of synchronous refresh by the setting data 79 among a plurality of devices.

S6でCPU10(ユニット間同期部73)はユニット間同期プログラムを実行する。基本ユニット3のユニット間同期部73と拡張ユニット4のユニット間同期部114は拡張バスを通じて通信し、相互にタイマ値を一致させることで双方の制御周期を同期させる。   In S6, the CPU 10 (inter-unit synchronization unit 73) executes the inter-unit synchronization program. The inter-unit synchronization unit 73 of the basic unit 3 and the inter-unit synchronization unit 114 of the expansion unit 4 communicate through the expansion bus, and synchronize their control periods by matching the timer values with each other.

S7でCPU10(ユニット間同期部73、プログラム実行部71)はラダープログラム78を再開する。たとえば、ユニット間同期部73はプログラム実行部71にラダープログラムを再開するよう指示する。これによりプログラム実行部71はラダープログラムを再開する。   In S7, the CPU 10 (inter-unit synchronization unit 73, program execution unit 71) resumes the ladder program 78. For example, the inter-unit synchronization unit 73 instructs the program execution unit 71 to resume the ladder program. As a result, the program execution unit 71 resumes the ladder program.

S8でCPU10(基本ユニット制御部70)はラダープログラム78が終了したかどうかを判定する。ラダープログラム78が終了していなければ、S3に戻る。ラダープログラム78が終了したのであれば、S9に進む。   In S8, the CPU 10 (basic unit controller 70) determines whether or not the ladder program 78 has ended. If the ladder program 78 has not ended, the process returns to S3. If the ladder program 78 is completed, the process proceeds to S9.

S9でCPU10(基本ユニット制御部70)は上述したEND処理を実行する。これにより1つのキャンタイムが終了する。その後、次のスキャンを開始するために、S1に戻る。以降、ランモードからメンテナンスモードに切り替わるまで、図5に示したように、スキャンTにしたがって本フローチャートに係る処理が繰り返し実行される。   In S9, the CPU 10 (basic unit controller 70) executes the END process described above. This completes one can time. Thereafter, the process returns to S1 to start the next scan. Thereafter, until the mode is switched from the run mode to the maintenance mode, the processing according to this flowchart is repeatedly executed according to the scan T as shown in FIG.

ここではラダープログラム78の実行中にユニット間同期が実行されるものとして説明したが、一括リフレッシュ(S1)中やEND処理(S9)中のいずれにおいてもユニット間同期は実行される。つまり、S1およびS9にはS3ないしS7に相当するステップが含まれている。ここで、S4、S7に記載のラダープログラムは一括リフレッシュとEND処理に読み替えられるものとする。   Here, it has been described that the inter-unit synchronization is executed during the execution of the ladder program 78, but the inter-unit synchronization is executed in both the batch refresh (S1) and the END process (S9). That is, S1 and S9 include steps corresponding to S3 to S7. Here, it is assumed that the ladder program described in S4 and S7 can be read as batch refresh and END processing.

図11は拡張ユニット4が実行する処理を示すフローチャートである。ここでは一括リフレッシュについては省略している。なお、CPU110はシステムプログラム117にしたがって以下の処理を実行する。   FIG. 11 is a flowchart showing processing executed by the expansion unit 4. Here, the batch refresh is omitted. The CPU 110 executes the following processing according to the system program 117.

S11でCPU110(ユニット間同期部114)はユニット間同期の通知が発生するのを待つ。拡張バスを通じてユニット間同期の通知を受信すると、S12に進む。   In S11, the CPU 110 (inter-unit synchronization unit 114) waits for notification of inter-unit synchronization. When the notification of inter-unit synchronization is received through the expansion bus, the process proceeds to S12.

S12でCPU110(ユニット間同期部114、バッファ更新部116)は同期リフレッシュを実行する。バッファ更新部116は、第2デバイス120のうち入力デバイスに格納されているデバイス値を基本ユニット3に転送し、基本ユニット3から受信したデバイス値を出力デバイスに格納する。なお、ダブルバッファ構成が採用される場合、バッファ更新部116は、第1バッファ121と第2バッファ間でデバイス値の更新を行う。出力デバイスに関しては、基本ユニット3から受信したデバイス値が第1バッファ121に格納され、その後、第1バッファ121から第2バッファ122にコピーされる。拡張ユニット制御部113によって実行される内部処理は第2バッファ122に格納されているデバイス値を参照する。入力デバイスに関しては、拡張ユニット制御部113が実行する内部処理によって第2バッファ122に格納されたデバイス値が第1バッファ121にコピーされ、その後、第1バッファ121から基本ユニット3に転送される。   In S12, the CPU 110 (inter-unit synchronization unit 114, buffer update unit 116) executes synchronous refresh. The buffer update unit 116 transfers the device value stored in the input device of the second device 120 to the basic unit 3 and stores the device value received from the basic unit 3 in the output device. When the double buffer configuration is adopted, the buffer update unit 116 updates the device value between the first buffer 121 and the second buffer. Regarding the output device, the device value received from the basic unit 3 is stored in the first buffer 121, and then copied from the first buffer 121 to the second buffer 122. Internal processing executed by the extension unit control unit 113 refers to the device value stored in the second buffer 122. Regarding the input device, the device value stored in the second buffer 122 is copied to the first buffer 121 by internal processing executed by the expansion unit control unit 113, and then transferred from the first buffer 121 to the basic unit 3.

S13でCPU110(拡張ユニット制御部113)は第1デバイス118や第2デバイス120のうち入力デバイスからデバイス値を読み出し、デバイス値にしたがって内部処理を実行する。拡張ユニット制御部113は内部処理の実行結果を第1デバイス118や第2デバイス120のうち出力デバイス(とりわけ、出力デバイスの第2バッファ122)に格納する。   In S13, the CPU 110 (extension unit control unit 113) reads the device value from the input device of the first device 118 and the second device 120, and executes internal processing according to the device value. The expansion unit control unit 113 stores the execution result of the internal processing in the output device (in particular, the second buffer 122 of the output device) of the first device 118 and the second device 120.

このようにユニット間同期のタイミングで同期リフレッシュを実行することで、一括リフレッシュを前提とした通信用プログラム(基本ユニットが拡張ユニットと通信するためのプログラム)を同期リフレッシュの対象となったデバイスについても適用できるようになる。従来技術では、一括リフレッシュの対象となっていなかったデバイスなどについて任意のタイミングで最新のデバイス値が必要になるときは、平場のラダープログラム(メインのラダープログラム)内でダイレクト通信によってデバイス値を更新する必要があった。しかし、これはユーザにとって面倒なプログラミング作業であった。一方で、本実施例によれば、一括リフレッシュの対象となっていなかったデバイスについても同期リフレッシュによって更新されるため、ダイレクト通信のためのコードが不要となり、一括リフレッシュを前提とした通信用プログラムを同期リフレッシュに関しても流用できるようになる。   By executing synchronous refresh at the timing of inter-unit synchronization in this way, communication programs (programs for the basic unit to communicate with the expansion unit) that are premised on batch refresh can also be used for devices that are subject to synchronous refresh. Applicable. In the prior art, when the latest device value is required at any timing for devices that were not subject to batch refresh, the device value is updated by direct communication within the flat ladder program (main ladder program). There was a need to do. However, this was a cumbersome programming task for the user. On the other hand, according to the present embodiment, devices that are not subject to batch refresh are also updated by synchronous refresh, so a code for direct communication is not required, and a communication program that assumes batch refresh is provided. It can also be used for synchronous refresh.

<バッファメモリへの同期リフレッシュの適用>
なお、PLC2ではデバイスとは別にバッファメモリUGと呼ばれる記憶領域が存在する。デバイスはリフレッシュの対象となる記憶領域であり、バッファメモリUG(単にバッファと呼ばれることもある)はリフレッシュの対象とならず、ダイレクト通信によりアクセスされていた。このようなバッファメモリUGについても同期リフレッシュの対象として選択されてもよい。これにより、デバイスと比較してより複雑なコードが必要となっていたバッファメモリUGについても、同期リフレッシュにより、デバイスと同様なコードにより扱うことが可能となる。とりわけ、複数のバッファメモリUGに格納される値(バッファ値と呼ぶことにする)には、一緒のタイミングで更新される必要がある複数のバッファ値の集合や(同時性)、更新の順序が決まっている複数のバッファ値の集合が存在する(順序性)。たとえば、1つ目のバッファメモリには分母が格納され、2つ目のデバイスには分子が格納されており、この分母と分子とによって制御値が決定されることがある。このような制御値において、拡張ユニット制御部113が分母を取得した後で、分子が同期リフレッシュによって書き換えられてしまうと、分母と分子のペアが破たんし(泣き別れ)、制御値が異常となる。よって、分母と分子のペアのように同時性を要求されるバッファ値に関しては同期リフレッシュにおいて同時性や順序性を維持しつつ、更新される。また、伝達遅延時間の一定性が要求されるバッファメモリUGについても、第3デバイス83を割り付けて同期リフレッシュが適用されてもよい。これにより伝達遅延時間の一定性が確保されよう。なお、バッファメモリUGについてもダブルバッファ構成が採用されてもよい。なお、同期リフレッシュの対象となるバッファメモリUGおよび第3デバイス83については明細書の全体において第2デバイスと同様に扱われるものとする。つまり、第2デバイスに関する説明はそのままバッファメモリUGと第3デバイス83に適用される。また、バッファメモリUGおよび第3デバイス83が一括リフレッシュの対象として選択された場合、第1デバイスに関する説明はそのままバッファメモリUGと第3デバイス83に適用される。
<Application of synchronous refresh to buffer memory>
Note that the PLC 2 has a storage area called a buffer memory UG separately from the device. The device is a storage area to be refreshed, and the buffer memory UG (sometimes referred to simply as a buffer) is not to be refreshed and is accessed by direct communication. Such a buffer memory UG may also be selected as a target for synchronous refresh. As a result, the buffer memory UG that requires a more complicated code than the device can be handled by the same code as the device by synchronous refresh. In particular, values stored in a plurality of buffer memories UG (referred to as buffer values) include a set of a plurality of buffer values that need to be updated at the same time, (simultaneity), and an update order. There is a set of multiple fixed buffer values (ordering). For example, the denominator is stored in the first buffer memory, and the numerator is stored in the second device, and the control value may be determined by this denominator and numerator. In such a control value, if the numerator is rewritten by synchronous refresh after the expansion unit control unit 113 acquires the denominator, the denominator / numerator pair is broken (crying apart), and the control value becomes abnormal. Therefore, buffer values that require simultaneity, such as denominator and numerator pairs, are updated while maintaining simultaneity and order in synchronous refresh. In addition, the synchronous refresh may be applied to the buffer memory UG that requires constant transmission delay time by assigning the third device 83. This will ensure the uniformity of the transmission delay time. Note that the buffer memory UG may also employ a double buffer configuration. Note that the buffer memory UG and the third device 83 to be subjected to synchronous refresh are treated in the same manner as the second device throughout the specification. That is, the description regarding the second device is applied to the buffer memory UG and the third device 83 as they are. In addition, when the buffer memory UG and the third device 83 are selected as a target for batch refresh, the description regarding the first device is applied to the buffer memory UG and the third device 83 as they are.

<同期リフレッシュの対象となるデバイスの選択>
上述したようにユニット間同期はリフレッシュタイミングよりも短い周期(例:50us〜5ms)で実行されることがある。これは、基本ユニット3と拡張ユニット4との応答性(別の言い方をすれば、外部入力機器に対する基本ユニットの応答性、又は、基本ユニットに対する外部出力機器の応答性)のバラツキを小さくするためである。ユニット間同期を実行するタイミングで同期リフレッシュを実行するには、ユニット間同期の同期周期内で同期リフレッシュを完了しなければならない。よって、同期リフレッシュの対象となるデバイスの数はある程度制限される必要があるだろう。たとえば、一括リフレッシュの対象となっていたすべてのデバイスを同期リフレッシュの対象として選択してしまうと、ユニット間同期の周期を短くできなくなり、基本ユニット3と拡張ユニット4との応答性のバラツキを小さくすることが困難となろう。そこで、ユニット間同期の同期周期の長さを考慮して同期リフレッシュの対象が予め選択される。この選択は、プログラム作成支援装置1で実行されたり、または、基本ユニット3の操作部6を通じて実行されたりする。また、同期リフレッシュを割り込みプログラムにより実現し、選択されたデバイスについて同期リフレッシュが実行される。これは、スキャンタイムが長くなったりするなど、変動したりしても、安定的にユニット間同期と同期リフレッシュとを実現する。この場合、ユニット間同期は、スキャンタイム内のいずれの場所でも実行されうる。たとえば、ユニット間同期部73および第2更新部76は、ラダープログラムの実行期間だけでなく、一括リフレッシュの期間でもユニット間同期と同期リフレッシュを実行してもよい。定周期でユニット間同期と同期リフレッシュが実行されるようになり、基本ユニット3と拡張ユニット4との応答性のバラツキが小さくなろう。
<Selection of devices subject to synchronous refresh>
As described above, the inter-unit synchronization may be executed at a cycle shorter than the refresh timing (for example, 50 us to 5 ms). This is to reduce variations in the responsiveness of the basic unit 3 and the expansion unit 4 (in other words, the responsiveness of the basic unit to the external input device or the responsiveness of the external output device to the basic unit). It is. In order to execute the synchronous refresh at the timing of executing the inter-unit synchronization, the synchronous refresh must be completed within the synchronization cycle of the inter-unit synchronization. Thus, the number of devices subject to synchronous refresh will need to be limited to some extent. For example, if all devices that have been subject to batch refresh are selected as subjects for synchronous refresh, the inter-unit synchronization cycle cannot be shortened, and variations in responsiveness between the basic unit 3 and the expansion unit 4 are reduced. It will be difficult to do. Therefore, the synchronous refresh target is selected in advance in consideration of the length of the synchronization cycle of inter-unit synchronization. This selection is executed by the program creation support apparatus 1 or through the operation unit 6 of the basic unit 3. Further, the synchronous refresh is realized by an interrupt program, and the synchronous refresh is executed for the selected device. This realizes stable inter-unit synchronization and synchronous refresh even if the scan time fluctuates, for example. In this case, the inter-unit synchronization can be executed anywhere within the scan time. For example, the inter-unit synchronization unit 73 and the second update unit 76 may perform inter-unit synchronization and synchronous refresh not only during the ladder program execution period but also during the batch refresh period. Inter-unit synchronization and synchronous refresh will be executed at regular intervals, and variations in responsiveness between the basic unit 3 and the expansion unit 4 will be reduced.

なお、プログラム作成支援装置1の設定データ作成部84は、同期リフレッシュの対象となるデバイスやバッファメモリUGを選択するが、そもそもユニット間同期の対象となる拡張ユニット4を選択してもよい。これにより、ユニット間同期の対象となる拡張ユニット4の数が多く、ユニット間同期リフレッシュの対象になるデータの量が多い場合であっても、ユニット同期を実現しつつ、ユニット間同期の同期周期(例えば200μs)を短くすることができる。図16に例示するように、設定データ作成部84は、基本ユニット3に対して接続される複数の拡張ユニット4を列挙したリスト90などを表示し、操作部8から入力された指示に応じて、複数の拡張ユニット4のそれぞれについてユニット間同期の対象とするか否かを選択してもよい。たとえば、基本ユニット3と拡張ユニット4との応答性のバラツキを小さくする必要がある位置決めユニット(モーションユニット)についてはユニット間同期の対象として選択されてもよい。LAN通信ユニットなどはそれほどリアルタイム性を要求されないため、ユニット間同期の対象として選択されなくてもよい。なお、設定データ作成部84は、ユニット間同期に対応していない拡張ユニット4については強制的にユニット間同期の対象外を選択し、ユーザに対して選択の余地を与えなくてもよい。たとえば、設定データ作成部84はそのような拡張ユニットについてはグレーアウト表示し、操作部8による選択を不能にしてもよい。   The setting data creation unit 84 of the program creation support apparatus 1 selects a device or buffer memory UG that is a target of synchronous refresh, but may select an expansion unit 4 that is a target of synchronization between units in the first place. As a result, even when the number of extension units 4 that are subject to inter-unit synchronization is large and the amount of data that is subject to inter-unit synchronous refresh is large, the unit synchronization is realized while the unit synchronization is performed. (For example, 200 μs) can be shortened. As illustrated in FIG. 16, the setting data creation unit 84 displays a list 90 that lists a plurality of extension units 4 connected to the basic unit 3, and responds to an instruction input from the operation unit 8. It may be selected whether or not each of the plurality of expansion units 4 is to be subject to inter-unit synchronization. For example, a positioning unit (motion unit) that needs to reduce variations in responsiveness between the basic unit 3 and the extension unit 4 may be selected as a target for inter-unit synchronization. Since the LAN communication unit or the like is not required to be so real-time, it does not have to be selected as a target for inter-unit synchronization. Note that the setting data creation unit 84 may forcibly select the extension unit 4 that does not support inter-unit synchronization and exclude the unit from being subject to inter-unit synchronization, and may not give the user room for selection. For example, the setting data creation unit 84 may gray out such an extension unit and disable selection by the operation unit 8.

設定データ作成部84は、ユニット間同期の対象として選択された拡張ユニットについては、さらに、占有デバイスなどの特定のデバイスのリフレッシュを一括リフレッシュの対象とするか、それとも同期リフレッシュの対象とするかを選択するためのGUIを表示部7に表示してもよい。占有デバイスとは、拡張ユニットごとに予め割り付けられたデバイスのことである。たとえば、基本ユニット3との間での通信量が多い拡張ユニット4についてはその占有デバイスを同期リフレッシュの対象とすることで、一括リフレッシュ用のプログラムコードを同期リフレッシュ用に流用することが容易になる。なお、設定データ作成部84は、ユニット間同期の周期を短くすることが必要な拡張ユニット4の占有デバイスについてはあえて同期リフレッシュの対象外として選択してもよい。このようなデバイスについてはユニット間同期のタイミングで同期リフレッシュを行わないため、同期周期を短くすることが可能となる。   For the extension unit selected as the target for inter-unit synchronization, the setting data creation unit 84 further determines whether refresh of a specific device such as an occupied device is subject to batch refresh or subject to synchronous refresh. A GUI for selection may be displayed on the display unit 7. The occupied device is a device allocated in advance for each expansion unit. For example, with respect to the expansion unit 4 having a large amount of communication with the basic unit 3, it is easy to divert the program code for batch refresh for synchronous refresh by making the occupied device the subject of synchronous refresh. . Note that the setting data creation unit 84 may intentionally select the occupied device of the extension unit 4 that needs to shorten the synchronization cycle between units as a target for synchronous refresh. Such a device does not perform synchronous refresh at the timing of inter-unit synchronization, so that the synchronization cycle can be shortened.

<複数のデバイス値の泣き別れの抑制>
上述したように分子と分母とにより定まる比率などを正しく伝達するには、分子と分母とが同時性の要件を満たしてユニット間でリフレッシュされる必要がある。これを実現する手法としてすでにダブルバッファ構成について説明したが、他の排他調停方法が使用されてもよい。
<Suppression of crying of multiple device values>
As described above, in order to correctly transmit the ratio determined by the numerator and the denominator, the numerator and the denominator must satisfy the simultaneity requirement and be refreshed between units. Although the double buffer configuration has already been described as a method for realizing this, other exclusive arbitration methods may be used.

上述したように、拡張ユニット4の内部処理は複数の出力デバイスの値を参照する。また、拡張ユニット4の内部処理は複数の処理結果を入力デバイス値に格納する。複数の出力デバイスの値には同時性を要求されるものがある。同様に、複数の入力デバイス値にも同時性を要求されるものがある。   As described above, the internal processing of the expansion unit 4 refers to the values of a plurality of output devices. The internal processing of the expansion unit 4 stores a plurality of processing results in the input device value. Some output device values require simultaneity. Similarly, some input device values may require simultaneity.

そこで、図12が示すように、基本ユニット3の第2更新部76がこれのデバイスについて同期リフレッシュを完了するまで待ってから、拡張ユニット4は内部処理を開始する。つまり、図12に示すように、第1拡張ユニットおよび第2拡張ユニットのユニット間同期部114は、ユニット間同期によって同期リフレッシュのための割り込みが発生すると所定の待ち時間(リフレッシュ待ち時間と呼ばれてもよい)が経過するのを待ってから、拡張ユニット制御部113に内部処理を開始させる。なお、この待ち時間の間に、基本ユニット3の第2更新部76がデバイスやバッファメモリUGの同期リフレッシュを実行する。これにより、デバイス値が同期リフレッシュされている期間においては、拡張ユニット制御部113の内部処理がデバイス値を読み込んだり、書き込んだりしないようになり、泣き別れが発生しないようになる。このように拡張ユニット4のユニット間同期部114が同期リフレッシュと内部処理とを同期させることで、同期リフレッシュによるデバイスへのアクセスと、内部処理によるそのデバイスへのアクセスとが同時には発生しないようになる。つまり、拡張ユニット制御部113は待ち時間中のデバイスへのアクセスが排他または調停される。この排他・調停機能は、ユニット間同期部114に内蔵されてもよいが、拡張ユニット制御部113に内蔵されてもよい。排他・調停機能(禁止機能)は、同期周期の開始タイミングから所定の待ち時間を計時するタイマやカウンタを備えていてもよい。   Therefore, as shown in FIG. 12, the extension unit 4 starts internal processing after waiting for the second update unit 76 of the basic unit 3 to complete the synchronous refresh for the device. That is, as shown in FIG. 12, the inter-unit synchronization unit 114 of the first expansion unit and the second expansion unit has a predetermined waiting time (called a refresh waiting time) when an interrupt for synchronous refresh occurs due to inter-unit synchronization. The expansion unit control unit 113 starts the internal processing after waiting for the elapse of time). During this waiting time, the second update unit 76 of the basic unit 3 executes synchronous refresh of the device and the buffer memory UG. As a result, during the period when the device value is synchronously refreshed, the internal processing of the expansion unit control unit 113 does not read or write the device value, and crying does not occur. As described above, the inter-unit synchronization unit 114 of the expansion unit 4 synchronizes the synchronous refresh and the internal processing, so that the access to the device by the synchronous refresh and the access to the device by the internal processing do not occur at the same time. Become. That is, the expansion unit control unit 113 is exclusively or arbitrated for access to the device during the waiting time. This exclusive / arbitration function may be built in the inter-unit synchronization unit 114 or may be built in the extension unit control unit 113. The exclusive / arbitration function (prohibition function) may include a timer or a counter that measures a predetermined waiting time from the start timing of the synchronization cycle.

なお、所定の待ち時間内に同期リフレッシュが完了しない場合や、そもそも所定の待ち時間を設けない場合などでは、同期リフレッシュが完了する前に内部処理が開始されてしまうことがあろう。この場合は、上述したダブルバッファ構成が有効である。つまり、同期リフレッシュは第1バッファ121に対して実行され、拡張ユニット4の内部処理による第1バッファ121へのアクセスは排他または調停される。つまり、同期リフレッシュによるアクセスよりも後に発生したアクセスは同期リフレッシュによるアクセスが完了するまで待たされることになる。同様に、拡張ユニット4の内部処理は第2バッファ122にアクセスし、同期リフレッシュによる第2バッファ122へのアクセスは排他または調停される。つまり、内部処理によるアクセスよりも後に発生した同期リフレッシュによるアクセスは内部処理によるアクセスが完了するまで待たされることになる。第1バッファ121と第2バッファ122のデバイス値の更新はバッファ更新部116によってユニット間同期タイミング(同期周期の開始タイミング)で実行される。これによって、複数のデバイス値の泣き別れが抑制される。上述したように、バッファメモリUGについてもダブルバッファ構成が採用されてもよい。   If synchronous refresh is not completed within a predetermined waiting time, or if no predetermined waiting time is provided in the first place, internal processing may be started before synchronous refresh is completed. In this case, the above-described double buffer configuration is effective. That is, synchronous refresh is performed on the first buffer 121, and access to the first buffer 121 by internal processing of the expansion unit 4 is exclusive or arbitrated. That is, an access that occurs after an access by synchronous refresh is kept waiting until the access by synchronous refresh is completed. Similarly, the internal processing of the expansion unit 4 accesses the second buffer 122, and access to the second buffer 122 by synchronous refresh is exclusive or arbitrated. That is, the access by the synchronous refresh that occurs after the access by the internal processing is waited until the access by the internal processing is completed. The device values of the first buffer 121 and the second buffer 122 are updated by the buffer update unit 116 at the inter-unit synchronization timing (synchronization cycle start timing). This suppresses crying of multiple device values. As described above, a double buffer configuration may also be adopted for the buffer memory UG.

<デバイス値の伝達遅延時間>
デバイス値の伝達遅延時間については一定時間に制御されることが望ましいことがある。上述したようにユニット間同期は、基本ユニット3と拡張ユニット4との間における応答性のバラツキを小さくするために実行される。しかし、基本ユニット3の制御周期と拡張ユニット4の制御周期とを同期させるだけでは不十分なことがある。つまり、基本ユニット3と拡張ユニット4との間におけるデバイス値の伝達遅延時間が一定になれば、さらに応答性のバラツキが小さくなる。上述したように複数のデバイス値の泣き別れは、これらのデバイス値それぞれの伝達遅延時間が一致しないために発生することが多い。特に、これらのデバイス値に対する内部処理によるアクセスが非同期で発生することが原因となりやすい。
<Device value propagation delay time>
It may be desirable to control the transmission delay time of the device value to a certain time. As described above, the inter-unit synchronization is executed in order to reduce variation in responsiveness between the basic unit 3 and the expansion unit 4. However, it may not be sufficient to synchronize the control cycle of the basic unit 3 and the control cycle of the expansion unit 4. That is, if the transmission delay time of the device value between the basic unit 3 and the expansion unit 4 becomes constant, the variation in responsiveness is further reduced. As described above, crying of a plurality of device values often occurs because the transmission delay times of these device values do not match. In particular, access to these device values by internal processing is likely to occur asynchronously.

そこで、上述したように同期リフレッシュの実行タイミングと内部処理の実行タイミングとを同期させることで、デバイスに対する非同期アクセスが抑制され、伝達遅延時間のバラツキが小さくなる。なお、伝達遅延時間のバラツキを小さくするためには、上述したダブルバッファ構成も有効である。あるデバイスに対する同期リフレッシュによるアクセスと、拡張ユニット4の内部処理によるアクセスとが競合しなくなるため、基本ユニット3と内部処理による非同期アクセスが生じないようになる。よって、伝達遅延時間のバラツキが小さくなる。   Thus, by synchronizing the execution timing of the synchronous refresh and the execution timing of the internal processing as described above, asynchronous access to the device is suppressed, and the variation in the transmission delay time is reduced. Note that the above-described double buffer configuration is also effective in reducing variations in transmission delay time. Since the access by the synchronous refresh for a certain device and the access by the internal processing of the extension unit 4 do not compete, the asynchronous access by the basic unit 3 and the internal processing does not occur. Therefore, the variation in the transmission delay time is reduced.

図13はダブルバッファの動作を説明する図である。ここでは基本ユニット3に対して入力ユニットである第1拡張ユニットと出力ユニットである第2拡張ユニットが接続されているものとする。同期周期の開始時点では、第1拡張ユニットの第1バッファ121にはデバイス値としてX0が格納されており、第2バッファ122にはX1が格納されている。同様に、第2拡張ユニットの第1バッファ121にはデバイス値としてY0が格納されており、第2バッファ122にもY0が格納されている。   FIG. 13 is a diagram for explaining the operation of the double buffer. Here, it is assumed that the basic unit 3 is connected with a first extension unit as an input unit and a second extension unit as an output unit. At the start of the synchronization cycle, X0 is stored as the device value in the first buffer 121 of the first extension unit, and X1 is stored in the second buffer 122. Similarly, Y0 is stored as a device value in the first buffer 121 of the second extension unit, and Y0 is also stored in the second buffer 122.

ユニット間同期のための割り込みが発生すると、第1拡張ユニットのバッファ更新部116は第2バッファ122のデバイス値を第1バッファ121にコピーする。なお、出力ユニットである第2拡張ユニットはこの時点でバッファ間のコピーを実行しなくてもよい。基本ユニット3の第2更新部76はまず、同期リフレッシュのうち入力リフレッシュを実行する。つまり、第2更新部76は第1拡張ユニットの第1バッファ121からデバイス値を読み出し、第1拡張ユニットに割り付けられた第2デバイスに82コピーする。   When an interrupt for unit synchronization occurs, the buffer update unit 116 of the first expansion unit copies the device value of the second buffer 122 to the first buffer 121. Note that the second expansion unit, which is the output unit, does not have to execute copying between the buffers at this time. First, the second update unit 76 of the basic unit 3 executes the input refresh of the synchronous refresh. That is, the second update unit 76 reads the device value from the first buffer 121 of the first extension unit, and copies it to the second device assigned to the first extension unit.

次に、第2更新部76は、同期リフレッシュのうち出力リフレッシュを実行する。つまり、第2更新部76は第2拡張ユニットの第1バッファ121からデバイス値を読み出し、第2拡張ユニットに割り付けられた第2デバイス82にコピーする。   Next, the 2nd update part 76 performs output refresh among synchronous refreshes. That is, the second update unit 76 reads the device value from the first buffer 121 of the second extension unit and copies it to the second device 82 allocated to the second extension unit.

割り込みが発生したタイミングから所定時間が経過すると、基本ユニット3のユニット間同期部73と第1拡張ユニットおよび第2拡張ユニットのユニット間同期部114がお互いの制御周期を位相レベルで一致させる。この同期処理が完了した時点、またはこの同期処理の開始時点に、第1拡張ユニットおよび第2拡張ユニットの拡張ユニット制御部113は、内部処理を開始する。図13では、同期処理の開始時点で内部処理が開始されるように制御されている。なお、第2拡張ユニットのバッファ更新部116は、内部処理の開始タイミングで第1バッファ121のデバイス値を第2バッファ122にコピーする。   When a predetermined time elapses from the timing at which the interrupt is generated, the inter-unit synchronization unit 73 of the basic unit 3 and the inter-unit synchronization unit 114 of the first extension unit and the second extension unit match each other's control periods at the phase level. When this synchronization processing is completed, or at the start of this synchronization processing, the extension unit control unit 113 of the first extension unit and the second extension unit starts internal processing. In FIG. 13, control is performed so that the internal processing is started at the start of the synchronization processing. The buffer update unit 116 of the second extension unit copies the device value of the first buffer 121 to the second buffer 122 at the start timing of internal processing.

その後、第1拡張ユニットの拡張ユニット制御部113は内部処理の結果に応じて第2バッファ122のデバイス値を更新する。第2拡張ユニットの拡張ユニット制御部113は第2バッファ122のデバイス値を参照し、デバイス値に応じて内部処理を実行する。   Thereafter, the extension unit control unit 113 of the first extension unit updates the device value of the second buffer 122 according to the result of the internal processing. The expansion unit control unit 113 of the second expansion unit refers to the device value in the second buffer 122 and executes internal processing according to the device value.

なお、入力リフレッシュを実行し、次に、ユニット間同期(ユニット間同期プログラム)や内部処理を実行し、最後に出力リフレッシュを実行することも考えられる。この場合、第1拡張ユニットと第2拡張ユニットとの間でデバイス値を伝達すると、2つの同期周期が必要になる。つまり、1つ目の同期周期において第1拡張ユニットから基本ユニット3にデバイス値を伝達し、その後、内部処理が実行されて、基本ユニット3からデバイス値が第2拡張ユニットに伝達される。第2拡張ユニットは次の同期周期においてデバイス値を参照し、内部処理を実行する。よって、2つの同期周期が必要になる。一方で、図13に示すように、入力リフレッシュを実行し、次に出力リフレッシュを実行し、最後にユニット間同期や内部処理を実行すると、1つの同期周期の遅延で済むといった利点がある。つまり、1つ目の同期周期において第1拡張ユニットから基本ユニット3にデバイス値が伝達され、その後、基本ユニット3からデバイス値が第2拡張ユニットに伝達され、そのデバイス値が内部処理よって参照可能となる。よって、1つの同期周期内で、第1拡張ユニットと第2拡張ユニットとがデバイス値を送受信できるようになる。ただし、内部処理は割り込みが発生したタイミングから所定の待ち時間が経過するまで待ってから実行される必要がある。   It is also conceivable that input refresh is executed, then inter-unit synchronization (inter-unit synchronization program) and internal processing are executed, and finally output refresh is executed. In this case, if a device value is transmitted between the first extension unit and the second extension unit, two synchronization periods are required. That is, the device value is transmitted from the first extension unit to the basic unit 3 in the first synchronization cycle, and then the internal processing is executed, and the device value is transmitted from the basic unit 3 to the second extension unit. The second extension unit refers to the device value in the next synchronization cycle and executes internal processing. Therefore, two synchronization periods are required. On the other hand, as shown in FIG. 13, when the input refresh is executed, the output refresh is executed next, and the inter-unit synchronization and the internal processing are executed at the end, there is an advantage that only one synchronization cycle delay is required. That is, the device value is transmitted from the first extension unit to the basic unit 3 in the first synchronization cycle, and then the device value is transmitted from the basic unit 3 to the second extension unit, and the device value can be referred to by internal processing. It becomes. Therefore, the first extension unit and the second extension unit can transmit and receive device values within one synchronization period. However, the internal processing needs to be executed after a predetermined waiting time elapses from the timing when the interrupt occurs.

第1拡張ニットと第2拡張ユニットとが通信する必要がある事例としては位置決めユニットと、位置決めユニットにトリガーを与える入力ユニットとを含むPLC2が考えられる。より具体的には、入力ユニットのセンサでワーク(検査対象物)を検知すると、検知したことを示すデバイス値が基本ユニット3に伝達され、さらに位置決めユニットに伝達される。位置決めユニットはこのデバイス値に基づいてモータなどを起動し、位置決めを実行する。   As an example in which the first extension unit and the second extension unit need to communicate with each other, a PLC 2 including a positioning unit and an input unit that gives a trigger to the positioning unit can be considered. More specifically, when a workpiece (inspection object) is detected by the sensor of the input unit, a device value indicating the detection is transmitted to the basic unit 3 and further transmitted to the positioning unit. The positioning unit activates a motor or the like based on this device value and executes positioning.

このような複数の拡張ユニット間でのデバイス値の通信における遅延を短くするには、入力リフレッシュと出力リフレッシュを実行してからユニット間同期を実行する方が有利であろう。とりわけ、位置決めユニットのように高速動作が要求されるユニットが関与する、拡張ユニット間でのデバイス値の通信では、このような処理の順番が向いている。   In order to reduce the delay in communication of device values between a plurality of extension units, it may be advantageous to execute inter-unit synchronization after executing input refresh and output refresh. In particular, in the communication of device values between expansion units that involve units that require high-speed operation such as positioning units, the order of such processing is suitable.

<ビットデバイスとワードデバイスのリフレッシュ>
デバイスやバッファメモリには1ビットのデバイス値を記憶するものと、1ワードのデバイス値を記憶するものとがある。つまり、リフレッシュの対象となるものにはビット型のものやワード型のものが混在している。このような場合にも上述した順序性が必要となることがある。順序性の要件を満たす方法としては、デバイス値の送信側が送信すべきデバイス値をデバイスに格納すると、フラグをセットする。伝送路においては、デバイス値が先に伝送され、その後でフラグが伝送される。受信側は、フラグがセットされたことを認識すると、デバイスからデバイス値を読み出す。これにより、受信側はデバイス値を少ない遅延時間でもって読み出せるようになる。なお、フラグはビット型のデバイスで実現されうる。つまり、ワードデバイスに格納された伝送すべきワードデータ(ワードデバイス値)を先に転送し、フラグを格納したビットデバイスのデバイス値を後から転送することが要求されることがある。もし、フラグを先に転送してしまうと、古いワードデバイス値が読み出されてしまうことがあるからである。
<Refresh bit device and word device>
Some devices and buffer memories store a 1-bit device value, and others store a one-word device value. In other words, there are a mixture of bit type and word type to be refreshed. Even in such a case, the order described above may be necessary. As a method of satisfying the order requirement, a flag is set when a device value to be transmitted is stored in the device. In the transmission path, the device value is transmitted first, and then the flag is transmitted. When the receiving side recognizes that the flag is set, it reads the device value from the device. As a result, the receiving side can read the device value with a small delay time. The flag can be realized by a bit type device. That is, it may be required to transfer the word data (word device value) to be transmitted stored in the word device first and transfer the device value of the bit device storing the flag later. This is because if the flag is transferred first, the old word device value may be read out.

ユニット間同期よりも高い優先度の割り込みが同期リフレッシュの実行中に発生することがある。この場合、入力デバイスに関してはワードデバイスが先に更新され、その後でビットデバイスが更新される。出力デバイスに関しても同様に順序性が要求される。この場合は、ビットデバイスが先に転送され、ワードデバイスが後に転送される。なお、基本ユニット3の基本ユニット制御部70や拡張ユニット4の拡張ユニット制御部113は、同期リフレッシュが実行されている期間での他の手段による割り込みを禁止してもよい。   Interrupts with higher priority than inter-unit synchronization may occur during synchronous refresh execution. In this case, regarding the input device, the word device is updated first, and then the bit device is updated. Similarly, output devices are required to be ordered. In this case, the bit device is transferred first and the word device is transferred later. Note that the basic unit control unit 70 of the basic unit 3 and the expansion unit control unit 113 of the expansion unit 4 may prohibit interruption by other means during the period when the synchronous refresh is being executed.

なお、フラグとなるデバイスにダブルバッファ構成を適用してもよい。この場合、上述したビットデバイスとワードデバイスの更新順序が逆になる。ここでは、ビットデバイスとワードデバイスについて説明したが、ワードデバイスをビットデバイスとして使用するケースでも本実施例は適用可能である。つまり、本実施例は、ワードデバイスしか存在しないケースでもワードデバイス間の更新順序を維持するためにも使用可能である。   Note that a double buffer configuration may be applied to a device to be a flag. In this case, the update order of the bit device and the word device described above is reversed. Although the bit device and the word device have been described here, the present embodiment can be applied even when the word device is used as the bit device. That is, the present embodiment can be used to maintain the update order between word devices even when only word devices exist.

<内部処理の延期>
拡張ユニット4のユニット間同期部114は延期部115を備えていてもよい。同期リフレッシュが完了していないにもかかわらず、内部処理が開始されてしまうと、上述した泣き別れ問題が発生しうる。そこで、ユニット間同期部114は同期リフレッシュが所定の待ち時間で完了しなかったことを検知すると、内部処理の発生タイミングを延期させてもよい。なお、延期時間は動的に決定されてもよいし、静的に決定されていてもよい。前者では、ユニット間同期部114が同期リフレッシュの完了を検知すると、内部処理を開始させる。後者では、ユニット間同期部114が所定の延期時間の経過を待って、内部処理を開始させる。
<Postponement of internal processing>
The inter-unit synchronization unit 114 of the extension unit 4 may include a postponement unit 115. If the internal processing is started even though the synchronous refresh has not been completed, the above-mentioned tearing problem may occur. Therefore, when the inter-unit synchronization unit 114 detects that the synchronous refresh has not been completed within a predetermined waiting time, the inter-unit synchronization unit 114 may postpone the generation timing of the internal processing. The postponement time may be determined dynamically or may be determined statically. In the former, when the inter-unit synchronization unit 114 detects the completion of the synchronous refresh, the internal process is started. In the latter, the inter-unit synchronization unit 114 waits for the elapse of a predetermined postponement time to start internal processing.

同期リフレッシュの遅延は、フロー制御に伴うリトライなどが原因で発生することがある。このような場合に延期部115は有用であるが、代わりに上述したダブルバッファ構成が採用されてもよい。ダブルバッファ構成を採用することで、同時性の問題や順序性の問題、さらには伝達遅延時間のバラツキ問題も緩和される。   Synchronous refresh delays may occur due to retries associated with flow control. In such a case, the postponing unit 115 is useful, but the double buffer configuration described above may be employed instead. By adopting the double buffer configuration, the problem of simultaneity, the problem of order, and the problem of variation in transmission delay time are alleviated.

<一括リフレッシュやスキャンタイムを拡張ユニットの制御周期に同期させること>
上述した実施例はユニット間同期により基本ユニット3の制御周期と拡張ユニット4の制御周期とが整合されるが、一括リフレッシュやスキャンタイムはこれらとは非同期で実施されてもよい。しかし、ユニット間同期を実行するためには割り込みが必要となる。もし、拡張ユニット4の制御周期に対して、一括リフレッシュやスキャンタイムも同期させることができれば、割り込みが不要となろう。
<Synchronizing the batch refresh and scan time with the control cycle of the expansion unit>
In the above-described embodiment, the control cycle of the basic unit 3 and the control cycle of the expansion unit 4 are matched by inter-unit synchronization. However, the batch refresh and the scan time may be performed asynchronously. However, an interrupt is required to execute inter-unit synchronization. If the batch refresh and the scan time can be synchronized with the control cycle of the expansion unit 4, no interrupt will be required.

図14は一括リフレッシュやスキャンタイムを拡張ユニットの制御周期に同期させる処理を示すフローチャートである。この処理は基本ユニット3のCPU10で実行される。   FIG. 14 is a flowchart showing a process of synchronizing batch refresh and scan time with the control cycle of the extension unit. This process is executed by the CPU 10 of the basic unit 3.

S15でCPU10(第1更新部75)は一括入力リフレッシュを実行する。一括入力リフレッシュとは、入力デバイスについての上述した一括リフレッシュである。S16でCPU10(プログラム実行部71)はラダープログラム78を実行する。S17でCPU10(第1更新部75)は一括出力リフレッシュを実行する。一括出力リフレッシュとは、出力デバイスについての上述した一括リフレッシュである。S18でCPU10(基本ユニット制御部70)はEND処理を実行する。END処理は周辺処理とも呼ばれ、外部インターフェースからのデータの取得やロギング処理によるデータの収集などである。END処理も同期周期に連動して実行されるようになる。S19でCPU10(ユニット間同期部73)はユニット間同期を実行するタイミングになったかどうかを判定する。ユニット間同期タイミングが到来すると、ユニット間同期部73は、ユニット間同期の対象として指定されている拡張ユニット4のユニット間同期部114と同期処理を実行し、お互いの制御周期を一致させる。その後、S15に戻る。つまり、ユニット間同期によって、基本ユニット3と拡張ユニット4の制御周期が一致するともに、拡張ユニット4の制御周期とスキャンタイミングも同期することになる。   In S15, the CPU 10 (first updating unit 75) executes batch input refresh. The batch input refresh is the batch refresh described above for the input device. In S <b> 16, the CPU 10 (program execution unit 71) executes the ladder program 78. In S17, the CPU 10 (first updating unit 75) executes batch output refresh. The batch output refresh is the batch refresh described above for the output device. In S18, the CPU 10 (basic unit controller 70) executes an END process. The END processing is also called peripheral processing, and includes data acquisition from an external interface and data collection by logging processing. The END process is also executed in conjunction with the synchronization cycle. In S19, the CPU 10 (inter-unit synchronization unit 73) determines whether it is time to execute inter-unit synchronization. When the inter-unit synchronization timing arrives, the inter-unit synchronization unit 73 performs a synchronization process with the inter-unit synchronization unit 114 of the extension unit 4 designated as the target for inter-unit synchronization, and matches the control cycles with each other. Thereafter, the process returns to S15. In other words, due to the inter-unit synchronization, the control cycle of the basic unit 3 and the expansion unit 4 coincide, and the control cycle of the expansion unit 4 and the scan timing are also synchronized.

このようにユニット間同期をトリガーとしてラダープログラム78のスキャンが実行されるため、スキャンタイムは拡張ユニット4の制御周期に対して同期することになる。なお、図14に示してフローチャートからわかるように、同期周期とスキャンタイムはほぼ同じ長さとなる。   Thus, since the scan of the ladder program 78 is executed with the synchronization between units as a trigger, the scan time is synchronized with the control cycle of the expansion unit 4. As can be seen from the flowchart shown in FIG. 14, the synchronization period and the scan time are substantially the same length.

図15は一括リフレッシュやスキャンタイムを拡張ユニットの制御周期に同期させる他の処理を示すフローチャートである。この処理は基本ユニット3のCPU10で実行される。図14と比較すると、同期リフレッシュも実行される点が特に異なっている。   FIG. 15 is a flowchart showing another process for synchronizing the batch refresh and the scan time with the control cycle of the extension unit. This process is executed by the CPU 10 of the basic unit 3. Compared to FIG. 14, the point that synchronous refresh is also executed is particularly different.

S20でCPU10(第2更新部76)は同期リフレッシュを実行する。S21でCPU10(第1更新部75)は一括リフレッシュを実行する。一括リフレッシュには一括入力リフレッシュと一括出力リフレッシュとが含まれている。S22でCPU10(プログラム実行部71)はラダープログラム78を実行する。S23でCPU10(基本ユニット制御部70)はEND処理を実行する。S24でCPU10(ユニット間同期部73)は基本ユニットタイマ88のタイマ値に基づき、ユニット間同期を実行するタイミングになったかどうかを判定する。ユニット間同期タイミングが到来すると、ユニット間同期部73は、ユニット間同期の対象として指定されている拡張ユニット4のユニット間同期部114と同期処理を実行し、お互いの制御周期を一致させる。その後、S20に戻る。このようにユニット間同期に連動して同期リフレッシュと一括リフレッシュとが実行されてもよい。これにより割り込みプログラムを使用することなく、一括リフレッシュやスキャンタイムを拡張ユニットの制御周期に同期させることが可能となる。   In S20, the CPU 10 (second update unit 76) executes synchronous refresh. In S21, the CPU 10 (first update unit 75) executes batch refresh. Batch refresh includes batch input refresh and batch output refresh. In S <b> 22, the CPU 10 (program execution unit 71) executes the ladder program 78. In S23, the CPU 10 (basic unit controller 70) executes an END process. In S24, the CPU 10 (inter-unit synchronization unit 73) determines whether it is time to execute inter-unit synchronization based on the timer value of the basic unit timer 88. When the inter-unit synchronization timing arrives, the inter-unit synchronization unit 73 performs a synchronization process with the inter-unit synchronization unit 114 of the extension unit 4 designated as the target for inter-unit synchronization, and matches the control cycles with each other. Thereafter, the process returns to S20. In this way, synchronous refresh and batch refresh may be executed in conjunction with inter-unit synchronization. This makes it possible to synchronize batch refresh and scan time with the control period of the expansion unit without using an interrupt program.

なお、スキャンタイムは固定長のものと可変長のものとがある。プログラム作成支援装置1の設定データ作成部84は、固定長のスキャンタイムにしたがってラダープログラム78を実行することをユーザによって指示されたときは、さらに、スキャンタイムをユニット間同期によって同期させるか、同期させないかをユーザの指示にしたがって選択してもよい。どちらが選択されたかは設定データ79に格納される。基本ユニット3のCPU10は設定データ79を参照することで、どちらが選択されたかを認識に、選択された動作モードにしたがってスキャンを実行する。なお、スキャンタイムをユニット間同期によって同期させることが選択された場合、設定データ作成部84は、ユーザ指示にしたがって同期周期を設定してもよい。スキャンタイムをユニット間同期によって同期させることが選択されていない場合、設定データ作成部84は、ユーザ指示にしたがってスキャンタイムを設定してもよい。   The scan time has a fixed length and a variable length. When the user is instructed to execute the ladder program 78 in accordance with the fixed-length scan time, the setting data creation unit 84 of the program creation support apparatus 1 further synchronizes the scan time with inter-unit synchronization or synchronization. You may select according to a user's instruction | indication whether it does not make it. Which is selected is stored in the setting data 79. The CPU 10 of the basic unit 3 refers to the setting data 79 to recognize which one has been selected, and executes a scan according to the selected operation mode. In addition, when it is selected that the scan time is synchronized by inter-unit synchronization, the setting data creation unit 84 may set the synchronization period according to a user instruction. When it is not selected that the scan time is synchronized by inter-unit synchronization, the setting data creation unit 84 may set the scan time according to a user instruction.

<バッファメモリの同期リフレッシュ>
すでに所々で触れたように、デバイスだけでなく、バッファメモリUGについても同期リフレッシュが適用されてもよい。一般にデバイスはリフレッシュにより更新されるが、バッファメモリUGは更新されない。そのため、従来は、バッファメモリUGに関しては、必要に応じてラダープログラム78内でダイレクト通信を実行するための命令が記述される必要があった。なお、基本ユニット3は複数の占有デバイスを有しており、そのうちの幾つかが拡張ユニット4に対して割り付けられる。よって、拡張ユニット4のデバイスに対して割り付けられていない基本ユニット3のデバイス(第3デバイス83)については、バッファメモリUGを割り付けることでバッファメモリUGもリフレッシュすることが可能となる。これにより、バッファメモリUGについても同期リフレッシュの対象となる。
<Synchronous refresh of buffer memory>
As already mentioned in some places, synchronous refresh may be applied not only to the device but also to the buffer memory UG. Generally, the device is updated by refresh, but the buffer memory UG is not updated. Therefore, conventionally, with respect to the buffer memory UG, it is necessary to describe an instruction for executing direct communication in the ladder program 78 as necessary. The basic unit 3 has a plurality of occupied devices, some of which are allocated to the expansion unit 4. Therefore, for the device of the basic unit 3 (the third device 83) that is not assigned to the device of the expansion unit 4, the buffer memory UG can be refreshed by assigning the buffer memory UG. As a result, the buffer memory UG is also subject to synchronous refresh.

プログラム作成支援装置1の設定データ作成部84はユーザ指示に応じてバッファメモリUGに対応する第3デバイス83を選択する。たとえば、設定データ作成部84は、拡張ユニットごとの設定データを作成するために、デバイスのリストを表示部7に表示する。このリストには、各デバイスの識別情報、たとえば、デバイス番号(例:DM31000など)が列挙される。また、各デバイスの隣の欄には、対応するバッファメモリUGを指定するための欄が設けられてもよい。この欄には、バッファメモリUGの識別情報(例:UG2158など)が操作部8から入力される。なお、設定データ作成部84はバッファメモリUGに対応する第3デバイス83を一括リフレッシュの対象とするか、同期リフレッシュの対象とするかを、ユーザ指示に応じて選択する。設定データ作成部84はユーザによって選択されたリフレッシュの方式についても設定データ79に書き込む。   The setting data creation unit 84 of the program creation support apparatus 1 selects the third device 83 corresponding to the buffer memory UG in response to a user instruction. For example, the setting data creation unit 84 displays a list of devices on the display unit 7 in order to create setting data for each expansion unit. In this list, identification information of each device, for example, a device number (for example, DM31000) is listed. Further, a column for designating the corresponding buffer memory UG may be provided in a column next to each device. In this column, identification information (eg, UG2158) of the buffer memory UG is input from the operation unit 8. The setting data creation unit 84 selects whether the third device 83 corresponding to the buffer memory UG is to be subjected to batch refresh or synchronous refresh according to a user instruction. The setting data creation unit 84 also writes in the setting data 79 the refresh method selected by the user.

このように、バッファメモリUGが第3デバイス83に関連付けられるため、第2更新部76は設定データ79にしたがって、バッファメモリUGも第2デバイスとして同期リフレッシュを実行する。また、一括リフレッシュの対象として選択されたバッファメモリUGについては第1デバイスとして第1更新部75が一括リフレッシュを実行する。   As described above, since the buffer memory UG is associated with the third device 83, the second update unit 76 performs synchronous refresh as the second device according to the setting data 79. In addition, for the buffer memory UG selected as a target for batch refresh, the first update unit 75 performs batch refresh as the first device.

バッファメモリUGに関しても上述した同期リフレッシュを実行することで同時性や順序性、伝達遅延時間の一定性などの問題が解決ないしは緩和される。   For the buffer memory UG as well, by executing the above-described synchronous refresh, problems such as simultaneity, order, and constant transfer delay time are solved or alleviated.

占有デバイスの同期リフレッシュとバッファメモリUGの同期リフレッシュが同期周期内のどのタイミングで実行されるかについて説明する。たとえば、第2更新部76は、入力デバイスについて同期リフレッシュを実行し、次に、入力バッファメモリについて同期リフレッシュを実行する。第2更新部76は、出力バッファメモリについて同期リフレッシュを実行し、次に、出力デバイスについて同期リフレッシュを実行する。このように入力系が先にリフレッシュされ、その後に、出力系がリフレッシュされてもよい。占有デバイスが先にリフレッシュされ、その後にバッファメモリがリフレッシュされてもよい。第2更新部76は、入力デバイスについて同期リフレッシュを実行し、次に、出力デバイスについて同期リフレッシュを実行する。さらに、第2更新部76は、出力バッファメモリについて同期リフレッシュを実行し、次に入力バッファメモリについて同期リフレッシュを実行する。最後に、ユニット間同期部73がユニット間同期を実行する。なお、上述したように拡張ユニット間での通信に関しては後者の事例の方が有利であろう。   The timing at which the synchronous refresh of the occupied device and the synchronous refresh of the buffer memory UG are executed within the synchronization period will be described. For example, the second update unit 76 executes synchronous refresh for the input device, and then executes synchronous refresh for the input buffer memory. The second updating unit 76 executes synchronous refresh for the output buffer memory, and then executes synchronous refresh for the output device. In this way, the input system may be refreshed first, and then the output system may be refreshed. The occupied device may be refreshed first and then the buffer memory may be refreshed. The second update unit 76 executes synchronous refresh for the input device, and then executes synchronous refresh for the output device. Further, the second update unit 76 executes synchronous refresh for the output buffer memory, and then executes synchronous refresh for the input buffer memory. Finally, the inter-unit synchronization unit 73 performs inter-unit synchronization. As described above, the latter case may be more advantageous for communication between expansion units.

ところでバッファメモリUGについてダイレクト通信で更新しようとすると、泣き別れ問題が発生することがあった。これはバッファメモリUGのサイズが32ビットなどに制限されているときに発生しうる。そこで、上述したダブルバッファ構成などの泣き別れ対策をバッファメモリUGにも適用することで、泣き別れ問題が緩和される。   By the way, when trying to update the buffer memory UG by direct communication, a problem of crying may occur. This can occur when the size of the buffer memory UG is limited to 32 bits or the like. Therefore, by applying the above-mentioned measures against crying such as a double buffer configuration to the buffer memory UG, the crying-off problem is alleviated.

<まとめ>
図1などを用いて説明したように、PLC2は、ユーザプログラムをスキャン毎に繰り返し実行する基本ユニット3と、基本ユニット3に接続される拡張ユニット4とを有する。図8などを用いて説明したように、拡張ユニット4は、
外部機器が接続されるインターフェース123と、インターフェース123を介した外部機器からの入力値またはインターフェース123を介した外部機器への出力値に関するデバイス値が格納され、基本ユニット3とデータ共有するためのデバイスが割り付けられた記憶部である記憶装置111と、クロックを計数して時間を計測する拡張ユニットタイマ119を有している。図7などを用いて説明したように、基本ユニット3は基本ユニットタイマ88、ユニット間同期部73、第1更新部75および第2更新部76を有している。ユニット間同期部73は拡張ユニットタイマ119のタイマ値と基本ユニットタイマ88のタイマ値を同期させる。第1更新部75はスキャン毎のリフレッシュの期間内で拡張ユニット4が保持しているデータと基本ユニット3が保持しているデータとを一致させる。第2更新部76はユニット間同期部73により拡張ユニットタイマ119のタイマ値と同期した基本ユニットタイマ88のタイマ値に基づいてスキャン中に定周期で実行される処理の期間内で拡張ユニット4が保持しているデータと基本ユニット3が保持しているデータとを一致させる。なお、ユーザプログラムであるラダープログラム78に記述される拡張ユニット4に割り付けられたデバイスは、第1更新部75による更新の対象および/または第2更新部76による更新の対象として設定可能に構成される。これによりユーザのプログラミングの負担が軽減され、ユーザビリティが向上する。
<Summary>
As described with reference to FIG. 1 and the like, the PLC 2 includes the basic unit 3 that repeatedly executes the user program for each scan and the expansion unit 4 that is connected to the basic unit 3. As described with reference to FIG. 8 and the like, the expansion unit 4 is
A device for storing device values related to an input value from an external device via the interface 123 or an output value to the external device via the interface 123 and to share data with the basic unit 3 Are allocated to the storage device 111 and an expansion unit timer 119 that counts clocks to measure time. As described with reference to FIG. 7 and the like, the basic unit 3 includes the basic unit timer 88, the inter-unit synchronization unit 73, the first update unit 75, and the second update unit 76. The inter-unit synchronization unit 73 synchronizes the timer value of the extension unit timer 119 and the timer value of the basic unit timer 88. The first updating unit 75 matches the data held in the extension unit 4 with the data held in the basic unit 3 within the refresh period for each scan. The second updating unit 76 detects whether the expansion unit 4 is within the period of processing executed at regular intervals during scanning based on the timer value of the basic unit timer 88 synchronized with the timer value of the expansion unit timer 119 by the inter-unit synchronization unit 73. The data held and the data held by the basic unit 3 are matched. The device allocated to the extension unit 4 described in the ladder program 78 that is a user program can be set as an update target by the first update unit 75 and / or an update target by the second update unit 76. The This alleviates the user's programming burden and improves usability.

見方を変えれば、本実施例では、一括リフレッシュの対象に設定可能なデバイスや同期リフレッシュの対象に設定可能なデバイス、あるいは、一括リフレッシュの対象にも同期リフレッシュの対象にも設定可能なデバイスが用意されたことになる。その結果、平場のラダープログラム78の記述をユニット間同期プログラムにコピーした場合であっても、平場のラダープログラム78に記述されたデバイスを、ユニット間同期リフレッシュの対象に設定変更するだけで、リフレッシュが実行される。よって、プログラムの変更作業が軽減される。また、ユニット間同期リフレッシュの対象に含めるかどうかはユーザが自由に設定可能であるため、一部のデバイスをユニット間同期リフレッシュの対象から外すことで(図16には拡張ユニットに割り付けられた複数のデバイスを一括して対象に設定したり、対象外に設定したりする例が示されている。)、ユニット間同期リフレッシュ期間の増大を抑制することができる。   In other words, in this embodiment, a device that can be set as a batch refresh target, a device that can be set as a synchronous refresh target, or a device that can be set as a batch refresh target or a synchronous refresh target is prepared. It will be done. As a result, even if the description of the flat field ladder program 78 is copied to the inter-unit synchronization program, the device described in the flat field ladder program 78 can be refreshed only by changing the setting to the target of the inter-unit synchronous refresh. Is executed. Therefore, the program change work is reduced. In addition, since it is possible for the user to freely set whether or not to include in the inter-unit synchronous refresh target, by removing some devices from the inter-unit synchronous refresh target (FIG. 16 shows a plurality of devices allocated to the expansion unit). In this example, the devices are collectively set as a target or excluded from the target.), And an increase in the inter-unit synchronous refresh period can be suppressed.

このように、デバイスは、第1更新部75による更新の対象として設定されてもよいし、第2更新部76による更新の対象として設定されてもよい。基本ユニット制御部70や設定データ作成部84は、デバイスを更新する手段として第1更新部75と第2更新部76とのうち少なくとも一方を選択する選択手段として機能してもよい。この更新部の選択は一括リフレッシュの対象とするか、それとも同期リフレッシュの対象とするかの選択に相当し、更新タイミングの選択にも相当しよう。このように基本ユニット3と拡張ユニット4との間で共有すべきデータの更新タイミングを選択可能とすることで、ユーザビリティを向上させることが可能となる。つまり、一括リフレッシュ期間だけでなく、ユーザプログラムが実行されている期間などの他の期間において同期リフレッシュが実行されるようになる。その結果、一括リフレッシュ期間が長くなりすぎるといったことは起きにくくなる。なお、いくつかのデバイスについては同期リフレッシュと一括リフレッシュの双方が適用されてもよい。   As described above, the device may be set as an update target by the first update unit 75 or may be set as an update target by the second update unit 76. The basic unit control unit 70 and the setting data creation unit 84 may function as a selection unit that selects at least one of the first update unit 75 and the second update unit 76 as a unit for updating the device. This selection of the update unit corresponds to selection of whether to perform batch refresh or synchronous refresh, and may correspond to selection of update timing. Thus, by making it possible to select the update timing of data to be shared between the basic unit 3 and the extension unit 4, it is possible to improve usability. That is, synchronous refresh is executed not only in the batch refresh period but also in other periods such as a period in which the user program is being executed. As a result, it is difficult for the batch refresh period to become too long. For some devices, both synchronous refresh and batch refresh may be applied.

基本ユニット3は、基本ユニット3が有する内部機能の制御タイミングと拡張ユニット4の制御タイミングとを同期させる同期処理を実行するユニット間同期部73をさらに有している。ユニット間同期部73は、例えばタイマ等によって実現される。第2更新部76は、ユーザプログラムが実行されている期間内でユニット間同期部73が同期処理を実行するタイミングになると、拡張ユニット4が保持しているデータと基本ユニット3が保持しているデータとを一致させるよう同期リフレッシュを実行する。このようにユニット間同期のタイミングで同期リフレッシュが実行されるようになる。ユーザプログラム内でデバイスやバッファメモリのダイレクト通信を行うことも可能であるが、これはプログラムコード(ラダー図)の流用性が乏しく、また複雑なプログラミングが必要になる。一方で、ユニット間同期のタイミングで同期リフレッシュを実行すれば、一括リフレッシュ用のプログラムコードと同様の簡易なコードによってデバイスやバッファメモリの同期リフレッシュが可能となる。よって、ユーザのプログラミングに関する負担が軽減されよう。   The basic unit 3 further includes an inter-unit synchronization unit 73 that executes a synchronization process for synchronizing the control timing of the internal function of the basic unit 3 with the control timing of the expansion unit 4. The inter-unit synchronization unit 73 is realized by a timer or the like, for example. The second update unit 76 holds the data held by the extension unit 4 and the basic unit 3 at the timing when the inter-unit synchronization unit 73 executes the synchronization process within the period in which the user program is being executed. Synchronous refresh is performed to match the data. In this way, synchronous refresh is executed at the timing of inter-unit synchronization. Although it is possible to perform direct communication between the device and the buffer memory in the user program, this is poor in applicability of the program code (ladder diagram) and requires complicated programming. On the other hand, if synchronous refresh is executed at the timing of inter-unit synchronization, synchronous refresh of devices and buffer memories can be performed with a simple code similar to the program code for batch refresh. Thus, the burden on the user's programming will be reduced.

図6や図10などを用いて説明したように、ユニット間同期部73は、ユニット間同期のタイミングが到来するとユニット間同期を実行する。これによりユーザプログラムの実行期間中であってもユニット間同期が実行されるため、基本ユニット3の制御タイミングと拡張ユニット4の制御タイミングとのずれを小さくすることが可能となる。また、ユーザプログラムの実行期間中においてユニット間同期に付随して同期リフレッシュが実行されるようになり、一括リフレッシュの期間を待つことなく、デバイスやバッファメモリを更新できるようになる。   As described with reference to FIGS. 6 and 10, the inter-unit synchronization unit 73 performs inter-unit synchronization when the inter-unit synchronization timing comes. As a result, the synchronization between the units is executed even during the execution period of the user program, so that the difference between the control timing of the basic unit 3 and the control timing of the expansion unit 4 can be reduced. In addition, synchronous refresh is performed accompanying the inter-unit synchronization during the execution period of the user program, and the device and buffer memory can be updated without waiting for the batch refresh period.

図14や図15を用いて説明したように、基本ユニット3は、ユニット間同期をトリガー(トリガ)としてスキャンを実行してもよい。つまり、基本ユニット3は、拡張ユニット4に適用されている制御周期に対して第1更新部75が更新を実行するタイミングを同期させるユニット間同期部73をさらに有していてもよい。ユニット間同期部73は基本ユニット3の制御周期に対して拡張ユニット4に適用されている制御周期を同期させるものである。しかし、ユニット間同期部73は拡張ユニット4に適用されている制御周期に対して第1更新部75が更新を実行するタイミングを同期させるように動作してもよい。拡張ユニット4の内部処理は拡張ユニット4の制御周期に同期して実行される。また、デバイスやバッファメモリに格納されるデータは内部処理の動作に必要なものであったり、内部処理の結果であったりする。拡張ユニット4の制御周期にしたがってデータをリフレッシュすれば、データの伝達遅延時間が削減されよう。   As described with reference to FIG. 14 and FIG. 15, the basic unit 3 may execute a scan using the synchronization between units as a trigger. That is, the basic unit 3 may further include an inter-unit synchronization unit 73 that synchronizes the timing at which the first update unit 75 executes the update with respect to the control cycle applied to the extension unit 4. The inter-unit synchronization unit 73 synchronizes the control cycle applied to the extension unit 4 with respect to the control cycle of the basic unit 3. However, the inter-unit synchronization unit 73 may operate so as to synchronize the timing at which the first update unit 75 executes the update with respect to the control cycle applied to the extension unit 4. Internal processing of the expansion unit 4 is executed in synchronization with the control cycle of the expansion unit 4. The data stored in the device or buffer memory may be necessary for internal processing operations or may be the result of internal processing. If the data is refreshed according to the control cycle of the expansion unit 4, the data transmission delay time will be reduced.

基本ユニット3および拡張ユニット4はそれぞれデータを保持するメモリであるデバイスメモリを有し、デバイスメモリは、拡張ユニット4のデータを基本ユニット3へ伝達するための入力デバイスメモリと、基本ユニット3のデータを拡張ユニット4に伝達するための出力デバイスメモリとを含む。第1更新部75および第2更新部76は、拡張ユニット4のデバイスメモリに記憶されているデータを基本ユニット3のデバイスメモリへコピーすることで入力デバイスメモリのデータを更新するとともに、基本ユニット3のデバイスメモリに記憶されているデータを拡張ユニット4のデバイスメモリへコピーすることで出力デバイスメモリのデータを更新する。これにより入力デバイスや出力デバイスについて一括リフレッシュと同期リフレッシュとが実行されるようになる。このように第1更新部75および第2更新部76のリフレッシュ動作はよく似ているため、一括リフレッシュ用のコードを同期用のリフレッシュ用のコードとして流用しやすくなる。   Each of the basic unit 3 and the expansion unit 4 has a device memory that is a memory for holding data. The device memory includes an input device memory for transmitting the data of the expansion unit 4 to the basic unit 3, and the data of the basic unit 3. Output device memory for transmitting to the expansion unit 4. The first update unit 75 and the second update unit 76 update the data in the input device memory by copying the data stored in the device memory of the expansion unit 4 to the device memory of the basic unit 3, and The data in the output device memory is updated by copying the data stored in the device memory to the device memory of the expansion unit 4. As a result, batch refresh and synchronous refresh are performed on the input device and output device. As described above, the refresh operations of the first update unit 75 and the second update unit 76 are very similar, so that the batch refresh code can be easily used as a synchronization refresh code.

入力デバイスメモリは拡張ユニット4が有する機能の状態を表すデータを記憶するものである。たとえば、拡張ユニット4の被制御装置16がセンサなどであれば、センサの検知結果(検知状態)を示すデバイス値が入力デバイスメモリに格納されることになる。出力デバイスメモリは拡張ユニット4が有する機能の制御するデータを記憶するものである。たとえば、拡張ユニット4の被制御装置16がモータなどであれば、そのモータの回転数などを示すデバイス値が出力デバイスメモリに格納されるようになる。   The input device memory stores data representing the state of the functions of the expansion unit 4. For example, if the controlled device 16 of the expansion unit 4 is a sensor or the like, a device value indicating a detection result (detection state) of the sensor is stored in the input device memory. The output device memory stores data controlled by the function of the expansion unit 4. For example, if the controlled device 16 of the expansion unit 4 is a motor or the like, a device value indicating the rotational speed of the motor or the like is stored in the output device memory.

図6などを用いて説明したように、一括リフレッシュの期間において第1更新部75が出力デバイスメモリに保持されているデータを更新する。次に、第1更新部75が入力デバイスメモリに保持されているデータを更新する。その次にユーザプログラムが実行されている期間内において第2更新部76がデータを更新してもよい。出力デバイスメモリには内部処理によって参照されるデータや命令が格納されているため、一括リフレッシュの期間においては出力デバイスメモリが先にリフレッシュされてもよい。もちろん、入力デバイスメモリが先にリフレッシュされてもよい。   As described with reference to FIG. 6 and the like, the first update unit 75 updates the data held in the output device memory during the batch refresh period. Next, the first update unit 75 updates the data held in the input device memory. Then, the second update unit 76 may update the data within a period during which the user program is executed. Since the output device memory stores data and instructions that are referred to by internal processing, the output device memory may be refreshed first during the batch refresh period. Of course, the input device memory may be refreshed first.

第2更新部76は、基本ユニット3に設けられ、データを保持するメモリであるデバイスメモリと、拡張ユニット4に設けられ、一括リフレッシュの対象とならないデータを保持するバッファメモリとの間でデータを一致させてもよい。このようにデバイスとバッファメモリとを対応付けることで、バッファメモリについてもあたかもデバイスであるかのようにリフレッシュ可能となる。   The second updating unit 76 provides data between the device memory that is provided in the basic unit 3 and holds data, and the buffer memory that is provided in the expansion unit 4 and holds data that is not subject to batch refresh. You may match. By associating the device with the buffer memory in this way, the buffer memory can be refreshed as if it were a device.

基本ユニット制御部70は、第2更新部76による更新の対象となるデータを指定する更新対象指定情報(設定データ79)を記憶する記憶装置12を有していてもよい。第2更新部76は、設定データ79によって指定されたデータをユーザプログラムが実行されている期間内で同期リフレッシュする。第1更新部75は、設定データ79によって指定されていないデータを一括リフレッシュの期間で一括リフレッシュする。このようにデバイスやバッファメモリについて適用されるリフレッシュのタイミングは設定データ79によって保持されてもよい。   The basic unit control unit 70 may include a storage device 12 that stores update target designation information (setting data 79) for designating data to be updated by the second update unit 76. The second update unit 76 refreshes the data specified by the setting data 79 synchronously within a period during which the user program is being executed. The first update unit 75 performs batch refresh of data not specified by the setting data 79 during the batch refresh period. Thus, the refresh timing applied to the device and the buffer memory may be held by the setting data 79.

設定データ作成部84に関して説明したように、設定データ79は、基本ユニット3に接続され、ユーザプログラムを作成して当該基本ユニット3に転送するプログラム作成支援装置上で作成された情報であってもよい。プログラム作成支援装置1の操作部8は基本ユニット3の操作部6よりも操作がしやすい。また、プログラム作成支援装置1の表示部7は基本ユニット3の表示部5よりも表示可能な情報量が多い。よって、デバイスやバッファメモリについて適用されるリフレッシュのタイミングを選択しやすくなるであろう。   As described with respect to the setting data creation unit 84, the setting data 79 may be information created on a program creation support device that is connected to the basic unit 3 and creates a user program and transfers it to the basic unit 3. Good. The operation unit 8 of the program creation support apparatus 1 is easier to operate than the operation unit 6 of the basic unit 3. Further, the display unit 7 of the program creation support apparatus 1 has a larger amount of information that can be displayed than the display unit 5 of the basic unit 3. Therefore, it will be easy to select the refresh timing applied to the device and the buffer memory.

第2更新部76がデータを更新している間は第2更新部76以外の他の手段による当該データの読み書きを排他または調停する排他・調停手段として基本ユニット制御部70やデバイス制御部72が機能してもよい。上述したように同期リフレッシュの実行中にデータが変更されてしまうと、同時性の問題が発生しうる。よって、他の手段によるデータの読み書きを排他または調停することで、同時性の問題を解決できるようになろう。   While the second update unit 76 is updating data, the basic unit control unit 70 and the device control unit 72 serve as an exclusive / arbitration unit that excludes or arbitrates reading / writing of the data by means other than the second update unit 76. May function. As described above, if the data is changed during the execution of the synchronous refresh, a simultaneity problem may occur. Therefore, the problem of simultaneity can be solved by exclusive or arbitrating the reading and writing of data by other means.

デバイス制御部72は、相互に更新の連動性を要求される複数のデータが第2更新部76によって更新されている期間においては第2更新部76以外の他の手段による当該複数のデータの読み書きを排他または調停してもよい。これにより同時性の問題が解決しよう。   The device control unit 72 reads / writes the plurality of data by means other than the second update unit 76 during a period in which the plurality of data that are required to be linked to each other is updated by the second update unit 76. May be exclusive or arbitrated. This will solve the concurrency problem.

デバイス制御部72は、それぞれ基本ユニット3と拡張ユニット4との間におけるデータの伝達時間(伝達遅延時間)をほぼ一定にすることが要求される複数のデータが第2更新部76によって更新されている期間においては第2更新部76以外の他の手段による当該複数のデータの読み書きを排他または調停してもよい。これにより複数のデバイス値についての伝達遅延時間のバラツキが小さくなろう。   In the device control unit 72, the second update unit 76 updates a plurality of data required to make the data transmission time (transmission delay time) between the basic unit 3 and the expansion unit 4 substantially constant. In a certain period, reading / writing of the plurality of data by means other than the second updating unit 76 may be exclusive or arbitrated. As a result, the variation in the propagation delay time for a plurality of device values will be reduced.

デバイス制御部72は、それぞれ更新順序が定められている複数のデータが第2更新部76によって更新されている期間においては第2更新部76以外の他の手段による当該複数のデータの読み書きを排他または調停してもよい。たとえば、複数のデータは、ビット型のデータとワード型のデータであってもよい。第2更新部76は、基本ユニット3のビット型のデータとワード型のデータを拡張ユニット4へコピーするときはビット型のデータをコピーしてからワード型のデータをコピーしてもよい。また、第2更新部76は、拡張ユニット4のビット型のデータとワード型のデータを基本ユニット3へコピーするときはワード型のデータをコピーしてからビット型のデータをコピーしてもよい。これにより上述した順序性の問題が解決するであろう。なお、ワード型のデータの一部がビット型のデータとして使用されるケースにも本実施例は適用可能である。   The device control unit 72 excludes reading / writing of the plurality of data by means other than the second update unit 76 during a period in which the plurality of data each having an update order is updated by the second update unit 76 Or mediation may be performed. For example, the plurality of data may be bit type data and word type data. When copying the bit type data and the word type data of the basic unit 3 to the extension unit 4, the second updating unit 76 may copy the bit type data and then copy the word type data. In addition, when copying the bit type data and the word type data of the extension unit 4 to the basic unit 3, the second update unit 76 may copy the bit type data after copying the word type data. . This will solve the ordering problem described above. The present embodiment can also be applied to a case where a part of word type data is used as bit type data.

拡張ユニット4は、第2更新部76における更新処理の遅延時間に応じて当該拡張ユニット4で実行される内部処理の開始を遅延させてもよい。同期リフレッシュの対象となるデバイスやバッファメモリの数が多くなったり、フロー制御によるデータの再送が多く発生したりすると、同期リフレッシュの時間が長くなる。その結果、所定の待ち時間を過ぎても同期リフレッシュが完了しなくなってしまう。同期リフレッシュが完了していないにもかかわらず、内部処理を開始してしまえば、上述した同時性の問題が発生しうる。よって、このよう場合は内部処理を遅延させて、同時性等の問題を解決してもよい。   The extension unit 4 may delay the start of internal processing executed by the extension unit 4 according to the delay time of the update process in the second update unit 76. If the number of devices and buffer memories to be subjected to synchronous refresh increases or if data retransmission due to flow control frequently occurs, the time for synchronous refresh becomes longer. As a result, the synchronous refresh cannot be completed even after a predetermined waiting time. If the internal processing is started even though the synchronous refresh has not been completed, the above-described simultaneity problem may occur. Therefore, in such a case, internal processing may be delayed to solve problems such as simultaneity.

デバイス制御部72は、第2更新部76がデータを更新している間は割り込み処理を禁止してもよい。同期リフレッシュの最中に割り込みが入ってしまうと、同時性の問題や伝達遅延時間のバラツキの問題などが発生しやすくなる。同期リフレッシュの最中は割り込みを禁止することで、同時性の問題や伝達遅延時間のバラツキの問題などが緩和されよう。   The device control unit 72 may prohibit the interrupt process while the second update unit 76 is updating data. If an interrupt occurs during synchronous refresh, problems such as simultaneity and variations in transmission delay time are likely to occur. Disabling interrupts during synchronous refresh will alleviate simultaneity problems and transmission delay time variations.

拡張ユニット4は、基本ユニット3に設けられている記憶装置12にデータを保持していてもよい。一般にデバイスやバッファメモリは基本ユニット3と拡張ユニット4との双方に設けられるために、リフレッシュが必要となる。しかし、拡張ユニット4の第1デバイス118や第2デバイス120が基本ユニット3の記憶装置12に設けられ、記憶装置12内でリフレッシュが実行されてもよい。これは、拡張ユニット4のデバイスメモリやバッファメモリがどこあるかは問題とならないことを意味する。このように、基本ユニット3のデバイスメモリやバッファメモリと拡張ユニット4のデバイスメモリやバッファメモリとが同一の記憶装置内に配置されていたとしても、上述した実施例は適用可能である。   The expansion unit 4 may hold data in the storage device 12 provided in the basic unit 3. Generally, since the device and the buffer memory are provided in both the basic unit 3 and the expansion unit 4, refreshing is necessary. However, the first device 118 and the second device 120 of the expansion unit 4 may be provided in the storage device 12 of the basic unit 3 and the refresh may be executed in the storage device 12. This means that it does not matter where the expansion unit 4 has device memory and buffer memory. As described above, even if the device memory and buffer memory of the basic unit 3 and the device memory and buffer memory of the expansion unit 4 are arranged in the same storage device, the above-described embodiments can be applied.

ところで、基本ユニット3の記憶装置12は、ユーザプログラム(ラダープログラム78)と、拡張ユニット4の内部処理の実行タイミングと同期して実行される同期プログラム(制御プログラム77の一部)とを記憶するプログラム記憶手段として機能してもよい。これらはプログラム実行手段であるCPU10によって実行される。とりわけ、ラダープログラム78についてプログラム実行部71で実行される。第1デバイス81や第2デバイス82はユーザプログラムにおいて拡張ユニット4の内部処理に割り付けられている第1デバイスメモリの一例である。   Meanwhile, the storage device 12 of the basic unit 3 stores a user program (ladder program 78) and a synchronous program (part of the control program 77) that is executed in synchronization with the execution timing of the internal processing of the expansion unit 4. It may function as a program storage means. These are executed by the CPU 10 as program execution means. In particular, the ladder program 78 is executed by the program execution unit 71. The first device 81 and the second device 82 are an example of a first device memory allocated to internal processing of the expansion unit 4 in the user program.

PLC2の基本ユニット3または拡張ユニット4は、第1デバイスメモリに記憶されているデータと同一のデータを記憶するように制御される第2デバイスメモリを有している。第2デバイスメモリは、たとえば、記憶装置12に確保され、拡張ユニット4によってアクセスされる。または、第2デバイスメモリは、拡張ユニット4の記憶装置111に確保された第1デバイス118や第2デバイス120であってもよい。第1更新部75や第2更新部76は第1デバイスメモリに記憶されているデータと第2デバイスメモリに記憶されているデータとが一致するように更新処理を実行する更新手段として機能する。ただし、第1更新部75や第2更新部76は拡張ユニット4のCPU110によって実現されていてもよい。拡張ユニット4のユニット間同期部114は自己または拡張ユニット制御部113が管理する同期周期にしたがって基本ユニット3に割り込みを実行し、同期リフレッシュとユニット間同期を実行してもよい。なお、プログラム作成支援装置1の設定データ作成部84や基本ユニット3の操作部6などは、一括リフレッシュの期間と同期リフレッシュの期間とのうちのいずれの期間で更新処理を実行するかを設定する設定手段として機能する。設定データ79は、拡張ユニット4からアクセス可能な記憶装置12、記憶装置111に格納され、拡張ユニット制御部113やユニット間同期部114により読み出されてもよい。   The basic unit 3 or the expansion unit 4 of the PLC 2 has a second device memory that is controlled so as to store the same data as the data stored in the first device memory. For example, the second device memory is secured in the storage device 12 and accessed by the expansion unit 4. Alternatively, the second device memory may be the first device 118 or the second device 120 secured in the storage device 111 of the expansion unit 4. The first update unit 75 and the second update unit 76 function as an update unit that executes an update process so that the data stored in the first device memory matches the data stored in the second device memory. However, the first update unit 75 and the second update unit 76 may be realized by the CPU 110 of the expansion unit 4. The inter-unit synchronization unit 114 of the expansion unit 4 may execute an interrupt to the basic unit 3 according to a synchronization period managed by itself or the expansion unit control unit 113, and perform synchronous refresh and inter-unit synchronization. Note that the setting data creation unit 84 of the program creation support device 1 and the operation unit 6 of the basic unit 3 set which of the batch refresh period and the synchronous refresh period to execute the update process. Functions as setting means. The setting data 79 may be stored in the storage device 12 and the storage device 111 accessible from the expansion unit 4 and read by the expansion unit control unit 113 and the inter-unit synchronization unit 114.

基本ユニット3は、基本ユニット3の制御周期と拡張ユニット4の制御周期とを同期させるユニット間同期部73と、ユニット間同期部73が同期処理を実行する同期周期における所定期間において、拡張ユニット4が保持しているデータと基本ユニット3が保持しているデータとが一致するように更新する第2更新部75とを有する。第2更新部75は、相互に更新の連動性を要求される複数のデータまたは予め定められた更新順序にしたがって更新されることを要求される複数のデータを更新してもよい。これにより同時性の問題や順序性の問題などが緩和されよう。   The basic unit 3 includes an inter-unit synchronization unit 73 that synchronizes the control cycle of the basic unit 3 and the control cycle of the extension unit 4, and a predetermined period in the synchronization cycle in which the inter-unit synchronization unit 73 executes synchronization processing. Has a second updating unit 75 that updates so that the data held by the basic unit 3 matches the data held by the basic unit 3. The second update unit 75 may update a plurality of data that are required to be linked to each other or a plurality of data that are requested to be updated in accordance with a predetermined update order. This will alleviate simultaneity and ordering issues.

なお、リアルタイム性が要求されないようなデータを扱う拡張ユニットについては、従来通り、一括リフレッシュされればよい。一方で、モーションユニット(位置決めユニット)などリアルタイム性や高速動作が要求される拡張ユニットについては、同期リフレッシュの対象とされてもよい。とりわけ、同期周期が短くなると、1つのスキャンタイムにおいて多数の回数にわたって同期リフレッシュが実行されることになる。よって、同期リフレッシュの対象となる拡張ユニットやそのデバイスが増えれば増えるほど、スキャンタイムが延びてしまったり、内部処理の開始が遅れてしまったりする。よって、同期周期がスキャンタイムより短い場合は、同期リフレッシュの対象を絞ることが望ましいだろう。これは、第2拡張ユニット4のデータのうち第2更新部76によって更新されるデータと第1更新部75によって更新されるデータとを選択する選択手段を設けることで、ユーザが同期リフレッシュの対象を絞ってもよい。   Note that an expansion unit that handles data for which real-time performance is not required may be batch refreshed as in the past. On the other hand, an extension unit that requires real-time performance and high-speed operation such as a motion unit (positioning unit) may be subjected to synchronous refresh. In particular, when the synchronization period is shortened, synchronous refresh is executed many times in one scan time. Therefore, as the number of expansion units and devices to be subjected to synchronous refresh increases, the scan time becomes longer or the start of internal processing is delayed. Therefore, if the synchronization period is shorter than the scan time, it may be desirable to narrow down the target of synchronization refresh. This is because the user can select the data to be updated by the second update unit 76 and the data to be updated by the first update unit 75 from among the data of the second extension unit 4 so that the user can perform synchronous refresh. You may squeeze.

拡張ユニット4は、第2更新部76がデータの更新処理を完了した後で当該データを参照して内部処理を実行してもよい。これは、データの更新処理が完了する前にそのデータを内部処理が使用してしまうと同時性の問題などが発生するからである。なお、第2更新部76は、拡張ユニット4が内部処理を実行していない期間にデータの更新処理を実行してもよい。これにより同時性の問題が緩和されよう。   The extension unit 4 may execute internal processing with reference to the data after the second update unit 76 completes the data update processing. This is because if the internal processing uses the data before the data update processing is completed, a simultaneity problem occurs. Note that the second update unit 76 may execute data update processing during a period when the expansion unit 4 is not executing internal processing. This will alleviate the simultaneity problem.

拡張ユニット4は、第2更新部76によって更新されるデータを記憶する第1バッファ121と、当該拡張ユニット4の内部処理によって参照されるデータを記憶する第2バッファ122とを備えていてもよい。この場合、バッファ更新部116は、ユニット間同期処理が実行されるときに第1バッファ121に記憶されているデータと第2バッファ122に記憶されているデータとが一致するように更新する第3更新手段として機能する。第2更新部76は、バッファ更新部116が更新処理を完了した後で、更新処理を実行する。たとえば、第2更新部76は、同期周期の開始タイミングから所定期間が経過してから同期リフレッシュを実行する。所定期間は、バッファ更新部116が更新処理を完了するのに十分な期間であり、予め設定される。   The extension unit 4 may include a first buffer 121 that stores data updated by the second update unit 76 and a second buffer 122 that stores data referred to by internal processing of the extension unit 4. . In this case, the buffer updating unit 116 updates the data stored in the first buffer 121 and the data stored in the second buffer 122 so that the data stored in the second buffer 122 matches when the inter-unit synchronization process is executed. Functions as update means. The second update unit 76 executes the update process after the buffer update unit 116 completes the update process. For example, the second update unit 76 executes the synchronous refresh after a predetermined period has elapsed from the start timing of the synchronous cycle. The predetermined period is a period sufficient for the buffer update unit 116 to complete the update process, and is set in advance.

拡張ユニット4は、ユニット間同期部114による同期処理が遅延すると、内部処理の開始タイミングを延期する延期部115をさらに有していてもよい。同期処理の遅延は、伝送路でのエラー等、突発的な事象が原因となることが多い。そのため、常に一定期間を待たせるよりも、遅延時間に応じて内部処理を遅らせた方が有利であろう。   The extension unit 4 may further include a postponing unit 115 that postpones the start timing of the internal processing when the synchronization processing by the inter-unit synchronization unit 114 is delayed. The delay of the synchronization process is often caused by an unexpected event such as an error in the transmission path. Therefore, it would be advantageous to delay the internal processing according to the delay time rather than always waiting for a certain period.

図14や図15を用いて説明したように、基本ユニット3は、ユニット間同期部73が同期処理を実行するタイミングになると、一括リフレッシュの期間に遷移してもよい。これにより、ユニット間同期により獲得された同期周期に対してスキャンの開始タイミングを整合させることが可能となる。   As described with reference to FIGS. 14 and 15, the basic unit 3 may transition to a batch refresh period when the inter-unit synchronization unit 73 performs the synchronization process. This makes it possible to match the scan start timing with the synchronization period obtained by the inter-unit synchronization.

上述したように、基本ユニット3はユーザプログラムにおいて拡張ユニット4の内部処理に割り付けられているデバイスメモリを有している。また、基本ユニット3または拡張ユニット4は、デバイスメモリに記憶されているデータと同一のデータを記憶するように制御されるバッファメモリUGを有していてもよい。なお、基本ユニット3にバッファメモリUGが配置される場合、拡張ユニット4からこのバッファメモリUGはアクセスされ、データを読み書きされることになろう。第1更新部75や第2更新部76は、拡張ユニット4の制御周期に同期して、デバイスメモリに記憶されているデータとバッファメモリUGに記憶されているデータとが一致するように更新処理を実行してもよい。このようにバッファメモリUGをデバイスに割り付けることで、バッファメモリUGについてもあたかもデバイスのように一括リフレッシュや同期リフレッシュが適用可能となる。   As described above, the basic unit 3 has a device memory allocated to the internal processing of the expansion unit 4 in the user program. The basic unit 3 or the expansion unit 4 may have a buffer memory UG that is controlled to store the same data as the data stored in the device memory. When the buffer memory UG is arranged in the basic unit 3, the buffer memory UG is accessed from the expansion unit 4 and data is read / written. The first update unit 75 and the second update unit 76 perform update processing so that the data stored in the device memory matches the data stored in the buffer memory UG in synchronization with the control cycle of the expansion unit 4. May be executed. By assigning the buffer memory UG to the device in this way, batch refresh and synchronous refresh can be applied to the buffer memory UG as if it were a device.

上述したように複数の拡張ユニット4が基本ユニット3を介してデバイス値を送受信するときにも本発明は有利であろう。この場合、基本ユニット3は、少なくとも、基本ユニット3の制御周期と複数の拡張ユニット4の制御周期とを同期させるユニット間同期部73と、ユーザプログラムにおいて第1拡張ユニット4の内部処理に割り付けられており、当該第1拡張ユニット4から基本ユニット3に転送すべきデータを記憶する第1デバイスメモリと、ユーザプログラムにおいて第2拡張ユニット4の内部処理に割り付けられており、基本ユニット3から当該第2拡張ユニット4へ転送すべきデータを記憶する第2デバイスメモリとを有している。なお、図7では第1デバイス81や第2デバイス82はそれぞれ1つずつしか記載されていないが、これらは複数個あってもよい。よって、第1デバイスメモリや第2デバイスメモリとは、複数の第1デバイス81や複数の第2デバイス82に相当する。   As described above, the present invention may be advantageous when a plurality of expansion units 4 transmit and receive device values via the basic unit 3. In this case, the basic unit 3 is allocated to internal processing of the first extension unit 4 in the user program and the inter-unit synchronization unit 73 that synchronizes at least the control period of the basic unit 3 and the control periods of the plurality of extension units 4. A first device memory for storing data to be transferred from the first extension unit 4 to the basic unit 3 and an internal process of the second extension unit 4 in the user program. 2 has a second device memory for storing data to be transferred to the expansion unit 4. In FIG. 7, only one each of the first device 81 and the second device 82 is shown, but there may be a plurality of them. Therefore, the first device memory and the second device memory correspond to a plurality of first devices 81 and a plurality of second devices 82.

第1拡張ユニット4は、第1デバイスメモリに記憶されているデータと同一のデータを記憶するように制御される第1バッファメモリを有していてもよい。第2拡張ユニット4は、第2デバイスメモリに記憶されているデータと同一のデータを記憶するように制御される第2バッファメモリを有していてもよい。図8には、第1デバイス118と第2デバイス120が例示されているが、これとは別にバッファメモリUGが記憶装置111に設けられている。図13が示すように、第1拡張ユニット4から入力されたデバイス値が基本ユニット3を介して第2拡張ユニット4に転送されてもよい。これを実現するために、第1更新部75または第2更新部76は、拡張ユニット4の制御周期に同期して、第1デバイスメモリに記憶されているデータと第1バッファメモリに記憶されているデータとが一致するように更新処理を実行し、次に、第2デバイスメモリに記憶されているデータと第2バッファメモリに記憶されているデータとが一致するように更新処理を実行する。なお、第1更新部75または第2更新部76は拡張ユニット4側に設けられていてもよい。第1拡張ユニット4は、第2更新部76が同期リフレッシュを完了した後で内部処理を開始する。同様に、第2拡張ユニット4は、第2更新部76が同期リフレッシュを完了した後で内部処理を開始する。これにより一つの同期周期の伝達遅延時間だけで複数の拡張ユニット間でのデバイス値の送受信が実現可能となる。   The first extension unit 4 may have a first buffer memory controlled to store the same data as the data stored in the first device memory. The second expansion unit 4 may have a second buffer memory that is controlled to store the same data as the data stored in the second device memory. FIG. 8 illustrates the first device 118 and the second device 120, but a buffer memory UG is provided in the storage device 111 separately from this. As shown in FIG. 13, the device value input from the first extension unit 4 may be transferred to the second extension unit 4 via the basic unit 3. In order to realize this, the first update unit 75 or the second update unit 76 is stored in the first buffer memory and the data stored in the first device memory in synchronization with the control cycle of the expansion unit 4. The update process is executed so that the stored data matches, and then the update process is executed so that the data stored in the second device memory matches the data stored in the second buffer memory. The first update unit 75 or the second update unit 76 may be provided on the extension unit 4 side. The first extension unit 4 starts internal processing after the second update unit 76 completes the synchronous refresh. Similarly, the second extension unit 4 starts internal processing after the second update unit 76 completes synchronous refresh. Thereby, transmission / reception of device values between a plurality of extension units can be realized with only a transmission delay time of one synchronization period.

Claims (29)

ユーザプログラムをスキャン毎に繰り返し実行する基本ユニットと、前記基本ユニットに接続される拡張ユニットとを有するプログラマブル・ロジック・コントローラであって、
前記拡張ユニットは、
外部機器が接続されるインターフェースと、
前記インターフェースを介した前記外部機器からの入力値または前記インターフェースを介した前記外部機器への出力値に関するデバイス値が格納され、前記基本ユニットとデータ共有するためのデバイスが割り付けられた記憶部と、
クロックを計数して時間を計測する拡張ユニットタイマと、
を備え、
前記基本ユニットは、
クロックを計数して時間を計測する基本ユニットタイマと、
前記拡張ユニットタイマと前記基本ユニットタイマのタイマ値を同期させる同期手段と、
スキャン毎のリフレッシュの期間内で前記拡張ユニットが保持しているデータと前記基本ユニットが保持しているデータとを一致させる第1更新手段と、
前記同期手段により前記拡張ユニットタイマのタイマ値と同期した前記基本ユニットタイマのタイマ値に基づいてスキャン中に定周期で実行される処理の期間内で前記拡張ユニットが保持しているデータと前記基本ユニットが保持しているデータとを一致させる第2更新手段と、
を備え、
前記ユーザプログラムに記述される前記拡張ユニットの前記デバイスは、前記第1更新手段による更新の対象および/または前記第2更新手段による更新の対象として設定可能に構成されることを特徴とするプログラマブル・ロジック・コントローラ。
A programmable logic controller having a basic unit that repeatedly executes a user program for each scan, and an expansion unit connected to the basic unit,
The expansion unit is
An interface to which an external device is connected;
A storage unit in which a device value related to an input value from the external device via the interface or an output value to the external device via the interface is stored, and a device for sharing data with the basic unit is allocated;
An expansion unit timer that counts the clock and measures time,
With
The basic unit is
A basic unit timer that counts the clock and measures time,
Synchronization means for synchronizing the timer values of the extension unit timer and the basic unit timer;
First update means for matching the data held by the extension unit and the data held by the basic unit within a refresh period for each scan;
Based on the timer value of the basic unit timer synchronized with the timer value of the extension unit timer by the synchronization means, the data held by the extension unit within the period of processing executed at regular intervals during scanning and the basic Second update means for matching the data held by the unit;
With
The programmable unit characterized in that the device of the extension unit described in the user program can be set as an update target by the first update means and / or an update target by the second update means. Logic controller.
前記デバイスは、前記第1更新手段による更新の対象および前記第2更新手段による更新の対象のいずれか一方に設定されることを特徴とする請求項1に記載のプログラマブル・ロジック・コントローラ。   2. The programmable logic controller according to claim 1, wherein the device is set as one of an update target by the first update unit and an update target by the second update unit. 前記デバイスを更新する更新手段として、前記第1更新手段および前記第2更新手段のうち少なくとも一方を選択する選択手段を備えることを特徴とする請求項1に記載のプログラマブル・ロジック・コントローラ。   2. The programmable logic controller according to claim 1, further comprising selection means for selecting at least one of the first update means and the second update means as update means for updating the device. 前記基本ユニットは、前記ユーザプログラムと、前記同期手段により同期させた前記基本ユニットタイマのタイマ値に基づいて実行されるユニット間同期プログラムとを記憶するプログラム記憶部を備え、
前記第2更新手段は、前記デバイスが前記ユニット間同期プログラムに記述されているときに、前記拡張ユニットが前記デバイスに保持しているデータと前記基本ユニットが保持しているデータとを一致させることを特徴とする請求項1に記載のプログラマブル・ロジック・コントローラ。
The basic unit includes a program storage unit that stores the user program and an inter-unit synchronization program executed based on a timer value of the basic unit timer synchronized by the synchronization unit,
The second update means matches the data held in the extension unit with the data held in the basic unit when the device is described in the inter-unit synchronization program. The programmable logic controller according to claim 1.
前記第2更新手段は、前記スキャン中において前記ユーザプログラムが実行されている期間であっても、前記拡張ユニットが保持しているデータと前記基本ユニットが保持しているデータとを一致させることを特徴とする請求項1に記載のプログラマブル・ロジック・コントローラ。   The second updating means matches the data held by the extension unit with the data held by the basic unit even during a period in which the user program is being executed during the scan. The programmable logic controller of claim 1 characterized by the above. 前記拡張ユニットタイマのタイマ値は、前記拡張ユニットの内部処理の開始タイミングとして使用され、
前記拡張ユニットの内部処理は、前記外部機器からの入力値に基づいて前記デバイス値を演算する処理または前記デバイス値から前記外部機器への出力値を演算する処理であることを特徴とする請求項1ないし5のいずれか1項に記載のプログラマブル・ロジック・コントローラ。
The timer value of the extension unit timer is used as a start timing of internal processing of the extension unit,
The internal processing of the extension unit is processing for calculating the device value based on an input value from the external device or processing for calculating an output value from the device value to the external device. The programmable logic controller according to any one of 1 to 5.
前記第1更新手段は、前記同期手段によって前記拡張ユニットタイマのタイマ値と同期した前記基本ユニットタイマのタイマ値に基づくスキャン毎のリフレッシュの期間内で更新を実行することを特徴とする請求項1に記載のプログラマブル・ロジック・コントローラ。   2. The first update means performs update within a refresh period for each scan based on a timer value of the basic unit timer synchronized with a timer value of the extension unit timer by the synchronization means. Programmable logic controller described in 1. 前記基本ユニットおよび前記拡張ユニットはそれぞれデータを保持する記憶領域であるデバイスを有し、
前記デバイスは、前記拡張ユニットのデータを前記基本ユニットへ伝達するための入力デバイスと、前記基本ユニットのデータを前記拡張ユニットに伝達するための出力デバイスとを含み、
前記第1更新手段および前記第2更新手段は、前記拡張ユニットのデバイスに記憶されているデータであるデバイス値を前記基本ユニットのデバイスへコピーすることで前記入力デバイスのデータであるデバイス値を更新するとともに、前記基本ユニットのデバイスに記憶されているデータであるデバイス値を前記拡張ユニットのデバイスへコピーすることで前記出力デバイスのデータであるデバイス値を更新することを特徴とする請求項1ないし7のいずれか1項に記載のプログラマブル・ロジック・コントローラ。
The basic unit and the extension unit each have a device that is a storage area for holding data,
The device includes an input device for transmitting data of the expansion unit to the basic unit, and an output device for transmitting data of the basic unit to the expansion unit;
The first update unit and the second update unit update a device value that is data of the input device by copying a device value that is data stored in the device of the expansion unit to the device of the basic unit. And updating a device value, which is data of the output device, by copying a device value, which is data stored in the device of the basic unit, to the device of the extension unit. 8. The programmable logic controller according to any one of 7 above.
前記入力デバイスは前記拡張ユニットが有する機能の状態を表すデータを記憶し、
前記出力デバイスは前記拡張ユニットが有する機能を制御するデータを記憶することを特徴とする請求項8に記載のプログラマブル・ロジック・コントローラ。
The input device stores data representing a function state of the extension unit;
The programmable logic controller according to claim 8, wherein the output device stores data for controlling a function of the extension unit.
前記リフレッシュの期間において前記第1更新手段が前記出力デバイスに保持されているデータと前記入力デバイスに保持されているデータを更新し、前記基本ユニットタイマのタイマ値に基づいてスキャン中に定周期で実行される処理の期間において前記第2更新手段が前記拡張ユニットに保持されているデータと前記基本ユニットに保持されているデータとを更新することを特徴とする請求項8または9に記載のプログラマブル・ロジック・コントローラ。   In the refresh period, the first updating means updates the data held in the output device and the data held in the input device, and is scanned at regular intervals during scanning based on the timer value of the basic unit timer. The programmable according to claim 8 or 9, wherein the second updating means updates data held in the extension unit and data held in the basic unit during a period of processing to be executed. -Logic controller. 前記第2更新手段は、前記基本ユニットに設けられ、データを保持するメモリであるデバイスと、前記拡張ユニットに設けられ、前記リフレッシュの対象とならないデータを保持するバッファメモリとの間でデータを一致させることを特徴とする請求項1ないし7のいずれか1項に記載のプログラマブル・ロジック・コントローラ。   The second update unit matches data between a device provided in the basic unit and holding data and a buffer memory provided in the extension unit and holding data not to be refreshed The programmable logic controller according to any one of claims 1 to 7, wherein the programmable logic controller is provided. 前記選択手段は、前記第2更新手段による更新の対象となるデータを指定する更新対象指定情報を記憶する記憶手段を有し、
前記第2更新手段は、前記更新対象指定情報によって指定されたデータを更新し、
前記第1更新手段は、前記更新対象指定情報によって指定されていないデータを前記リフレッシュの期間で更新することを特徴とする請求項3に記載のプログラマブル・ロジック・コントローラ。
The selection means includes storage means for storing update target designation information for designating data to be updated by the second update means,
The second update means updates the data specified by the update target specification information,
4. The programmable logic controller according to claim 3, wherein the first update unit updates data that is not specified by the update target specification information during the refresh period. 5.
前記更新対象指定情報は、前記基本ユニットに接続され、前記ユーザプログラムを作成して当該基本ユニットに転送するプログラム作成支援装置上で作成された情報であることを特徴とする請求項12に記載のプログラマブル・ロジック・コントローラ。   13. The update target designation information is information created on a program creation support device that is connected to the basic unit, creates the user program, and transfers the user program to the basic unit. Programmable logic controller. 前記第2更新手段がデータを更新している間は前記第2更新手段以外の他の手段による当該データの読み書きを排他または調停する排他・調停手段をさらに有することを特徴とする請求項1ないし13のいずれか1項に記載のプログラマブル・ロジック・コントローラ。   2. The apparatus according to claim 1, further comprising an exclusion / arbitration unit that exclusively or arbitrates reading / writing of the data by means other than the second update unit while the second update unit is updating data. 14. The programmable logic controller according to any one of items 13. 前記排他・調停手段は、相互に更新の連動性を要求される複数のデータが前記第2更新手段によって更新されている期間においては前記第2更新手段以外の他の手段による当該複数のデータの読み書きを排他または調停することを特徴とする請求項14に記載のプログラマブル・ロジック・コントローラ。   The exclusion / arbitration means is configured to store the plurality of data by means other than the second update means during a period in which the plurality of data required to be linked to each other is updated by the second update means. The programmable logic controller according to claim 14, wherein reading and writing are exclusive or arbitrated. 前記排他・調停手段は、それぞれ前記基本ユニットと前記拡張ユニットとの間におけるデータの伝達時間を一定にすることが要求される複数のデータが前記第2更新手段によって更新されている期間においては前記第2更新手段以外の他の手段による当該複数のデータの読み書きを排他または調停することを特徴とする請求項14に記載のプログラマブル・ロジック・コントローラ。   The exclusion / arbitration means is configured to update the second update means during a period in which a plurality of data required to make the data transmission time between the basic unit and the extension unit constant is updated by the second update means. The programmable logic controller according to claim 14, wherein reading / writing of the plurality of data by means other than the second update means is exclusive or arbitrated. 前記排他・調停手段は、それぞれ更新順序が定められている複数のデータが前記第2更新手段によって更新されている期間においては前記第2更新手段以外の他の手段による当該複数のデータの読み書きを排他または調停することを特徴とする請求項14に記載のプログラマブル・ロジック・コントローラ。   The exclusion / arbitration means reads / writes the plurality of data by means other than the second update means in a period in which the plurality of data each having an update order is updated by the second update means. 15. The programmable logic controller of claim 14, wherein the programmable logic controller is exclusive or arbitrated. 前記複数のデータは、ビット型のデータとワード型のデータであり、
前記第2更新手段は、前記基本ユニットのビット型のデータとワード型のデータを前記拡張ユニットへコピーするときはビット型のデータをコピーしてからワード型のデータをコピーし、前記拡張ユニットのビット型のデータとワード型のデータを前記基本ユニットへコピーするときはワード型のデータをコピーしてからビット型のデータをコピーすることを特徴とする請求項17に記載のプログラマブル・ロジック・コントローラ。
The plurality of data are bit type data and word type data,
The second updating means copies the bit type data and the word type data after copying the bit type data and the word type data of the basic unit to the extension unit. 18. The programmable logic controller according to claim 17, wherein when the bit type data and the word type data are copied to the basic unit, the bit type data is copied after the word type data is copied. .
前記排他・調停手段は、前記第2更新手段がデータを更新している間は割り込み処理を禁止することを特徴とする請求項14ないし18のいずれか1項に記載のプログラマブル・ロジック・コントローラ。   The programmable logic controller according to any one of claims 14 to 18, wherein the exclusion / arbitration unit prohibits an interrupt process while the second update unit is updating data. 前記拡張ユニットは、前記第2更新手段における更新処理の遅延時間に応じて当該拡張ユニットで実行される内部処理の開始を遅延させることを特徴とする請求項1ないし19のいずれか1項に記載のプログラマブル・ロジック・コントローラ。   20. The extension unit according to claim 1, wherein the extension unit delays a start of an internal process executed by the extension unit according to a delay time of an update process in the second update unit. Programmable logic controller. 前記拡張ユニットは、前記基本ユニットに設けられている記憶装置に前記データを保持していることを特徴とする請求項1ないし20のいずれか1項に記載のプログラマブル・ロジック・コントローラ。   21. The programmable logic controller according to claim 1, wherein the extension unit holds the data in a storage device provided in the basic unit. 前記拡張ユニットは、前記第2更新手段が前記データの更新処理が完了した後で当該データを参照して内部処理を実行することを特徴とする請求項1ないし21のいずれか1項に記載のプログラマブル・ロジック・コントローラ。   The extension unit performs internal processing with reference to the data after the second update unit completes the data update processing, according to any one of claims 1 to 21. Programmable logic controller. 前記第2更新手段は、前記拡張ユニットが内部処理を実行していない期間に前記データの更新処理を実行することを特徴とする請求項1ないし22のいずれか1項に記載のプログラマブル・ロジック・コントローラ。   The programmable logic circuit according to any one of claims 1 to 22, wherein the second update unit executes the data update process during a period when the extension unit is not executing an internal process. controller. 前記拡張ユニットは、
前記第2更新手段によって更新される前記データを記憶する第1バッファと、
当該拡張ユニットの内部処理によって参照されるデータを記憶する第2バッファと、
前記同期手段が同期処理を実行するときに前記第1バッファに記憶されているデータと前記第2バッファに記憶されているデータとが一致するように更新する第3更新手段をさらに有し、
前記第2更新手段は、前記第3更新手段が更新処理を完了した後で、更新処理を実行することを特徴とする請求項1に記載のプログラマブル・ロジック・コントローラ。
The expansion unit is
A first buffer for storing the data updated by the second update means;
A second buffer for storing data referred to by internal processing of the extension unit;
Further comprising third update means for updating the data stored in the first buffer and the data stored in the second buffer so that the data stored in the second buffer coincide with each other when the synchronization means executes a synchronization process;
The programmable logic controller according to claim 1, wherein the second update unit executes the update process after the third update unit completes the update process.
前記拡張ユニットは、
前記同期手段による同期処理が遅延すると、前記拡張ユニットの内部処理の開始タイミングを延期する手段をさらに有することを請求項1に記載のプログラマブル・ロジック・コントローラ。
The expansion unit is
2. The programmable logic controller according to claim 1, further comprising means for delaying a start timing of internal processing of the expansion unit when the synchronization processing by the synchronization unit is delayed.
前記基本ユニットは、前記同期手段が同期処理を実行するタイミングになると、前記リフレッシュの期間に遷移することを特徴とする請求項1に記載のプログラマブル・ロジック・コントローラ。   2. The programmable logic controller according to claim 1, wherein the basic unit transitions to the refresh period when the synchronization unit performs a synchronization process. 3. プログラマブル・ロジック・コントローラの拡張ユニットに接続され、ユーザプログラムをスキャン毎に繰り返し実行する基本ユニットであって、
前記拡張ユニットは、
外部機器が接続されるインターフェースと、
前記インターフェースを介した前記外部機器からの入力値または前記インターフェースを介した前記外部機器への出力値に関するデバイス値が格納され、前記基本ユニットとデータ共有するためのデバイスが割り付けられた記憶部と、
クロックを計数して時間を計測する拡張ユニットタイマと、
を備えており、
前記基本ユニットは、
クロックを計数して時間を計測する基本ユニットタイマと、
前記拡張ユニットタイマと前記基本ユニットタイマのタイマ値を同期させる同期手段と、
スキャン毎のリフレッシュの期間内で前記拡張ユニットが保持しているデータと前記基本ユニットが保持しているデータとを一致させる第1更新手段と、
前記同期手段により前記拡張ユニットタイマのタイマ値と同期した前記基本ユニットタイマのタイマ値に基づいてスキャン中に定周期で実行される処理の期間内で前記拡張ユニットが保持しているデータと前記基本ユニットが保持しているデータとを一致させる第2更新手段と、
を備え、
前記ユーザプログラムに記述される前記拡張ユニットの前記デバイスは、前記第1更新手段による更新の対象および/または前記第2更新手段による更新の対象として設定可能に構成されることを特徴とする基本ユニット。
A basic unit that is connected to an expansion unit of a programmable logic controller and repeatedly executes a user program for each scan.
The expansion unit is
An interface to which an external device is connected;
A storage unit in which a device value related to an input value from the external device via the interface or an output value to the external device via the interface is stored, and a device for sharing data with the basic unit is allocated;
An expansion unit timer that counts the clock and measures time,
With
The basic unit is
A basic unit timer that counts the clock and measures time,
Synchronization means for synchronizing the timer values of the extension unit timer and the basic unit timer;
First update means for matching the data held by the extension unit and the data held by the basic unit within a refresh period for each scan;
Based on the timer value of the basic unit timer synchronized with the timer value of the extension unit timer by the synchronization means, the data held by the extension unit within the period of processing executed at regular intervals during scanning and the basic Second update means for matching the data held by the unit;
With
The basic unit is characterized in that the device of the extension unit described in the user program can be set as an update target by the first update means and / or an update target by the second update means. .
プログラマブル・ロジック・コントローラの拡張ユニットに接続され、ユーザプログラムをスキャン毎に繰り返し実行する基本ユニットの制御方法であって、
前記拡張ユニットは、
外部機器が接続されるインターフェースと、
前記インターフェースを介した前記外部機器からの入力値または前記インターフェースを介した前記外部機器への出力値に関するデバイス値が格納され、前記基本ユニットとデータ共有するためのデバイスが割り付けられた記憶部と、
クロックを計数して時間を計測する拡張ユニットタイマと、
を備えており、
前記制御方法は、
クロックを計数して時間を計測する基本ユニットタイマと、前記拡張ユニットタイマと前記基本ユニットタイマのタイマ値を同期させる同期工程と、
スキャン毎のリフレッシュの期間内で前記拡張ユニットが保持しているデータと前記基本ユニットが保持しているデータとを一致させる第1更新工程と、
前記同期工程により前記拡張ユニットタイマのタイマ値と同期した前記基本ユニットタイマのタイマ値に基づいてスキャン中に定周期で実行される処理の期間内で前記拡張ユニットが保持しているデータと前記基本ユニットが保持しているデータとを一致させる第2更新工程と、
を有し、
前記ユーザプログラムに記述される前記拡張ユニットの前記デバイスは、前記第1更新工程による更新の対象および/または前記第2更新工程による更新の対象として設定可能に構成されることを特徴とする基本ユニットの制御方法。
A control method of a basic unit connected to an extension unit of a programmable logic controller and repeatedly executing a user program for each scan,
The expansion unit is
An interface to which an external device is connected;
A storage unit in which a device value related to an input value from the external device via the interface or an output value to the external device via the interface is stored, and a device for sharing data with the basic unit is allocated;
An expansion unit timer that counts the clock and measures time,
With
The control method is:
A basic unit timer that counts clocks and measures time; a synchronization step that synchronizes the timer values of the extension unit timer and the basic unit timer;
A first update step of matching the data held by the extension unit with the data held by the basic unit within a refresh period for each scan;
Based on the timer value of the basic unit timer synchronized with the timer value of the extension unit timer by the synchronization step, the data held by the extension unit within the period of processing executed at regular intervals during scanning and the basic A second update step for matching the data held by the unit;
Have
The basic unit characterized in that the device of the extension unit described in the user program can be set as an update target by the first update step and / or an update target by the second update step. Control method.
請求項28に記載の制御方法の各工程をコンピュータに実行させるプログラム。   A program for causing a computer to execute each step of the control method according to claim 28.
JP2014248402A 2014-12-08 2014-12-08 Programmable logic controller, basic unit, control method and program Active JP6535459B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2014248402A JP6535459B2 (en) 2014-12-08 2014-12-08 Programmable logic controller, basic unit, control method and program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2014248402A JP6535459B2 (en) 2014-12-08 2014-12-08 Programmable logic controller, basic unit, control method and program

Publications (3)

Publication Number Publication Date
JP2016110458A true JP2016110458A (en) 2016-06-20
JP2016110458A5 JP2016110458A5 (en) 2017-10-12
JP6535459B2 JP6535459B2 (en) 2019-06-26

Family

ID=56124332

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2014248402A Active JP6535459B2 (en) 2014-12-08 2014-12-08 Programmable logic controller, basic unit, control method and program

Country Status (1)

Country Link
JP (1) JP6535459B2 (en)

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2018063612A (en) * 2016-10-14 2018-04-19 オムロン株式会社 Arithmetic device and control system
CN109324535A (en) * 2017-07-31 2019-02-12 松下神视株式会社 Control unit, programmable controller
KR20190089155A (en) * 2018-01-18 2019-07-30 미쓰비시덴키 가부시키가이샤 PLC, network unit, CPU unit, and data transmission method
WO2020213853A1 (en) * 2019-04-15 2020-10-22 엘에스일렉트릭(주) Plc system, and method for controlling input/output refresh period thereof
JP2020177712A (en) * 2020-08-07 2020-10-29 株式会社キーエンス External setting device
JP2021036479A (en) * 2020-08-07 2021-03-04 株式会社キーエンス Programmable logic controller and main unit
CN113544600A (en) * 2019-03-15 2021-10-22 欧姆龙株式会社 Control system, relay device, and relay program
US11188048B2 (en) 2018-10-23 2021-11-30 Keyence Corporation Programmable logic controller and main unit
US11467990B2 (en) 2018-10-15 2022-10-11 Mitsubishi Electric Corporation Programmable logic controller, external apparatus, method, and recording medium
JP7221465B1 (en) * 2022-06-15 2023-02-13 三菱電機株式会社 Control system, programmable logic controller, visualization method and program

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2003029809A (en) * 2001-07-19 2003-01-31 Omron Corp Cpu unit and programmable controller
JP2008251051A (en) * 2008-07-07 2008-10-16 Okwave:Kk Management server
JP2008251052A (en) * 2008-07-08 2008-10-16 Omron Corp I/o unit and programmable controller system
JP2010198600A (en) * 2009-02-02 2010-09-09 Omron Corp Industrial controller
JP2014052672A (en) * 2012-09-04 2014-03-20 Keyence Corp Programmable controller, program creation support device, program, and basic unit
WO2014108999A1 (en) * 2013-01-08 2014-07-17 富士電機株式会社 Control system, master programmable controller, slave programmable controller, and control method

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2003029809A (en) * 2001-07-19 2003-01-31 Omron Corp Cpu unit and programmable controller
JP2008251051A (en) * 2008-07-07 2008-10-16 Okwave:Kk Management server
JP2008251052A (en) * 2008-07-08 2008-10-16 Omron Corp I/o unit and programmable controller system
JP2010198600A (en) * 2009-02-02 2010-09-09 Omron Corp Industrial controller
JP2014052672A (en) * 2012-09-04 2014-03-20 Keyence Corp Programmable controller, program creation support device, program, and basic unit
WO2014108999A1 (en) * 2013-01-08 2014-07-17 富士電機株式会社 Control system, master programmable controller, slave programmable controller, and control method

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2018063612A (en) * 2016-10-14 2018-04-19 オムロン株式会社 Arithmetic device and control system
CN109324535A (en) * 2017-07-31 2019-02-12 松下神视株式会社 Control unit, programmable controller
KR20190089155A (en) * 2018-01-18 2019-07-30 미쓰비시덴키 가부시키가이샤 PLC, network unit, CPU unit, and data transmission method
KR102016629B1 (en) 2018-01-18 2019-08-30 미쓰비시덴키 가부시키가이샤 PLC, network unit, CPU unit, and data transfer method
US11467990B2 (en) 2018-10-15 2022-10-11 Mitsubishi Electric Corporation Programmable logic controller, external apparatus, method, and recording medium
US11188048B2 (en) 2018-10-23 2021-11-30 Keyence Corporation Programmable logic controller and main unit
CN113544600A (en) * 2019-03-15 2021-10-22 欧姆龙株式会社 Control system, relay device, and relay program
CN113544600B (en) * 2019-03-15 2024-04-05 欧姆龙株式会社 Control system, relay device, and recording medium
WO2020213853A1 (en) * 2019-04-15 2020-10-22 엘에스일렉트릭(주) Plc system, and method for controlling input/output refresh period thereof
JP2020177712A (en) * 2020-08-07 2020-10-29 株式会社キーエンス External setting device
JP2021036479A (en) * 2020-08-07 2021-03-04 株式会社キーエンス Programmable logic controller and main unit
JP7221465B1 (en) * 2022-06-15 2023-02-13 三菱電機株式会社 Control system, programmable logic controller, visualization method and program
WO2023243012A1 (en) * 2022-06-15 2023-12-21 三菱電機株式会社 Control system, programmable logic controller, visualization method, and program

Also Published As

Publication number Publication date
JP6535459B2 (en) 2019-06-26

Similar Documents

Publication Publication Date Title
JP2016110458A (en) Programmable logic controller, basic unit, control method and program
JP6626315B2 (en) Monitoring device for programmable logic controller and programmable logic controller system
US8346378B2 (en) Programmable controller
CN110456707B (en) Control device
JP6433635B1 (en) Simulation apparatus and simulation method
US10025281B2 (en) Control device and system program, and recording medium
US10180674B2 (en) Controller and control system
JP2016194830A (en) Control device
JP2016110458A5 (en)
JP2016110460A (en) Programmable controller, method for controlling programmable controller and program
JP5680466B2 (en) Parallel processing system and method of operating parallel processing system
JP6626313B2 (en) Programmable logic controller, expansion unit, control method, program creation support device, program creation support method, and program
JP5549455B2 (en) Programmable controller system and program updating method thereof
JP6772748B2 (en) Arithmetic logic unit and control system
JP2018128845A (en) Processor system
JP6419400B1 (en) PLC, network unit, CPU unit, and data transfer method
JP4152079B2 (en) Peripheral device of programmable controller
JP6626314B2 (en) Programmable logic controller
JP6516874B2 (en) Programmable controller and synchronous control program
JP2021002113A (en) Control device
JP2007241570A (en) Setting system of shared memory for communication between programmable controller
JP2003345406A (en) Control device
JP4349687B2 (en) Programmable controller
JPWO2014080457A1 (en) Programmable controller
JP5951123B2 (en) Control device

Legal Events

Date Code Title Description
A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20170831

A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20170831

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20180629

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20180727

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20180919

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20190225

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20190409

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20190513

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20190603

R150 Certificate of patent or registration of utility model

Ref document number: 6535459

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250