Skip to main content
Skip table of contents

add_modbus_rtu_signal(slaveid=1, port=None, baudrate=115200, bytesize=DR_EIGHTBITS, parity=DR_PARITY_NONE, stopbits=DR_STOPBITS_ONE, name, reg_type, index, value=0)

Features

This function registers the ModbusRTU 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

slaveid

int

1

Slave ID of the ModbusRTU (0 or 1-247)

0 : Broadcase address

port

string

None

E.g.) “COM”, “COM_USB”, “/dev/ttyUSB0”

baudrate

int

115200

Baud rate

9600, 19200, 57600, 115200, etc

bytesize

int

8

Number of data bits

  • DR_FIVEBITES: 5
  • DR_SIXBITS: 6
  • DR_SEVENBITS: 7
  • DR_EIGHTBITS: 8

parity

string

"N"

Parity checking

  • DR_PARITY_NONE: "N"
  • DR_PARITY_EVEN: "E"
  • DR_PARITY_ODD: "O"

stopbits

int

1

Number of stop bits

  • DR_STOPBITS_ONE =1
  • DR_STOPBITS_TWO = 2

name

string

-

Modbus signal name

reg_type

int

-

Modbus signal type

  • DR_DISCRETE_INPUT =DR_MODBUS_DIG_INPUT
  • DR_COIL =DR_MODBUS_DIG_OUTPUT
  • DR_INPUT_REGISTER =DR_MODBUS_REG_INPUT
  • DR_HOLDING_REGISTER =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)

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
add_modbus_rtu_signal(slaveid=1, port=port_info, baudrate=115200, bytesize=DR_EIGHTBITS, parity=DR_PARITY_NONE, stopbits=DR_STOPBITS_ONE, name=’di1’, reg_type=DR_INPUT_REGISTER, index=0)

add_modbus_rtu_signal(slaveid=1, port=port_info, baudrate=115200, bytesize=DR_EIGHTBITS, parity=DR_PARITY_NONE, stopbits=DR_STOPBITS_ONE, name=’do1’, reg_type=DR_HOLDING_REGISTER, index=0, value=12345)
JavaScript errors detected

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

If this problem persists, please contact our support.