Skip to content

Instantly share code, notes, and snippets.

@TG9541
Last active December 21, 2018 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TG9541/4f61ce53e2f3d7fb4e8521428161b0e1 to your computer and use it in GitHub Desktop.
Save TG9541/4f61ce53e2f3d7fb4e8521428161b0e1 to your computer and use it in GitHub Desktop.
C0135 MODBUS RTU Examples

Examples

Do not provide source communication MODBUS code

MODBUS RTU communication instruction:

Modbus RTU instruction

Baud rate: 96008 NONE 1

The relay module can have multiple network communication, and the communication address can be set by serial port instruction. (communication instructions provided by SkyDrive)

Relay module factory default communication address fixed to 1, serial assistant operation instructions:

Note: the following specific test instructions are passed through the network

Instruction function:

  1. set address to 2. read address 3. read software version 4. read the hardware version

Output instructions:

MODBUS-RTU communication instructions:

Function code: 05 is relay output [control relay on / off].

Function code: 06 is to store data [user defined storage data, user defined data, address number, set by the user himself. Generally, it is a useless state.]


Baud rate: 96008 None 1

16 Decimal transmission

16 Decimal receiver

Operation steps:

  1. software set communication baud rate

  2. set the address (the address of the device used for communication, the default address is 01).


The set address is: 01

000640000001 5C 1B

The set address is: 02

000640000002 1C 1A

Read address

00034000000190 1B

000640020000 3C 1B

000640020001 FC 4B

Read address

00030000000185 DB

Return:

00030200014444 //01 is the address



The meaning of the representative of each byte:

[1 address]

/ / - to - - to - - ---

Relay No. 1: 010500010100 9D 9A

Byte 1: Address

Byte 2: function

Byte 34: register address

Byte 56: register data

Byte 7 8:CRC check

/ / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

[1 address]

/ / - to - - to - - ---

Relay No. 0: 01050000 FF 00 8C 3A

No. 0 relay closes: 010500000000 CD CA

/ / - to - - to - - ---

Relay No. 1: 01050001 FF 00 DD FA

No. 1 relay closes: 010500010000 9C 0A

/ / - to - -- - ----

Relay No. 2: 01050002 FF 00 2D FA

No. 2 relay closes: 010500020000 6C 0A

/ / - to - -- - ----

Relay No. 3: 01050003 FF 00 7C 3A

No. 3 relay closes: 010500030000 3D CA

/ / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =


Read all interface input states

Send: 01020000000879 CC / / read 8 input states

Return: 01020100 A1 88

All out

Read instructions:

Read the 1 channel state [IN1] 2 channel state [IN2] 3 channel state [IN3] 4 channel state [IN4]

Read all input interface states

/////////////////////////////

Serial assistant operation structions:

Below are the test instructions for device number 1:

No. 1 relay close:

01 06 00 01 01 00 d9 9a

No. 1 relay open:

01 06 00 01 01 01 18 5a

No. 2 relay close:

01 06 00 01 02 00 d9 6a

No. 1 relay open:

01 06 00 01 02 01 18 aa

No. 3 relay close:

01 06 00 01 03 00 d8 fa

No. 1 relay open:

01 06 00 01 03 01 19 3a

No. 4 relay close:

01 06 00 01 04 00 da ca

No. 1 relay open:

01 06 00 01 04 01 1b 0a

All put out:

01 06 00 01 00 00 d8 0a

All light:

01 06 00 01 ff ff d9 ba

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment