JP2004272629A - Device for programmable controller, and programmable updating method and program starting method for the same - Google Patents

Device for programmable controller, and programmable updating method and program starting method for the same Download PDF

Info

Publication number
JP2004272629A
JP2004272629A JP2003062990A JP2003062990A JP2004272629A JP 2004272629 A JP2004272629 A JP 2004272629A JP 2003062990 A JP2003062990 A JP 2003062990A JP 2003062990 A JP2003062990 A JP 2003062990A JP 2004272629 A JP2004272629 A JP 2004272629A
Authority
JP
Japan
Prior art keywords
memory
program
stored
programmable controller
downloaded
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.)
Pending
Application number
JP2003062990A
Other languages
Japanese (ja)
Inventor
Fumiaki Narutani
文明 成谷
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.)
Omron Corp
Original Assignee
Omron Corp
Omron Tateisi Electronics Co
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 Omron Corp, Omron Tateisi Electronics Co filed Critical Omron Corp
Priority to JP2003062990A priority Critical patent/JP2004272629A/en
Publication of JP2004272629A publication Critical patent/JP2004272629A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Programmable Controllers (AREA)

Abstract

<P>PROBLEM TO BE SOLVED: To provide a PLC device capable of performing rewriting of retained programs during operation of programs. <P>SOLUTION: An expanded CPU unit 20 constituting the PLC can execute a program described by C language in the device for the programmable controller. The device comprises a first memory 21 maintaining programs, a second memory 22 backing up the first memory, and a third memory 23 used when a program is executed. The device stores a downloaded program to the second memory during operation. In the case of downloading in success, the device is set to boot it in the third memory after copying the downloaded program in the first memory. <P>COPYRIGHT: (C)2004,JPO&NCIPI

Description

