JP5851819B2 - Data writing / reading apparatus and data writing / reading method - Google Patents

Data writing / reading apparatus and data writing / reading method Download PDF

Info

Publication number
JP5851819B2
JP5851819B2 JP2011274249A JP2011274249A JP5851819B2 JP 5851819 B2 JP5851819 B2 JP 5851819B2 JP 2011274249 A JP2011274249 A JP 2011274249A JP 2011274249 A JP2011274249 A JP 2011274249A JP 5851819 B2 JP5851819 B2 JP 5851819B2
Authority
JP
Japan
Prior art keywords
data
writing
block
latest
latest block
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.)
Active
Application number
JP2011274249A
Other languages
Japanese (ja)
Other versions
JP2013125435A (en
Inventor
亘 高林
亘 高林
大江 英城
英城 大江
滋男 小畑
滋男 小畑
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.)
Yazaki Energy System Corp
Original Assignee
Yazaki Energy System 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 Yazaki Energy System Corp filed Critical Yazaki Energy System Corp
Priority to JP2011274249A priority Critical patent/JP5851819B2/en
Publication of JP2013125435A publication Critical patent/JP2013125435A/en
Application granted granted Critical
Publication of JP5851819B2 publication Critical patent/JP5851819B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Memory System (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Description

本発明は、データ書込読取装置及びデータ書込読取方法に係り、特に、上書き不可能なメモリに順次発生するデータを格納するデータ書込読取装置及びデータ書込読取方法に関するものである。   The present invention relates to a data writing / reading apparatus and a data writing / reading method, and more particularly to a data writing / reading apparatus and a data writing / reading method for storing sequentially generated data in a memory that cannot be overwritten.

ガス漏れや火災などの警報器では、工場出荷時に設定された設定データ(例えばガス濃度の警報値など)、警報発生時の警報履歴、故障発生時の故障履歴、通電時間などをEEPROMに記録している。しかしながら、これらデータを格納するために、EEPROMの容量を大きくする必要がありコスト的に問題があった。   For alarm devices such as gas leaks and fires, the setting data (eg gas concentration alarm value) set at the time of shipment from the factory, the alarm history at the time of alarm occurrence, the failure history at the time of failure occurrence, the energization time, etc. are recorded in the EEPROM. ing. However, in order to store these data, it is necessary to increase the capacity of the EEPROM, which causes a problem in cost.

最近では、警報器を構成するマイコン内部のフラッシュメモリをEEPROMの代わりに使用してこれらデータを格納することが考えられている。これにより、EEPROMが必要なくなり、コストダウンとなる。   Recently, it has been considered to use flash memory inside a microcomputer constituting an alarm device in place of EEPROM to store these data. This eliminates the need for an EEPROM and reduces costs.

しかしながら、上記フラッシュメモリは、EEPROMと異なりデータの上書きをすることができない。このため、従来では、データが発生する毎に、フラッシュメモリに全種類のデータ(即ち、設定データ、通電時間、警報履歴、故障履歴)を追記している。   However, unlike the EEPROM, the flash memory cannot overwrite data. For this reason, conventionally, every time data is generated, all types of data (that is, setting data, energization time, alarm history, failure history) are added to the flash memory.

図12〜図16を参照して詳しく説明する。即ち、まず、工場出荷時において、例えば出荷操作が行われると警報器内のCPUは、図12(A)に示すように、フラッシュメモリの領域を2つのブロックB1と、ブロックB2と、に分け、両方のブロックB1、B2に格納されているデータを消去して、空き領域とする。   This will be described in detail with reference to FIGS. That is, first, at the time of factory shipment, for example, when a shipment operation is performed, the CPU in the alarm device divides the flash memory area into two blocks B1 and B2 as shown in FIG. The data stored in both the blocks B1 and B2 are erased to make a free area.

次に、警報器内のCPUは、図12(B)に示すように、外部からの通信により受信した設定データをブロックB1の先頭に書き込む。次に、警報器内のCPUは、通電時間、警報履歴1〜3、故障履歴1〜3の順にブロックB1に書き込む。なお、このとき出荷時であるので、通電時間としては0が書き込まれる。また、警報も故障も発生していない状態であるため、警報履歴1〜3、故障履歴1〜3としては空のデータが書き込まれる。   Next, as shown in FIG. 12B, the CPU in the alarm device writes the setting data received by communication from the outside at the head of the block B1. Next, the CPU in the alarm device writes in the block B1 in the order of energization time, alarm history 1 to 3, and failure history 1 to 3. Since it is the time of shipment at this time, 0 is written as the energization time. In addition, since no alarm or failure has occurred, empty data is written as the alarm histories 1 to 3 and the failure histories 1 to 3.

また、これら通電時間、警報履歴1〜3、故障履歴1〜3は、全て同じデータ長となるように、これらのうち最大データ長よりも短いデータ長のものにはデータ長調整用のエリアが設けられている。例えば、通電時間として、数バイト書き込めばよいところを、警報履歴1〜3、故障履歴1〜3のような長いデータ合わせて、数十バイト書き込んでいる。   Further, these energization times, alarm histories 1 to 3 and failure histories 1 to 3 all have the same data length, so that a data length adjustment area has a data length adjustment area shorter than the maximum data length. Is provided. For example, as the energization time, several tens of bytes are written together with long data such as alarm histories 1 to 3 and failure histories 1 to 3 where a few bytes can be written.

その後、警報が発生すると、警報器内のCPUは、図13に示すように、警報履歴2を警報履歴1へ、警報履歴3を警報履歴2へ移動し、新たな警報履歴を警報履歴3とする全種類のデータ(設定データ、通電時間データ、警報履歴1〜3、故障履歴1〜3)を追記する。その後、故障が発生すると、警報器内のCPUは、図14に示すように、故障履歴2を故障履歴1へ、故障履歴3を故障履歴2へ移動し、新たな故障履歴を故障履歴3とする全種類のデータを追記する。   Thereafter, when an alarm is generated, the CPU in the alarm device moves the alarm history 2 to the alarm history 1, the alarm history 3 to the alarm history 2, and the new alarm history as the alarm history 3 as shown in FIG. All types of data (setting data, energization time data, alarm histories 1 to 3 and failure histories 1 to 3) are added. Thereafter, when a failure occurs, the CPU in the alarm device moves the failure history 2 to the failure history 1 and the failure history 3 to the failure history 2 as shown in FIG. Append all types of data.

その後、設置してから所定時間毎の計時が終了すると、警報器内のCPUは、図15に示すように、所定時間を加算した新たな通電時間を通電時間とする全種類のデータを追記する。ブロックB1の最後まで書き込むと、警報器内のCPUは、図16(A)に示すように、ブロックB2に格納したデータを全消去して空き領域にする。次に、警報器内のCPUは、図16(B)に示すように、消去したブロックB2の先頭に最新の全種類のデータ(即ち、ブロックB1に格納された全種類のデータのうち一番後ろの全種類のデータ)を書き込む。   Thereafter, when the clocking for each predetermined time is completed after the installation, the CPU in the alarm device adds all kinds of data with the new energization time obtained by adding the predetermined time as the energization time, as shown in FIG. . When writing to the end of the block B1, the CPU in the alarm device erases all the data stored in the block B2 to make a free space as shown in FIG. Next, as shown in FIG. 16B, the CPU in the alarm device has the latest all types of data (that is, the first of all types of data stored in the block B1) at the beginning of the erased block B2. Write back all data types).

この警報器にフラッシュメモリ内のデータを読み出す設定器を接続すると、警報器は、ブロックB2の後ろの領域からデータが書き込まれているか否かを判断し、データが書き込まれている領域に達すると、そこから通電時間、警報履歴1〜3、故障履歴1〜3の互いに等しいデータ長毎のデータを最新の故障履歴3〜1、最新の警報履歴3〜1、最新の通電時間として、設定器に送信する。   When a setting device that reads data in the flash memory is connected to this alarm device, the alarm device determines whether or not data has been written from the area after block B2, and reaches the area to which data has been written. Then, the energizing time, the alarm history 1 to 3 and the data for each equal data length of the failure history 1 to 3 are set as the latest failure history 3-1, the latest alarm history 3-1, the latest energizing time, and the setting device. Send to.

