LC-NW-3-1

From LCWIKI
Revision as of 15:48, 6 August 2024 by Melody (talk | contribs) (LC-NW-3-1 View)
Jump to: navigation, search

Product Name

Modbus RTU single network relay module wired Ethernet LAN control 1 output


About LC-NW-3-1

The LC single channel Modbus network relay module is equipped with a mature and stable 32-bit MCU and W5500 full hardware TCP/IP protocol stack network chip. Reserved MCU debugging interface supports secondary development
Using the standard MODBUS RTU communication protocol, it is possible to control one relay output within a local area network, which can be used for power control in wired networks


LC-NW-3-1 View

LC-NW-3-1 Front View
NW-3-1-01.png

LC-NW-3-1 reverse view
NW-3-1-02.png

Functional Features

  • On board mature and stable 32-bit MCU STM32F103C6T6 chip
  • Onboard W5500 full hardware TCP/IP protocol stack Ethernet chip, supporting 10/100M bps speed
  • Communication protocol: Supports standard Modbus RTU protocol
  • The device serves as a TCP server and supports IP address DHCP functionality, with port number 5000
  • Module IP address can be viewed through serial port, UART communication baud rate: 115200
  • Output signal: Relay switch signal, supporting manual, flash close, and flash off modes. The delay base for flash close/flash off is 0.1s, and the maximum allowable flash close/flash off time is 0xFFFF * 0.1S=6553.5S
  • Device address: Range 1-255, default 255, supports power down saving
  • Relay status and device address can be read using software/instructions
  • Onboard 1-channel 5V, 10A/250V AC 10A/30V DC relay, capable of continuous closing up to 100000 times, with diode leakage protection and short response time
  • Onboard power supply and relay switch indicator lights
  • On board MCU reset button
  • Reserve UART serial port and SWD program programming port, support secondary development
  • Power supply voltage: DC7-28V, supports 5.08mm terminal power supply, with input anti reverse protection


Hardware Introduction and Explanation

Board size and weight
Board size: 73 * 45mm/32g
NW-3-1-03.png

Interface Introduction
NW-3-1-04.png
1. Main control MCU: STM32F103C6T6
2. Network chip: W5500 full hardware TCP/IP protocol stack Ethernet chip
3. Network interface: 10Mbps/100Mbps HR911105A network transformer
4.5.08mm terminal power supply port: DC7-28V power input, where GND is negative
5. MCU reset button: Short press to reset
6. MCU SWD debugging interface: for secondary development programming
7. MCU UART debugging interface: GND, RXD, TXD: TTL level UART communication interface, GND, RXD, TXD are respectively connected to the external control terminal GND, TXD, RXD
Support connection to 3.3V/5V external TTL serial port, default for serial port viewing device IP address and port number, baud rate 115200
8.1 Relay switch signal output:
NC: normally closed end, short circuited to COM before relay closing, suspended after closing
COM: Public End
NO: Normal start, the relay is suspended before closing, and short circuited to COM after closing

Introduction to Modbus RTU Instructions
Modbus devices perform related operations by receiving Modbus RTU instructions from external control terminals (such as upper computers). A frame of instructions generally consists of device address, function code, register address, register data, and checksum. The frame length is related to the function code
Generally, the first byte of each frame of data is the device address, which can be set within the range of 1-255. The default is 255 (i.e. 0xFF), and the last 2 bytes are the CRC checksum

Assuming the device address is 255, the commonly used Modbus RTU instructions are as follows:
1. Turn on relay 1 (manual mode)
send out: FF 05 00 00 FF 00 99 E4
Return as is: FF 05 00 00 FF 00 99 E4
Note:
(1) The 3rd to 4th bytes of the sent frame represent relay addresses, with relay addresses #1 to #32 being 0x0000-0x001F
(2) The 5th to 6th bytes of the sending frame represent data, 0xFF00 represents opening the relay, and 0x0000 represents closing the relay

2. Turn off relay 1 (manual mode)
send out: FF 05 00 00 00 00 D8 14
Return as is: FF 05 00 00 00 D8 14

3. Turn on relay 2 (manual mode)
send out: FF 05 00 01 FF 00 C8 24
Return as is: FF 05 00 01 FF 00 C8 24

4. Turn off relay 2 (manual mode)
send out: FF 05 00 01 00 00 89 D4
Return as is: FF 05 00 01 00 89 D4

5. Turn on all relays
Send: FF 0F 00 00 20 01 FF B0 15
Return: FF 0F 00 00 20 41 CD

