> 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/dnp3.md).

# Connect DNP3 devices

Set up DNP3 channels, RTUs and ranges in DATRAN VI to poll DNP3 slave devices, including CROB outputs.

Configuration of a DNP3 RTU comprises of three or more `_Comms_Object_` nodes representing:

* the channel (TCP or RS232);
* the RTU;
* and the ranges. Remember that a range represents a type of I/O so you may have a range for Binary Inputs another one for Analog inputs and another for Binary Outputs.

{% hint style="info" %}
**Applies to:** DATRAN VI with the DNP3 Protocol component installed and licensed, from QTech's DATRAN DNP3 Quick Start. For the XL4 DNP3 RTU's own settings and device profile, see its pages in DATRAN telemetry.
{% endhint %}

DNP3 (Distributed Network Protocol) was developed and has become the standard protocol for communications between substation computers, RTUs, IEDs (Intelligent Electronic Devices) and master stations for the electric utility industry. This protocol is also starting to be used in other adjacent industries such as water, transportation, oil and gas.

## Install the DNP3 component

When you reach the **Select Components** screen you will need to ensure the **DNP3 Protocol** component is selected.

For a minimal test system all other components can be deselected. However, the following components may be of interest:

* **ADO Database Connectivity** - provides DATRAN with logging capabilities to a MS SQL Server.
* **Alarm Management** - provides DATRAN with event/alarm and escalation abilities.
* **Email Service** - an extension to the alarm system providing SMTP support for notification of events and alarms.