このように、従来では、データが発生する毎に、フラッシュメモリに全種類のデータ(即ち、設定データ、通電時間、警報履歴、故障履歴)を追記しているため、効率が悪い。また、フラッシュメモリは、消去可能回数がEEPROMに比べて少ないため、データを書き込む回数を少なくする必要があり、警報器での使用には問題がある。   Thus, conventionally, every time data is generated, all types of data (that is, setting data, energization time, alarm history, failure history) are additionally written in the flash memory, so that the efficiency is low. Further, since the flash memory has a smaller number of erasable times than that of the EEPROM, it is necessary to reduce the number of times data is written, and there is a problem in use in an alarm device.

そこで、本発明は、データが発生する毎に、書き込むデータ量を少なくすることにより、消去回数が削減でき、効率良く上書き不可なメモリを使用することができるデータ書込読取装置及びデータ書込読取方法を提供することを課題とする。   Therefore, the present invention provides a data writing / reading apparatus and a data writing / reading device that can reduce the number of times of erasing by reducing the amount of data to be written each time data is generated, and can efficiently use a memory that cannot be overwritten. It is an object to provide a method.

上述した課題を解決するための請求項1記載の発明は、機器に搭載され、上書き不可能なメモリに順次発生する複数種類のデータを書き込むデータ書込読取装置において、前記メモリの領域内に複数のブロックを設け、前記複数のブロックの1つを最新ブロックとして設定する最新ブロック設定手段と、前記データが発生する毎に又は所定時間経過する毎に前記最新ブロックの空き領域の先頭から順に当該発生したデータ又は前記機器使用開始からの経過時間データにデータ種類又はデータ長を付加したデータを書き込む書込読取手段と、前記最新ブロックに空き領域があるか否かを判定する空き領域判定手段と、前記空き領域判定手段により空き領域がないと判定された場合、前記最新ブロックを除いた他のブロックの少なくとも一つに格納されたデータを全消去する消去手段と、前記消去手段により全消去された後、前記最新ブロックに書き込まれているデータのうち種類毎最新又は最新から所定個前までのデータを前記消去手段により全消去された他のブロックの先頭に順に書き込むデータ書込手段と、を備え、前記最新ブロック設定手段が、前記データ書込手段による書き込み終了後、当該他のブロックを最新ブロックとして設定することを特徴とするデータ書込読取装置に存する。 An invention according to claim 1 for solving the above-described problem is provided in a data writing / reading apparatus which is mounted on a device and sequentially writes a plurality of types of data generated in a non-overwriteable memory. The latest block setting means for setting one of the plurality of blocks as the latest block, and the occurrence of the data in order from the head of the empty area of the latest block every time the data is generated or every predetermined time elapses. Writing / reading means for writing data or data obtained by adding a data type or data length to elapsed time data from the start of use of the device, free space determining means for determining whether or not there is a free space in the latest block, If the free space determination means determines that there is no free space, the free space is determined as at least one of the other blocks excluding the latest block. And erasing means for totally erasing the data, after being totally erased by said erasing means, by the erasing unit of data from the most recent or current to a predetermined one before each type of data written in the newest block Data writing means for sequentially writing to the head of other erased blocks, and the latest block setting means sets the other blocks as the latest blocks after the writing by the data writing means is completed. It exists in the data writing / reading apparatus characterized.

請求項2記載の発明は、前記データ書込手段が、前記消去手段により全消去された後、前記最新ブロックの後ろから順にデータを読み取り、前記データを付加したデータ種類又はデータ長に基づいて種類毎に一番後ろ又は一番後ろから所定個前までのデータを抽出し、当該抽出したデータを前記消去手段により全消去された他のブロックの先頭から順に書き込むことを特徴とする請求項1に記載のデータ書込読取装置に存する。 According to the second aspect of the present invention, the data writing means reads data sequentially from the back of the latest block after being completely erased by the erasing means, and is based on the data type or data length to which the data is added. 2. The data from the back or from the back to a predetermined number of times is extracted every time, and the extracted data is written in order from the head of another block that has been completely erased by the erasing means. It exists in the data writing / reading apparatus of description.

請求項3記載の発明は、上書き可能な第2メモリに前記書込読取手段により書き込まれる複数種類のデータのうち少なくとも1つの種類のデータを前記書込読取手段により書き込まれる毎に上書きする上書き手段をさらに備え、前記データ書込手段が、前記消去手段により全消去された後、前記最新ブロックの後ろから順にデータを読み取り、前記データに付加したデータ種類又はデータ長に基づいて、前記第2メモリに上書きされている種類を除いた各種類毎に一番後ろ又は一番後ろから所定個前までのデータを抽出し、前記第2メモリに格納されたデータ及び当該抽出したデータを前記消去手段により全消去された他のブロックの先頭から順に書き込むことを特徴とする請求項1に記載のデータ書込読取装置に存する。   According to a third aspect of the present invention, overwriting means for overwriting at least one type of data among a plurality of types of data written by the writing / reading means in the overwritable second memory each time the writing / reading means writes the data. And the data writing means reads the data in order from the rear of the latest block after being completely erased by the erasing means, and based on the data type or data length added to the data, the second memory The data from the back or the back to the predetermined number is extracted for each type excluding the type overwritten by the data, and the data stored in the second memory and the extracted data are extracted by the erasing means 2. The data writing / reading apparatus according to claim 1, wherein writing is performed in order from the head of the other erased blocks.

請求項4記載の発明は、前記メモリには、前記経過時間データが書き込まれ、前記各ブロックに格納された前記経過時間データを比較し、最大経過時間が書き込まれているブロックを最新ブロックとして判定する最新ブロック判定手段をさらに備え、前記書込読取手段が、前記最新ブロックの後ろから前に向かって順にデータを読み取り、前記データに付加されたデータ種類又はデータ長に基づいて種類毎に一番後ろ又は一番後ろから所定個前までのデータを読み取ることを特徴とする請求項1〜3何れか1項に記載のデータ書込読取装置に存する。   According to a fourth aspect of the present invention, the elapsed time data is written in the memory, the elapsed time data stored in each block is compared, and the block in which the maximum elapsed time is written is determined as the latest block. The latest block determination means, and the writing / reading means reads the data in order from the back to the front of the latest block, and determines the first for each type based on the data type or data length added to the data. The data writing / reading apparatus according to any one of claims 1 to 3, wherein the data from the back or from the back to a predetermined number is read.

請求項5記載の発明は、前記書込読取手段及び前記データ書込手段が、前記データに付加されているデータ種類からデータ長を判定し、そのデータが書き込まれているエリアを判定することを特徴とする請求項1〜4いずれか1項に記載のデータ書込読取装置に存する。   According to a fifth aspect of the present invention, the writing / reading means and the data writing means determine a data length from a data type added to the data and determine an area in which the data is written. The data writing / reading apparatus according to claim 1, wherein the data writing / reading apparatus is provided.

