Milesight Router UR32/UR35/UR75 supports 1 digital output. This article describes the principle of DO and how to control DO. The hardware design of 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.
1. Principle of DO
DO is Optocoupler output. When DO outputs low level, the circuit turns on. When DO outputs high level, the circuit turns off. So you need to add power in external circuit to control device. DO port can accept 30V DC (max) input. Output current is 0.3A and output power is 0.3W. Because of the low output power, it’s not used to drive external device. In real case when DO port is connected with high voltage input, you need to add a resistance in series to make sure the circuit works correctly.
2. Ways to control DO
- Trigger by DI
- Trigger by SMS
- Trigger by CLI Commands
- Trigger by Modbus TCP
- Trigger by Modbus RTU
- Trigger by Modbus RTU over TCP
Note: do not use more than one trigger ways at the same time.
- Milesight Router UR32/UR35/UR75
- Battery(12VDC) and buzzer LED
Make connection according to the below drawing:
COM -- Battery(-) -- Battery (+) -- LED --DO
When DO outputs low level, the circuit turns on, and LED is on.
When DO outputs high level, the circuit turns off, and LED is off.
Here’s simple test to check if DO is working correctly:
- Enable DI setting on Industrial -> I/O -> DI and set Action as DO;
- Enable DO settingon Industrial -> I/O -> DO, then change DO mode and click Save and Apply button. DO mode means when DI triggers, DO will change to this mode. When it’s set “High Level”, DO status is low level DI triggers, LED is on. When it’s set “Low Level”, DO status is high level without DI triggers, LED is off.
- During test LED is always off.
A. Check if LED can be on when connecting with the battery.
B. Check if Modbus Slave mode is already dis
C. Check if you click Save and Apply button to make settings take effect.
D. Check if you connect to the correct PINsof DO.
- During test LED is always on.
A. Check if there is short circuit in wiring.
B. Check if COM port and OUT port connected oppositely.
C. Check if Modbus Slave mode is already disabled.
Trigger by DI
- Go to Industrial -> I/O -> DI to configure DI Setting.
- Click Save. 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 PIN1-IN and PIN2-GND short connected), DO will be triggered as high level for 1 second.
Trigger by SMS
- Go to Network -> Interface -> Cellular to configure SMS Centernumber. 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 -> DO to configure Mode as Custom. Select the initial status and phone group.Click Save and Apply button.
- SMS content to control DO is as below.
set do1 low, 20 // set DO to output low level, 20 means duration of outputting low level is 20s.
set do1 high, 0 // set DO to output high level, 0 means continuously outputting high level.
do information // query the current DO status.
After receiving the SMS, router will send response as below.
Trigger by CLI Commands
You can control DO by CLI commands as below.
ROUTER# conf t
ROUTER(config)# industrial-io-output 1
ROUTER(config-output_io)# mode-out low
ROUTER(config-output_io)# no shutdown //set DO to output low level.
ROUTER(config-output_io)# mode-out high
ROUTER(config-output_io)# no shutdown //set DO to output high level.
Trigger by Modbus TCP
- Enable Modbus TCP on Industrial -> Modbus Slave -> Modbus TCP. Configure port and DO address. The DO 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 is connected to PC via LAN port. So IP is LAN IP 192.168.1.1.Select function as “01 Read Coil (0x)”.Then you can read current DO status on Modbus Poll.
- Double click the value of the register, you can control DO status by changing the value.
off/0 means low level, LED turns on.
on/1 meas high level, LED turns off.
Trigger 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 DO address. DO address can’t be 1.Click Save and Apply button.
- Run Modbus Poll software. Connect to the router by Serial Port mode.
- Then you can control DO by changing the value of the register.
Trigger by Modbus RTU over TCP
- Run Netassist software as TCP server. Make sure the TCP server is reachable from the router.
In this example, router is connected to the PC via LAN port. And PC IP is 192.168.1.100.
- Go to Industrial -> Modbus Slave -> Modbus RTU over TCP and enable it.
Device ID: user-defined
DO address can’t be 1.
Configure the server IP and port which is set on Netassist software.
Click Save and Apply button. And the router will be connected after a while.
- Then you can send command from TCP server to control DO status.
Control command varies according to the Slave ID and DO address.
In this example, Slave ID is 1 And DO address is 0.
|Slave ID||Function Code||Start(DO Address)||Value||CRC Parity|
|0x01||0x05||0x00 0x00||0xFF 0x00|
|0x01||0x05||0x00 0x0||0x00 0x00|
If DO is controlled successfully, the router will send the same frame as response.