【0001】
【発明の属する技術分野】
この発明は、C言語で記述可能なプログラマブルコントローラに関するものであり、特に、C言語のプログラムを稼働状態のまま入れ替えることが出来るようなプログラマブルコントローラに関する。
【0002】
【従来の技術】
ファクトリーオートメーション(FA)の制御装置として、プログラマブルコントローラ(PLC)が用いられている。このPLCは、複数のユニットから構成される。すなわち、電源供給源の電源ユニット,PLC全体の制御を統率するCPUユニット,FAの生産装置や設備装置の適所に取り付けたスイッチやセンサの信号を入力する入力ユニット,アクチュエータなどに制御出力を出す出力ユニット,通信ネットワークに接続するための通信ユニットなどの各種のユニットを適宜組み合わせて構成される。
【0003】
PLCのCPUユニットにおける制御は、入力ユニットで入力した信号をCPUユニットのI/Oメモリに取り込み(INリフレッシュ)、予め登録されたユーザプログラム記述言語(例えばラダー言語)で組まれたユーザプログラムに基づき論理演算をし(演算実行)、その演算実行結果をI/Oメモリに書き込んで出力ユニットに送り出し(OUTリフレッシュ)、その後、いわゆる周辺処理を行うと言うことをサイクリックに繰り返し処理するようになる。そして、上記したユーザプログラムは、CPUユニットのユーザメモリに格納される。
【0004】
ところで、PLCの一般的な使われ方としては、複数のINデータの論理演算をして、その演算結果によってOUTデータを出力して、被制御装置を制御するような使われ方がある。この場合のユーザプログラムは、ラダー言語を用いることが多い。その理由は、ラダーによるプログラミングは、入力機器の接点のON/OFF状態と出力機器へのOUT信号の状態との論理関係を表しやすく、目視でわかりやすいためである。しかし、最近ではPLCの制御内容も単なる論理演算だけでなく、関数演算や数式演算,アナログ情報を扱う処理をすることもある。このような比較的高度な演算や処理をする場合のプログラミング言語としてC言語を使用することがある。そこで、PLCの中に、ラダープログラムを実行するCPUと、C言語を実行するCPUとの両方を持たせたものがある。このようなPLCでは、C言語などのコンパイル方式の言語でプログラムを記述して演算処理可能となっている。そのようなPLCにおいては、プログラムは、外部のプログラミング開発環境(プログラミングツール)で作成したのち、コンパイル→アセンブル→リンクの工程を経てオブジェクトコードに変換し、その変換されたオブジェクトコードをPLCのCPUユニットにダウンロードして、CPUユニット内に記憶される。そのプログラムはCPUユニット内にて実行される。
【0005】
そして、現在実行中のプログラムを変更すべくメモリ内容を書き換えるには、通常、以下のような手順を実行する。すなわち、(1)まずジャンパーピンやディップスイッチ等のモード切替手段によって、PLCをプログラム転送モードに変更する。(2)次いで、オブジェクトコードのダウンロードを実行する。これにより、PLCが持つプログラムを格納するメモリに、オブジェクトコードが格納される。(3)ダウンロードが完了したらならば、PLCをプログラム実行モードに変更した後、立ち上げ直す。
【0006】
【発明が解決しようとする課題】
しかしながら、PLCにおける動作モードの決定は、電源ON時に決定されることが多いため、プログラムのダウンロードを行うに際し、コントローラの再起動が必要となる場合があった。従って、C言語で記述された制御プログラムを、コントローラの稼働中に安全に入れ換えることができなかった。
【0007】
また、プログラム転送中に電源断が発生したり、プログラムの転送をキャンセルしたりした場合は、メモリに保持されている既存のプログラムが壊れてしまう可能性がある。このような場合には、再起動時にプログラムが正しく稼働しない場合があった。
【0008】
この発明は、プログラム稼動中に保持されているプログラムの書き換えを可能にするとともに、プログラム転送中の不意の電源断やプログラム転送のキャンセルなどにより保持されたプログラムが破壊された場合にも、以前のプログラムにて正常に稼働できるようにし、また、1つのメモリに記憶保持したプログラムが破壊されていた場合でも、正常に立ち上げることのできるプログラマブルコントローラ用機器並びにプログラマブルコントローラ用機器におけるプログラム更新方法並びにプログラム起動方法を提供することを目的とする。
【0009】
【課題を解決するための手段】
この発明によるプログラマブルコントローラ用機器は、プログラマブルコントローラを構成する機器であって、前記機器は、C言語などのコンパイル方式の言語で記述されたプログラムを実行可能であり、前記プログラムを保持する第1メモリと、その第1メモリをバックアップするための第2メモリと、前記プログラムを実行する際に使用する第3メモリとを備え、稼働中にダウンロードしたプログラムは、前記第2メモリに格納させ、ダウンロードが成功した場合に、そのダウンロードしたプログラムに基づくプログラムを第3メモリに展開して実行するようにした。
【0010】
ここで、プログラマブルコントローラ用機器とは、例えば、プログラマブルコントローラを構成する1つのユニットでも良いし、ボードのように所定のユニットに実装されるものでも良いし、プログラマブルコントローラそのものでも良い。
【0011】
また、前記ダウンロードしたプログラムに基づくプログラムは、前記ダウンロードが成功した場合に、前記第2メモリに格納したプログラムを前記第1メモリにコピーする機能を有し、前記第3メモリに展開するプログラムは、前記第1メモリにコピーされたプログラムとするとよい。もちろん、本発明はこれに限ることはなく、第2メモリに格納したプログラムを第1メモリに展開しても良い。つまり、ダウンロードしたプログラムに基づくプログラムとは、第2メモリに格納したプログラムそのものでも良いし、第1メモリにコピーしたプログラムでもよく、要は、内容がダウンロードしたプログラムと等しくなっていればよい。
【0012】
また、本発明に係るプログラム更新方法は、C言語などのコンパイル方式の言語で記述されたプログラムを実行可能なプログラマブルコントローラ用機器におけるプログラムの更新方法であって、前記プログラマブルコントローラ用機器は、前記プログラムを保持する第1メモリと、その第1メモリをバックアップするための第2メモリと、前記プログラムを実行する際に使用する第3メモリとを備え、稼働中にダウンロードしたプログラムを前記第2メモリに格納させ、前記ダウンロードが成功したか否かを判断し、成功した場合には、そのダウンロードしたプログラムに基づくプログラムを第3メモリに展開し、以後、前記ダウンロードした新たなプログラムを実行するようにした。
【0013】
また、別の解決手段としては、C言語などのコンパイル方式の言語で記述されたプログラムを実行可能なプログラマブルコントローラ用機器におけるプログラムの更新方法であって、前記プログラマブルコントローラ用機器は、前記プログラムを保持する第1メモリと、その第1メモリをバックアップするための第2メモリと、前記プログラムを実行する際に使用する第3メモリとを備え、稼働中にダウンロードしたプログラムを前記第2メモリに格納させ、前記ダウンロードが成功したか否かを判断し、成功した場合には、前記第2メモリに格納されたプログラムを前記第1メモリにコピーし、そのコピーが正常に行われた場合に、前記第1メモリにコピーしたプログラムを第3メモリに展開し、以後、前記ダウンロードした新たなプログラムを実行するようにすることもできる。
【0014】
第2メモリを設けたため、プログラム実行中であっても、その第2メモリにプログラムをダウンロードすることができ、その後、第2メモリに格納したプログラムに基づくプログラムを第3メモリに展開(ブート)することにより、それまで使用していたプログラムから、新たにダウンロードしたプログラムへの切替を電源OFFすることなくそのまま連続して実行することができる。つまり、プログラム稼動中に、保持されているプログラムの書き換えを実現することができる。
【0015】
また、第1,第2メモリというように、プログラムを保持するメモリを2つ持つことで、プログラム転送中の不意の電源断やプログラム転送のキャンセルなどにより保持されたプログラムが破壊された場合にも、以前のプログラムにて正常に稼働できる。
【0016】
さらに本発明に係るプログラマブルコントローラ用機器は、起動する際に前記第1メモリに格納されたプログラムを前記第3メモリに展開するに際し、前記第1メモリに格納されたプログラムに異常がある場合に、前記第2メモリに格納された正常なプログラムに基づくプログラムを前記第3メモリに展開する機能を備えた。
【0017】
また、本発明に係るプログラム起動方法は、前記プログラムを保持する第1メモリと、その第1メモリをバックアップするための第2メモリと、前記プログラムを実行する際に使用する第3メモリとを備えた前記プログラマブルコントローラ用機器を前提とし、起動時に、前記第1メモリに格納されたプログラムをチェックし、正常な場合には、その第1メモリから第3メモリに展開して起動し、前記チェックの結果異常があった場合には、前記第2メモリに格納されたプログラムを用いて起動するようにした。これにより、たとえ第1メモリに格納されたプログラムが壊れていても、確実にプログラムの起動が行える。
【0018】
【発明の実施の形態】
図1は、本発明の好適な一実施の形態を示している。図1に示すように、PLC1は、CPUユニット10や、拡張CPUユニット20等を備えて構成される。もちろん、図示省略するが、通信ユニット,I/Oユニット,マスタユニット,電源ユニットなど、その他のユニットも存在する。
【0019】
CPUユニット10は、図示省略するシステムROMに格納されたシステムプログラムにしたがって、CPU11が所定の処理をサイクリックに実行するものである。ここで所定の処理とは、共通処理,演算処理,サイクルタイム算出処理,I/Oリフレッシュ処理,周辺サービス処理がある。演算処理は、プログラムメモリ12に格納されたユーザプログラムを順次実行するもので、その演算実行時に、適宜IOメモリ13にアクセスし、IOデータを読み書きしたり、パラメータを取得する。そして、I/Oリフレッシュ処理では、IOメモリ13に対して、IOデータの更新処理を行う。CPU11は、バスコントローラ14を介してIOメモリ13にアクセスしたり、拡張CPUユニット20にアクセスしたりできるようになっている。なお、このCPU11で実行されるユーザプログラムは、従来と同様にラダー言語で作成されている。
【0020】
一方、拡張CPUユニット20は、高級言語(例えばC言語)で作成されたプログラムを保持する第1メモリ21と、そのプログラムのバックアップ用メモリである第2メモリ22と、プログラム稼働用の第3メモリ23を備えている。この拡張CPUユニット20の形態は、CPUユニット10とは別体のユニットで、CPUユニット10とPLCバス(内部バス)を介して、他のユニット(通信ユニット,I/Oユニットなど)と同様にユニット接続されている。なお、拡張CPUユニット20の別の形態として、CPUユニット10内に挿入して内蔵できるような増設基板タイプであってもよい。また別の形態として、CPUユニット10に対する増設ユニットタイプでもよい。増設基板タイプや増設ユニットタイプの場合の接続バスは、他ユニットがつながるPLCバスとは別のバスで、CPUユニット11自体の内部バスでもよい(この場合もバスも回線はべつでもPLCバスには経由接続できるようになっている)。要するに、CPU11とバスを介してつながれ、拡張CPUとしてCPU11とは別途に独自に動作するもので、CPUユニット10のIOメモリ13に対してアクセスする機能を持っていれば形態はなんでもよい。
【0021】
第1,第2メモリ21,22は、不揮発性のフラッシュメモリから構成され、第3メモリ23は高速に実行させる必要から、揮発性のRAMから構成される。そして、プログラムを実行するには、電源投入時その他適宜のタイミングで第1メモリ21に格納されたプログラムを、第3メモリ23にコピーし、その第3メモリ23に記憶保持されたプログラムに基づいてCPU24が所定のアルゴリズムを実行するようになる(詳細は後述する)。
【0022】
そして、CPU24が実行するメインプログラムの管理シーケンスは、例えば図2に示すように、制御スロットと管理スロットを交互に繰り返すことになる。ここで、制御スロットは、ユーザタスクの実行を制御するもので、登録されたタスクを指定された順番で実行する。つまり、第3メモリ23にコピーされたプログラムを実行することになる。また、管理スロットは、自分自身の動作を管理するもので、各要求に応じた処理を行う。要求としては、例えば、本発明との関係で言うと、プログラム受信要求,コピー要求,再ブート要求などがある。
【0023】
また、拡張CPUユニット20は、専用バスを介してメインのCPUユニット10と連携されている。具体的には、バスコントローラ14とアドレスデコーダ25の間でデータの送受を行うことにより、CPUユニット11がアドレスデコーダ25経由で各種のメモリにアクセスしたり、CPU24に所定の命令を与えたりする。また、拡張CPUユニット20からのイベント等も、アドレスデコーダ25からバスコントローラ14経由でCPUユニット10(CPU11)に伝えられる。
【0024】
ここで本発明では、第2メモリ22を設け、新たなプログラムのダウンロードを第2メモリ22に対して行うようにした。すなわち、図3に示すように、ダウンロードする場合には、まず、外部装置よりバックアップ用メモリ(メモリ2)にプログラムを書き込む(▲1▼)。具体的には、PLC1の通信ユニットに接続したツールから、CPUユニット10経由で第2メモリ22にプログラムを格納する。そして、プログラム転送が終了すると、サム値を書き込む(▲2▼)。その後、ダウンロード完了イベントを通知する(▲3▼)。
【0025】
一方、すでに述べたとおり、プログラムは第3メモリ23上で稼働する。そして、第3メモリ23上のプログラムは、ユーザプログラムを実行するための制御スロットと自分自身の管理のための管理スロットを持っており、管理スロット実行中にダウンロード完了イベントをチェックする(▲4▼)。そこで、この管理スロット実行中にダウンロード完了イベントが発生していたらダウンロードしたプログラムのサムチェックを行い、正常にダウンロードされたか否かを判断する(▲5▼)。そして、正常にダウンロードされていた場合のみ、第2メモリ22に格納されたプログラムとサム値の両方を第1メモリ21にコピーする(▲6▼)。
【0026】
上記した▲1▼〜▲6▼の手順を実行することにより、プログラム転送の中断や不意の電源断などが発生した場合であっても、第1,第2メモリ21,22の少なくとも一方には正しいプログラムが格納されていることが保証される。すなわち、第2メモリ22へのダウンロード中に中断等が発生し、第2メモリ22のデータ(プログラム)が壊れたとしても、第1メモリ21には現在運用中の正しいプログラムが保持されたままとなる。よって、再度第2メモリにダウンロードすればよいし、ダウンロードの中断が意図的で元のプログラムを実行し続けたい場合には、第1メモリ21のプログラムに基づいて実行すればよい。また、第2メモリ22から第1メモリ21へコピー中に中断した場合には、第1メモリ21のデータ(プログラム)は壊れるおそれがあるが、その場合でも第2メモリ22には正しいプログラムが格納されているので、再度第2メモリ22から第1メモリへコピーすればよい。そして、第1メモリ21へのプログラムとサム値のコピーが完了したら、ブートプログラムの先頭にジャンプする。
【0027】
このブートプログラムは、第1メモリ21上に配置されており、第1メモリ21上で稼働する。具体的には、第1メモリ21上に保持されているプログラムのサム値をチェックする(▲7▼)。そして、サム値チェックをした結果、正常であれば第1メモリ21にコピーされたプログラムを第3メモリ23にプログラムをブートし、第3メモリ23上のプログラムの先頭にジャンプする(▲8▼)。これにより、第3メモリ23の内容も、ダウンロードされた新しいプログラムとなり、次のサイクルからは、新しいプログラムに基づく処理が実行される。これにより、電源をOFFすることなく、稼働中のままプログラムのダウンロード・更新が行える。
【0028】
上記した処理手順は、実際には図4,図5に示すフローチャートを実行することになる。すなわち、管理スロットがスタートすると、受信要求フラグがONになるのを待つ(ST1)。管理スロット開始から一定時間経過しても受信要求がONにならないと、今回の管理スロットは終了する。
【0029】
そして、受信要求フラグがONになると、送信されてきたプログラムを受信する(ST2)。実際には、送られてきたプログラムを第2メモリ22に格納する。さらに、サム値も記録する。つまり、図3で言う▲1▼,▲2▼の処理を実行する。
【0030】
次いで、ダウンロード完了フラグからONになるのを待ち(ST3)、ONになるとサム値まで第2メモリ22に格納されたことを意味するのでサム値チェックを行う(ST5)。ここまでの処理は、図3における▲3▼〜▲5▼に対応する。そして、サム値が異常であればこの管理スロットを終了する。
【0031】
また、サム値がOKであると、ダウンロードが正しく行われたと判断し、第2メモリ22から第1メモリ21へプログラムをコピーする(ST6)。そして、コピーしたプログラムのサム値を計算し(ST7)、コピーが終了したならば計算したサム値を第1メモリに格納する(ST8,9)。その後、ブートにジャンプする。
【0032】
ブート処理は、図5に示すように、第1メモリ21のサム値が正しいか否かを判断し(ST11)、正しい場合には、第1メモリ21に格納されたプログラムが新たにダウンロードされたプログラムと判断し、その第1メモリ21に格納されたプログラムをブートする(ST16)。そして、メインプログラムにジャンプし、次の制御スロットを実行する。
【0033】
また、ステップ11の分岐判断でNoの場合には、ステップ6で行ったプログラムのコピーが失敗したと判断し、第2メモリ22のサム値をチェックする(ST12)。通常であれば、ステップ4,5の処理を経ているため、このステップ12でのサム値チェックの結果はYesとなるが、何かしらの要因でNoとなると、エラー表示をして処理を終了する(ST13)。
【0034】
そして、第2メモリ22のサム値がOKの場合には、第2メモリ22から第1メモリ21へ再度プログラムのコピーを行い(ST14)、コピー後、サム値を計算し正しいことを確認の上(ST15)、第1メモリ21にコピーしたプログラムを第3メモリ23にブートする(ST16)。なお、フローチャートには記載していないが、ステップ15で算出したサム値が異常の場合には、所定の異常処理、つまり、再度ステップ14に戻ってプログラムのコピーを試みたり、ステップ13に飛ぶなど各種の方法が採れる。
【0035】
なお、上記した実施の形態では、第3メモリ23へのブートは第1メモリ21のみから行えるようになっているため、第1メモリ21のサム値異常の場合には、一旦第2メモリ22から第1メモリ21へ転送後、第1メモリ21からブートするようにしたが、第2メモリ22からブートするようにしても良い。
【0036】
また、上記したように、バックアップメモリとして第2メモリ22を設けたことから、起動時処理を図6に示すようにすることにより、確実に正常なプログラムに基づく処理を実行することができる。
【0037】
すなわち、通常、第1メモリ21上で稼動し、第1メモリ21に保持されているプログラムのサム値をチェックし(▲1▼)、サム値が正常であれば第3メモリ23にプログラムをブートした後、第3メモリ23上のプログラム先頭にジャンプし、プログラムを順次実行するようになる(▲2▼)。
【0038】
このとき、第1メモリ21のサム値が異常であった場合は、第2メモリ22のサム値をチェックし(▲3▼)、正常であれば第2メモリ22のプログラムを第1メモリ21にコピーする(▲4▼)。その後、▲1▼,▲2▼の処理を経て、再度ブートプログラムの先頭にジャンプする。このようにすることにより、電源OFF時や、起動時などにおいて第1メモリ21に格納されたプログラムが壊れた場合でも、第2メモリ22に格納されたプログラムに基づいて、正常に起動処理することができる。なお、第2メモリ22のサム値も異常であった場合は、エラー出力の後、処理を停止する。
【0039】
なお、再度説明するが、上記した実施の形態では、拡張CPUユニット20は、PLCを構成する1つのユニットとして説明したが、ボードのようにし、CPUユニット10内に実装するようにしたりすることもできる。
【0040】
【発明の効果】
以上のように、この発明では、バックアップ用の第2メモリを設け、プログラム実行中のダウンロードは、その第2メモリに行うようにしたため、稼働状態のままプログラムの書き換えが行える。
【図面の簡単な説明】
【図1】本発明に係るPLCの一実施の形態を示すブロック図である。
【図2】管理シーケンスを説明する図である。
【図3】本発明の要部の機能を説明する図である。
【図4】CPU24の機能を説明するフローチャートである。
【図5】CPU24の機能を説明するフローチャートである。
【図6】起動時の機能を説明する図である。
【符号の説明】
1 PLC
10 CPUユニット
11 CPU
12 プログラムメモリ
13 IOメモリ
14 バスコントローラ
20 拡張CPUユニット
21 第1メモリ
22 第2メモリ
23 第3メモリ
24 CPU
25 アドレスデコーダ
[0001]
TECHNICAL FIELD OF THE INVENTION
The present invention relates to a programmable controller that can be described in C language, and more particularly to a programmable controller that can replace a C language program in an operating state.
[0002]
[Prior art]
A programmable controller (PLC) is used as a control device for factory automation (FA). This PLC is composed of a plurality of units. That is, a power supply unit of a power supply source, a CPU unit for directing the control of the entire PLC, an input unit for inputting a signal of a switch or a sensor installed at an appropriate position in an FA production device or an equipment device, an output for outputting a control output to an actuator or the like Various units such as a unit and a communication unit for connecting to a communication network are appropriately combined and configured.
[0003]
The control in the CPU unit of the PLC is performed by taking a signal input from the input unit into the I / O memory of the CPU unit (IN refresh), and based on a user program written in a user program description language (eg, a ladder language) registered in advance. A logical operation is performed (operation execution), the operation execution result is written to an I / O memory and sent to an output unit (OUT refresh), and thereafter, so-called peripheral processing is performed cyclically and repeatedly. . Then, the above-described user program is stored in the user memory of the CPU unit.
[0004]
By the way, as a general usage of the PLC, there is a usage in which a logical operation is performed on a plurality of IN data and OUT data is output based on the operation result to control the controlled device. In this case, the user program often uses a ladder language. The reason is that the ladder programming is easy to express the logical relationship between the ON / OFF state of the contact point of the input device and the state of the OUT signal to the output device, and is easy to visually recognize. However, recently, the control content of the PLC may be not only a mere logical operation but also a function operation, a mathematical operation, and a process for handling analog information. In some cases, C language is used as a programming language for performing such relatively advanced calculations and processes. Therefore, some PLCs have both a CPU that executes a ladder program and a CPU that executes the C language. In such a PLC, arithmetic processing can be performed by writing a program in a compilation language such as the C language. In such a PLC, a program is created in an external programming development environment (programming tool), then converted into object code through a process of compiling, assembling, and linking, and the converted object code is converted into a CPU unit of the PLC. And stored in the CPU unit. The program is executed in the CPU unit.
[0005]
Then, to rewrite the contents of the memory so as to change the currently running program, the following procedure is usually executed. That is, (1) First, the PLC is changed to the program transfer mode by mode switching means such as a jumper pin or a dip switch. (2) Next, the object code is downloaded. Thus, the object code is stored in the memory for storing the program of the PLC. (3) When the download is completed, change the PLC to the program execution mode and restart.
[0006]
[Problems to be solved by the invention]
However, since the determination of the operation mode in the PLC is often determined when the power is turned on, it may be necessary to restart the controller when downloading the program. Therefore, the control program described in the C language cannot be safely replaced while the controller is operating.
[0007]
In addition, if a power failure occurs during the transfer of the program or if the transfer of the program is canceled, the existing program stored in the memory may be broken. In such a case, the program may not operate correctly at the time of restart.
[0008]
The present invention makes it possible to rewrite a stored program while the program is running, and to prevent the stored program from being destroyed due to unexpected power-off during program transfer or cancellation of program transfer. Programmable controller device, program updating method and program in programmable controller device capable of operating normally with a program, and capable of starting up normally even if a program stored in one memory is broken The purpose is to provide an activation method.
[0009]
[Means for Solving the Problems]
A device for a programmable controller according to the present invention is a device constituting a programmable controller, the device being capable of executing a program described in a language of a compile method such as the C language, and a first memory holding the program. And a second memory for backing up the first memory, and a third memory used when executing the program, wherein the program downloaded during operation is stored in the second memory, When succeeding, the program based on the downloaded program is developed in the third memory and executed.
[0010]
Here, the programmable controller device may be, for example, one unit constituting the programmable controller, a device mounted on a predetermined unit such as a board, or the programmable controller itself.
[0011]
Also, the program based on the downloaded program has a function of copying the program stored in the second memory to the first memory when the download is successful, and the program expanded in the third memory includes: The program may be a program copied to the first memory. Of course, the present invention is not limited to this, and the program stored in the second memory may be expanded in the first memory. In other words, the program based on the downloaded program may be the program itself stored in the second memory or the program copied to the first memory, that is, the content may be the same as the downloaded program.
[0012]
A program updating method according to the present invention is a method for updating a program in a programmable controller device capable of executing a program described in a compilation language such as C language, wherein the programmable controller device includes the program Memory, a second memory for backing up the first memory, and a third memory for use in executing the program, wherein the program downloaded during operation is stored in the second memory. Then, it is determined whether or not the download is successful. If the download is successful, a program based on the downloaded program is expanded in the third memory, and thereafter, the downloaded new program is executed. .
[0013]
Another solution is a method of updating a program in a programmable controller device capable of executing a program described in a compile-type language such as C language, wherein the programmable controller device stores the program. A first memory, a second memory for backing up the first memory, and a third memory for use in executing the program, wherein the program downloaded during operation is stored in the second memory. Determining whether or not the download was successful; if successful, copying the program stored in the second memory to the first memory; if the copy was performed normally, The program copied to the first memory is expanded to the third memory, and thereafter, the downloaded new program It can also be adapted to perform the beam.
[0014]
Since the second memory is provided, the program can be downloaded to the second memory even during the execution of the program, and then the program based on the program stored in the second memory is developed (booted) in the third memory. As a result, switching from the program used so far to the newly downloaded program can be executed continuously without turning off the power. That is, while the program is running, the stored program can be rewritten.
[0015]
Further, by having two memories for holding the program, such as the first and second memories, even if the held program is destroyed due to unexpected power-off during program transfer or cancellation of the program transfer, etc. , Can work normally with the previous program.
[0016]
Furthermore, the device for a programmable controller according to the present invention, when expanding the program stored in the first memory to the third memory when starting, when there is an abnormality in the program stored in the first memory, A function of expanding a program based on a normal program stored in the second memory to the third memory is provided.
[0017]
Also, a program starting method according to the present invention includes a first memory for holding the program, a second memory for backing up the first memory, and a third memory used for executing the program. The program stored in the first memory is checked at the time of start-up, and if normal, the program is expanded from the first memory to the third memory and started, and If there is an abnormal result, the program is started using the program stored in the second memory. Thereby, even if the program stored in the first memory is broken, the program can be reliably started.
[0018]
BEST MODE FOR CARRYING OUT THE INVENTION
FIG. 1 shows a preferred embodiment of the present invention. As shown in FIG. 1, the PLC 1 includes a CPU unit 10, an extended CPU unit 20, and the like. Of course, although not shown, there are other units such as a communication unit, an I / O unit, a master unit, and a power supply unit.
[0019]
In the CPU unit 10, the CPU 11 executes predetermined processing cyclically according to a system program stored in a system ROM (not shown). Here, the predetermined processing includes common processing, arithmetic processing, cycle time calculation processing, I / O refresh processing, and peripheral service processing. The arithmetic processing sequentially executes a user program stored in the program memory 12, and at the time of performing the arithmetic, accesses the IO memory 13 as appropriate, reads and writes IO data, and acquires parameters. Then, in the I / O refresh processing, the IO memory 13 is updated with IO data. The CPU 11 can access the IO memory 13 and the extended CPU unit 20 via the bus controller 14. It should be noted that the user program executed by the CPU 11 is created in a ladder language as in the prior art.
[0020]
On the other hand, the extended CPU unit 20 includes a first memory 21 for holding a program created in a high-level language (for example, C language), a second memory 22 as a backup memory for the program, and a third memory for operating the program. 23. The form of the extended CPU unit 20 is a unit separate from the CPU unit 10 and is similar to other units (communication unit, I / O unit, etc.) via the CPU unit 10 and a PLC bus (internal bus). Unit is connected. As another form of the extension CPU unit 20, an extension board type that can be inserted into the CPU unit 10 and built in may be used. As another form, an extension unit type for the CPU unit 10 may be used. The connection bus in the case of the extension board type or the extension unit type is a bus different from the PLC bus to which other units are connected, and may be the internal bus of the CPU unit 11 itself. Connection is possible). In short, the CPU 11 is connected to the CPU 11 via a bus and operates independently of the CPU 11 as an extended CPU. The CPU 11 may have any form as long as it has a function of accessing the IO memory 13 of the CPU unit 10.
[0021]
The first and second memories 21 and 22 are composed of non-volatile flash memories, and the third memory 23 is composed of volatile RAM because it is necessary to execute the memory at high speed. Then, in order to execute the program, the program stored in the first memory 21 is copied to the third memory 23 at power-on or other appropriate timing, and based on the program stored and held in the third memory 23. The CPU 24 executes a predetermined algorithm (details will be described later).
[0022]
Then, in the management sequence of the main program executed by the CPU 24, for example, as shown in FIG. 2, the control slot and the management slot are alternately repeated. Here, the control slot controls the execution of the user task, and executes the registered tasks in a designated order. That is, the program copied to the third memory 23 is executed. The management slot manages its own operation, and performs processing according to each request. The requests include, for example, a program reception request, a copy request, and a reboot request in relation to the present invention.
[0023]
The extended CPU unit 20 is linked with the main CPU unit 10 via a dedicated bus. Specifically, by transmitting and receiving data between the bus controller 14 and the address decoder 25, the CPU unit 11 accesses various memories via the address decoder 25 or gives a predetermined command to the CPU 24. Further, events and the like from the extended CPU unit 20 are also transmitted from the address decoder 25 to the CPU unit 10 (CPU 11) via the bus controller 14.
[0024]
Here, in the present invention, the second memory 22 is provided, and a new program is downloaded to the second memory 22. That is, as shown in FIG. 3, when downloading, first, a program is written from an external device to the backup memory (memory 2) ((1)). Specifically, a program is stored in the second memory 22 via the CPU unit 10 from a tool connected to the communication unit of the PLC 1. When the program transfer is completed, a sum value is written ((2)). Thereafter, a download completion event is notified ([3]).
[0025]
On the other hand, as described above, the program runs on the third memory 23. The program in the third memory 23 has a control slot for executing a user program and a management slot for managing itself, and checks a download completion event during execution of the management slot ((4)). ). Therefore, if a download completion event has occurred during the execution of the management slot, a sum check of the downloaded program is performed, and it is determined whether or not the downloaded program has been normally downloaded ([5]). Then, only when the program has been normally downloaded, both the program and the sum value stored in the second memory 22 are copied to the first memory 21 ([6]).
[0026]
By executing the above-mentioned procedures (1) to (6), even if the program transfer is interrupted or the power is unexpectedly cut off, at least one of the first and second memories 21 and 22 is stored. It is guaranteed that the correct program is stored. That is, even if an interruption or the like occurs during downloading to the second memory 22 and the data (program) in the second memory 22 is broken, the first memory 21 keeps the correct program currently in operation. Become. Therefore, the program may be downloaded to the second memory again, or when the download is intentionally interrupted and the original program is to be continuously executed, the program may be executed based on the program in the first memory 21. Also, if the data is interrupted during copying from the second memory 22 to the first memory 21, the data (program) in the first memory 21 may be destroyed, but even in such a case, the correct program is stored in the second memory 22. Therefore, copying from the second memory 22 to the first memory may be performed again. When the copying of the program and the sum value to the first memory 21 is completed, the process jumps to the head of the boot program.
[0027]
This boot program is arranged on the first memory 21 and operates on the first memory 21. Specifically, the sum value of the program stored in the first memory 21 is checked ([7]). Then, as a result of the sum value check, if the program is normal, the program copied to the first memory 21 is booted into the third memory 23 and jumped to the beginning of the program on the third memory 23 ([8]). . Thus, the contents of the third memory 23 also become the downloaded new program, and processing based on the new program is executed from the next cycle. As a result, the program can be downloaded / updated without turning off the power while the program is running.
[0028]
The processing procedure described above actually executes the flowcharts shown in FIGS. That is, when the management slot starts, it waits until the reception request flag is turned ON (ST1). If the reception request does not turn ON even after a certain time has elapsed from the start of the management slot, the current management slot ends.
[0029]
Then, when the reception request flag is turned ON, the transmitted program is received (ST2). Actually, the transmitted program is stored in the second memory 22. In addition, the sum value is recorded. That is, the processing of (1) and (2) referred to in FIG. 3 is executed.
[0030]
Next, it waits for the download completion flag to turn on (ST3). When it turns on, it means that the sum value has been stored in the second memory 22 so that a sum value check is performed (ST5). The processing so far corresponds to (3) to (5) in FIG. If the sum value is abnormal, the management slot ends.
[0031]
If the sum value is OK, it is determined that the download has been correctly performed, and the program is copied from the second memory 22 to the first memory 21 (ST6). Then, the sum value of the copied program is calculated (ST7), and when the copy is completed, the calculated sum value is stored in the first memory (ST8, 9). Then jump to boot.
[0032]
In the boot process, as shown in FIG. 5, it is determined whether or not the sum value of the first memory 21 is correct (ST11). If the sum value is correct, the program stored in the first memory 21 is newly downloaded. The program is determined to be a program, and the program stored in the first memory 21 is booted (ST16). Then, the process jumps to the main program and executes the next control slot.
[0033]
If the determination in step 11 is NO, it is determined that the copy of the program performed in step 6 has failed, and the sum value in the second memory 22 is checked (ST12). Normally, since the processing of steps 4 and 5 has been performed, the result of the sum value check in step 12 is Yes, but if the result is No for some reason, an error is displayed and the processing is terminated ( ST13).
[0034]
If the sum value in the second memory 22 is OK, the program is copied from the second memory 22 to the first memory 21 again (ST14), and after copying, the sum value is calculated and checked for correctness. (ST15), the program copied to the first memory 21 is booted into the third memory 23 (ST16). Although not described in the flowchart, when the sum value calculated in step 15 is abnormal, a predetermined abnormal process, that is, the process returns to step 14 to try to copy the program or jumps to step 13 Various methods can be adopted.
[0035]
In the above embodiment, since the boot to the third memory 23 can be performed only from the first memory 21, when the sum value of the first memory 21 is abnormal, the boot from the second memory 22 is performed once. After the transfer to the first memory 21, the boot is performed from the first memory 21, but the boot may be performed from the second memory 22.
[0036]
Further, as described above, since the second memory 22 is provided as the backup memory, by performing the startup process as shown in FIG. 6, it is possible to reliably execute the process based on the normal program.
[0037]
That is, normally, the program operates on the first memory 21, checks the sum value of the program stored in the first memory 21 ((1)), and boots the program into the third memory 23 if the sum value is normal. Then, the program jumps to the beginning of the program on the third memory 23, and the programs are sequentially executed ((2)).
[0038]
At this time, if the sum value of the first memory 21 is abnormal, the sum value of the second memory 22 is checked (3), and if normal, the program of the second memory 22 is stored in the first memory 21. Copy (4). After that, the processing jumps to the top of the boot program again through the processing of (1) and (2). In this way, even if the program stored in the first memory 21 is broken at the time of power-off or at the time of startup, it is possible to perform normal startup processing based on the program stored in the second memory 22. Can be. If the sum value of the second memory 22 is also abnormal, the process is stopped after outputting the error.
[0039]
Although described again, in the above-described embodiment, the extended CPU unit 20 has been described as one unit configuring the PLC. However, the extended CPU unit 20 may be mounted on the CPU unit 10 like a board. it can.
[0040]
【The invention's effect】
As described above, in the present invention, the second memory for backup is provided, and the download during the execution of the program is performed in the second memory, so that the program can be rewritten in the operating state.
[Brief description of the drawings]
FIG. 1 is a block diagram showing an embodiment of a PLC according to the present invention.
FIG. 2 is a diagram illustrating a management sequence.
FIG. 3 is a diagram illustrating the function of a main part of the present invention.
FIG. 4 is a flowchart illustrating functions of a CPU 24.
FIG. 5 is a flowchart illustrating functions of a CPU 24.
FIG. 6 is a diagram illustrating functions at the time of activation.
[Explanation of symbols]
1 PLC
10 CPU unit 11 CPU
12 Program memory 13 IO memory 14 Bus controller 20 Extended CPU unit 21 First memory 22 Second memory 23 Third memory 24 CPU
25 Address decoder