請求項6記載の発明は、機器に搭載され、上書き不可能なメモリに順次発生する複数種類のデータを書き込むデータ書込読取方法において、前記メモリの領域内に複数のブロックを設け、前記複数のブロックの1つを最新ブロックとして設定する最新ブロック設定工程と、前記データが発生する毎に又は所定時間経過する毎に前記最新ブロックの空き領域の先頭から順に当該発生したデータ又は前記機器使用開始からの経過時間データにデータ種類又はデータ長を付加したデータを書き込む書込読取工程と、前記最新ブロックに空き領域があるか否かを判定する空き領域判定工程と、前記空き領域判定工程により空き領域がないと判定された場合、前記最新ブロックを除いた他のブロックの少なくとも一つに格納されたデータを全消去する消去工程と、前記消去工程により全消去された後、前記最新ブロックに書き込まれているデータのうち種類毎最新又は最新から所定個前までのデータを前記消去工程により全消去された他のブロックの先頭に順に書き込むデータ書込工程と、を備え、前記最新ブロック設定工程が、前記データ書込工程による書き込み終了後、当該他のブロックを最新ブロックとして設定することを特徴とするデータ書込読取方法に存する。 According to a sixth aspect of the present invention, in a data writing / reading method for writing a plurality of types of data that are sequentially generated in a memory that is mounted on a device and cannot be overwritten, a plurality of blocks are provided in an area of the memory, The latest block setting step for setting one of the blocks as the latest block, and from the start of use of the generated data or the device in order from the top of the empty area of the latest block every time the data is generated or every predetermined time elapses A writing / reading process for writing data obtained by adding a data type or a data length to the elapsed time data, an empty area determining process for determining whether or not there is an empty area in the latest block, and an empty area by the empty area determining process If it is determined that there is no data, the data stored in at least one of the other blocks excluding the latest block is erased completely. A step, after being all erased by the erasing step, the by each type of the latest or the erasing step the data from the most recent to the predetermined or pre-out data written in the newest block of the other blocks has been totally deleted A data writing step of sequentially writing to the head, wherein the latest block setting step sets the other block as the latest block after the writing by the data writing step is completed. Exist.

以上説明したように請求項1及び6記載の発明によれば、データにデータ種類又はデータ長を付加することにより、データが発生したり、所定時間経過する毎に、全種類のデータを追記することなく、その発生したデータだけを後ろに追記しても、最新ブロックから種類毎に最新又は最新から所定個前までのデータを読み取ることができる。これにより、データが発生する毎に、書き込むデータ量を少なくすることができ、消去回数が削減でき、効率良く上書き不可なメモリを使用することができる。なお、所定個はデータの種類毎に予め定められ、種類毎に一部異なってもよい。   As described above, according to the first and sixth aspects of the invention, by adding a data type or a data length to data, every type of data is added every time a predetermined time elapses. Even if only the generated data is added later, it is possible to read the data from the latest block to the latest or a predetermined number of data from the latest block for each type. As a result, the amount of data to be written can be reduced each time data is generated, the number of erasures can be reduced, and a memory that cannot be overwritten efficiently can be used. The predetermined number is determined in advance for each type of data, and may be partially different for each type.

請求項2記載の発明によれば、最新ブロックから種類毎に一番後ろ又は一番後ろから所定個前のデータ、即ち最新又は最新から所定個前までのデータを読み取って、他のブロックの先頭に書き込むことができる。   According to the second aspect of the present invention, the latest block is read from the latest block or the predetermined number of pieces of data for each type, that is, the latest or latest piece of data is read from the latest block, and the beginning of another block is read. Can be written on.

請求項3記載の発明によれば、第2メモリに格納されている種類のデータについては、最新ブロックの後ろから順に読み取ることなく、他のブロックに移動することができる。   According to the third aspect of the present invention, the type of data stored in the second memory can be moved to another block without sequentially reading from the back of the latest block.

請求項4記載の発明によれば、最新ブロック判定手段が、各ブロックに格納された経過時間データを比較し、最大経過時間が書き込まれているブロックを最新ブロックとして判定するので、最新ブロックに関する情報を持っていなくても、各ブロックの何れが最新ブロックであるかを判定できる。   According to the invention described in claim 4, the latest block determination means compares the elapsed time data stored in each block and determines the block in which the maximum elapsed time is written as the latest block. Even if it does not have, it can be determined which of the blocks is the latest block.

請求項5記載の発明によれば、書込読取手段及びデータ書込手段が、データに付加されているデータ種類からデータ長を判定し、そのデータが書き込まれているエリアを判定する。従って、各種類のデータのデータ長を同じにしなくても、データを特定することができるので、各種類のデータのデータ長を同じに調整するためのデータ長調整エリアを設ける必要がなく、無駄なデータがメモリに格納されることがない。   According to the fifth aspect of the present invention, the writing / reading means and the data writing means determine the data length from the data type added to the data, and determine the area where the data is written. Therefore, since the data can be specified without making the data length of each type of data the same, there is no need to provide a data length adjustment area for adjusting the data length of each type of data to be the same. Data is not stored in memory.

本発明のデータ書込読取装置を組み込んだ警報器の一実施形態を示すブロック図である。It is a block diagram which shows one Embodiment of the alarm device incorporating the data writing / reading apparatus of this invention. 図1に示すデータ書込読取装置を構成するフラッシュメモリに書き込まれる通電時間、設定データ、警報履歴、故障履歴の構成を示す図である。It is a figure which shows the structure of the energization time written in the flash memory which comprises the data writing / reading apparatus shown in FIG. 1, setting data, an alarm history, and a failure history. 図1に示すCPUのデータ書込読取処理手順を示すフローチャートである。It is a flowchart which shows the data writing / reading process procedure of CPU shown in FIG. 図1に示す警報器の工場出荷時におけるフラッシュメモリに格納されるデータを示す図である。It is a figure which shows the data stored in the flash memory at the time of factory shipment of the alarm device shown in FIG. 図1に示す警報器の通常時間書き込み時におけるフラッシュメモリに格納されるデータを示す図である。It is a figure which shows the data stored in the flash memory at the time of normal time writing of the alarm device shown in FIG. 図1に示す警報器の警報発生時におけるフラッシュメモリに格納されるデータを示す図である。It is a figure which shows the data stored in the flash memory at the time of the alarm generation of the alarm device shown in FIG. 図1に示す警報器の故障発生時におけるフラッシュメモリに格納されるデータを示す図である。It is a figure which shows the data stored in the flash memory at the time of failure occurrence of the alarm device shown in FIG. 図1に示す警報器のブロックB1の最後まで書き込んだときのフラッシュメモリに格納されるデータを示す図である。It is a figure which shows the data stored in the flash memory when writing to the last of the block B1 of the alarm device shown in FIG. 図1に示す警報器の読み込み時の動作を説明するための説明図である。It is explanatory drawing for demonstrating the operation | movement at the time of the reading of the alarm device shown in FIG. 他の実施形態におけるフラッシュメモリに書き込まれる通電時間、設定データ、警報履歴、故障履歴の構成を示す図である。It is a figure which shows the structure of the energization time written in the flash memory in another embodiment, setting data, an alarm history, and a failure history. 他の実施形態におけるフラッシュメモリに書き込まれる通電時間、設定データ、警報履歴、故障履歴の構成を示す図である。It is a figure which shows the structure of the energization time written in the flash memory in another embodiment, setting data, an alarm history, and a failure history. 従来の工場出荷時におけるフラッシュメモリに格納されるデータを示す図0である。FIG. 0 is a diagram showing data stored in a flash memory at the time of conventional factory shipment. 従来の警報発生時におけるフラッシュメモリに格納されるデータを示す図である。It is a figure which shows the data stored in the flash memory at the time of the conventional alarm generation. 従来の故障発生時におけるフラッシュメモリに格納されるデータを示す図である。It is a figure which shows the data stored in the flash memory at the time of the conventional failure occurrence. 従来の通電時間書き込み時におけるフラッシュメモリに格納されるデータを示す図である。It is a figure which shows the data stored in the flash memory at the time of the conventional energization time writing. 従来のブロックB1の最後まで書き込んだときのフラッシュメモリに格納されるデータを示す図である。It is a figure which shows the data stored in the flash memory when writing to the last of the conventional block B1.

以下、本発明のデータ書込読取装置及びデータ書込読取方法について図面を参照して説明する。図1は、本発明のデータ書込読取装置を組み込んだ警報器の一実施形態を示すブロック図である。同図に示すように、機器としての警報器1は、警報器1全体の制御を司るマイクロコンピュータ(以下μCOM)2と、ガス漏れや火災などの異常を検出するセンサ3と、後述する設定器4を接続するための入出力端子5と、を備えている。   The data writing / reading apparatus and data writing / reading method of the present invention will be described below with reference to the drawings. FIG. 1 is a block diagram showing an embodiment of an alarm device incorporating the data writing / reading apparatus of the present invention. As shown in the figure, an alarm device 1 as a device includes a microcomputer (hereinafter referred to as μCOM) 2 that controls the alarm device 1 as a whole, a sensor 3 that detects an abnormality such as a gas leak or a fire, and a setting device described later. 4 and an input / output terminal 5 for connecting the terminal 4.