6. Turn off all relays
Send: FF 0F 00 00 00 20 01 00 F0 55
Return: FF 0F 00 00 20 41 CD

7. Set the device address to 1
Send: 00 10 00 00 00 01 02 00 01 6A 00
Return as is: 00 10 00 00 00 01 02 00 01 6A 00
Note: The 9th byte 0x01 of the sending frame is the device address written

8. Set the device address to 255
Send: 00 10 00 00 00 01 02 00 FF EB 80
Return as is: 00 10 00 00 00 01 02 00 FF EB 80
Note: The 9th byte 0xFF of the sending frame is the device address written

9. Read device address
Sent: 00 03 00 00 01 85 DB
Return: 00 03 02 00 FF C5 C4
Note: The 5th byte 0xFF of the returned frame is the device address read

10. Read relay status
send out: FF 01 00 00 00 20 28 0C
return: FF 01 04 00 00 00 01 25 DE
Note: Bit31-Bit0 in the 4th to 7th bytes of the return frame represent the status of relay #32- #1, with 0 indicating off and 1 indicating on

11. Turn on relay 1 (flash off mode 2S)
send out: FF 10 00 00 00 02 04 00 04 00 14 85 8A
return: FF 10 00 00 00 02 A4 16
Note:
(1) The 3rd to 4th bytes of the sent frame represent relay addresses, with relay addresses #1 to #32 being 0x0000-0x001F
(2) The 10-11 bytes of the sending frame represent the delay setting value, with a delay base of 0.1S. Therefore, the delay time is 0x0014*0.1=20*0.1S=2S, and the relay will automatically turn off after 2 seconds of opening

12. Turn off relay 1 (flash mode 3S)
send out: FF 10 00 00 00 02 04 00 02 00 1E E5 8C
return: FF 10 00 00 00 02 54 16
Note:
(1) The 3rd to 4th bytes of the sent frame represent relay addresses, with relay addresses # 1 to # 32 being 0x0000-0x001F
(2) The 10-11 bytes of the sending frame represent the delay setting value, with a delay base of 0.1S. Therefore, the delay time is 0x001E * 0.1=30 * 0.1S=3S. The relay will automatically turn on after being turned off for 3S


Simple usage instructions
1. View device parameters
After the device is powered on, it will automatically obtain an IP address using DHCP function. You need to use the serial port debugging assistant to check the device IP and port number (note: all devices have a port number of 5000). The method is as follows:
(1) Plug in the internet cable, connect the UART debugging port to the USB to TTL module (such as CH340), and connect the power supply. The UART wiring is as follows:

Network relay module TTL module
GND GND
TXD RXD
RXD TXD

NW-3-1-05.png

(2) Open the serial port debugging assistant (such as SSCOM), select the correct COM port with a baud rate of 115200. After powering on the module or pressing the reset button for more than 6 seconds, the IP address will be automatically obtained. Please remember this IP address and port number as follows:
NW-3-1-06.png

2. Using the Network Debugging Assistant to Control Devices
After the device successfully obtains an IP address, it will generate a TCP Server for the client to connect to. Taking sending a TCP command to control the relay as an example (assuming the device address is 255), the steps are as follows:
(1) Open the Network Debugging Assistant, select the protocol type: TCP Client, as well as the IP address and port number obtained in the previous step, and click Connect
NW-3-1-07.png

(2) After successful connection, enter the command to open relay 1 in the data transmission window: FF 05 00 00 FF 00 99 E4. If the relay is activated, it indicates normal communication
NW-3-1-08.png

How to validate checksum
When Modbus RTU instructions are sent through existing upper computer software (such as Modbus RTU configuration tool), the CRC checksum is automatically generated. If you want to use network debugging software (such as NetAssist)
When testing Modbus relay modules, it is necessary to manually generate a CRC checksum and place it at the end of the transmission frame, such as turning on the first relay (manual mode):
1. The frame composition for opening/closing the relay (manual mode) is:
Device address (1Byte)+Function code (1Byte)+Register address (2Byte)+Register data (2Byte)+CRC checksum (2Byte)

2. Assuming the device address is 0xFF, the first 6 bytes of the sent frame are: FF 05 00 00 FF 00

3. Use CRC verification tool to calculate the verification code for these 6 bytes: http://www.ip33.com/crc.html
NW-3-1-09.png

4. Exchange the high and low byte positions of the verification calculation result E499 to obtain the CRC verification code 99E4, as well as the completed transmission frame: FF 05 00 FF 00 99 E4

