
3Customization
The firmware default configuration can be modified using the MotorControl Workbench and the STM32CubeMX
software.
3.1 MODBUS section customization
The MODBUS section (i.e., slave address, coils, direct inputs, holding registers, etc.) can be customized by
modifying the following code files:
• mb_API.c/.h: API interfacing the MODBUS with application level
• mbtask.c/.h: Implementation of the callbacks managing:
– Holding registers read/write
– Input registers read
– Coils read/write
– Discrete inputs read
The following table provides the parameters defining the MODBUS data model and slave address:
Table 1. MODBUS configuration parameters
Parameter Location Description
MB_SLAVE_ADDRESS mbtask.h Set the slave address of the device
REG_INPUT_START mbtask.h Input registers starting counter
REG_INPUT_NREGS mbtask.h Number of input registers (bytes)
REG_HOLDING_START mbtask.h Holding registers starting counter
REG_HOLDING_NREGS mbtask.h Number of holding registers (bytes)
REG_COILS_START mbtask.h Coils starting counter
REG_COILS_SIZE mbtask.h Number of coils (bits)
REG_DISC_START mbtask.h Discrete inputs starting counter
REG_DISC_SIZE mbtask.h Number of discrete inputs (bits)
MB_FUNC_OTHER_REP_SLAVEID_ENABLED mbconfig.h Enable/Disable Report Slave ID function
MB_FUNC_READ_INPUT_ENABLED mbconfig.h Enable/Disable read input register function
MB_FUNC_READ_HOLDING_ENABLED mbconfig.h Enable/Disable read holding register function
MB_FUNC_WRITE_HOLDING_ENABLED mbconfig.h Enable/Disable write holding register function
MB_FUNC_WRITE_MULTIPLE_HOLDING_ENABLED mbconfig.h Enable/Disable write multiple holding register function
MB_FUNC_READ_COILS_ENABLED mbconfig.h Enable/Disable read coils function
MB_FUNC_WRITE_COIL_ENABLED mbconfig.h Enable/Disable write coils function
MB_FUNC_WRITE_MULTIPLE_COILS_ENABLED mbconfig.h Enable/Disable write multiple coils function
MB_FUNC_READ_DISCRETE_INPUTS_ENABLED mbconfig.h Enable/Disable read discrete inputs function
MB_FUNC_READWRITE_HOLDING_ENABLED mbconfig.h Enable/Disable read/write holding register function
3.2 Starting from MotorControl Workbench project
The package contains the MotorControl Workbench project used for code generation. Using this project, it is
possible to modify all the configurations related to the control algorithm and related peripherals.
Note: The communication protocol included in the MCSDK does not support RS485 implemented in the EVALKIT-
ROBOT-1 board.
UM2711
Customization
UM2711 - Rev 1 page 5/18