上記μCOM2は、処理プログラムに従って各種の処理を行うCPU2Aと、CPU2Aが行う処理のプログラムなどを格納したROM2Bと、CPU2Aでの各種の処理過程で利用するワークエリア、各種データを格納するデータ記憶エリアなどを有する上書き可能な第2メモリとしてのRAM2Cと、上書き不可能な不揮発性のメモリであるフラッシュメモリ2Dと、を備えている。上記CPU2Aは、センサ3からの出力に基づいて警報を発生する警報発生処理や、故障を検出する故障検出処理などを行う。   The μCOM 2 includes a CPU 2A that performs various processes according to a processing program, a ROM 2B that stores a program for processing performed by the CPU 2A, a work area that is used in various processes in the CPU 2A, a data storage area that stores various data, and the like. And a flash memory 2D, which is a non-overwritable non-volatile memory. The CPU 2A performs an alarm generation process for generating an alarm based on an output from the sensor 3, a failure detection process for detecting a failure, and the like.

上記フラッシュメモリ2Dは、メモリ領域に2つのブロックB1、B2が設けられている。このフラッシュメモリ2Dには、通電時間、設定値データ、警報履歴、故障履歴といったデータが順次書き込まれる。これら通電時間、設定データ、警報履歴、故障履歴といったデータは、図2(A)〜(D)に示すように、先頭にチェックサムを書き込む領域、最後尾にデータ種類(即ち、通電時間、設定データ、警報履歴、故障履歴の何れであるかを示すデータ)を書き込む領域、チェックサムとデータ種類との間にデータ自体を書き込む領域が、設けられている。これらデータは、データ種類に応じてデータ長が異なり、設定データが一番長く、その次に警報履歴、故障履歴が長く、通電時間が一番短い。   The flash memory 2D is provided with two blocks B1 and B2 in the memory area. In the flash memory 2D, data such as energization time, set value data, alarm history, and failure history are sequentially written. As shown in FIGS. 2A to 2D, the data such as energization time, setting data, alarm history, and failure history include an area in which a checksum is written at the beginning and a data type at the end (that is, energization time, setting). An area for writing data), and an area for writing the data itself between the checksum and the data type. These data have different data lengths depending on the data type, the longest setting data, the longest alarm history and failure history, and the shortest energization time.

次に、上述した構成のデータ書込読取装置の動作について図3〜図8を参照して説明する。図3は、図1に示すデータ書込読取装置を構成するCPU2Aのデータ書込読取処理における処理手順を示すフローチャートである。図4は、図1に示す警報器1の工場出荷時におけるフラッシュメモリ2Dに格納されるデータを示す図である。図5は、図1に示す警報器1の通電時間書き込み時におけるフラッシュメモリ2Dに格納されるデータを示す図である。図6は、図1に示す警報器1の警報発生時におけるフラッシュメモリ2Dに格納されるデータを示す図である。図7は、図1に示す警報器1の故障発生時におけるフラッシュメモリ2Dに格納されるデータを示す図である。図8は、図1に示す警報器1のブロックB1の最後まで書き込んだときのフラッシュメモリ2Dに格納されるデータを示す図である。   Next, the operation of the data writing / reading apparatus having the above-described configuration will be described with reference to FIGS. FIG. 3 is a flowchart showing a processing procedure in the data writing / reading process of the CPU 2A constituting the data writing / reading apparatus shown in FIG. FIG. 4 is a diagram showing data stored in the flash memory 2D when the alarm device 1 shown in FIG. 1 is shipped from the factory. FIG. 5 is a diagram showing data stored in the flash memory 2D at the time of writing the energization time of the alarm device 1 shown in FIG. FIG. 6 is a diagram showing data stored in the flash memory 2D when an alarm is generated by the alarm device 1 shown in FIG. FIG. 7 is a diagram showing data stored in the flash memory 2D at the time of failure of the alarm device 1 shown in FIG. FIG. 8 is a diagram showing data stored in the flash memory 2D when writing to the end of the block B1 of the alarm device 1 shown in FIG.

工場出荷時には、フラッシュメモリ2Dの最新ブロックB1の先頭に通電時間(0時間)と設定データだけが格納されている。その後、CPU2Aは、電源のオンに応じて上記データ書込読取処理を開始する。なお、CPU2Aは、このデータ書込読取処理と並列に上述した警報発生処理、故障検出処理を行う。ステップS1では、CPU2Aは、空き領域判定手段として働き、最新ブロックが一杯であるか否かを判定する。具体的には、CPU2Aは、最新ブロックの最後尾からデータを読み込んで空データ「0」が所定バイト以上連続しているか否かを判定する。CPU2Aは、最後尾から空データが所定バイト以上連続していなければ最新ブロックが一杯であると判定し、最後尾から空データが所定バイト以上連続していれば最新ブロックが一杯でないと判定する。このステップS1が請求項中の空き領域判定工程に相当する。   At the time of factory shipment, only the energization time (0 hour) and setting data are stored at the head of the latest block B1 of the flash memory 2D. Thereafter, the CPU 2A starts the data writing / reading process in response to power-on. The CPU 2A performs the alarm generation process and the failure detection process described above in parallel with the data writing / reading process. In step S1, the CPU 2A functions as an empty area determination unit and determines whether or not the latest block is full. Specifically, the CPU 2A reads data from the end of the latest block, and determines whether or not empty data “0” continues for a predetermined byte or more. The CPU 2A determines that the latest block is full if empty data is not continuous for a predetermined byte or more from the end, and determines that the latest block is not full if empty data is continuous for a predetermined byte or more from the end. This step S1 corresponds to a free space determination step in the claims.

最新ブロックが一杯ではないと判定すると(ステップS1でN)、次に、CPU2Aは、電源オンしてから開始させている所定時間毎の計時が終了したか否かを判定する(ステップS7)。所定時間の計時が終了したと判定すると(ステップS7でY)、CPU2Aは、図5に示すように、最新ブロック(図5の例ではブロックB1)の空き領域の先頭に前の通電時間に所定時間を加算した新たな通電時間2を書き込むと共に、RAM2C内に格納された通電時間に新たな通電時間を上書きして(ステップS8)、次のステップS9に進む。ステップS8により、RAM2C内には最新の通電時間が常に保存される。所定時間の計時が終了していなければ(ステップS7でN)、CPU2Aは、ステップS8に進むことなく、直ちにステップ9に進む。   If it is determined that the latest block is not full (N in Step S1), then the CPU 2A determines whether or not the timing for every predetermined time started after the power is turned on (Step S7). If it is determined that the measurement of the predetermined time has ended (Y in step S7), the CPU 2A determines a predetermined energization time at the beginning of the empty area of the latest block (block B1 in the example of FIG. 5) as shown in FIG. The new energization time 2 added with the time is written, and the energization time stored in the RAM 2C is overwritten with the new energization time (step S8), and the process proceeds to the next step S9. By step S8, the latest energization time is always stored in the RAM 2C. If the measurement of the predetermined time has not ended (N in step S7), the CPU 2A immediately proceeds to step 9 without proceeding to step S8.

ステップS9において、CPU2Aは、警報や故障、設定器4による設定データの更新要求などが生じて、フラッシュメモリ2Dに格納すべきデータが発生しているか否かを判定する。フラッシュメモリ2Dに格納すべきデータが発生していなければ(ステップS9でN)、CPU2Aは、直ちにステップS1に戻る。一方、フラッシュメモリ2Dに格納すべきデータが発生していれば(ステップS9でY)、CPU2Aは、発生したデータを最新ブロックの空き領域の先頭に書き込んだ後(ステップS10)、ステップS1に戻る。   In step S9, the CPU 2A determines whether or not data to be stored in the flash memory 2D is generated due to an alarm or failure, a setting data update request from the setting device 4, and the like. If there is no data to be stored in the flash memory 2D (N in step S9), the CPU 2A immediately returns to step S1. On the other hand, if data to be stored in the flash memory 2D has occurred (Y in step S9), the CPU 2A writes the generated data at the head of the empty area of the latest block (step S10), and then returns to step S1. .

