Inputting a Register Value

<< Click to Display Table of Contents >>

Navigation:  Modbus Universal MasterOPC Server > Quick Start > Example 1 - Operation Check Using Simulator >

Inputting a Register Value

ModRSSim is now configured. Let's input values to registers in order to be sure that the OPC server polls registers properly. ModRSSim supports scripts written in Visual Basic - for instance, for generation random values (see Script Automation for details) - but here we will do simple manual input of values to registers.

Change values of several registers manually, and poll registers from Modbus OPC Server. Assume we need to poll 3 registers:

1.The Holding Registers region - a register address 12 - a data type word

2.The Input Registers region - a register address 6 - a data type float

3.The Coils region - a register address 8 - a data type bool.

Find those registers and input values to them

1. Holding Registers.

In ModRSSim settings, select the region Holding Registers and the data type word 16.

vvod_znachenij_registrov

Now we have to fund the register number 12 and input a value to it.

In ModRSSim, register addresses are displayed in the standard appearance. A standard Modbus address defines a number of read function used, a number of write function used, and an address of the variable. In the standard addressing, there are 4 memory areas:

Discrete flags (COILS): addresses 00001...09999, the read function 0x01, the write function 0x0F

Discrete inputs (DISCRETE_INPUTS): addresses 10001...19999, the read function 0x02

Input registers (INPUT_REGISTERS): addresses 30001...39999, the read function 0x04

Stored registers (HOLDING_REGISTERS): addresses 40001...49999, the read function 0x03, the write function 0x10.

To transform a standard Modbus address to an address appearance of the OPC server (as well as to an appearance used in documentation of the most Modbus devices), you need do the follows:

1.Using the first digit of a standard address, detect a region the register belongs to.  

2.Remove the first digit from a standard address and subtract 1.

We must solve the inverse task, therefore we need to add 1 to an initial address, and supplement the address with the respective region number.  In or case, the register 12 is the address 400013. Find and double click it in the table.

vvod_znachenij_registrov1

A dialog to input a value opens. For example, input 50 and click OK - the value is displayed in the table.

vvod_znachenij_registrov2

2. Input Registers

Select the region Analog Input and the data type float 32.

vvod_znachenij_registrov3

Find the register 6 (300007) and input to it some fractional value - for instance, 12.25.

vvod_znachenij_registrov4

A value is written to an adjacent register as well. It is correct, because a float-type variable is 4-byte one and therefore occupies 2 Modbus registers - in our case, registers 6 (300007) and 7 (300008).

3. Coils

Switch to the region Coils. A data type in that region is always bool. The table displays values 0 (false) or 1 (true).

Find the register 8 and input to it 1 - that is, True.

vvod_znachenij_registrov5

Register values are set in the simulator, and now the OPC server can be configured.