The DATRAN Service will periodically stop functioning unless they are properly [licensed](https://help.qtech.co.nz/datran/datran-vi-scada/datran-vi/licensing.md).

## 1. Add a DNP3 channel

There are two available `_Comms_Objects_` in the DATRAN Insert dialogue for DNP3 Channels:

* **DNP3 Channel** – this refers to a serial channel either RS232 or RS485. The associated dialogue allows for the baud rate and COM port to be modified. It also allows the DNP3 Master address to be modified but under normal circumstances this should be left at the default of 1.
* **DNP3 TCP Channel** – this allows a single connection to a fixed IP Address and TCP Port.

The TCP Channel also has settings for keep-alive. This is a small data packet that is periodically sent to the slave device purely as a ping. The reason for this is that in a scenario where only unsolicited messages are used the master would never know if the connection had failed as it is the master that establishes the TCP connection (it does not listen for incoming reconnections as would occur in the serial link scenario). So if keep-alives are enabled and they time-out for any reason the master will attempt to re-establish connection with the slave device.

![DNP3 serial and TCP channels in the DATRAN Browser tree](https://3621580088-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5hMAUl7E1cWeN5Rghg0%2Fuploads%2FWVEf10mlCIofvTD62BeC%2Fdnp3-channels.png?alt=media)

## 2. Add the DNP3 RTU

The DNP3 RTU represents the slave device whether it is a SEL or Multilin Relay or a DATRAN XL4 DNP3 RTU or any other DNP3 slave device.

It has standard properties for the slave devices DNP3 Address, a link to the appropriate channel object and if the RTU is active. A TCP site connects to the TCP Channel and also contains the IP Address and TCP Port as configured within the RTU.

| Setting                   | What it does                                                                                                                                                                       |
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| DLL Confirmation Disabled | Refers to if each packet frame is acknowledged before sending the next one. Some DNP3 Slave devices require confirmation to be disabled. The XL4 RTU will work either way.         |
| Time Sync Disabled        | Instructs DATRAN to ignore any Time Sync request that may be present in the packet IIN flags.                                                                                      |
| Allow Unsolicited         | The value of this is sent on start up to the slave device to either enable or disable unsolicited messages. The Class flags are only used if we are enabling unsolicited messages. |

The initial network packets on connection are as follows:

* Reset Link – informs the slave device that we are starting
* Disable Unsolicited
* Integrity Poll – normally requests all data (Class 1, 2 and 3)
* If Allow Unsolicited is set then assign the classes (e.g. Class 1 = Binary Inputs etc)
* If Allow Unsolicited is set then Re-enable Unsolicited
* Reset the Restart IIN flag – clears any slave device restart flag that has been set. Note that this start-up sequence may be due to the slave device restarting.
* If the Time Sync Required IIN flag is set and the Time Sync Disabled node isn’t set then send a time sync packet.

The IIN flags, which form part of the Application Layer header for any message received from the slave device, are presented in a readable format under the **IIN** node.

## 3. Add ranges for the I/O

The DNP3 Range object represents a type of I/O that can be read or written to on the slave device. There will normally be multiple ranges associated with the DNP3 RTU representing Binary Inputs, Binary Outputs, Analog Inputs etc. The convention is that each range should appear under a **Ranges** node underneath the DNP3 RTU. Because of the way that DATRAN works a DNP3 Range object must have a unique name. The convention for this is to include the DNP3 RTUs name as part of the Range Name

![The DNP Range settings dialog](https://3621580088-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5hMAUl7E1cWeN5Rghg0%2Fuploads%2FoYAz1ZYXQwbQGzEu0dE1%2Fdnp3-range-dialog.png?alt=media)

| Setting                      | What to enter                                                                                                                                                                                                                        |
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Domain                       | Specifies the range that is required e.g. Binary Inputs etc.                                                                                                                                                                         |
| Rtu                          | A link back to the DNP3 RTU object                                                                                                                                                                                                   |
| RtuActive                    | Indicates if this IO range is active or not.                                                                                                                                                                                         |
| Method                       | Specifies what to do with the range? e.g. retrieval or sending of point data. In general, **Read** is used for obtaining data and **Direct Operate** is used for writing outputs.                                                    |
| Obj                          | The object identifier. Common ones are 1 and 2 for Binary Inputs, 12 for Binary Outputs (CROBs), 20 for Counters and 30 for Analog Inputs.                                                                                           |
| Obj Variation                | How the data is returned and presented to the user. This is different for each object. Example: Object 1, variation 1 returns the normal 1 or 0 whereas variation 2 will return a packed byte that also contains status information. |
| Obj Qualifier                | This specifies how the data is packed in the network packet. Example 01 refers to packet without prefix and 2 byte start and stop indexes.                                                                                           |
| Index Start                  | The first point index. In DNP3 these start at 0. So for a Q03 the RDIs are 0 to 7.                                                                                                                                                   |
| Index Stop                   | The last point index.                                                                                                                                                                                                                |
| Polling interval (third tab) | How often this range is polled for. In DNP3 it is normal to poll for different ranges with different polling intervals. For unsolicited messages this is usually set to 0 min.                                                       |

In addition to the above the **RxTime** shows when points within this DNP3 Range have changed and the **Points** node contains the actual point data. Force polling can be used to invoke an immediate retrieval of data - right mouse click on the **ForcePoll** node and select **Transmit** from the pop up menu.

As all of the polls for a DNP3 RTU are serialised the **Poll Pending** node shows if this Range is waiting to poll.

## Control outputs (CROBs)

Object 12. These are more complicated than simply setting the output point to 0 or 1. In DATRAN this is a comma separated list placed in the point node and takes the format:

`Control, Count, OnTime, OffTime, Status`

e.g. `65,1,100,0` = 65 = 0x41 (hex) = Close + Pulse On, 1 iteration, on for 100ms

| Control code (low 4 bits) | Action    |
| ------------------------- | --------- |
| 0                         | NUL       |
| 1                         | Pulse On  |
| 2                         | Pulse Off |
| 3                         | Latch On  |
| 4                         | Latch Off |

T/C represents Trip and Close. C Clear – which cancels any currently running operation (e.g. pulsing). Q Queue – places the operation at the back of the control queue.

Trip/Close and Latch are used depending on the slave device. Some systems have a trip/close relay pair others don’t in which case these values should both be 0 and Latch should be used. Pulse On/Off requires the Count, OnTime and OffTime.

Status shouldn’t be specified, it is added automatically to the point data when the message reply is received from the slave device. Status code 0 = OK. 1-6 are failure codes.

## Check it's working

The binary data transferred to and from the RTU can be viewed from DATRAN Browser by ensuring you have the diagnostics window on display (Select **Diagnostics** from the **View** menu) and that the DNP3 diagnostics are enabled (Select **On Screen Categories** from the **Diagnostic** menu).