ステップS10の詳細について説明すると、例えば、警報が発生すると、CPU2Aは、図6に示すように、新たな警報履歴2を最新ブロック(図6に示す例ではブロックB1)の空き領域の先頭に書き込む。また、故障が発生すると、CPU2Aは、図7に示すように、新たな故障履歴3を最新ブロック(図7に示す例ではブロックB1)の空き領域の先頭に書き込む。上述したステップS7〜S10において、CPU2Aは書込読取手段として働く。また、ステップS7〜S10が請求項中の書込読取工程に相当する。   The details of step S10 will be described. For example, when an alarm is generated, the CPU 2A writes a new alarm history 2 at the head of the free area of the latest block (block B1 in the example shown in FIG. 6) as shown in FIG. . When a failure occurs, the CPU 2A writes a new failure history 3 at the head of the empty area of the latest block (block B1 in the example shown in FIG. 7) as shown in FIG. In steps S7 to S10 described above, the CPU 2A functions as a writing / reading unit. Steps S7 to S10 correspond to the writing / reading step in the claims.

これに対して、最新ブロックが一杯であると判定すると(ステップS1でY)、次に、CPU2Aは、図8(A)に示すように、消去手段として働き、最新ブロックを除いた他のブロック(図8の例ではブロックB2)に格納したデータを全消去して空き領域にする(ステップS2)。このステップS2が請求項中の消去工程に相当する。次に、CPU2Aは、RAM2C内に格納された最新の通電時間を他のブロックの先頭に書き込む(ステップS3)。   On the other hand, if it is determined that the latest block is full (Y in step S1), then the CPU 2A functions as an erasing unit as shown in FIG. The data stored in (block B2 in the example of FIG. 8) is completely erased to make a free area (step S2). This step S2 corresponds to an erasing step in the claims. Next, the CPU 2A writes the latest energization time stored in the RAM 2C at the head of another block (step S3).

次に、CPU2Aは、図8(B)に示すように、最新ブロックに格納された設定データのうち一番後ろに格納されているものを検索して、通電時間の後ろに書き込む(ステップS4)。その後、CPU2Aは、図8(C)に示すように、最新ブロックに格納された警報履歴のうち後ろから3つ前までの警報履歴を検索して、設定データの後ろに書き込み、その後、図8(D)に示すように、最新ブロックに格納された故障履歴のうち後ろから3つ前までの故障履歴を検索して、警報履歴の後ろに書き込んだ後(ステップS5)、ステップS6に進む。   Next, as shown in FIG. 8B, the CPU 2A searches the setting data stored in the latest block among the setting data stored in the latest block, and writes it after the energization time (step S4). . After that, as shown in FIG. 8C, the CPU 2A searches the alarm history from the back to the previous three out of the alarm histories stored in the latest block, writes it to the back of the setting data, and thereafter, FIG. As shown in (D), the fault history stored in the latest block is searched from the last three fault histories and written after the alarm history (step S5), and the process proceeds to step S6.

上記検索について詳細に説明すると、CPU2Aは、まず最新ブロック(ブロックB1)の最後尾から読み込みを開始する。CPU2Aは、最後尾にはデータの最後に付加されたデータ種類が格納されている。CPU2Aは、このデータ種類からブロックB1の最後に書き込まれたデータの種類を判定する。図8(C)に示す例では、CPU2Aは、警報履歴7が最新ブロックの最後に書き込まれていると判定する。CPU2Aは、判定したデータ種類からそのデータのデータ長を判定し、データ種類が書き込まれているエリアから判定したデータ長だけ前までのエリアのデータを、そのデータ種類のデータであると判定する。   The above search will be described in detail. First, the CPU 2A starts reading from the end of the latest block (block B1). The CPU 2A stores the data type added to the end of the data at the end. The CPU 2A determines the type of data written at the end of the block B1 from this data type. In the example shown in FIG. 8C, the CPU 2A determines that the alarm history 7 is written at the end of the latest block. The CPU 2A determines the data length of the data from the determined data type, and determines that the data in the area before the determined data length from the area where the data type is written is the data of that data type.

図8(C)に示す例で説明すると、最後尾から警報履歴のデータ長だけ前までのエリアのデータを警報履歴7であると判定する。さらに、CPU2Aは、最新ブロックの先頭に向かってデータを読み込み、警報履歴7よりも前のエリアに格納されているデータ種類から、警報履歴7の前に書き込まれたデータの種類を判定する。図8(C)に示す例では、警報履歴6が警報履歴7の前に書き込まれていると判定する。このように、CPU2Aは、後ろから前に向かって順にデータを読み取って最新ブロックに格納された警報履歴のうち後ろから3つ前までを検索する。   In the example shown in FIG. 8C, the data in the area from the tail to the previous data length of the alarm history is determined as the alarm history 7. Further, the CPU 2A reads the data toward the head of the latest block, and determines the type of data written before the alarm history 7 from the data type stored in the area before the alarm history 7. In the example illustrated in FIG. 8C, it is determined that the alarm history 6 is written before the alarm history 7. As described above, the CPU 2A sequentially reads data from the back to the front, and searches the alarm history stored in the latest block from the back to the previous three.

図8(C)に示す例では、警報履歴7、6、5が最新ブロックに格納された警報履歴のうち後ろから3つ前までの警報履歴として検索される。CPU2Aは、これら3つの警報履歴7、6、5のうち一番前から順にブロックB2に書き込んでいく。即ち、警報履歴5を警報履歴1、警報履歴6を警報履歴2、警報履歴7を警報履歴3へ移動して追記する。また、図8(D)に示す例では、故障履歴6、5、4が最新ブロックに格納された故障履歴のうち後ろから3つ前までの故障履歴として検索される。CPU2Aは、これら3つの故障履歴6、5、4のうち一番前のものから順にブロックB2に書き込んでいく。即ち、故障履歴4を故障履歴1、故障履歴5を故障履歴2、故障履歴6を故障履歴3へ移動して追記する。上述したステップS3〜S5において、CPU2Aは、データ書込手段として働く。また、ステップS3〜S5が請求項中のデータ書込工程に相当する。   In the example shown in FIG. 8C, the alarm histories 7, 6, and 5 are searched as the alarm histories from the back to the previous three out of the alarm histories stored in the latest block. The CPU 2A sequentially writes the three alarm histories 7, 6, and 5 in the block B2 from the front. That is, the alarm history 5 is moved to the alarm history 1, the alarm history 6 is moved to the alarm history 2, and the alarm history 7 is moved to the alarm history 3. In the example shown in FIG. 8D, the failure histories 6, 5, and 4 are searched as failure histories from the last three to the previous failure histories stored in the latest block. The CPU 2A writes to the block B2 in order from the earliest of these three failure histories 6, 5, and 4. That is, the failure history 4 is moved to the failure history 1, the failure history 5 is moved to the failure history 2, and the failure history 6 is moved to the failure history 3 to be additionally recorded. In steps S3 to S5 described above, the CPU 2A functions as data writing means. Steps S3 to S5 correspond to the data writing step in the claims.

ステップS6において、CPU2Aは、最新ブロック設定手段として働き、上記他のブロック(図8に示す例ではブロックB2)を最新ブロックに設定し、次のステップS7に進む。このステップS7が請求項中の最新ブロック設定工程に相当する。   In step S6, the CPU 2A functions as the latest block setting means, sets the other block (block B2 in the example shown in FIG. 8) as the latest block, and proceeds to the next step S7. This step S7 corresponds to the latest block setting step in the claims.

