Example for Register Communication

Control Byte

The Control Byte is located in the output image, and can be read or written.

Bit

7

6

5

4

3

2

1

0

Name

REG

R/W

register number

Bit

Name

Description

7

REG

1bin

Register Communication switched on: The first two Data Bytes are not used for process data exchange, but are written to the register set of the Fieldbus Box or are read from there.

6

R/W

0bin

Read: the register should be read without changing it.

1bin

Write: the register should be written.

5-0

register number

Number of the Registers, that should be read or written. 64 Registers are addressable.

Status Byte

The  Status-Byte is located in the output image und can only be read.

Bit

7

6

5

4

3

2

1

0

Name

REG

R

register number

Bit

Name

Description

7

REG

1bin

receipt register number

6

R

0bin

Read

5-0

register number

Number of the Registers, that was read or written. 

Example 1

Reading register 8 of KL3204 or IP/IE3202

Byte 0 (control byte)

Byte 1 (data out, high byte)

Byte 2 (data out, low byte)

0x88 (1000 1000bin)

0xXX

0xXX

Bit 0.7 set indicates register communication active
Bit 0.6 not set indicates reading the register.
Bit 0.5 to Bit 0.0 indicates with 001000bin the register number 8.
The output data word (Byte 1 and Byte 2) has no function at the reading access. If you want to change a register, you have to write the desired value into the output data word.

Byte 0 (status byte)

Byte 1 (data in, high byte)

Byte 2 (data in, low byte)

0x88

0x0C

0x84

The terminal/box returns the type name 0x0C84 (equivalent unsigned integer 3204) in the input data word (Byte 1 and Byte 2).

Special feature in the naming of Fieldbus Boxes:
The last figure of the delivered unsigned Integer (3204) is not the same like the last character of the Fieldbus Box name (3202), witch stands for the connector type (0 for S8, 1 for M8 and 2 for M12). It returns instead of that the number of channels (IE3204 owns 4 channels).

User code word

In order to write into registers, you have to write the user code word (0x1235) into register 31, so that write protection is deactivated. It is activated again by writing any value other than 0x1235. Note that some of the settings that can be made in registers only become active after the next power restart (power-off/power-on) of the module.

Example 2

Process of register communication for writing into register.

1. Write register 31 (set code word)

Byte 0 (control byte)

Byte 1 (data out, high byte)

Byte 2 (data out, low byte)

0xDF

0x12

0x35

Answer of the module/terminal

Byte 0 (status byte)

Byte 1 (data in, high byte)

Byte 2 (data in, low byte)

0x9F

0xXX

0xXX

2. Read register 31 (verify, if code word is set)

Byte 0 (control byte)

Byte 1 (data out, high byte)

Byte 2 (data out, low byte)

0x9F

0xXX

0xXX

Answer of the module/terminal

Byte 0 (status byte)

Byte 1 (data in, high byte)

Byte 2 (data in, low byte)

0x9F

0x12

0x35

CAUTION
Pay attention to the register description!

The given value 0x0002 is only an example! The bits of the feature register change the properties of the module und and have different meanings, depending on the module type. Please check the description of the feature register of your module (chapter register description) about the meanings of the bits in detail, before changing the values!

Byte 0 (control byte)

Byte 1 (data out, high byte)

Byte 2 (data out, low byte)

0xE0

0x00

0x02

Answer of the module/terminal

Byte 0 (status byte)

Byte 1 (data in, high byte)

Byte 2 (data in, low byte)

0xA0

0xXX

0xXX

4. Read Register 32 (verify changed register)

Byte 0 (control byte)

Byte 1 (data out, high byte)

Byte 2 (data out, low byte)

0xA0

0xXX

0xXX

Answer of the module/terminal

Byte 0 (status byte)

Byte 1 (data in, high byte)

Byte 2 (data in, low byte)

0xA0

0x00

0x02

5. Write Register 31 (set code word back)

Byte 0 (control byte)

Byte 1 (data out, high byte)

Byte 2 (data out, low byte)

0xDF

0x00

0x00

Answer of the module/terminal

Byte 0 (status byte)

Byte 1 (data in, high byte)

Byte 2 (data in, low byte)

0x9F

0xXX

0xXX