Description

Milesight Router UR32/UR35/UR75 supports 1 digital input. This article describe how to use DI and query DI status. The hardware design of DI/DO on these models is the same. In this article UR32 is taken as example.

The PIN definition on UR32 is as below. For other models please refer to corresponding quick guides.

PINRS232RS485DIDODescription
1---------OUTDigital Output
2------IN---Digital Input
3GND---GND---Ground
4---------COMCommon Ground
5RXDB------Receive Data
6TXDA------Transmit Data



  1. Principle of DI

DI can be connected as dry contact and default status is high level.

When PIN2-IN is connected with PIN3-GND, DI status is low level; when PIN2-IN is disconnected with PIN3-GND, DI status is high level. With the change you can achieve corresponding triggers.


  1. Actions linked with DI change


  1. How to Read DI status


Requirement

Milesight Router UR32/UR35/UR75


 

Configuration

Actions linked with DI change

Trigger SMS

Go to Network -> Interface -> Cellular to configure SMS Center number. SMS center number is different based on different Telecom operators.

Go to System -> Phone & SMS -> Phone to add Phone Number List and Phone Group List.

Click Save and Apply button.

Go to Industrial -> I/O -> DI to configure DI Setting.

In this example, when DI changes to low level (make PIN2-IN and PIN3-GND short connected), the router sends SMS alarms to the preset phone group.


 Trigger Email

Go to System -> General Settings -> Email to configure SMTP Client Settings. Click Save button at the bottom. And then click Test button to sent a test email to confirm if the settings are correct.

After test email has been sent successfully, configure Email List and Email Phone List.

Click Save and Apply button.

Go to Industrial -> I/O -> DI to configure DI Setting.

In this example, when DI changes to low level (make PIN2-IN and PIN3-GND short connected), the router sends SMS alarm to the preset email group.

Trigger Cellular Up

Go to Network -> Interface -> Cellular to configure IO as connection trigger.

Click Save and Apply button.

Go to Industrial - I/O -> DI to configure DI settings.

Click Save and Apply button.

In this example, router is in standby mode and waits DI trigger to dial up. When DI changes to low level (make PIN2-IN and PIN3-GND short connected), the router is triggered to dial up and connect on cellular.


Trigger DO

Go to Industrial -> I/O -> DI to configure DI Setting.

Click Save button. Then go to Industrial -> I/O -> DO to enable DO and configure mode.

Click Save and Apply button.

In this example, when DI changes to low level (make PIN2-IN and PIN3-GND short connected), DO will be triggered as high level for 1 second.


 

How to Read DI Status

Read by Modbus TCP

Enable Modbus TCP on Industrial -> Modbus Slave -> Modbus TCP. Configure port and DI address. The DI address can’t be 1.

Click Save and Apply button.


Run Modbus Poll software. Connect to the router by Modbus TCP/IP and configure IP and port. In this example, UR32 has WAN IP 192.168.22.105.

Set function code as “02 Read Discrete Inputs (1x)” and quantity as 1.

Then you can read current DI status.

1 meas DI status is high level.

Make PIN2-IN and PIN3-GND short connected, DI value will change to 0 (low level).


 

Read by Modbus RTU

Connect the router to PC via USB to RS232/RS485 cable. Take RS232 as an example.

Enable Modbus Slave mode on Industrial -> Serial Port -> Serial RS232 type.

Click Save & Apply button.


Enable the corresponding serial port on Industrial -> Modbus Slave -> Modbus RTU. Configure Slave ID and DI address. DI address can’t be 1.

Click Save and Apply button.


Run Modbus Poll software. Connect to the router by Serial Port mode and same serial parameters.

Set function code as “02 Read Discrete Inputs (1x)”and quantity as 1.

Then you can read current DI status.

1 meas DI status is high level.

Make PIN2-IN and PIN3-GND short connected, DI value will change to 0 (low level).


Read by Modbus RTU over TCP

Connect the router to the Internet.

Go to Interface -> Modbus Slave -> Modbus RTU over TCP, enable this function and configure Slave ID, Device ID, DI Address. DI address can’t be 1. Add a reachable TCP server in Server List.  

Click Save and Apply.


Run NetAssist software. Set protocol as TCP server and configure the local IP and port. Click Open to allow connection. Choose Receive and Send Option as HEX.

When the router is connected to TCP server, it will send register info with Device ID included.

The Status on the router web page also shows Connected.

Send Modbus command in HEX from TCP Server to read DI status. Query command changes with the Slave ID and DI Address. In this configuration example, the command is 0x01 0x02 0x00 0x00 0x00 0x01 0xB9 0xCA. DI is high level by default. So response is0x01 0x02 0x01 0x01 0x60 0x48.

If you connect DI to GND, DI becomes low level.Reply will be 0x01 0x02 0x01 0x00 0xA1 0x88.


 Query frame:

Slave IDFunction CodeStart (DI Address)Length
CRC Parity
0x010x020x00 0x000x00 0x010xB9 0xCA


Response frame:

Slave IDFunction CodeLengthData (DI Status)CRC Parity
CRC Parity
0x01
0x02
0x01
0x01 (high level)
0x60 0x48
0x60 0x48
0x01
0x02
0x01
0x00 (low level)
0xA1 0x88
0xA1 0x88