> 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/sites-and-rtus.md).

# Sites, channels and RTUs

Comms channels and comms objects in DATRAN VI: add a channel, add a site, add digital and analogue points, extended point counts, and remove a site.

Each channel has a `_Comms_Object_` in a similar way to each site in the system also has a `_Comms_Object_`. The `_Comms_Object_` is a special node that is present in every site in the TBD file. It contains information about the site including the address of the site, the comms channel that the site has been installed on and the DLP the site should be using. The `_Comms_Object_` is also the entry point for the I/O from each site into the DATRAN TBD file.

{% hint style="info" %}
**Applies to:** DATRAN VI. For RTU-specific settings, see the RTU's own pages, for example [Port an XL4 site to the XL4 Plus in DATRAN VI](https://help.qtech.co.nz/datran/datran-telemetry/datran-xl4-plus-rtu/upgrade-xl4-to-xl4-plus/port-xl4-site.md). For DNP3 devices, see [Connect DNP3 devices](https://help.qtech.co.nz/datran/datran-vi-scada/datran-vi/sites-and-rtus/dnp3.md).
{% endhint %}

## Channels

In a standard TBD file, all communications channel configuration is contained in the **Data Root\Channels** section of the TBD file. Each channel represents a unique com port and its associated configuration. Each channel needs a dedicated port of the correct type; RS232 for Direct, Radio and Dialup channels or RS485 for RS485 channels. TCP/IP is handled by your network hardware, and as such does not require a serial port.

### Add a channel

1. Select the channels node in the TBD file, right click and **Add Node**. Type the name of the new channel (in this case, `Channel B`) into the top field.
2. Select the type of channel required and click **OK**. This will open the channel configuration dialog for the channel type you have chosen. In this example we are using **Direct RS232 RTU Channel** which you would use to plug an RTU in directly to the base station serial port. It is also the channel type you would use when setting up a channel to use serial data radios.
3. Configure the serial port options for **Mode** and **Port** and then click **Apply Channel**.

{% hint style="warning" %}
If you only click **OK** then the options you entered will be remembered, but the system will not use them to open the serial port.
{% endhint %}

The best way to check that the channel is open and talking to the DATRAN Modem is to apply the channel, and using diagnostics check whether the port was opened without error.

### Channel settings