Claims (6)

プログラマブルコントローラを構成する機器であって、
前記機器は、C言語などのコンパイル方式の言語で記述されたプログラムを実行可能であり、
前記プログラムを保持する第1メモリと、
その第1メモリをバックアップするための第2メモリと、
前記プログラムを実行する際に使用する第3メモリとを備え、
稼働中にダウンロードしたプログラムは、前記第2メモリに格納させ、ダウンロードが成功した場合に、そのダウンロードしたプログラムに基づくプログラムを第3メモリに展開して実行するようにしたことを特徴とするプログラマブルコントローラ用機器。
A device constituting a programmable controller,
The device is capable of executing a program described in a compile-type language such as C language,
A first memory for holding the program;
A second memory for backing up the first memory;
A third memory used when executing the program,
A program downloaded during operation is stored in the second memory, and when the download is successful, a program based on the downloaded program is developed in a third memory and executed. Equipment.
前記ダウンロードしたプログラムに基づくプログラムは、
前記ダウンロードが成功した場合に、前記第2メモリに格納したプログラムを前記第1メモリにコピーする機能を有し、
前記第3メモリに展開するプログラムは、前記第1メモリにコピーされたプログラムであることを特徴とする請求項1に記載のプログラマブルコントローラ用機器。
The program based on the downloaded program is:
Having a function of copying the program stored in the second memory to the first memory when the download is successful;
2. The programmable controller device according to claim 1, wherein the program loaded on the third memory is a program copied on the first memory. 3.
起動する際に前記第1メモリに格納されたプログラムを前記第3メモリに展開するに際し、前記第1メモリに格納されたプログラムに異常がある場合に、前記第2メモリに格納された正常なプログラムに基づくプログラムを前記第3メモリに展開する機能を備えたことを特徴とする請求項1または2に記載のプログラマブルコントローラ用機器。When the program stored in the first memory is expanded to the third memory at the time of activation, if the program stored in the first memory has an error, the normal program stored in the second memory 3. The programmable controller device according to claim 1, further comprising a function of expanding a program based on the third memory in the third memory. 4. C言語などのコンパイル方式の言語で記述されたプログラムを実行可能なプログラマブルコントローラ用機器におけるプログラムの更新方法であって、
前記プログラマブルコントローラ用機器は、前記プログラムを保持する第1メモリと、その第1メモリをバックアップするための第2メモリと、前記プログラムを実行する際に使用する第3メモリとを備え、
稼働中にダウンロードしたプログラムを前記第2メモリに格納させ、
前記ダウンロードが成功したか否かを判断し、成功した場合には、そのダウンロードしたプログラムに基づくプログラムを第3メモリに展開し、以後、前記ダウンロードした新たなプログラムを実行することを特徴とするプログラマブルコントローラ用機器におけるプログラム更新方法。
A method of updating a program in a programmable controller device capable of executing a program described in a compilation language such as C language,
The programmable controller device includes a first memory for holding the program, a second memory for backing up the first memory, and a third memory for use in executing the program.
The program downloaded during operation is stored in the second memory,
Determining whether or not the download has succeeded; if successful, expanding a program based on the downloaded program in a third memory, and thereafter executing the downloaded new program; How to update the program in the controller device.
C言語などのコンパイル方式の言語で記述されたプログラムを実行可能なプログラマブルコントローラ用機器におけるプログラムの更新方法であって、
前記プログラマブルコントローラ用機器は、前記プログラムを保持する第1メモリと、その第1メモリをバックアップするための第2メモリと、前記プログラムを実行する際に使用する第3メモリとを備え、
稼働中にダウンロードしたプログラムを前記第2メモリに格納させ、
前記ダウンロードが成功したか否かを判断し、成功した場合には、前記第2メモリに格納されたプログラムを前記第1メモリにコピーし、
そのコピーが正常に行われた場合に、前記第1メモリにコピーしたプログラムを第3メモリに展開し、以後、前記ダウンロードした新たなプログラムを実行することを特徴とするプログラマブルコントローラ用機器におけるプログラム更新方法。
A method of updating a program in a programmable controller device capable of executing a program described in a compilation language such as C language,
The programmable controller device includes a first memory for holding the program, a second memory for backing up the first memory, and a third memory for use in executing the program.
The program downloaded during operation is stored in the second memory,
Determining whether the download was successful, and if successful, copying the program stored in the second memory to the first memory;
When the copy is performed normally, the program copied to the first memory is expanded to a third memory, and thereafter, the downloaded new program is executed. Method.
プログラマブルコントローラ用機器におけるプログラム起動方法であって、
前記プログラマブルコントローラ用機器は、前記プログラムを保持する第1メモリと、その第1メモリをバックアップするための第2メモリと、前記プログラムを実行する際に使用する第3メモリとを備え、
起動時に、前記第1メモリに格納されたプログラムをチェックし、正常な場合には、その第1メモリから第3メモリに展開して起動し、
前記チェックの結果異常があった場合には、前記第2メモリに格納されたプログラムを用いて起動するようにしたことを特徴とするプログラマブルコントローラ用機器におけるプログラム起動方法。
A program activation method in a programmable controller device,
The programmable controller device includes a first memory for holding the program, a second memory for backing up the first memory, and a third memory for use in executing the program.
At the time of starting, the program stored in the first memory is checked. If the program is normal, the program is expanded from the first memory to the third memory and started.
If there is an abnormality as a result of the check, the program is started using a program stored in the second memory, the program starting method in the programmable controller device.
JP2003062990A 2003-03-10 2003-03-10 Device for programmable controller, and programmable updating method and program starting method for the same Pending JP2004272629A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2003062990A JP2004272629A (en) 2003-03-10 2003-03-10 Device for programmable controller, and programmable updating method and program starting method for the same

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2003062990A JP2004272629A (en) 2003-03-10 2003-03-10 Device for programmable controller, and programmable updating method and program starting method for the same