次に、設定器4により履歴の読み込み要求が行われたときの動作について説明する。まず、CPU2Aは、最新ブロック判定手段として働き、ブロックB1、B2の先頭に書き込まれている通電時間を比較し、最大値が書き込まれているブロックを最新ブロックとして判定する。その後、CPU2Aは、読取手段として働き、最新ブロックの後ろから読み出し、最初に見つかった通電時間を最新通電時間、最初に見つかった設定データを最新設定データ、後ろから3つ前までの警報履歴、故障履歴を最新警報履歴、最新故障履歴として、設定器4に送信する。   Next, an operation when a history reading request is made by the setting device 4 will be described. First, the CPU 2A functions as the latest block determination means, compares the energization times written at the heads of the blocks B1 and B2, and determines the block in which the maximum value is written as the latest block. After that, the CPU 2A functions as a reading unit, reads from the back of the latest block, the first energization time found first is the latest energization time, the first setting data found is the latest setting data, the alarm history from the back to the previous three, and the failure The history is transmitted to the setting device 4 as the latest alarm history and the latest failure history.

図9に示す例では、CPU2Aは、ブロックB2を最新ブロックとして判定し、通電時間3を最新通電時間、設定データ2を最新設定データ、警報履歴4、3、2を最新警報履歴、故障履歴3、2、1を最新故障履歴として、設定器4に対して送信する。   In the example shown in FIG. 9, the CPU 2A determines that the block B2 is the latest block, the energization time 3 is the latest energization time, the setting data 2 is the latest setting data, the alarm histories 4, 3, and 2 are the latest alarm history, and the failure history 3 2 and 1 are transmitted to the setting device 4 as the latest failure history.

