Difference between revisions of "Slave Mode"

From IPLOG
Jump to: navigation, search
(Created page with "=== 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...")
 
 
Line 48: Line 48:
 
|word
 
|word
 
|
 
|
|Error ID - see [[Error codes for IEC 61131-3 libraries|Error table]]
+
|Error ID - see [[Error_Codes|Error table]]
 
|-
 
|-
 
|out
 
|out
Line 88: Line 88:
 
|word
 
|word
 
|
 
|
|Error ID - see [[Error codes for IEC 61131-3 libraries|Error table]]
+
|Error ID - see [[Error_Codes|Error table]]
 
|-
 
|-
 
|out
 
|out
Line 128: Line 128:
 
|word
 
|word
 
|
 
|
|Error ID - see [[Error codes for IEC 61131-3 libraries|Error table]]
+
|Error ID - see [[Error_Codes|Error table]]
 
|-
 
|-
 
|out
 
|out
Line 167: Line 167:
 
|word
 
|word
 
|
 
|
|Error ID - see [[Error codes for IEC 61131-3 libraries|Error table]]
+
|Error ID - see [[Error_Codes|Error table]]
 
|-
 
|-
 
|out
 
|out
Line 206: Line 206:
 
|word
 
|word
 
|
 
|
|Error ID - see [[Error codes for IEC 61131-3 libraries|Error table]]
+
|Error ID - see [[Error_Codes|Error table]]
 
|-
 
|-
 
|out
 
|out
Line 245: Line 245:
 
|word
 
|word
 
|
 
|
|Error ID - see [[Error codes for IEC 61131-3 libraries|Error table]]
+
|Error ID - see [[Error_Codes|Error table]]
 
|-
 
|-
 
|out
 
|out
Line 290: Line 290:
 
|word
 
|word
 
|
 
|
|Error ID - see [[Error codes for IEC 61131-3 libraries|Error table]]
+
|Error ID - see [[Error_Codes|Error table]]
 
|}
 
|}
  
Line 326: Line 326:
 
|word
 
|word
 
|
 
|
|Error ID - see [[Error codes for IEC 61131-3 libraries|Error table]]
+
|Error ID - see [[Error_Codes|Error table]]
 
|}
 
|}
  
Line 348: Line 348:
 
|word
 
|word
 
|
 
|
|Error ID - see [[Error codes for IEC 61131-3 libraries|Error table]]
+
|Error ID - see [[Error_Codes|Error table]]
 
|}
 
|}
  
Line 376: Line 376:
 
|word
 
|word
 
|
 
|
|Error ID - see [[Error codes for IEC 61131-3 libraries|Error table]]
+
|Error ID - see [[Error_Codes|Error table]]
 
|}
 
|}
  

Latest revision as of 10:10, 16 July 2025

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, MODBUS_GET_INPUT, MODBUS_GET2_HOLDING or MODBUS_GET2_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, MODBUS_SET_INPUT, MODBUS_SET2_HOLDING or MODBUS_SET2_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
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_GET2_HOLDING

Reads the two appropriate HOLDING registers value from the internal modbus table of values (lower register with higher weight).

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 dword 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_GET2_INPUT

Reads the two appropriate INPUT registers value from the internal modbus table of values (lower register with higher weight).

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 dword 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_COILS

Writes the appropriate COILS value to the internal modbus table of values. In the range OfsAddrStart to OfsAddrEnd.

Always OfsAddrStart must be less than OfsAddrEnd.

in OfsAddrStart word address start (1-9999)
in OfsAddrEnd word address stop (1-9999)
in VAL bool value to vrite
out Err bool F = No error, T = occur any error
out Err_ID word Error ID - see Error table
MODBUS_SET_COILS_ALL

Write all COILS value cross all registers 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_DISCRETES

Writes the appropriate DISCRETES value to the internal modbus table of values. In the range OfsAddrStart to OfsAddrEnd.

in OfsAddrStart word address start (1-9999)
in OfsAddrEnd word address stop (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_DISCRETES_ALL

Write all DISCRETES value cross all registers 1 - 9999.

in VAL word val 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_HOLDINGS

Writes the appropriate HOLDINGS value to the internal modbus table of values. In the range OfsAddrStart to OfsAddrEnd.

in OfsAddrStart word address start (1-9999)
in OfsAddrStop word address stop(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_HOLDINGS_ALL

Write all HOLDINGS value cross all registers 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_SET2_HOLDING

Writes the two appropriate HOLDING registers value to the internal modbus table of values (lower register with higher weight).

in OfsAdr word register address (1-9999)
in VAL dword 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
MODBUS_SET_INPUTS

Writes the appropriate INPUTS value to the internal modbus table of values. In the range OfsAddrStart to OfsAddrEnd.

in OfsAddrStart word address start (1-9999)
in OfsAddrStop word address stop (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_INPUTS_ALL

Write all INPUTS value cross all registers 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_SET2_INPUT

Writes the two appropriate INPUT registers value to the internal modbus table of values (lower register with higher weight).

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_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