Skip to main content
Skip table of contents

add_modbus_signal(ip, port, name, reg_type, index, value=0, slaveid=255)

Features

This function registers the ModbusTCP signal. The Modbus I/O must be set in the Teach Pendant I/O set-up menu. Use this command only for testing if it is difficult to use the Teach Pendant. The Modbus menu is disabled in the Teach Pendant if it is set using this command.

Parameters

Parameter NameData TypeDefault ValueDescription

ip

string

-

IP address of the ModbusTCP module

port

int

-

Port number of the ModbusTCP module

name

string

-

Modbus signal name

reg_type

int

-

Modbus signal type

  • DR_MODBUS_DIG_INPUT
  • DR_MODBUS_DIG_OUTPUT
  • DR_MODBUS_REG_INPUT
  • DR_MODBUS_REG_OUTPUT

index

int

-

Modbus signal index

value

int

0

Output when the type is

DR_COIL or DR_HOLDING_REGISTER

(ignored otherwise)

slaveid

int

255

  • Slave ID of the ModbusTCP module
    (0 or 1-247 or 255)

0 : Broadcase address

255 : Default value for ModbusTCP

Return

ValueDescription

0

Success

Negative value

Failed

Exception

ExceptionDescription

DR_Error (DR_ERROR_TYPE)

Parameter data type error occurred

DR_Error (DR_ERROR_VALUE)

Parameter value is invalid

DR_Error (DR_ERROR_RUNTIME)

C extension module error occurred

DR_Error (DR_ERROR_STOP)

Program terminated forcefully

Example

PY
# An example of connecting two Modbus IO and allocating the contacts 
# Modbus IO 1 : IP address 192.168.137.254, port 502
Input Register Address 0 ~ 3, signal name “input1”~”input4”
Holding Register Addreess 0 ~ 3, signal name “output1”~”output4” 
# Modbus IO 2 : IP address 192.168.137.253, port 502
Input Register Address 0 ~ 3, signal name “input1”~”input4”
Holding Register Addreess 0 ~ 3, signal name “output1”~”output4” 
 
# set < Modbus IO 1 > “input1”~”input4”, “output1”~”output4”
add_modbus_signal(ip="192.168.137.254",port=502, name="input1", reg_type=DR_INPUT_REGISTER, index=0, slaveid=255)
add_modbus_signal(ip="192.168.137.254",port=502, name="input2", reg_type=DR_INPUT_REGISTER, index=1, slaveid=255)
add_modbus_signal(ip="192.168.137.254",port=502, name="input3", reg_type=DR_INPUT_REGISTER, index=2, slaveid=255)
add_modbus_signal(ip="192.168.137.254",port=502, name="input4", reg_type=DR_INPUT_REGISTER, index=3, slaveid=255)
 
add_modbus_signal(ip="192.168.137.254",port=502, name="output1", reg_type=DR_HOLDING_REGISTER, index=0, value=0, slaveid=255)
add_modbus_signal(ip="192.168.137.254",port=502, name=" output2", reg_type=DR_HOLDING_REGISTER, index=1, value=0, slaveid=255)
add_modbus_signal(ip="192.168.137.254",port=502, name=" output3", reg_type=DR_HOLDING_REGISTER, index=2, value=0, slaveid=255)
add_modbus_signal(ip="192.168.137.254",port=502, name=" output4", reg_type=DR_HOLDING_REGISTER, index=3, value=0, slaveid=255)
 
# set < Modbus IO 1 > “input5”~”input8”, “output5”~”output8”
add_modbus_signal(ip="192.168.137.253",port=502, name="input5", 
reg_type= DR_INPUT_REGISTER, index=0, slaveid=255)
add_modbus_signal(ip="192.168.137.253",port=502, name=" input6", 
reg_type= DR_INPUT_REGISTER, index=1, slaveid=255)
add_modbus_signal(ip="192.168.137.253",port=502, name=" input7", 
reg_type= DR_INPUT_REGISTER, index=2, slaveid=255)
add_modbus_signal(ip="192.168.137.253",port=502, name=" input8", 
reg_type= DR_INPUT_REGISTER, index=3, slaveid=255)
 
add_modbus_signal(ip="192.168.137.253",port=502, name=" output5", reg_type=DR_HOLDING_REGISTER, index=0, value=0, slaveid=255)
add_modbus_signal(ip="192.168.137.253",port=502, name=" output6", reg_type=DR_HOLDING_REGISTER, index=1, value=0, slaveid=255)
add_modbus_signal(ip="192.168.137.253",port=502, name=" output7", reg_type=DR_HOLDING_REGISTER, index=2, value=0, slaveid=255)
add_modbus_signal(ip="192.168.137.253",port=502, name=" output8", reg_type=DR_HOLDING_REGISTER, index=3, value=0, slaveid=255)
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.