5. Send the sent frame to the Modbus relay module through the network debugging assistant to turn on the first relay.

Detailed Explanation of Modbus RTU Instructions

1. Turn on relay 1 (manual mode)
send out: FF 05 00 00 FF 00 99 E4

Field Meaning Annotation
FF Device Address Range 1-255, default 255
05 Function code Write a single coil
00 00 Relay address 0x0000--0x0007 respectively represent # 1 relay -- # 8 relay
FF 00 On/Off command 0x0000 is off, 0xFF00 is on
99 E4 CRC16 CRC-16/MODBUS checksum

Return as is: FF 05 00 00 FF 00 99 E4

Field Meaning Annotation
FF Device Address Range 1-255, default 255
05 Function code Write a single coil
00 00 Relay address 0x0000--0x0007 respectively represent #1 relay -- #8 relay
FF 00 On/Off command 0x0000 is off, 0xFF00 is on
99 E4 CRC16 CRC-16/MODBUS checksum


2. Turn off relay 1 (manual mode)
send out: FF 05 00 00 00 00 D8 14

Field Meaning Annotation
FF Device Address Range 1-255, default 255
05 Function code Write a single coil
00 00 Relay address 0x0000--0x0007 respectively represent #1 relay -- #8 relay
00 00 On/Off command 0x0000 is off, 0xFF00 is on
D8 14 CRC16 CRC-16/MODBUS checksum

Return as is: FF 05 00 00 00 D8 14

Field Meaning Annotation
FF Device Address Range 1-255, default 255
05 Function code Write a single coil
00 00 Relay address 0x0000--0x0007 respectively represent #1 relay -- #8 relay
00 00 On/Off command 0x0000 is off, 0xFF00 is on
D8 14 CRC16 CRC-16/MODBUS checksum


3. Turn on all relays
send out: FF 0F 00 00 00 20 01 FF B0 15

Field Meaning Annotation
FF Device Address Range 1-255, default 255
0F Function code Write multiple coils
00 00 Starting address #1 relay address
00 20 Number of relays Total number of relays to be controlled
01 Command byte count Control command word length
FF Control command 0x00 is fully closed, 0xFF is fully open
B0 15 CRC16 CRC-16/MODBUS checksum

Return: FF 0F 00 00 20 41 CD

Field Meaning Annotation
FF Device Address Range 1-255, default 255
0F Function code Write multiple coils
00 00 Starting address #1 relay address
00 20 Number of relays Total number of relays to be controlled
41 CD CRC16 CRC-16/MODBUS checksum


4. Turn off all relays
send out: FF 0F 00 00 00 20 01 00 F0 55

Field Meaning Annotation
FF Device Address Range 1-255, default 255
0F Function code Write multiple coils
00 00 Starting address #1 relay address
00 20 Number of relays Total number of relays to be controlled
01 Command byte count Control command word length
00 Control command 0x00 is fully closed, 0xFF is fully open
F0 15 CRC16 CRC-16/MODBUS checksum

Return: FF 0F 00 00 20 41 CD

Field Meaning Annotation
FF Device Address Range 1-255, default 255
0F Function code Write multiple coils
00 00 Starting address #1 relay address
00 20 Number of relays Total number of relays to be controlled
41 CD CRC16 CRC-16/MODBUS checksum


5. Set the device address to 255
Send: 00 10 00 00 00 01 02 00 FF EB 80

Field Meaning Annotation
00 Fixed value
10 Function code Write multiple registers
00 00 Starting address
00 01 Write the number of registers
02 Write register byte count Write register data length
00 FF Register data Write device address 0x00FF, range: 0x0001-0x00FF
E8 80 CRC16 CRC-16/MODBUS checksum

Return as is: 00 10 00 00 00 01 02 00 FF EB 80

Field Meaning Annotation
00 Fixed value
10 Function code Write multiple registers
00 00 Starting address
00 01 Write the number of registers
02 Write register byte count Write register data length
00 FF Register data That is, write device address 0x00FF, range: 0x0001-0x00FF
EB 80 CRC16 CRC-16/MODBUS checksum


6. Read device address 255
Sent: 00 03 00 00 01 85 DB

Field Meaning Annotation
00 Fixed value
03 Function code Read and hold register
00 00 Starting address
00 01 Number of registers Number of read registers
85 DB CRC16 CRC-16/MODBUS checksum