| Setting                                    | What it does                                                                                                                                                                                                                                                                                                                   |
| ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Mode                                       | Mode has four parameters; `<baud rate>,<parity..(e)ven, (o)dd or (n)one>,<data bits>, <stop bits>`. Baud rate for conventional radio channels is either 300 or 1200 baud. Parity is usually 'o' for Odd parity. The number of data bits and stop bits is almost never changed.                                                 |
| Port                                       | Specifies which serial port is used for this channel                                                                                                                                                                                                                                                                           |
| Max Packet Length                          | Specifies the maximum packet length for packets being transmitted on this channel. For radio channels a maximum of 250 Bytes is normal, but on faster media (Ethernet, Data Radios) larger packets are desirable. See [RTU data logging (HDI)](https://help.qtech.co.nz/datran/datran-vi-scada/datran-vi/rtu-data-logging.md). |
| Eavesdrop                                  | Instructs the channel to listen to other traffic only, not to transmit any messages of its own. This is used as a crude method of keeping two base stations up to date without having to set up Source / Destination addressing over the radio network.                                                                        |
| Stagger Time                               | Specifies how long the base station should wait between getting a response from one station before transmitting the next packet in its queue                                                                                                                                                                                   |
| Poll Skip Timeout                          | Allows the base to be configured to ignore any scheduled polls of the site if the base has recently received a COS message from the site                                                                                                                                                                                       |
| Timeset Interval                           | Specifies how often the base should automatically send Time Set commands to each RTU on this channel                                                                                                                                                                                                                           |
| Busy Window, DCD Lock Time, Too Quiet Time | Busy Window specifies the averaging period for the Busy (%) statistic. DCD Lock Time specifies how long DCD must be on before the DCD Locked On Alarm is raised. Too Quiet Time specifies how long DCD must be off before the Too Quiet Alarm is raised                                                                        |

### Channel statistics

| Statistic                      | Means                                                                                                                                                                                                                |
| ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Busy (%), Busy (%) 24hr        | An average view of how busy the comms channel has been over the specified period                                                                                                                                     |
| DCD Locked On Alarm            | Shows if the DCD signal coming from the modem has been on continuously for a set period. This may indicate a site has its transmitter locked on                                                                      |
| Too Quiet Alarm                | Shows when there has been no activity on the DCD signal for a given period. This may indicate the radio at the base station has been turned off or unplugged, or that the repeater (if any) has failed               |
| Site Count                     | Indicates the total number of sites that are using this channel                                                                                                                                                      |
| Comms Usage Today, Yesterday   | These site statistics show how busy the individual site has been                                                                                                                                                     |
| Packet Counts Today, Yesterday | In V6.77 these were added: Packets Sent Today, Packets Received Today, Acks Sent Today, Acks Received Today, COS's Sent Today and Background Polls Today. These will help to quickly identify imbalances in a system |

## The site's comms object

Double Clicking a `_Comms_Object_` node will cause a dialog box to appear with all the various properties grouped into categories to make configuration easier.

Useful nodes under it:

* **ForcePoll:** causes the Base Station to immediately poll the site and retrieve its current I/O and status. The force poll is triggered by either selecting it and pressing Alt A, right clicking it and choosing **Transmit**, or pressing enter on it and changing its value to a 1.
* **RTU Active:** when RTU Active is set to False the base station will make no attempt to communicate with that site, and will ignore any incoming comms from that site.

There are 8 categories of I/O that can be passed between the base station and the RTU. These are Digital Input and Outputs and Analogue Inputs and Outputs of either "Real I/O" or "Notional I/O". Note that the value of analogues is shown as their RAW value, which is an unsigned 16 bit number. Consider when a 4-20 mA transducer is connected to an RTU that shows pressure with a range of 0-10 bar. When the pressure being measured is 10 bar, the current will be 20 mA, which will equate to a RAW value of 65535. When the pressure is 3 bar, the current will be 8.8 mA, which equates to a RAW value of 19660.

### Comms fail on TCP and cellular RTUs

TCP RTU and Cellular Data RTU handling has been refactored. Comms fails are now identified only if DATRAN sends to an RTU and does not receive an Ack after the specified timeout and number of retries as defined by the RTU object. The following clarification notes now apply:

* a Master RTU in Comms Fail does not necessarily imply Slave RTUs are in Comms Fail (but is very likely if all are polled at a similar time)
* TCP connection level: successful reestablishment of underlying TCP connection does not clear a Coms Fail, an expected Ack must still be received before Comms Fail status will clear.
* Application level: successful receipt of a Change of State (COS) does not clear Comms Fail status. Just fixing the TCP connection is not enough. At the application level a message must be sent, and an acknowledgment must be received before the comms fail state will reset.

## Give I/O meaningful names

A site in a TBD file is arranged in such a way as to publish the values from the `_Comms_Object_` to a location that describes what that I/O is associated with, for example `Pump No 1\Fault` and `Pump No 1\Current`:

* The **`_Formula_`** under `Pump No 1\Fault` contains a reference to `RDI\1` from the `_Comms_Object_`. In this particular case, the `_formula_` reads the value of `RDI\1` and pushes the result into the `Pump No 1\Fault` node.
* The `_Formula_` under `Pump No 1\Current` reads the value from `RAI\1` in the comms object but also scales it so that it shows the value in terms of the units that are appropriate. i.e. The raw value in the range 0 > 65535 gets scaled to a number in the range 0 > 5 with a rounding granularity of 0.1. This would correspond to a 0 to 5 Amp transducer being used in the field.
* A **`_Copy_To_`** node takes the value of its parent node and pushes it to the designated location in the TBD file, in this case `NAO\3` in the comms object. It can also reverse scale the value at the same time, if desired. When the value 1.8 arrives at `NAO\3`, it will have already been rescaled to a RAW number for use in the RTU. The value will be 23593.
* An **`_Alarm_`** node triggers whenever the parent node of the `_Alarm_` changes state. When the `_Alarm_` triggers, it calls the "Alarm Class" to which it has been assigned to execute. See [Alarms and alarm paging](https://help.qtech.co.nz/datran/datran-vi-scada/datran-vi/alarms.md).
* A **`_View_`** node writes settings for displaying points in DATRAN Supervisor as inputs and outputs. In the properties box on the property sheet type `Output 1, Digital 1`.

## The station template

Most DATRAN TBD files have a built in system script that is called the "Station Template". This script automates several tasks involved with the creation of new sites or new points in existing sites. Depending on how a particular system is configured, the Station Template may carry out the following tasks: filling out various sub nodes of an `_Alarm_` node that are required for its correct operation; write settings for displaying points in DATRAN Supervisor as inputs and outputs; write DDE Server settings; set up Analogue Logging for analogue points; insert Pump Run Hours accumulation scripts.

To run the station template, highlight it and press F2. An important point to note about the Station Template is that some of the tasks that it carries out the first time again require it to be run a second time to complete the job. For example, the first time it is run it may create some Pump Run Hours accumulators which require logging to the database. The script would then have to be run a second time to add the logging under these points. To be safe, the station template should always be run twice when it is used.

## Add a site

Here is a list of things to do when adding a new site:

1. Add the Site node for the new site.
2. Copy parts of other sites that are similar including the Comms Object.
3. Change the comms address in the Comms Object and any other communications specific settings, such as I/O count and DLP file location.
4. Change any formulae or alarm settings. It is a good idea to delete any nodes under an `_Alarm_` node that has been copied from another site at this point, as this will all be information from the old site.
5. If used, insert the Station Template. This will carry out several tasks that are applied automatically, including re building all the information under the `_Alarm_` nodes that was deleted in step 4. The station template should always be run twice.
6. Add a `_Site_` node to the new site. This makes this site visible to DATRAN Supervisor. Then delete it. This is another script that will generate some additional nodes that control how the point is displayed in DATRAN Supervisor.
7. If a third party GUI software is used, add a `_DDE_Server_Topic_` node under the site node, if using DDE, or an `_xml_datatopic_` node if using OPC. This will create a topic on the DDE or OPC server for this site and allow the external application to access I/O. Remember you may need to restart your GUI application for it to recognise the new I/O points exist.

## Add a point

### Digital input

1. Copy a similar point from the same or a different site.
2. Modify the alarm class and formula as appropriate: change the formula under the node so that it connects to `RDI6` instead of `RDI1`.
3. Delete all the sub nodes under the `_Alarm_` node for this point and then run the Station Template to re-create the correct ones.

### Digital output

1. Insert the point under the equipment node.
2. Insert a `_Copy_To_` node under the point and link it to `RDO 3`.
3. Insert an `_Alarm_` node under the point and allocate it to the 'Alarms' Alarm Class.
4. Insert a `_View_` node under the point and in the properties box on the property sheet type `Output 1, Digital 1`.
5. Reapply the Station Template.

### Analogue input

1. Copy a similar point.
2. Change the formula so that it connects to the right input (for example `RAI 1` instead of `RAI 2`). Also remember to change the scaling of the analogue if the detector has a different span at the new site.
3. Delete the `_log_` node from under the point, and run the Station template, twice.
4. Under the `_log_` node that the station template creates, you will find an `_Alarm_` node. Double click this to open its configuration dialog and change the Min and Max values to whatever is appropriate. These values will be the defaults that are used when the pen is displayed in DATRAN Trending.

## More than 255 points (extended point count)

From V6.70, with RTU firmware V7.00 or later, an RTU can use point numbers up to 65535 of each type. To use point numbers above the old limits:

1. Add the property `Use Extended Point Count = 1` to the site's `_Comms_Object_`, or to the channel's comms object for every RTU on that channel.
2. In the Channel objects the **Max Packet Length** property may need to be increased when using large point counts. A reasonable value would be 4096.
3. Due to the increased packet length, in the RTU comms object the RTU retry timeouts may need to be increased, especially if 1200 baud or slower is being used.

By default, QTech Comms will only allow configuring RTUs with analogue point indices < 128 (e.g., you can have NAI128 but not, say, NAI129). If you try to do this you will receive an error under the comms object to say that the NAI is set too high.

{% hint style="warning" %}
It is important that any sites that have RTUs with firmware older than v7.0 do not have any point count values of 255. If they do, then either disable the site, upgrade the firmware, or set the point count value to 254.
{% endhint %}

## Remove a site

* **Permanently:** permanent removal of a site from a DATRAN system is as easy as selecting the site in DATRAN Browser and deleting it. DATRAN Browser will warn the user if the delete operation is going to delete more than 1000 sub nodes. If this is the case, some thought should be given to deleting the site a piece at a time, rather than all in one go. After the site has been deleted, it is advisable to restart the system to clear any residual information that may still be present in I/O servers like DDE or DATRAN TCP server. In most cases it would be prudent to make a back up of the TBD file prior to deleting a site, "Just in case".
* **Temporarily:** if a site needs to be disabled on a temporary basis, this can be achieved by using the RTU Active property in the `_Comms_Object_` for that RTU. When RTU Active is set to False the base station will make no attempt to communicate with that site, and will ignore any incoming comms from that site. This way, radio bandwidth is not wasted trying to communicate with a site that is out of commission. Because some alarms that are "normally closed" may cause false alarms when stations are in this state, it is common that such alarms have an additional piece put in the formula node so that the alarm can only be active if RTU Active is set to true.

## Slave RTUs

DATRAN can reach slave RTUs through a master RTU (store and forward), over radio, TCP and cellular channels. See [Slave RTUs and store and forward](https://help.qtech.co.nz/datran/datran-telemetry/datran-xl4-plus-rtu/communications/slave-rtus-store-and-forward.md) on the XL4 Plus pages.