上述した実施形態によれば、CPU2Aが、フラッシュメモリ2Dの領域に2つのブロックB1、B2を設け、2つのブロックB1、B2の1つを最新ブロックとして設定し、データ(設定データ、警報履歴、故障履歴)が発生する毎又は所定時間経過する毎に最新ブロックの空き領域の先頭から順に発生したデータ又は通電時間の最後にデータ種類を付加して格納している。また、CPU2Aが、最新ブロックに空き領域があるか判定し、空き領域がないと判定された場合、最新ブロックを除いた他のブロックのデータを消去した後に、最新ブロックの後ろから順にデータを読み取り、データの最後に付加されたデータ種類に基づいて種類毎に一番後ろ、又は、一番後ろから3個前のデータを抽出して、抽出したデータを他のブロックの先頭から順に書き込む。その後、CPU2Aが、書き込み終了後に、その他のブロックを最新ブロックとして設定している。   According to the above-described embodiment, the CPU 2A provides the two blocks B1 and B2 in the area of the flash memory 2D, sets one of the two blocks B1 and B2 as the latest block, and sets data (setting data, alarm history, Every time a (failure history) occurs or a predetermined time elapses, data is generated in order from the top of the empty area of the latest block, or a data type is added to the end of the energization time and stored. Further, the CPU 2A determines whether or not there is an empty area in the latest block, and when it is determined that there is no empty area, after erasing data of other blocks excluding the latest block, the data is read sequentially from the back of the latest block. Based on the data type added at the end of the data, the last or last three data is extracted for each type, and the extracted data is written in order from the top of the other blocks. Thereafter, the CPU 2A sets other blocks as the latest blocks after the writing is completed.

このように、データの最後にデータ種類を付加することにより、データが発生したとき、従来例のように全種類のデータ(通電時間、設定データ、警報履歴1〜3、故障履歴1〜3)を追記することなく、その発生したデータだけ後ろに追記しても、最新ブロックから種類毎に最新又は最新から3個前までのデータを読み取ることができる。これにより、データが発生する毎に、書き込むデータ量を少なくすることができ、消去回数が削減でき、効率良く上書き不可なメモリを使用することができる。また、最新ブロックから種類毎に一番後ろ又は一番後ろから3個前のデータを読み取って、他のブロックの先頭に書き込むことができる。   As described above, when data is generated by adding the data type to the end of the data, all types of data (energization time, setting data, alarm history 1 to 3, failure history 1 to 3) are provided as in the conventional example. Even if only the generated data is added after the data, the latest data or the data from the latest to the previous three data can be read for each type from the latest block. As a result, the amount of data to be written can be reduced each time data is generated, the number of erasures can be reduced, and a memory that cannot be overwritten efficiently can be used. Also, the last or third data from the latest block can be read for each type from the latest block and written at the head of another block.

また、上述した実施形態によれば、CPU2Aは、通電時間に関してはRAM2Cに上書き保存して、全消去された後、RAM2Cに格納された最新の通電時間を他のブロックの先頭から順に書き込む。これにより、通電時間については最新ブロックの後ろから順に読み取ることなく、最新ブロックに格納されている最新の通電時間を他のブロックの先頭に移動することができる。   Further, according to the above-described embodiment, the CPU 2A overwrites and saves the energization time in the RAM 2C, and after all erasure is performed, the latest energization time stored in the RAM 2C is sequentially written from the top of the other blocks. As a result, the latest energization time stored in the latest block can be moved to the beginning of another block without sequentially reading the energization time from the back of the latest block.

また、上述した実施形態によれば、CPU2Aが、各ブロックB1、B2の先頭に格納されている通電時間を比較し、最大の通電時間が書き込まれているブロックを最新ブロックとして判定し、最新ブロックの後ろから順にデータを読み取り、データの最後に付加されたデータ種類に基づいて種類毎に一番後ろ(通電時間、設定データの場合)、又は、一番後ろから3個前まで(警報履歴、故障履歴の場合)のデータを最新データとして読み取るので、最新ブロックに関する情報を持っていなくても、各ブロックの何れが最新ブロックであるかを判定できる。   Further, according to the embodiment described above, the CPU 2A compares the energization times stored at the heads of the blocks B1 and B2, determines the block in which the maximum energization time is written as the latest block, and determines the latest block. The data is read in order from the back of the data, and based on the data type added at the end of the data, the last of each type (in the case of energization time and setting data), or the last three (alarm history, Data in the case of a failure history) is read as the latest data, so it is possible to determine which of the blocks is the latest block without having information on the latest block.

上述した実施形態によれば、CPU2Aが、データの最後に付加されているデータ種類からデータ長を判定し、そのデータが書き込まれているエリアから判定したデータ長分前までのエリアのデータを、データ種類のデータであると判定する。従って、従来のように、通電時間、警報履歴、故障履歴のデータ長を同じにしなくても、データを特定することができるので、各種類のデータのデータ長を同じに調整するためのデータ長調整用のエリアを設ける必要がなく、無駄なデータがフラッシュメモリ2Dに格納されることがない。   According to the above-described embodiment, the CPU 2A determines the data length from the data type added to the end of the data, and the data in the area up to the determined data length from the area where the data is written, It is determined that the data type is data. Therefore, since the data can be specified without making the data length of the energization time, the alarm history, and the failure history the same as before, the data length for adjusting the data length of each type of data to the same There is no need to provide an adjustment area, and useless data is not stored in the flash memory 2D.

なお、上述した実施形態によれば、通電時間をRAM2Cに上書きしていたが、本発明はこれに限ったものではない。RAM2Cに書き込まれるデータとしては、フラッシュメモリ2Dに書き込まれるデータの少なくとも1つであればよく、警報履歴や故障履歴であってもよい。また、最新ブロックが一杯になったときはRAM2Cに書き込まれた通電時間を最新のものとして他のブロックに移動させていたが、本発明はこれに限ったものではない。フラッシュメモリ2Dの最新ブロックから読み込んで、他のブロックに移動させてもよい。   According to the above-described embodiment, the energization time is overwritten in the RAM 2C, but the present invention is not limited to this. The data written to the RAM 2C may be at least one of data written to the flash memory 2D, and may be an alarm history or a failure history. When the latest block is full, the energization time written in the RAM 2C is moved to another block as the latest one, but the present invention is not limited to this. The latest block of the flash memory 2D may be read and moved to another block.

また、上述した実施形態によれば、RAM2Cには、通電時間のみを上書きしていたが、本発明はこれに限ったものではない。例えば、RAM2Cにフラッシュメモリ2Dに格納する全種類のデータをRAM2C内に上書きすることにより、RAM2Cに全種類の最新データを保存し、最新ブロックが一杯になったときはRAM2Cに書き込まれた全種類の最新データを他のブロックに移動させるようにしてもよい。この場合、最新ブロックから最新データを読み取る必要がなくなり、処理が簡単になる。   Further, according to the embodiment described above, only the energization time is overwritten in the RAM 2C, but the present invention is not limited to this. For example, all types of data stored in the flash memory 2D are overwritten in the RAM 2C in the RAM 2C, so that all types of latest data are stored in the RAM 2C. When the latest block becomes full, all types written in the RAM 2C are stored. The latest data may be moved to another block. In this case, it is not necessary to read the latest data from the latest block, and the processing is simplified.

また、上述した実施形態によれば、設定器4による読み込み時に、CPU2Aは、各ブロックB1、B2の先頭に格納されている通電時間から最新ブロックを判定していたが、本発明はこれに限ったものではない。例えば、フラッシュメモリ2DのブロックB1、B2とは別の領域に、最新ブロックを示すエリアを設け、そのエリアに格納されたブロックを最新ブロックとして判定するようにしてもよい。この場合、最新ブロックが一杯になったときに、他のブロックの先頭に通電時間を書き込む必要がない。   Further, according to the above-described embodiment, the CPU 2A determines the latest block from the energization time stored at the head of each of the blocks B1 and B2 at the time of reading by the setting device 4, but the present invention is not limited to this. Not a thing. For example, an area indicating the latest block may be provided in an area different from the blocks B1 and B2 of the flash memory 2D, and the block stored in the area may be determined as the latest block. In this case, when the latest block is full, it is not necessary to write the energization time at the beginning of the other blocks.

また、上述した実施形態では最後尾にデータ種類を付加していたが、本発明はこれに限ったものではない。データ種類を付加する場所は、最後尾でなくてもよく、例えば、図10に示すように、最後尾にはデータ長を付加するなどして最後尾から予め設定したデータ長分前のエリアにデータ種類を格納するようにしてもよい。   In the embodiment described above, the data type is added at the end, but the present invention is not limited to this. The location where the data type is added need not be at the end. For example, as shown in FIG. 10, the data length is added to the end and the data length is set in the area before the end by a predetermined data length. The data type may be stored.

また、実施形態では、最後尾に付加したデータ種類により履歴の種類を判別していたが、本発明はこれに限ったものではない。例えば、種類毎にデータ長が異なっていれば、最後尾又は最後尾よりも前にデータ長を付加して、そのデータ長から種類を判別するようにしてもよい。   In the embodiment, the history type is determined based on the data type added at the end, but the present invention is not limited to this. For example, if the data length is different for each type, the data length may be added before the end or before the end, and the type may be determined from the data length.

また、上述した実施形態では、最後尾にデータ種類を付加して、そのデータ種類により履歴の種類を判別していたが、本発明はこれに限ったものではない。例えば、図11に示すように、各種類のデータにデータ長を付加し、本実施形態の警報履歴及び故障履歴(図2参照)のようにデータ長が同じものについては、警報履歴か故障履歴かを区別できるデータ種類をさらに付加する。これにより、各種類のデータに付加されたデータ長を読み取って、読み取ったデータ長のデータが通電時間、設定データのように一種類しかない場合は、そのデータ長に基づいてデータ種類を判別し、読み取ったデータ長のデータが2種類以上ある場合は、さらにデータ種類を読み取って、そのデータ種類を判別するようにしてもよい。   In the above-described embodiment, the data type is added to the tail and the history type is determined based on the data type. However, the present invention is not limited to this. For example, as shown in FIG. 11, the data length is added to each type of data, and the alarm history or failure history is the same for the alarm history and failure history (see FIG. 2) of the present embodiment. A data type that can be distinguished is added. As a result, the data length added to each type of data is read, and if there is only one type of data with the read data length, such as energization time and setting data, the data type is determined based on the data length. If there are two or more types of data with the read data length, the data type may be further read to determine the data type.

また、上述した実施形態によれば、フラッシュメモリ2Dには、2つのブロックB1、B2が設けられていたが、本発明はこれに限ったものではない。ブロックとしては、2つ以上のブロックを設ければよく、3つでも、4つでもよい。   Further, according to the embodiment described above, the flash memory 2D is provided with the two blocks B1 and B2. However, the present invention is not limited to this. As the block, two or more blocks may be provided, and three or four blocks may be provided.

また、前述した実施形態は本発明の代表的な形態を示したに過ぎず、本発明は、実施形態に限定されるものではない。即ち、本発明の骨子を逸脱しない範囲で種々変形して実施することができる。   Further, the above-described embodiments are merely representative forms of the present invention, and the present invention is not limited to the embodiments. That is, various modifications can be made without departing from the scope of the present invention.

1 警報器(機器、データ書込読取装置)
2A CPU(最新ブロック設定手段、書込読取手段、空き領域判定手段、消去手段、データ書込手段、上書き手段、最新ブロック判定手段)
2C RAM(第2メモリ)
2D フラッシュメモリ(メモリ)
B1 ブロック
B2 ブロック
1 Alarm (device, data writing / reading device)
2A CPU (latest block setting means, writing / reading means, free area judging means, erasing means, data writing means, overwriting means, latest block judging means)
2C RAM (second memory)
2D flash memory (memory)
B1 block B2 block

Claims (6)

機器に搭載され、上書き不可能なメモリに順次発生する複数種類のデータを書き込むデータ書込読取装置において、
前記メモリの領域内に複数のブロックを設け、
前記複数のブロックの1つを最新ブロックとして設定する最新ブロック設定手段と、
前記データが発生する毎に又は所定時間経過する毎に前記最新ブロックの空き領域の先頭から順に当該発生したデータ又は前記機器使用開始からの経過時間データにデータ種類又はデータ長を付加したデータを書き込む書込読取手段と、
前記最新ブロックに空き領域があるか否かを判定する空き領域判定手段と、
前記空き領域判定手段により空き領域がないと判定された場合、前記最新ブロックを除いた他のブロックの少なくとも一つに格納されたデータを全消去する消去手段と、
前記消去手段により全消去された後、前記最新ブロックに書き込まれているデータのうち種類毎最新又は最新から所定個前までのデータを前記消去手段により全消去された他のブロックの先頭に順に書き込むデータ書込手段と、を備え、
前記最新ブロック設定手段が、前記データ書込手段による書き込み終了後、当該他のブロックを最新ブロックとして設定する
ことを特徴とするデータ書込読取装置。
In a data writing / reading device for writing a plurality of types of data generated sequentially in a memory that is mounted on a device and cannot be overwritten,
A plurality of blocks are provided in the memory area,
Latest block setting means for setting one of the plurality of blocks as the latest block;
Each time the data is generated or every time a predetermined time elapses, the generated data or the data added with the data type or the data length is sequentially written from the top of the empty area of the latest block. Writing and reading means;
Free space determination means for determining whether or not there is a free space in the latest block;
If it is determined by the free area determination means that there is no free area, erasing means for erasing all data stored in at least one of the other blocks excluding the latest block;
After all erasing by the erasing means, the data from the latest or latest to a predetermined number of pieces of data written in the latest block in order to the head of the other blocks that are all erased by the erasing means Data writing means for writing,
The data writing / reading apparatus, wherein the latest block setting means sets the other block as the latest block after completion of writing by the data writing means.
前記データ書込手段が、前記消去手段により全消去された後、前記最新ブロックの後ろから順にデータを読み取り、前記データを付加したデータ種類又はデータ長に基づいて種類毎に一番後ろ又は一番後ろから所定個前までのデータを抽出し、当該抽出したデータを前記消去手段により全消去された他のブロックの先頭から順に書き込む
ことを特徴とする請求項1に記載のデータ書込読取装置。
After the data erasing unit is completely erased by the erasing unit, the data is sequentially read from the back of the latest block, and the last or first data for each type based on the data type or data length to which the data is added. 2. The data writing / reading apparatus according to claim 1, wherein data from the back to a predetermined number is extracted, and the extracted data is written in order from the head of another block that has been completely erased by the erasing unit.
上書き可能な第2メモリに前記書込読取手段により書き込まれる複数種類のデータのうち少なくとも1つの種類のデータを前記書込読取手段により書き込まれる毎に上書きする上書き手段をさらに備え、
前記データ書込手段が、前記消去手段により全消去された後、前記最新ブロックの後ろから順にデータを読み取り、前記データに付加したデータ種類又はデータ長に基づいて、前記第2メモリに上書きされている種類を除いた各種類毎に一番後ろ又は一番後ろから所定個前までのデータを抽出し、前記第2メモリに格納されたデータ及び当該抽出したデータを前記消去手段により全消去された他のブロックの先頭から順に書き込む
ことを特徴とする請求項1に記載のデータ書込読取装置。
Overwriting means for overwriting each time at least one type of data written by the writing / reading means is written to the overwritable second memory by the writing / reading means,
After the data erasing unit is completely erased by the erasing unit, the data is read sequentially from the back of the latest block, and is overwritten in the second memory based on the data type or data length added to the data. The data from the back or from the back to the predetermined number is extracted for each type excluding certain types, and the data stored in the second memory and the extracted data are all erased by the erasing means The data writing / reading apparatus according to claim 1, wherein writing is performed in order from the top of another block.
前記メモリには、前記経過時間データが書き込まれ、
前記各ブロックに格納された前記経過時間データを比較し、最大経過時間が書き込まれているブロックを最新ブロックとして判定する最新ブロック判定手段をさらに備え、
前記書込読取手段が、前記最新ブロックの後ろから前に向かって順にデータを読み取り、前記データに付加されたデータ種類又はデータ長に基づいて種類毎に一番後ろ又は一番後ろから所定個前までのデータを読み取ることを特徴とする請求項1〜3何れか1項に記載のデータ書込読取装置。
The elapsed time data is written to the memory,
Comparing the elapsed time data stored in each block, further comprising a latest block determination means for determining the block in which the maximum elapsed time is written as the latest block,
The writing / reading unit reads data in order from the back to the front of the latest block, and based on the data type or data length added to the data, a predetermined number of data from the back or the back of each type The data writing / reading device according to claim 1, wherein the data writing / reading device is read.
前記書込読取手段及び前記データ書込手段が、前記データに付加されているデータ種類からデータ長を判定し、そのデータが書き込まれているエリアを判定する
ことを特徴とする請求項1〜4いずれか1項に記載のデータ書込読取装置。
5. The writing / reading means and the data writing means determine a data length from a data type added to the data, and determine an area in which the data is written. The data writing / reading apparatus according to claim 1.
機器に搭載され、上書き不可能なメモリに順次発生する複数種類のデータを書き込むデータ書込読取方法において、
前記メモリの領域内に複数のブロックを設け、
前記複数のブロックの1つを最新ブロックとして設定する最新ブロック設定工程と、
前記データが発生する毎に又は所定時間経過する毎に前記最新ブロックの空き領域の先頭から順に当該発生したデータ又は前記機器使用開始からの経過時間データにデータ種類又はデータ長を付加したデータを書き込む書込読取工程と、
前記最新ブロックに空き領域があるか否かを判定する空き領域判定工程と、
前記空き領域判定工程により空き領域がないと判定された場合、前記最新ブロックを除いた他のブロックの少なくとも一つに格納されたデータを全消去する消去工程と、
前記消去工程により全消去された後、前記最新ブロックに書き込まれているデータのうち種類毎最新又は最新から所定個前までのデータを前記消去工程により全消去された他のブロックの先頭に順に書き込むデータ書込工程と、を備え、
前記最新ブロック設定工程が、前記データ書込工程による書き込み終了後、当該他のブロックを最新ブロックとして設定する
ことを特徴とするデータ書込読取方法。
In a data writing / reading method for writing a plurality of types of data sequentially generated in a memory that is mounted on a device and cannot be overwritten,
A plurality of blocks are provided in the memory area,
A latest block setting step of setting one of the plurality of blocks as a latest block;
Each time the data is generated or every time a predetermined time elapses, the generated data or the data added with the data type or the data length is sequentially written from the top of the empty area of the latest block. Writing and reading process;
A free space determination step of determining whether there is a free space in the latest block;
If it is determined that there is no free space in the free space determination step, an erasing step of erasing all data stored in at least one of the other blocks except the latest block;
After all erasure by the erasing step, the data from the latest or latest to a predetermined number of types of data written in the latest block in order to the head of the other blocks that are all erased by the erasing step A data writing step for writing,
The data writing / reading method characterized in that the latest block setting step sets the other block as the latest block after completion of writing by the data writing step.
JP2011274249A 2011-12-15 2011-12-15 Data writing / reading apparatus and data writing / reading method Active JP5851819B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2011274249A JP5851819B2 (en) 2011-12-15 2011-12-15 Data writing / reading apparatus and data writing / reading method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2011274249A JP5851819B2 (en) 2011-12-15 2011-12-15 Data writing / reading apparatus and data writing / reading method

Publications (2)

Publication Number Publication Date
JP2013125435A JP2013125435A (en) 2013-06-24
JP5851819B2 true JP5851819B2 (en) 2016-02-03

Family

ID=48776626

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2011274249A Active JP5851819B2 (en) 2011-12-15 2011-12-15 Data writing / reading apparatus and data writing / reading method

Country Status (1)

Country Link
JP (1) JP5851819B2 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP6119682B2 (en) * 2014-06-27 2017-04-26 株式会社デンソー Electronic control unit

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0476642A (en) * 1990-07-12 1992-03-11 Fujitsu Ltd File output processor
JP2002108640A (en) * 2000-10-03 2002-04-12 Shinjo Keiei Kenkyusho:Kk Duplex system, single processor system and sub-board
JP2003076604A (en) * 2001-09-03 2003-03-14 Nec Access Technica Ltd Log information collecting system and method for flash memory
JP2009064369A (en) * 2007-09-10 2009-03-26 Fuji Electric Fa Components & Systems Co Ltd Alarm
JP5666273B2 (en) * 2010-12-03 2015-02-12 矢崎エナジーシステム株式会社 Data storage device and data storage method

Also Published As

Publication number Publication date
JP2013125435A (en) 2013-06-24

Similar Documents

Publication Publication Date Title
JP4215746B2 (en) Information processing apparatus and life monitoring method
US20100061150A1 (en) Logged-based flash memory system and logged-based method for recovering a flash memory system
CN112397128B (en) Control method and device of Flash memory
US9286992B2 (en) Refresh apparatus and electronic device that ensure simplified refresh process of flash memory
US9792070B2 (en) Data storage device, method of storing data, and on-vehicle control apparatus
JP5851819B2 (en) Data writing / reading apparatus and data writing / reading method
JP5666273B2 (en) Data storage device and data storage method
JP5983512B2 (en) Writing device
JP5929398B2 (en) Nonvolatile semiconductor memory device and control method thereof
JP6040895B2 (en) Microcomputer and non-volatile memory block management method
JP2007094767A (en) Memory controller and memory control method
US20110082995A1 (en) Information processing apparatus
JP6119682B2 (en) Electronic control unit
JP6636930B2 (en) Microcomputer with built-in flash memory, method of writing data to flash memory built in microcontroller, and program for writing data to flash memory
JP2017199162A (en) Terminal device, failure handling control program, and failure handling control method
CN113918485A (en) Method, device, equipment and storage medium for preventing flash memory data from being lost
JP2008225922A (en) Nonvolatile storage device
JP2007310803A (en) Writing method and reading method of nonvolatile storage device
JP4866114B2 (en) MEMORY CONTROLLER, NONVOLATILE MEMORY DEVICE, NONVOLATILE MEMORY SYSTEM, AND MEMORY CONTROL METHOD
JP2016151922A (en) Memory control device and memory control method
JP5486193B2 (en) Flash memory operation protection device and flash memory operation protection method
JP2011065513A (en) Device and method for storing operation history information
JP6263068B2 (en) Semiconductor memory device
JP5643708B2 (en) Electronic control unit
JP5821788B2 (en) Electronic control unit

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20141120

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20150824

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20150908

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20151015

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: 20151110

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20151203

R150 Certificate of patent or registration of utility model

Ref document number: 5851819

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

S531 Written request for registration of change of domicile

Free format text: JAPANESE INTERMEDIATE CODE: R313531

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250