Difference between revisions of "Blocks MODBUS Slave"

From IPLOG
Jump to: navigation, search
 
Line 2: Line 2:
  
 
=== Slave MODE ===
 
=== Slave MODE ===
 +
MODBUS SLAVE contains 4 mapping arrays each with 9999 entries. The arrays are:
 +
* Coils (0xxxxx) - cells of type BOOL
 +
 +
* Discretes Input (1xxxxx) - cells of type BOOL
 +
 +
* Holding Registers (4xxxxx) - cells of type WORD
 +
 +
* Input Registers (3xxxxx) - cells of type WORD
 +
Lines 1..9999 correspond to the MODBUS address offset.
 +
 +
The default value for all cells in the arrays is '''NULL'''.
 +
 +
===== Reading values from arrays =====
 +
Use the ''MODBUS_GET_COIL'', ''MODBUS_GET_DISCRETE'', ''MODBUS_GET_HOLDING'', or ''MODBUS_GET_INPUT'' function block to locally read array values.
 +
 +
For remote reading of array values, use the standard MODBUS function via TCP connection.
 +
 +
<u>NOTE: If you try to read a NULL value, the INVALID VALUE error is returned.</u>
 +
 +
===== Write the values to the arrays =====
 +
Use the ''MODBUS_SET_COIL'', ''MODBUS_SET_DISCRETE'', ''MODBUS_SET_HOLDING'', or ''MODBUS_SET_INPUT'' function block to locally write array values.
 +
 +
Remote values can be writen to Coils and Holding arrays. For write, use standard MODBUS functions via TCP connection.
 +
 +
===== Application =====
 +
MODBUS TCP SLAVE is useful if you need to provide a state of your own inputs for remote devices. For example, the switch on/off state of the button is provided for another device.
 +
 +
Similarly, if you need to set the status of the local relay from another device.
  
 
===== MODBUS_GET_COIL =====
 
===== MODBUS_GET_COIL =====

Latest revision as of 13:48, 12 November 2018

Back to Libraries

Slave MODE

MODBUS SLAVE contains 4 mapping arrays each with 9999 entries. The arrays are:

  • Coils (0xxxxx) - cells of type BOOL
  • Discretes Input (1xxxxx) - cells of type BOOL
  • Holding Registers (4xxxxx) - cells of type WORD
  • Input Registers (3xxxxx) - cells of type WORD

Lines 1..9999 correspond to the MODBUS address offset.

The default value for all cells in the arrays is NULL.

Reading values from arrays

Use the MODBUS_GET_COIL, MODBUS_GET_DISCRETE, MODBUS_GET_HOLDING, or MODBUS_GET_INPUT function block to locally read array values.

For remote reading of array values, use the standard MODBUS function via TCP connection.

NOTE: If you try to read a NULL value, the INVALID VALUE error is returned.

Write the values to the arrays

Use the MODBUS_SET_COIL, MODBUS_SET_DISCRETE, MODBUS_SET_HOLDING, or MODBUS_SET_INPUT function block to locally write array values.

Remote values can be writen to Coils and Holding arrays. For write, use standard MODBUS functions via TCP connection.

Application

MODBUS TCP SLAVE is useful if you need to provide a state of your own inputs for remote devices. For example, the switch on/off state of the button is provided for another device.

Similarly, if you need to set the status of the local relay from another device.

MODBUS_GET_COIL

Reads the appropriate COIL value from the internal modbus table of values.

in OfsAdr word register address (1-9999)
out ERR bool F = No error, T = occur any error
out ERR_ID word Error ID - see Error table
out Q bool return value
out R_TRIG bool for future use - not implemented
out W_TRIG bool for future use - not implemented

Example: Modbus Master device or software controls 'led_usr1_red' on the IPLOG.
Modbus getcoil.jpg

MODBUS_GET_DISCRETE

Reads the appropriate DISCRETE value from the internal modbus table of values.

in OfsAdr word register address (1-9999)
out ERR bool F = No error, T = occur any error
out ERR_ID word Error ID - see Error table
out Q bool return value
out R_TRIG bool for future use - not implemented
out W_TRIG bool for future use - not implemented
MODBUS_GET_HOLDING

Reads the appropriate HOLDING register value from the internal modbus table of values.

in OfsAdr word register address (1-9999)
out ERR bool F = No error, T = occur any error
out ERR_ID word Error ID - see Error table
out Q word return value
out R_TRIG bool for future use - not implemented
out W_TRIG bool for future use - not implemented
MODBUS_GET_INPUT

Reads the appropriate INPUT register value from the internal modbus table of values.

in OfsAdr word register address (1-9999)
out ERR bool F = No error, T = occur any error
out ERR_ID word Error ID - see Error table
out Q word return value
out R_TRIG bool for future use - not implemented
out W_TRIG bool for future use - not implemented
MODBUS_SET_COIL

Writes the appropriate COIL value to the internal modbus table of values.

in OfsAdr word register address (1-9999)
in VAL bool value to write
out ERR bool F = No error, T = occur any error
out ERR_ID word Error ID - see Error table
MODBUS_SET_DISCRETE

Writes the appropriate DISCRETE value to the internal modbus table of values.

in OfsAdr word register address (1-9999)
in VAL bool value to write
out ERR bool F = No error, T = occur any error
out ERR_ID word Error ID - see Error table
MODBUS_SET_HOLDING

Writes the appropriate HOLDING register value to the internal modbus table of values.

in OfsAdr word register address (1-9999)
in VAL word value to write
out ERR bool F = No error, T = occur any error
out ERR_ID word Error ID - see Error table
MODBUS_SET_INPUT

Writes the appropriate INPUT register value to the internal modbus table of values.

in OfsAdr word register address (1-9999)
in VAL word value to write
out ERR bool F = No error, T = occur any error
out ERR_ID word Error ID - see Error table

Example: Value from "resin1" is saved in register 2 of Input register.
B modbus s setinput.jpg


MODBUS_TCP_SLAVE

This function block starts listening TCP MODBUS slave deamon on the appropriate port.

in Port int Listening TCP port (default: 502)
in UnitID byte device bus address (1-247) (default: 1)
out ERR bool F = No error, T = occur any error
out ERR_ID word Error ID - see Error table