Return: 00 03 02 00 FF C5 C4

Field Meaning Annotation
00 Fixed value
03 Function code Read and hold register
02 Number of data bytes Length of data read from registers
00 FF Register data Device address read as 0x00FF
C5 C4 CRC16 CRC-16/MODBUS checksum


7. Read relay status
send out: FF 01 00 00 00 20 28 0C

Field Meaning Annotation
FF Device Address Range 1-255, default 255
01 Function code Read coil status
00 00 Starting address #1 relay address
00 20 Number of registers The total number of relays to be read is 0x0008
28 0C CRC16 CRC-16/MODBUS checksum

Return: FF 01 04 00 00 01 25 DE

Field Meaning Annotation
FF Fixed value
01 Function code Read and hold register
04 Number of data bytes Length of data read from registers
00 00
00 01
Data The read data, Bit0-Bit3 respectively represent the status of relay # 1- # 32, with 0 being off and 1 being on
25 DE CRC16 CRC-16/MODBUS checksum


8. Turn on relay 1 (flash off mode 2S)
send out: FF 10 00 00 00 02 04 00 04 00 14 85 8A

Field Meaning Annotation
FF Device Address Range 1-255, default 255
10 Function code Write multiple registers
00 00 Relay address # 1 relay -- # 32 relay addresses are 0x0000-0x001F respectively
00 02 Write the number of registers
04 Write register byte count Write register data length
00 04 Register 1 data Flash off/flash off value, 0x0004 represents flash off, 0x0002 represents flash off
00 14 Register 2 data Delay setting value, range: 0x0001--0xFFFF. The delay base is 0.1S, so the delay time is 0x0014 * 0.1=20 * 0.1S=2S. Relay # 1 will automatically disconnect after closing for 2S
C5 9F CRC16 CRC-16/MODBUS checksum

return: FF 10 00 00 00 02 A4 16

Field Meaning Annotation
FF Device Address Range 1-255, default 255
10 Function code Write multiple registers
00 00 Relay Address #1 Relay -- # 32 Relay addresses are: 0x0000-0x001F
00 02 Write the number of registers
54 16 CRC16 CRC-16/MODBUS checksum


9. Turn off relay 1 (flash mode 3S)
Sent: FF 10 00 00 00 02 04 00 02 00 1E E5 8C

Field Meaning Annotation
FF Device Address Range 1-255, default 255
10 Function code Write multiple registers
00 00 Relay address #1 relay -- # 32 relay addresses are 0x0000-0x001F respectively
00 02 Write the number of registers
04 Write register byte count Write register data length
00 02 Register 1 data Flash off/flash off value, 0x0004 represents flash off, 0x0002 represents flash off
00 1E Register 2 data Delay setting value, range: 0x0001--0xFFFF. The delay base is 0.1S,
so the delay time is 0x001E * 0.1=30 * 0.1S=3S. Relay # 1 will automatically disconnect after being closed for 3S
E5 8C CRC16 CRC-16/MODBUS checksum

Return: FF 10 00 00 02 54 16

Field Meaning Annotation
FF Device Address Range 1-255, default 255
10 Function code Write multiple registers
00 00 Relay Address #1 Relay -- # 32 Relay addresses are: 0x0000-0x001F
00 02 Write the number of registers
54 16 CRC16 CRC-16/MODBUS checksum


Detailed Explanation of Serial Port Instructions

1. Set the default MAC address to 00.00.00.58.58.58
Send: A0 A0 01 00 00 00 58 58 58 AA AA

Field Meaning Annotation
A0 A0 Frame header Starting byte
01 Function code Set default MAC address
00 00
00 58
58 58
Default MAC Address 6-byte MAC Address
Note: Do not use consecutive A0/AA when setting to avoid conflicts with the frame header/footer!
Factory default value: 00:08: dc: 11:11:11
AA AA Frame Tail End Byte

Return: A0 A0 01 01 AA AA

Field Meaning Annotation
A0 A0 Frame header Starting byte
01 Function code Set default MAC address
01 Setting Status Returning 01 indicates successful setting
AA AA Frame Tail End Byte


2. Set the default IP address to 192.168.0.88
Send: A0 A0 02 C0 A8 00 58 AA AA

Field Meaning Annotation
A0 A0 Frame header Starting byte
02 Function code Set default IP address
C0 A8
00 58<
Default IP address Hexadecimal data C0 A8 00 58 represents decimal IP address 192.168.0.88
Note: Do not use consecutive A0/consecutive AA when setting to avoid conflicts with frame header/footer!
Factory default value: 192.168.1.88
AA AA Frame Tail End Byte

