|
<< Click to Display Table of Contents >>
Example of Reading Data from an Energy Recorder |
Every Energy Data Recorder contains a handle, similar to a pointer, that points to its structure. Each meter contains a limited number of Data Recorders, which can store any variable, such as voltage, current, or power, among others. In this example, let's assume that Data Recorder 1 contains the power values needed. The next step is to create a Block Tag mapping each column of a data register for an Element. In this example, for an 8500 meter, the handle for Data Recorder 1 is F80h. To start reading, perform the next procedures.
1.Link an internal structure to the table to read and initialize this structure.
2.Find the current log position.
3.Define the initial register to read.
4.Enable this Block Tag's scan.
The application must execute the next procedures, by script.
1.Write the value F80h to the X.4.2.0 Tag. That writing links the zero structure (the N4 parameter equal to zero) to the handle F80h.
2.Write the value 28h to the X.4.3.0 Tag, default value for Table Pointer Method.
3.Write the value 10 to the X.4.5.0 Tag to retrieve, in this example, 10 registers at each reading operation or scan.
4.Read the X.4.4.0 Tag, which returns the current log position.
Assuming for example that Data Register 1 stores new registers at each 5 (five) minutes, users must calculate the number of registers to read, such as the examples on the next table.
Examples of registers
Pointer |
Timestamp |
|---|---|
1000 |
01/01/2010 00:00 |
1001 |
01/01/2010 00:05 |
1002 |
01/01/2010 00:10 |
1003 |
01/01/2010 00:15 |
1004 |
01/01/2010 00:20 |
1005 |
01/01/2010 00:25 |
... |
... |
1400 |
01/02/2010 09:20 |
1401 |
01/02/2010 09:25 |
1402 |
01/02/2010 09:30 |
1403 |
01/02/2010 09:35 |
1404 |
01/02/2010 09:40 |
Reading the value of the X.4.4.0 Tag returns the current position of the pointer. In this example it corresponds to position 1404, which is te last register of a meter, 01/02/2010 09:04.
To read the day before, users must calculate how many registers to return. Between the last register of a meter, 01/02/2010 09:40, and the initial timestamp, 01/01/2010 00:00, there are 2020 minutes, that is, 1 (one) day, 9 (nine) hours, and 40 minutes. At each 5 (five) minutes there is a register, so users must return 404 registers. Therefore, to read registers starting on 01/01/2010 00:00 from a meter, users must write 1000 to the X.4.0.0 Tag. After calculating the position of the initial register, execute the next steps.
1.Write the calculated value, which is 1000 in this example, from the position of the current register in the X.4.0.0 Tag.
2.Enable the scan for the X.3.F80h.0 Block Tag.
During this scan, each time a new Block is collected from a meter, 10 registers are returned and the value of the initial register returned by the X.4.0.0 Tag is incremented by 10 units, according to the value written to the X.4.5.0 Tag. The example application is available on the article Sample Application - ION Driver on Elipse Knowledgebase.