Publications (1)

Publication Number Publication Date
JP2004272629A true JP2004272629A (en) 2004-09-30

Family

ID=33124697

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2003062990A Pending JP2004272629A (en) 2003-03-10 2003-03-10 Device for programmable controller, and programmable updating method and program starting method for the same

Country Status (1)

Country Link
JP (1) JP2004272629A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2008188161A (en) * 2007-02-02 2008-08-21 Toshiba Corp Medical imaging apparatus
CN102566481A (en) * 2010-12-16 2012-07-11 无锡信捷电气有限公司 C language-based PLC (Programmable Logic Controller) control system and realization method thereof
EP3358428A1 (en) 2017-02-02 2018-08-08 Omron Corporation Method of loading system starting data into a programmable controller
WO2020079720A1 (en) * 2018-10-15 2020-04-23 三菱電機株式会社 Programmable logic controller, external apparatus, method, and program

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2008188161A (en) * 2007-02-02 2008-08-21 Toshiba Corp Medical imaging apparatus
CN102566481A (en) * 2010-12-16 2012-07-11 无锡信捷电气有限公司 C language-based PLC (Programmable Logic Controller) control system and realization method thereof
EP3358428A1 (en) 2017-02-02 2018-08-08 Omron Corporation Method of loading system starting data into a programmable controller
US10622734B2 (en) 2017-02-02 2020-04-14 Omron Corporation Method of manufacturing programmable controller
WO2020079720A1 (en) * 2018-10-15 2020-04-23 三菱電機株式会社 Programmable logic controller, external apparatus, method, and program
CN112840278A (en) * 2018-10-15 2021-05-25 三菱电机株式会社 Programmable logic controller, external device, method, and program
CN112840278B (en) * 2018-10-15 2022-05-10 三菱电机株式会社 Programmable logic controller, external device, method, and program
US11467990B2 (en) 2018-10-15 2022-10-11 Mitsubishi Electric Corporation Programmable logic controller, external apparatus, method, and recording medium