Return: A0 A0 02 01 AA AA

Field Meaning Annotation
A0 A0 Frame header Starting byte
02 Function code Set default IP address
01 Setting Status Returning 01 indicates successful setting
AA AA Frame Tail End Byte


3. Set the default gateway to 192.168.0.1
Send: A0 A0 03 C0 A8 00 01 AA AA

Field Meaning Annotation
A0 A0 Frame header Starting byte
03 Function code Set default gateway
C0 A8
00 01<
Default gateway Hexadecimal data C0 A8 00 01 represents decimal gateway 192.168.0.1
Note: Do not use consecutive A0/consecutive AA when setting to avoid conflicts with frame header/footer!
Factory default value: 192.168.1.1
AA AA Frame Tail End Byte

Return: A0 A0 03 01 AA AA

Field Meaning Annotation
A0 A0 Frame header Starting byte
03 Function code Set default gateway
01 Setting Status Returning 01 indicates successful setting
AA AA Frame Tail End Byte


4. Send query settings parameters: A0 A0 10 AA AA

Field Meaning Annotation
A0 A0 Frame header Starting byte
10 Function code Query set parameters
AA AA Frame Tail End Byte

Return: Default MAC, default IP, and default gateway parameters saved by Flash

Instructions for using serial port commands

Regarding the default MAC address:
Only when there are multiple Modbus network relay modules in the same LAN, it is necessary to set it according to actual needs

Regarding the default IP address and gateway:
The module obtains the IP address and gateway parameters from the router through DHCP by default,
and generally does not need to set these two parameters. Only in the case of DHCP acquisition failure, it is necessary to set them according to actual needs, as follows:
NW-3-1-10.png

Taking the example of setting network parameters using serial debugging software sscom5.13.1, the steps are as follows:
1. Connect the serial port of the module through a USB to TTL module (such as CH340/FT232 module), and the wiring is as follows:

USB to TTL module Network relay module
3V3 3V3
GND GND
TXD RXD
RXD TXD

Then plug the USB to TTL module into the computer's USB port

When setting parameters, you don't need to plug in an Ethernet cable!

2. Open the sscom5.13.1 software, select the correct COM port, set the baud rate to 115200, and 8 seconds before power on, the module will attempt to obtain network parameters through DHCP and output corresponding debugging information
NW-3-1-11.png

3. After the debugging information is displayed, you can set the default network parameters through the serial port. Since the command is in hexadecimal, you need to check "HEX Display" and "HEX Send", enter the command in the command area, and then click "Send" to set it.
NW-3-1-12.png

Here is a list of settings:
1. Set the default MAC address to 00.00.00.58.58.58
Send: A0 A0 01 00 00 00 58 58 58 AA AA
Return: A0 A0 01 01 AA AA
NW-3-1-13.png

2. Set the default IP address to 192.168.0.88
Send: A0 A0 02 C0 A8 00 58 AA AA
Return: A0 A0 02 01 AA AA
NW-3-1-14.png

3. Set the default gateway to 192.168.0.1
Send: A0 A0 03 C0 A8 00 01 AA AA
Return: A0 A0 03 01 AA AA
NW-3-1-15.png

4. Query the set parameters
Because the parameters are displayed in text form, it is necessary to uncheck the "HEX display" option first
NW-3-1-16.png

Send: A0 A0 10 AA AA
Return:
The network parameters for Flash storage are as follows:
MAC address for Flash storage: 0.0.0.58.58.58
Flash storage IP address: 192.168.0.88
Gateway for Flash storage: 192.168.0.1
NW-3-1-17.png

After completing the parameter settings, power off and restart/press the onboard RST key to make the settings effective!


Remarks:
1. The set parameters support power-off saving

2. When setting the default IP and gateway, the third data indicates that the network segment is critical. For example, if the IP address of other devices connected to the router is 192.168.0.XXX, then the default IP address and gateway can only be set to 192.168.0.XXX and 192.168.0.1, respectively

3. When setting the default IP address, you can enter the router backend to confirm whether the IP address is already occupied. Only idle addresses can be used.

4. The conversion between hexadecimal and decimal can be viewed using the built-in calculator software in Win10.

NW-3-1-18.png


Download LC-NW-3-1 User Manual

For more information on the use of LC-NW-3-1, please refer toBaidu Netdisk Extraction code: ug7n