> For the complete documentation index, see [llms.txt](https://help.qtech.co.nz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.qtech.co.nz/datran/datran-vi-scada/datran-vi/rtu-data-logging.md).

# RTU data logging (HDI)

DATRAN VI settings for collecting RTU logs: request byte count, max packet length, segment size and extended point count, plus how V6.78 handles log changes and timesets.

The Datran Historical Data Interface (HDI) service is used to configure and control the use of datalogging in the RTU, including retrieval of log records from the device. In Datran V6.78 there are several new features supported by the HDI. There are several settings to be adjusted when RTU logging with Datran V6.78.

{% hint style="info" %}
**Applies to:** DATRAN VI V6.78 with XL4 Plus RTUs, from QTech's HDI Datagram Settings application note (rev 01, August 2025). To set up logging on a site, see [Set up RTU data logging in DATRAN VI](https://help.qtech.co.nz/datran/datran-telemetry/datran-xl4-plus-rtu/data-logging/set-up-rtu-data-logging.md). For log capacity and the Datalogging Capacity Calculator, see [Data logging and the archive log](https://help.qtech.co.nz/datran/datran-telemetry/datran-xl4-plus-rtu/data-logging.md).
{% endhint %}

## What V6.78 adds

* The number of points that can be logged increases from 35 to **255** (RTU firmware V7.18 or later).
* The new **Request Byte Count** absolute limit is now 31,980 bytes.
* Log intervals as low as 1 sec can be entered as the I/O point logging interval (but it is not recommended except when troubleshooting instrumentation).
* The RTU (V7.18) increases its log capacity from about 65,535 records to just over 1 million records (when the RTU is fitted with an 8 MB Flash memory chip).
* Support for extended point ID count is retained; Point IDs are allowed up to the maximum point ID value of 65535.

![The Historical Data Configuration dialog, with Request Byte Count and Datagram Version](https://3621580088-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5hMAUl7E1cWeN5Rghg0%2Fuploads%2FzRoWUgXCjbCj35YjaNR2%2Fhistorical-data-configuration.png?alt=media)

## The four settings

| Setting                  | Where                                                             |
| ------------------------ | ----------------------------------------------------------------- |
| Request Byte Count       | The site's `_Comms_Hist_Data_` node                               |
| Max Packet Length        | The channel's `_Comms_Object_`                                    |
| Segment Size             | The site's `_Comms_Object_`, or the channel's for every RTU on it |
| Use Extended Point Count | The site's `_Comms_Object_`, or the channel's                     |

Note. Where dialog boxes are provided for changing values, if the edit control is a combo box providing a preset list of options, then these may be used. In most cases the value can usually also be entered directly by typing in the required value along with the correct unit of measurement if this is present.

### 1. Request Byte Count

A key parameter for efficiently uploading log records from the RTU is the Request Byte count, which dictates the payload sizes for each request of data from Datran. The default is 200 bytes. Optimising the count can be a matter of trial and error. If the number of bytes is too small then the overhead of requesting each record and acknowledging receipt and the turn-around time overhead becomes significant and transfer of a large number of records takes a long time and can interfere with communications to other RTU sites operating on the same channel. Conversely if the size is too high for the channel bandwidth, then the error rate of the channel comes into play and transactions can fail because of bit errors forcing Datran to repeatedly re-request the same data.

| Channel rate (bps) | Example                  | Typical (bytes) | Best Case (bytes) |
| ------------------ | ------------------------ | --------------- | ----------------- |
| 300                | Legacy QTech radio modem | 150             | 300               |
| 1200               | Tait TM8000 Radio        | 200             | 450               |
| 2400               | Tait TM9500 Radio        | 450             | 1000              |
| 9600               | QTech Data radio         | 450             | 2800              |
| > 150k             | Ethernet Radio           | 5,000           | 10,000            |
| > 500k             | Broadband Cellular       | 10,000          | 20,000\*          |
| > 1m               | Local Area Network (LAN) | 20,000          | \~30,000\*        |

\* The actual maximum is 31,980 but see notes below on the channel "Max Packet Length" property

* Operators should not configure the Request Byte Count greater than 31980 bytes. However, in doing so HDI will limit the value to 31980 as the count, so that an error is not generated.
* Setting values higher than 10,000 bytes may result in diminishing returns if the actual throughput or BERR of the channel has limitations. Increased Error rate and Channel hogging are reasons to be judicious about setting limits on the request count. In practical terms 10 Kbyte blocks are a good balance between channel hogging and channel bit error rate effects.
* For RTUs on V7.17 or older, the Request Byte Count must be no more than 2800 bytes. In Datran V6.77, when used with RTU firmware version V7.17 (or prior) the maximum Request Byte Count recommended is 450 bytes.
* In all cases if channels are congested with either frequent RTU communications (e.g. a lot of change of state messages) or if there are many RTUs attached to the channels then these settings should be derated to allow for load levelling. Request offsets can be employed to further spread or smooth the communications especially on radio channels.
* Care should be taken to test for reliable communications and adjust the request count as traffic on the channel increases over time with expansion of the telemetry network.
* There is also a limit to the throughput that each RTU can service, this is about 200 kbps for HDI log retrieval. However, with Datagram interleaving (between RTUs) the channel throughput usually exceeds this value.

### 2. Max Packet Length

The Max Packet Length property is defined in the channel object in the TBD. This constrains the total frame size including packet overheads in the QTech QComms Protocol (e.g. destination address, packet commands etc). There is a default property for each type of channel but this can be overridden by adding the node “Max Packet Length = nnn” to the specific channel under the Channels node.

![A TCP channel comms object with Max Packet Length](https://3621580088-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5hMAUl7E1cWeN5Rghg0%2Fuploads%2FPA6G3B0NYEahmEFkHGtQ%2Fchannel-max-packet-length.png?alt=media)

| Channel                                                         | Max Packet Length                                                                                                                                                                                                         |
| --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Traditional low bandwidth channels (300, 1200, 2400, 9600 baud) | Do not set large packet lengths (to handle large Request Byte Counts). Leave it at 4096 and keep the Request Byte count down per the table above.                                                                         |
| RTUs on firmware V7.17 or older                                 | For RTU firmware up to V7.17 the current recommendation is “Max Packet Length = 4096”. The Request Byte Count must be no more than 2800 bytes and the Max Packet Length must be larger by say 64 bytes or more than this. |
| Ethernet radio, broadband cellular, LAN, with V7.18 firmware    | The Max Packet Length should be just a little greater (say 64 bytes) than the Request Byte Count itself but no more than 32,000 as an absolute maximum. Setting the Max Packet Length to 32,000 is acceptable.            |

Currently, a QComms packet has an overhead in the region of 20 bytes but using a value of 64 bytes will allow for future changes to the QComms packet structure without having to readjust the packet length.

### 3. Segment Size

In Datagram V2 all datagram transfers occur in a single segment. All normal communications from HDI to the RTU, such as a command to define the log point configuration, must fit within one segment. The default segment size is set in the comms object for the Site (RTU) and is 500 bytes.

| Segment Size        | Logged points it can configure     |
| ------------------- | ---------------------------------- |
| 500 bytes (default) | Configure up to 70 logging points  |
| 1000 bytes          | Configure up to 141 logging points |
| 1500 bytes          | Configure up to 212 logging points |
| 1800 bytes          | Configure up to 255 logging points |

Double clicking the comms object node will allow you to select the comms object segment size and change it. Alternatively, the segment size can be set in the channel object and apply to all RTUs using that channel. Note that setting the segment size too small would normally result in an error such as invalid setup ID, Datagram rejected or possibly Invalid Point.

![The XL4 Comms Object dialog with Segment Size set to 1800](https://3621580088-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5hMAUl7E1cWeN5Rghg0%2Fuploads%2FN1WlqeX02nf9LXU9AJcv%2Fxl4-comms-object-segment-size.png?alt=media)

### 4. Extended point count

Extended Point count allows point indices to be defined above the limits in older RTU Firmware (V6.xx and older). The property can be added to the RTU comms object: "Use Extended Point Count" = 1. The extended point count can be added as a property of the comms object (RTU) or the channel (all RTUs on the channel). See [Sites, channels and RTUs](https://help.qtech.co.nz/datran/datran-vi-scada/datran-vi/sites-and-rtus.md#more-than-255-points-extended-point-count).

## How many points

| RTU firmware   | Maximum logged points |
| -------------- | --------------------- |
| V7.17 or older | 35                    |
| V7.18 or later | 255                   |

Operators should not configure more than 255 data points in the Comms Hist Data Object. Further increasing this value will cause an overflow in the RTU. 256 points will be stored as 0 (zero) points in the RTU, 257 points stored as 1 point. This will generally throw a diagnostic error (invalid setup ID) in Datran to show that there is a points mismatch between what is configured in the HDI and what is configured to log in the RTU.

## What changed in how logs are handled (V6.78)

### Changing the logging configuration no longer loses data

In previous versions, when the `_Comms_Hist_Data_` config was changed, the RTU would delete all current data in the RTU log and start afresh. In practice operators had to remember to retrieve all outstanding data before making a change to the config. This logged data is no longer lost and can still be retrieved from the RTU and if necessary can be reattached to the data point in SQL Server.

The RTU doesn't store point information like site name, equip name, point name etc., it only knows that it's logging RAI1, or NDI7 etc. And the `_Comms_Hist_Data_` config is required to map the retrieved log point data to the correct SQL points. So if the points are not configured at the time of data retrieval they will now be logged under generic names. Records in the RTU that are not (or no longer) associated with a named pointID in SQL may be retrieved and stored in the SQL server under a generic pointID e.g. `{site name} {equip name} RAI1`. Datran Diagnostics shows this up.

* If you've **deleted** a log point, HDI will log under generic PointID name.
* If you've **renamed** a log point, HDI will log under the new name.

In instances where the data is still required there are two methods available:

1. Reconfigure the node in `_Comms_Hist_Data_` with the same site/plan/point name information then re-retrieve the data from the RTU before it gets overwritten and it will be resubmitted to SQL under the correct point
2. Identify the generic nodes using SQL Server Management tools and modify the records to use the correct Point name

You can minimise the occurrence of generic logged data by ensuring that the HDI log is retrieved from the RTU prior to deconfiguring a node from being RTU logged.

### Upgrading the RTU firmware

There is no need to manually format the log using Workbench when upgrading from older RTU 7.xx versions to V7.18. However, if Operators are repurposing an RTU from a different site, make sure to format the data log as the old site data will still be on there and the RTU doesn't know the difference. The RTU Data log database can be reformatted using QTech Workbench V2.15 or later.

### Log integrity

Older versions of RTU firmware (V7.17 or prior) exhibit the following behaviour:

* A change to the log datapoint configuration reformats the database and stored logs are lost if they have not been uploaded to Datran beforehand.
* Unexpected power loss in the RTU could have the effect of causing a file system corruption potentially making the database or the RTU application itself fault.

The new behaviour of the log is to add more record integrity checks to correct or skip corrupted records.

### "Bytes remaining" doesn't always show

During testing of the new release, it was observed that when on screen diagnostics in Datran Browser showing datagram HDI log records (packets) retrieval, if the whole log is retrieved in one packet (e.g. 10 KB worth) then the “Bytes remaining” diagnostic message is not produced. This simply means that the log was retrieved successfully but the behaviour may appear dissimilar to Operators expectations.

## Timestamps for compliance logging

RTUs were tested for 6 months configured for multiple log points 1 minute logged. Results showed that neither were there missing records for a one minute interval nor was any data logged in such a way that the interval between log points exceeded 60 seconds.

However it was found that if a system timeset from the Datran Server was issued to an RTU so that if the timeset (which changes the time in the RTU) occurs at the same time that a 1 minute interval logged data point event occurs (triggering a log point), then it was possible to create a log record that exceeded the 60 second maximum delay between two log points. This is effectively caused by a race condition.

The recommendation for Operators is that for RTUs logging compliance data then the timeset should be configured such that it does not occur on a 1 minute boundary and not at midnight. This can be done by creating an offset. The offset was added to the comms object for the site. In this example the offset is 45 minutes and 30 s from midnight. A similar approach could be applied to the channel.

![A TimeSet formula with Poll Offset 2730 sec and Poll Rate 1 day](https://3621580088-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5hMAUl7E1cWeN5Rghg0%2Fuploads%2FYv7MdxjYuyhAUBi7p0Er%2Ftimeset-offset-formula.png?alt=media)

Timesets do not necessarily have to occur daily but bear in mind that RTU real time clock crystals will age over time and with environmental effects such as temperature and eventually will drift more quickly over time requiring a more frequent timeset than say weekly.

### Points logged by both the DLP and an interval

If a point is logged at the same time with both the DLP and interval logging two records will be produced with the same timestamp. It is not deterministic which one of them executes first. This will only be a problem in a quite specific scenario, for example:

* DLP updates NAI1 every time it sees the time tick over to a new minute
* NAI1 is interval logged at 1 minute

Then the interval logged NAI1 might be reading the value that was just calculated a few milliseconds ago, or from 1 minute ago. The race condition is on the value being logged, not the timestamp. The timestamps will be consistent at 1 minute intervals. There are a couple of solutions to the problem:

* Have the DLP do the calculation on the 59th second instead of on the minute boundary.
* OR have the DLP log the point as well as doing the calculation instead of interval logging.

## Collect a log by hand

RTU logs can now be retrieved from an RTU using QTech Workbench or by exporting the log to a file on a USB memory drive inserted into the XL4 Plus RTU. A new version of the Datran Database Import Tool has been produced which will enable Operators to upload RTU log data (otherwise destined for HDI) directly to the Datran Database in the SQL Server. See [Recover logged data manually](https://help.qtech.co.nz/datran/datran-telemetry/datran-xl4-plus-rtu/data-logging/recover-logged-data.md).

RTU Logged Data can be retrieved manually from DATRAN VI by right-click on the `_Comms_Hist_Data_` node in DATRAN VI Browser and selecting **Request Data**.

## Datalogging diagnostics

From V6.77, a new RTU Datalogging diagnostics category prints out log record values as they are retrieved from the RTU. This is only implemented for V2 datagrams. Workbench Diagnostics have categories to show data logging activity on the RTU. Workbench must be connected to the RTU while it is running to view diagnostics. Selecting lots of diagnostics to watch may cause some diagnostic messages to be dropped if the task is too busy and may have an impact on RTU performance. Therefore, it is recommended that Operators use the feature judiciously.