Similar Documents

Publication Publication Date Title
KR100415371B1 (en) Computer
JP2000357095A (en) Method and device for downloading software to embedded system
JP4810172B2 (en) Control device, version upgrade method, and program
JP2007052519A (en) Information processor, method, and program
JP3915808B2 (en) Programmable controller, programmable controller system, and CPU unit
WO2012071852A1 (en) Method and apparatus for upgrading bootstrap program
JP3886539B2 (en) How to load the operating system
CN105814545A (en) Electronic device
JP5084853B2 (en) Firmware update device, communication device, electronic device, firmware update system, firmware update method, and program
JP2010015316A (en) Numerical control apparatus
JP2004272629A (en) Device for programmable controller, and programmable updating method and program starting method for the same
JP4366575B2 (en) tool
CN112204479B (en) Program management system, program support device, program management method, and program support program
JPH10187454A (en) Bios reloading system
CN110442074B (en) Processing device for programmable logic controller program
JP2006260607A (en) Programmable controller, cpu unit, and method of starting duplexed operation
JP2827594B2 (en) Firmware online update method for microprocessor device and update method thereof
JP4247664B2 (en) Programmable controller equipment
JP2005050079A (en) Server device, bios updating program, bootstrap program, and bios updating method
JP7491765B2 (en) Firmware update system and firmware update method
JP7446537B1 (en) Programmable logic controller, control method and program
JP2004094725A (en) Firmware rewriting device and firmware rewriting method
JP2000200193A (en) Data processor
JP4715189B2 (en) Disk device and firmware determination method
JP2007133602A (en) Information processing system and onboard equipment

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20060130

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20080827

A131 Notification of reasons for refusal

Effective date: 20080902

Free format text: JAPANESE INTERMEDIATE CODE: A131

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20081104

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20081104

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20081218

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20090209

A02 Decision of refusal

Effective date: 20090409

Free format text: JAPANESE INTERMEDIATE CODE: A02