MBM - Modbus-Master Library

Description

Modbus Master Library for rapidM2M hardware platforms and devices.

Supported devices:

  • rapidM2M C3xx
  • myDatalogEASY IoT/IoTmini
  • rapidM2M M22x
  • rapidM2M M23x

See What the Microtronics Modbus Master Library offers for details.

OVERVIEW

M22X:

Abstract:
This library provides functions to enable Modbus Master communication.
  • RTU or ASCII mode via serial interface.
  • TCP mode via LAN interface.

  • Supported rapidM2M devices and interfaces:
    • rapidM2M C3xx (RTU and ASCII mode):
      • RS232
      • RS485

    Supported rapidM2M hardware platforms and interfaces:
    • rapidM2M EasyIoT (RTU and ASCII mode):
      • RS232
      • RS485

    • rapidM2M M2/M23 (RTU and ASCII mode):
      • 2x RS232 (UART0/1 + ext. converter for example MAX232)
      • 2x RS485 (SPI + ext. converter SC16IS741 + ext. converter for example LTC2862)
    • Note: 1 GPIO and 1 IRQ pin are required per RS485 interface
    • rapidM2M M2/M23 PoC Shield LAN (TCP mode):
      • 1x LAN (Wiznet W5200 via w5200-microtronics library, SPI0 with additional control GPIOs)

    Supported Modbus function codes
    • FC1 - Read coil
    • FC2 - Read discrete input
    • FC3 - Read holding registers
    • FC4 - Read input registers
    • FC5 - Write single coil
    • FC6 - Write single holding registers
    • FC15 - Write multiple coils
    • FC16 - Write multiple holding registers

    Note: Currently only 1 Modbus-Master - Instance per device is supported.
    Config:
    rapidM2M M2/M23 (RS232 interfaces only):
    No library configuration needed.

    rapidM2M M2/M23 (RS485 interfaces are required):
    To be able to use the RS485 interfaces, add the following block to the main.dde file.
    /** ---------------------------------------------------------------------------- * modbus-master-mt: RS485 interface Config * ----------------------------------------------------------------------------- * * Use this block to specify which pins of the rapidM2M M2/M23 the up to two SC16IS741 * (which are used to realize the RS485 interfaces) are connected to. * * -1: not in use * >=0: SPI interface that should be used (0 to DP_SPI_CNT-1) * GPIO pin that should be used (0 to DP_GPIO_CNT-1) * Interrupt pin that should be used (0 to DP_IRQ-1) * Note: If MBM_PIN_CSx is set to >=0 (i.e. SC16IS741 channel x should be used), * the corresponding MBM_PIN_IRQx must also be set >=0. */ #define MBM_PORT_SPI 0 // SC16IS741: SPI interface that should be used #define MBM_PIN_CS0 -1 // SC16IS741: GPIO pin for CS signal of Channel 0 #define MBM_PIN_CS1 -1 // SC16IS741: GPIO pin for CS signal of Channel 1 #define MBM_PIN_IRQ0 -1 // SC16IS741: Interrupt pin for Channel 0 #define MBM_PIN_IRQ1 -1 // SC16IS741: Interrupt pin for Channel 1 #define MBM_PIN_RESET -1 // SC16IS741: GPIO pin for chip hardware reset

    rapidM2M C3xx:
    To enable the MBM Library, add the following blocks to the main.dde file.
    This both blocks must be defined in order to use the library.
    /** ---------------------------------------------------------------------------- * rapidm2m-c3xx-base: rapidM2M C3xx Config * ----------------------------------------------------------------------------- * * Use this block to enable the callback functions for the features (provided by the IO Controller) which you want to use: * * 0: disables all callback functions for a specific feature * 1: only enables the essential callback functions for a specific feature * 2: enables all callback functions for a specific feature */ #define IOCTRL_COMMON 1 // Generell Information regarding the IO Controller #define IOCTRL_UI 0 // Universal inputs #define IOCTRL_RS232 2 // RS232 Interface #define IOCTRL_RS485 2 // RS485 Interface #define IOCTRL_CAN 0 // CAN Interface #define IOCTRL_DIGOUT 0 // Digital Outputs #define IOCTRL_SHUTDOWN 0 // Shutdown Handling /** ---------------------------------------------------------------------------- * modbus-master-mt: Library Config * ----------------------------------------------------------------------------- * * This block must be defined in order to use the library. * * Callback functions config (applies to MBM_COMMON) * 0: disables all callback functions for a specific feature * 1: enables the callback functions for a specific feature * Note: IOCTRL_COMMON must be set to at least 1 in any case * * RSxxx Interfaces config (applies to MBM_USE_RSxxx) * 0: the interface is available for the user program * 1: the interface is used by the MBM library * Note: If MBM_USE_RSxx is set to 1 (interface should be used) * the corresponding IOCTRL_RSxx must be set to 2 */ #define MBM_COMMON 0 // Generell Information regarding the IO Controller #define MBM_USE_RS232 1 // RS232 Interface #define MBM_USE_RS485 1 // RS485 Interface

    General information regarding the IO Controller

    MBM_COMMON >= 1
  • MBM_ReadyCallback
  • MBM_SysValuesCallback
  • Interface_Selection:
    Depending on the device profile (i.e. the rapidM2M hardware platform used) you have selected in the project settings and the rapidM2M devices (e.g. rapidM2M C3xx) you are using, different interfaces are supported.

    The interface can be selected by calling the MBM_Init() function for RTU or ASCII mode or MBM_TCP_Init() for TCP mode. This function must be called for a specific interface. If it is not required anymore, it is recommended to call MBM_Close(). Re-opening of the interface is performed by another call of MBM_Init()/MBM_TCP_Init().

    rapidM2M M2/M23 RTU/ASCII:
    new hMBM1; /* Inits the MBM_INTERFACE of the device. In this case the first RS232 interface is used */ if(MBM_Init(hMBM1, MBM_INTERFACE_RS232_1, BAUDRATE, MODE, MBM_TYPE_RTU) < OK) { // Error, selected interface probably not available on this device }

    rapidM2M C3xx:
    For rapidM2M C3xx device, additionally the two blocks described under "Library configuration" (see Config) have to be added into the main.dde file in order to activate the relevant callback functions of the relevant serial interface.
    new hMBM1; /* Inits the MBM_INTERFACE of the device. In this case the first RS485 interface is used */ if(MBM_Init(hMBM1, MBM_INTERFACE_RS232_1, BAUDRATE, MODE, MBM_TYPE_RTU) < OK) { // Error, selected interface probably not available on this device }

    How_to_use:
    /* Hardware setup */ const { PORT = MBM_INTERFACE_RS232_1, // The first RS232-interface should be used. BAUDRATE = 57600, // Baud rate to be used // MBM interface configuration (e.g 7/8 Data-bit, Stopbit yes/no, Parity yes/no, etc) MODE = MBM_MODE_1_STOPBIT | MBM_MODE_PARITY_NONE | MBM_MODE_8_DATABIT | MBM_MODE_HALF_DUPLEX, } /* Software setup */ const { READ_INTERVAL = 5, // Read interval [sec] SLAVE_ADDRESS = 1, // Adress of the Modbus Slaver (1-247) REG_START_ADDRESS = 0, // Start address of requested data (0 - 65535) REG_COUNT = 3, // Number of Modbus registers to be read out (1-125) } /* Handle for the MBM-Interface */ new hMBM1; /* Global variables for the remaining time until certain actions are triggered */ new readTimer = READ_INTERVAL; // Sec. until the next read out of the Modbus input registers /* Modbus callback function */ MBM_EvtResponse(handle, iResult, aResponse{}, iLen) { switch(iResult) // Switch the response type { case MBM_OK: // Valid response { new MB_response[TMBM_Ok_Response]; // Structure for valid response data /* Extracts the information from the "Response Ok" and issues handle for the MBM communication interface (number of the serial interface), Slave address, Modbus function code, start address, item count and byte count via the console */ MBM_ParseRespOK(aResponse, MB_response, iLen); #log("MBM received valid response from IF#%d, Slave:%d, FC:%d, StartAddr:%d, ItemCnt:%d, ByteCnt:%d bytes", handle, MB_response.iSlave, MB_response.iFC, MB_response.iStartAddr, MB_response.iItemCount, MB_response.iCount); if(MB_response.iCount>0) // If response includes data { // For the 3 Modbus input registers // Note: A Modbus input register value occupies two bytes in the playload data buffer of the response data for(new i=0; i<(MB_response.iCount);i=i+2) { new iVal; // Temporary memory for the value of an Modbus input register // unpack value from received payload data buffer and issue via console rM2M_Pack(MB_response.payload, i, iVal, RM2M_PACK_GET | RM2M_PACK_BE | RM2M_PACK_S16); #log("Value: %d", iVal); } } } case MBM_ERROR_EXCEPTION: // exception response { new MB_exception[TMBM_Exception_Response]; // structure for exception response data /* Extracts the information from the "Exception response" and issues handle for the MBM communication interface (number of the serial interface), Slave address, Modbus function code, exception code, start address and item count via the console */ MBM_ParseRespErrException(aResponse, MB_exception, iLen); #log("MBM received error exception from IF#%d, Slave:%d, FC:%d, StartAddr:%d, ItemCnt:%d, Exception:%d", handle, MB_exception.iSlave, MB_exception.iFC, MB_exception.iStartAddr, MB_exception.iItemCount, MB_exception.iExceptioncode); } case MBM_ERROR_CRC: // CRC-error { new MB_CRC[TMBM_CRC_Response]; // structure for CRC response data /* Extracts the information from the "CRC-error response" and issues handle for the MBM communication interface (number of the serial interface), Slave address, Modbus function code, start address and item count via the console */ MBM_ParseRespErrCRC(aResponse, MB_CRC, iLen); #log("MBM received CRC-Error from IF# %d, Slave:%d, FC:%d, StartAddr:%d, ItemCnt:%d", handle, MB_CRC.iSlave, MB_CRC.iFC, MB_CRC.iStartAddr, MB_CRC.iItemCount); } case MBM_ERROR_TIMEOUT: // timeout response { new MB_timeout[TMBM_Timeout_Response]; // structure for timeout response data /* Extracts the information from the "Timeout response" and issues handle for the MBM communication interface (number of the serial interface), Slave address, Modbus function code, start address and item count via the console */ MBM_ParseRespErrTimeout(aResponse, MB_timeout, iLen); #log("MBM timeout from IF# %d, Slave:%d, FC:%d, StartAddr:%d, ItemCnt:%d", handle, MB_timeout.iSlave, MB_timeout.iFC, MB_timeout.iStartAddr, MB_timeout.iItemCount); } } } /* 1 sec. timer is used for the general program sequence */ #callback MainTimer() { // issue state of read timer counter to console #watch("Rx-Timer=%d", readTimer); // When the counter counting down the sec. to the next read out of the Modbus input registers has expired -> if(readTimer <= 0) { // Read request for "REG_COUNT" input registers starting at reg "REG_START_ADDRESS" from slave "SLAVE_ADDRESS" catch(MBM_Read(hMBM1, SLAVE_ADDRESS, MBM_READ_INPUT_REGISTERS, REG_START_ADDRESS, REG_COUNT)); readTimer = READ_INTERVAL; // Resets counter var. to defined read intervall } readTimer--; // Counter counting down the sec. to the next read out } /** * Function that is called up when the device has been prepared for the start of the application by the * "salve" function. I.e. the device is ready for proceeding with the application initialization */ #callback appInit() { // Inits the MBM interface catch(MBM_Init(hMBM1, PORT, BAUDRATE, MODE, MBM_TYPE_RTU)); // Initialisation of a cyclic 1 sec. timer setInterval(MainTimer, 1000); } main() { salve( appInit); // Prepares device for application start (enable extended // debug interface, increase console buffer, say hello) }
    Modbus TCP Example:
    /* Software setup */ const { READ_INTERVAL = 10, // Read interval [sec] SLAVE_ADDRESS = 1, // Adress of the Modbus Slaver (1-247) REG_START_ADDRESS = 0, // Start address of requested data (0 - 65535) REG_COUNT = 3, // Number of Modbus registers to be read out (1-125) } /* Hardware setup */ static sLAN_Setup[TMBM_LANSetup] = [ {192, 168, 10, 101}, /* dummy local IP Address */ {255, 255, 255, 0}, /* dummy SubnetMask Address */ {192, 168, 10, 1}, /* dummy Gateway Address */ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*Mac address, if set to 0 the internal stored mac is used*/ ]; new DeviceIp{} = {192, 168, 10, 100}; //Ip address of the Modbus Slave /* Handle for the MBM-Interface */ new hMBM1; /* Global variables for the remaining time until certain actions are triggered */ new readTimer = READ_INTERVAL; // Sec. until the next read out of the Modbus input registers /* Modbus callback function */ MBM_EvtResponse(handle, iResult, aResponse{}, iLen) { switch(iResult) // Switch the response type { case MBM_OK: // Valid response { new MB_response[TMBM_Ok_Response]; // Structure for valid response data /* Extracts the information from the "Response Ok" and issues handle for the MBM communication interface (number of the serial interface), Slave address, Modbus function code, start address, item count and byte count via the console */ MBM_ParseRespOK(aResponse, MB_response, iLen); #log("MBM received valid response from IF#%d, Slave:%d, FC:%d, StartAddr:%d, ItemCnt:%d, ByteCnt:%d bytes", handle, MB_response.iSlave, MB_response.iFC, MB_response.iStartAddr, MB_response.iItemCount, MB_response.iCount); if(MB_response.iCount>0) // If response includes data { // For the 3 Modbus input registers // Note: A Modbus input register value occupies two bytes in the playload data buffer of the response data for(new i=0; i<(MB_response.iCount);i=i+2) { new iVal; // Temporary memory for the value of an Modbus input register // unpack value from received payload data buffer and issue via console rM2M_Pack(MB_response.payload, i, iVal, RM2M_PACK_GET | RM2M_PACK_BE | RM2M_PACK_S16); #log("Value: %d", iVal); } } } case MBM_ERROR_EXCEPTION: // exception response { new MB_exception[TMBM_Exception_Response]; // structure for exception response data /* Extracts the information from the "Exception response" and issues handle for the MBM communication interface (number of the serial interface), Slave address, Modbus function code, start address, item count and exception code via the console */ MBM_ParseRespErrException(aResponse, MB_exception, iLen); #log("MBM received error exception from IF#%d, Slave:%d, FC:%d, StartAddr:%d, ItemCnt:%d Exception:%d", handle, MB_exception.iSlave, MB_exception.iFC, MB_exception.iStartAddr, MB_exception.iItemCount, MB_exception.iExceptioncode); } case MBM_ERROR_TIMEOUT: // timeout response { new MB_timeout[TMBM_Timeout_Response]; // structure for timeout response data /* Extracts the information from the "Timeout response" and issues handle for the MBM communication interface (number of the serial interface), Slave address, Modbus function code, start address and item count via the console */ MBM_ParseRespErrTimeout(aResponse, MB_timeout, iLen); #log("MBM timeout from IF# %d, Slave:%d, FC:%d, StartAddr:%d, ItemCnt:%d", handle, MB_timeout.iSlave, MB_timeout.iFC, MB_timeout.iStartAddr, MB_timeout.iItemCount); } } } /* 1 sec. timer is used for the general program sequence */ #callback MainTimer() { new iState, iResult; iResult = MBM_TCP_GetConnectionState(hMBM1, SLAVE_ADDRESS, iState) #watch("State=%d", iState) if((iResult >= OK) && (iState != MBM_TCP_STATE_CONNECTED)) return; // issue state of read timer counter to console #watch("Rx-Timer=%d", readTimer); // When the counter counting down the sec. to the next read out of the Modbus input registers has expired -> if(readTimer <= 0) { // Read request for "REG_COUNT" input registers starting at reg "REG_START_ADDRESS" from slave "SLAVE_ADDRESS" catch(MBM_Read(hMBM1, SLAVE_ADDRESS, MBM_READ_INPUT_REGISTERS, REG_START_ADDRESS, REG_COUNT)); readTimer = READ_INTERVAL; // Resets counter var. to defined read intervall } readTimer--; // Counter counting down the sec. to the next read out } /** * Function that is called up when the device has been prepared for the start of the application by the * "salve" function. I.e. the device is ready for proceeding with the application initialization */ #callback appInit() { // Inits the MBM interface catch(MBM_TCP_Init(hMBM1, MBM_INTERFACE_LAN_1, sLAN_Setup)); MBM_TCP_Connect(hMBM1, SLAVE_ADDRESS, DeviceIp); setInterval(MainTimer, 1000); } main() { salve( appInit); // Prepares device for application start (enable extended // debug interface, increase console buffer, say hello) }

    M23X:

    Abstract:
    This library provides functions to enable Modbus Master communication.
  • RTU or ASCII mode via serial interface.
  • TCP mode via LAN interface.

  • Supported rapidM2M devices and interfaces:
    • rapidM2M C3xx (RTU and ASCII mode):
      • RS232
      • RS485

    Supported rapidM2M hardware platforms and interfaces:
    • rapidM2M EasyIoT (RTU and ASCII mode):
      • RS232
      • RS485

    • rapidM2M M2/M23 (RTU and ASCII mode):
      • 2x RS232 (UART0/1 + ext. converter for example MAX232)
      • 2x RS485 (SPI + ext. converter SC16IS741 + ext. converter for example LTC2862)
    • Note: 1 GPIO and 1 IRQ pin are required per RS485 interface
    • rapidM2M M2/M23 PoC Shield LAN (TCP mode):
      • 1x LAN (Wiznet W5200 via w5200-microtronics library, SPI0 with additional control GPIOs)

    Supported Modbus function codes
    • FC1 - Read coil
    • FC2 - Read discrete input
    • FC3 - Read holding registers
    • FC4 - Read input registers
    • FC5 - Write single coil
    • FC6 - Write single holding registers
    • FC15 - Write multiple coils
    • FC16 - Write multiple holding registers

    Note: Currently only 1 Modbus-Master - Instance per device is supported.
    Config:
    rapidM2M M2/M23 (RS232 interfaces only):
    No library configuration needed.

    rapidM2M M2/M23 (RS485 interfaces are required):
    To be able to use the RS485 interfaces, add the following block to the main.dde file.
    /** ---------------------------------------------------------------------------- * modbus-master-mt: RS485 interface Config * ----------------------------------------------------------------------------- * * Use this block to specify which pins of the rapidM2M M2/M23 the up to two SC16IS741 * (which are used to realize the RS485 interfaces) are connected to. * * -1: not in use * >=0: SPI interface that should be used (0 to DP_SPI_CNT-1) * GPIO pin that should be used (0 to DP_GPIO_CNT-1) * Interrupt pin that should be used (0 to DP_IRQ-1) * Note: If MBM_PIN_CSx is set to >=0 (i.e. SC16IS741 channel x should be used), * the corresponding MBM_PIN_IRQx must also be set >=0. */ #define MBM_PORT_SPI 0 // SC16IS741: SPI interface that should be used #define MBM_PIN_CS0 -1 // SC16IS741: GPIO pin for CS signal of Channel 0 #define MBM_PIN_CS1 -1 // SC16IS741: GPIO pin for CS signal of Channel 1 #define MBM_PIN_IRQ0 -1 // SC16IS741: Interrupt pin for Channel 0 #define MBM_PIN_IRQ1 -1 // SC16IS741: Interrupt pin for Channel 1 #define MBM_PIN_RESET -1 // SC16IS741: GPIO pin for chip hardware reset

    rapidM2M C3xx:
    To enable the MBM Library, add the following blocks to the main.dde file.
    This both blocks must be defined in order to use the library.
    /** ---------------------------------------------------------------------------- * rapidm2m-c3xx-base: rapidM2M C3xx Config * ----------------------------------------------------------------------------- * * Use this block to enable the callback functions for the features (provided by the IO Controller) which you want to use: * * 0: disables all callback functions for a specific feature * 1: only enables the essential callback functions for a specific feature * 2: enables all callback functions for a specific feature */ #define IOCTRL_COMMON 1 // Generell Information regarding the IO Controller #define IOCTRL_UI 0 // Universal inputs #define IOCTRL_RS232 2 // RS232 Interface #define IOCTRL_RS485 2 // RS485 Interface #define IOCTRL_CAN 0 // CAN Interface #define IOCTRL_DIGOUT 0 // Digital Outputs #define IOCTRL_SHUTDOWN 0 // Shutdown Handling /** ---------------------------------------------------------------------------- * modbus-master-mt: Library Config * ----------------------------------------------------------------------------- * * This block must be defined in order to use the library. * * Callback functions config (applies to MBM_COMMON) * 0: disables all callback functions for a specific feature * 1: enables the callback functions for a specific feature * Note: IOCTRL_COMMON must be set to at least 1 in any case * * RSxxx Interfaces config (applies to MBM_USE_RSxxx) * 0: the interface is available for the user program * 1: the interface is used by the MBM library * Note: If MBM_USE_RSxx is set to 1 (interface should be used) * the corresponding IOCTRL_RSxx must be set to 2 */ #define MBM_COMMON 0 // Generell Information regarding the IO Controller #define MBM_USE_RS232 1 // RS232 Interface #define MBM_USE_RS485 1 // RS485 Interface

    General information regarding the IO Controller

    MBM_COMMON >= 1
  • MBM_ReadyCallback
  • MBM_SysValuesCallback
  • Interface_Selection:
    Depending on the device profile (i.e. the rapidM2M hardware platform used) you have selected in the project settings and the rapidM2M devices (e.g. rapidM2M C3xx) you are using, different interfaces are supported.

    The interface can be selected by calling the MBM_Init() function for RTU or ASCII mode or MBM_TCP_Init() for TCP mode. This function must be called for a specific interface. If it is not required anymore, it is recommended to call MBM_Close(). Re-opening of the interface is performed by another call of MBM_Init()/MBM_TCP_Init().

    rapidM2M M2/M23 RTU/ASCII:
    new hMBM1; /* Inits the MBM_INTERFACE of the device. In this case the first RS232 interface is used */ if(MBM_Init(hMBM1, MBM_INTERFACE_RS232_1, BAUDRATE, MODE, MBM_TYPE_RTU) < OK) { // Error, selected interface probably not available on this device }

    rapidM2M C3xx:
    For rapidM2M C3xx device, additionally the two blocks described under "Library configuration" (see Config) have to be added into the main.dde file in order to activate the relevant callback functions of the relevant serial interface.
    new hMBM1; /* Inits the MBM_INTERFACE of the device. In this case the first RS485 interface is used */ if(MBM_Init(hMBM1, MBM_INTERFACE_RS232_1, BAUDRATE, MODE, MBM_TYPE_RTU) < OK) { // Error, selected interface probably not available on this device }

    How_to_use:
    /* Hardware setup */ const { PORT = MBM_INTERFACE_RS232_1, // The first RS232-interface should be used. BAUDRATE = 57600, // Baud rate to be used // MBM interface configuration (e.g 7/8 Data-bit, Stopbit yes/no, Parity yes/no, etc) MODE = MBM_MODE_1_STOPBIT | MBM_MODE_PARITY_NONE | MBM_MODE_8_DATABIT | MBM_MODE_HALF_DUPLEX, } /* Software setup */ const { READ_INTERVAL = 5, // Read interval [sec] SLAVE_ADDRESS = 1, // Adress of the Modbus Slaver (1-247) REG_START_ADDRESS = 0, // Start address of requested data (0 - 65535) REG_COUNT = 3, // Number of Modbus registers to be read out (1-125) } /* Handle for the MBM-Interface */ new hMBM1; /* Global variables for the remaining time until certain actions are triggered */ new readTimer = READ_INTERVAL; // Sec. until the next read out of the Modbus input registers /* Modbus callback function */ MBM_EvtResponse(handle, iResult, aResponse{}, iLen) { switch(iResult) // Switch the response type { case MBM_OK: // Valid response { new MB_response[TMBM_Ok_Response]; // Structure for valid response data /* Extracts the information from the "Response Ok" and issues handle for the MBM communication interface (number of the serial interface), Slave address, Modbus function code, start address, item count and byte count via the console */ MBM_ParseRespOK(aResponse, MB_response, iLen); #log("MBM received valid response from IF#%d, Slave:%d, FC:%d, StartAddr:%d, ItemCnt:%d, ByteCnt:%d bytes", handle, MB_response.iSlave, MB_response.iFC, MB_response.iStartAddr, MB_response.iItemCount, MB_response.iCount); if(MB_response.iCount>0) // If response includes data { // For the 3 Modbus input registers // Note: A Modbus input register value occupies two bytes in the playload data buffer of the response data for(new i=0; i<(MB_response.iCount);i=i+2) { new iVal; // Temporary memory for the value of an Modbus input register // unpack value from received payload data buffer and issue via console rM2M_Pack(MB_response.payload, i, iVal, RM2M_PACK_GET | RM2M_PACK_BE | RM2M_PACK_S16); #log("Value: %d", iVal); } } } case MBM_ERROR_EXCEPTION: // exception response { new MB_exception[TMBM_Exception_Response]; // structure for exception response data /* Extracts the information from the "Exception response" and issues handle for the MBM communication interface (number of the serial interface), Slave address, Modbus function code, exception code, start address and item count via the console */ MBM_ParseRespErrException(aResponse, MB_exception, iLen); #log("MBM received error exception from IF#%d, Slave:%d, FC:%d, StartAddr:%d, ItemCnt:%d, Exception:%d", handle, MB_exception.iSlave, MB_exception.iFC, MB_exception.iStartAddr, MB_exception.iItemCount, MB_exception.iExceptioncode); } case MBM_ERROR_CRC: // CRC-error { new MB_CRC[TMBM_CRC_Response]; // structure for CRC response data /* Extracts the information from the "CRC-error response" and issues handle for the MBM communication interface (number of the serial interface), Slave address, Modbus function code, start address and item count via the console */ MBM_ParseRespErrCRC(aResponse, MB_CRC, iLen); #log("MBM received CRC-Error from IF# %d, Slave:%d, FC:%d, StartAddr:%d, ItemCnt:%d", handle, MB_CRC.iSlave, MB_CRC.iFC, MB_CRC.iStartAddr, MB_CRC.iItemCount); } case MBM_ERROR_TIMEOUT: // timeout response { new MB_timeout[TMBM_Timeout_Response]; // structure for timeout response data /* Extracts the information from the "Timeout response" and issues handle for the MBM communication interface (number of the serial interface), Slave address, Modbus function code, start address and item count via the console */ MBM_ParseRespErrTimeout(aResponse, MB_timeout, iLen); #log("MBM timeout from IF# %d, Slave:%d, FC:%d, StartAddr:%d, ItemCnt:%d", handle, MB_timeout.iSlave, MB_timeout.iFC, MB_timeout.iStartAddr, MB_timeout.iItemCount); } } } /* 1 sec. timer is used for the general program sequence */ #callback MainTimer() { // issue state of read timer counter to console #watch("Rx-Timer=%d", readTimer); // When the counter counting down the sec. to the next read out of the Modbus input registers has expired -> if(readTimer <= 0) { // Read request for "REG_COUNT" input registers starting at reg "REG_START_ADDRESS" from slave "SLAVE_ADDRESS" catch(MBM_Read(hMBM1, SLAVE_ADDRESS, MBM_READ_INPUT_REGISTERS, REG_START_ADDRESS, REG_COUNT)); readTimer = READ_INTERVAL; // Resets counter var. to defined read intervall } readTimer--; // Counter counting down the sec. to the next read out } /** * Function that is called up when the device has been prepared for the start of the application by the * "salve" function. I.e. the device is ready for proceeding with the application initialization */ #callback appInit() { // Inits the MBM interface catch(MBM_Init(hMBM1, PORT, BAUDRATE, MODE, MBM_TYPE_RTU)); // Initialisation of a cyclic 1 sec. timer setInterval(MainTimer, 1000); } main() { salve( appInit); // Prepares device for application start (enable extended // debug interface, increase console buffer, say hello) }
    Modbus TCP Example:
    /* Software setup */ const { READ_INTERVAL = 10, // Read interval [sec] SLAVE_ADDRESS = 1, // Adress of the Modbus Slaver (1-247) REG_START_ADDRESS = 0, // Start address of requested data (0 - 65535) REG_COUNT = 3, // Number of Modbus registers to be read out (1-125) } /* Hardware setup */ static sLAN_Setup[TMBM_LANSetup] = [ {192, 168, 10, 101}, /* dummy local IP Address */ {255, 255, 255, 0}, /* dummy SubnetMask Address */ {192, 168, 10, 1}, /* dummy Gateway Address */ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*Mac address, if set to 0 the internal stored mac is used*/ ]; new DeviceIp{} = {192, 168, 10, 100}; //Ip address of the Modbus Slave /* Handle for the MBM-Interface */ new hMBM1; /* Global variables for the remaining time until certain actions are triggered */ new readTimer = READ_INTERVAL; // Sec. until the next read out of the Modbus input registers /* Modbus callback function */ MBM_EvtResponse(handle, iResult, aResponse{}, iLen) { switch(iResult) // Switch the response type { case MBM_OK: // Valid response { new MB_response[TMBM_Ok_Response]; // Structure for valid response data /* Extracts the information from the "Response Ok" and issues handle for the MBM communication interface (number of the serial interface), Slave address, Modbus function code, start address, item count and byte count via the console */ MBM_ParseRespOK(aResponse, MB_response, iLen); #log("MBM received valid response from IF#%d, Slave:%d, FC:%d, StartAddr:%d, ItemCnt:%d, ByteCnt:%d bytes", handle, MB_response.iSlave, MB_response.iFC, MB_response.iStartAddr, MB_response.iItemCount, MB_response.iCount); if(MB_response.iCount>0) // If response includes data { // For the 3 Modbus input registers // Note: A Modbus input register value occupies two bytes in the playload data buffer of the response data for(new i=0; i<(MB_response.iCount);i=i+2) { new iVal; // Temporary memory for the value of an Modbus input register // unpack value from received payload data buffer and issue via console rM2M_Pack(MB_response.payload, i, iVal, RM2M_PACK_GET | RM2M_PACK_BE | RM2M_PACK_S16); #log("Value: %d", iVal); } } } case MBM_ERROR_EXCEPTION: // exception response { new MB_exception[TMBM_Exception_Response]; // structure for exception response data /* Extracts the information from the "Exception response" and issues handle for the MBM communication interface (number of the serial interface), Slave address, Modbus function code, start address, item count and exception code via the console */ MBM_ParseRespErrException(aResponse, MB_exception, iLen); #log("MBM received error exception from IF#%d, Slave:%d, FC:%d, StartAddr:%d, ItemCnt:%d Exception:%d", handle, MB_exception.iSlave, MB_exception.iFC, MB_exception.iStartAddr, MB_exception.iItemCount, MB_exception.iExceptioncode); } case MBM_ERROR_TIMEOUT: // timeout response { new MB_timeout[TMBM_Timeout_Response]; // structure for timeout response data /* Extracts the information from the "Timeout response" and issues handle for the MBM communication interface (number of the serial interface), Slave address, Modbus function code, start address and item count via the console */ MBM_ParseRespErrTimeout(aResponse, MB_timeout, iLen); #log("MBM timeout from IF# %d, Slave:%d, FC:%d, StartAddr:%d, ItemCnt:%d", handle, MB_timeout.iSlave, MB_timeout.iFC, MB_timeout.iStartAddr, MB_timeout.iItemCount); } } } /* 1 sec. timer is used for the general program sequence */ #callback MainTimer() { new iState, iResult; iResult = MBM_TCP_GetConnectionState(hMBM1, SLAVE_ADDRESS, iState) #watch("State=%d", iState) if((iResult >= OK) && (iState != MBM_TCP_STATE_CONNECTED)) return; // issue state of read timer counter to console #watch("Rx-Timer=%d", readTimer); // When the counter counting down the sec. to the next read out of the Modbus input registers has expired -> if(readTimer <= 0) { // Read request for "REG_COUNT" input registers starting at reg "REG_START_ADDRESS" from slave "SLAVE_ADDRESS" catch(MBM_Read(hMBM1, SLAVE_ADDRESS, MBM_READ_INPUT_REGISTERS, REG_START_ADDRESS, REG_COUNT)); readTimer = READ_INTERVAL; // Resets counter var. to defined read intervall } readTimer--; // Counter counting down the sec. to the next read out } /** * Function that is called up when the device has been prepared for the start of the application by the * "salve" function. I.e. the device is ready for proceeding with the application initialization */ #callback appInit() { // Inits the MBM interface catch(MBM_TCP_Init(hMBM1, MBM_INTERFACE_LAN_1, sLAN_Setup)); MBM_TCP_Connect(hMBM1, SLAVE_ADDRESS, DeviceIp); setInterval(MainTimer, 1000); } main() { salve( appInit); // Prepares device for application start (enable extended // debug interface, increase console buffer, say hello) }

    M2EASYIOT:

    Abstract:
    This library provides functions to enable Modbus Master communication.
  • RTU or ASCII mode via serial interface.
  • TCP mode via LAN interface.

  • Supported rapidM2M devices and interfaces:
    • rapidM2M C3xx (RTU and ASCII mode):
      • RS232
      • RS485

    Supported rapidM2M hardware platforms and interfaces:
    • rapidM2M EasyIoT (RTU and ASCII mode):
      • RS232
      • RS485

    • rapidM2M M2/M23 (RTU and ASCII mode):
      • 2x RS232 (UART0/1 + ext. converter for example MAX232)
      • 2x RS485 (SPI + ext. converter SC16IS741 + ext. converter for example LTC2862)
    • Note: 1 GPIO and 1 IRQ pin are required per RS485 interface
    • rapidM2M M2/M23 PoC Shield LAN (TCP mode):
      • 1x LAN (Wiznet W5200 via w5200-microtronics library, SPI0 with additional control GPIOs)

    Supported Modbus function codes
    • FC1 - Read coil
    • FC2 - Read discrete input
    • FC3 - Read holding registers
    • FC4 - Read input registers
    • FC5 - Write single coil
    • FC6 - Write single holding registers
    • FC15 - Write multiple coils
    • FC16 - Write multiple holding registers

    Note: Currently only 1 Modbus-Master - Instance per device is supported.
    Interface_Selection:
    Depending on the device profile (i.e. the rapidM2M hardware platform used) you have selected in the project settings, different interfaces are supported.

    The interface can be selected by calling the MBM_Init() function. This function must be called for a specific interface. If it is not required anymore, it is recommended to call MBM_Close(). Re-opening of the interface is performed by another call of MBM_Init().

    rapidM2M EasyIoT:
    new hMBM1; /* Inits the MBM_INTERFACE of the device. In this case the first RS232 interface is used */ if(MBM_Init(hMBM1, MBM_INTERFACE_RS232_1, BAUDRATE, MODE, MBM_TYPE_RTU) < OK) { // Error, selected interface probably not available on this device }

    How_to_use:
    /* Hardware setup */ const { PORT = MBM_INTERFACE_RS232_1, // The first RS232-interface should be used. BAUDRATE = 57600, // Baud rate to be used // MBM interface configuration (e.g 7/8 Data-bit, Stopbit yes/no, Parity yes/no, etc) MODE = MBM_MODE_1_STOPBIT | MBM_MODE_PARITY_NONE | MBM_MODE_8_DATABIT | MBM_MODE_HALF_DUPLEX, } /* Software setup */ const { READ_INTERVAL = 5, // Read interval [sec] SLAVE_ADDRESS = 1, // Adress of the Modbus Slaver (1-247) REG_START_ADDRESS = 0, // Start address of requested data (0 - 65535) REG_COUNT = 3, // Number of Modbus registers to be read out (1-125) } /* Handle for the MBM-Interface */ new hMBM1; /* Global variables for the remaining time until certain actions are triggered */ new readTimer = READ_INTERVAL; // Sec. until the next read out of the Modbus input registers /* Modbus callback function */ MBM_EvtResponse(handle, iResult, aResponse{}, iLen) { switch(iResult) // Switch the response type { case MBM_OK: // Valid response { new MB_response[TMBM_Ok_Response]; // Structure for valid response data /* Extracts the information from the "Response Ok" and issues handle for the MBM communication interface (number of the serial interface), Slave address, Modbus function code, start address, item count and byte count via the console */ MBM_ParseRespOK(aResponse, MB_response, iLen); #log("MBM received valid response from IF#%d, Slave:%d, FC:%d, StartAddr:%d, ItemCnt:%d, ByteCnt:%d bytes", handle, MB_response.iSlave, MB_response.iFC, MB_response.iStartAddr, MB_response.iItemCount, MB_response.iCount); if(MB_response.iCount>0) // If response includes data { // For the 3 Modbus input registers // Note: A Modbus input register value occupies two bytes in the playload data buffer of the response data for(new i=0; i<(MB_response.iCount);i=i+2) { new iVal; // Temporary memory for the value of an Modbus input register // unpack value from received payload data buffer and issue via console rM2M_Pack(MB_response.payload, i, iVal, RM2M_PACK_GET | RM2M_PACK_BE | RM2M_PACK_S16); #log("Value: %d", iVal); } } } case MBM_ERROR_EXCEPTION: // exception response { new MB_exception[TMBM_Exception_Response]; // structure for exception response data /* Extracts the information from the "Exception response" and issues handle for the MBM communication interface (number of the serial interface), Slave address, Modbus function code, exception code, start address and item count via the console */ MBM_ParseRespErrException(aResponse, MB_exception, iLen); #log("MBM received error exception from IF#%d, Slave:%d, FC:%d, StartAddr:%d, ItemCnt:%d, Exception:%d", handle, MB_exception.iSlave, MB_exception.iFC, MB_exception.iStartAddr, MB_exception.iItemCount, MB_exception.iExceptioncode); } case MBM_ERROR_CRC: // CRC-error { new MB_CRC[TMBM_CRC_Response]; // structure for CRC response data /* Extracts the information from the "CRC-error response" and issues handle for the MBM communication interface (number of the serial interface), Slave address, Modbus function code, start address and item count via the console */ MBM_ParseRespErrCRC(aResponse, MB_CRC, iLen); #log("MBM received CRC-Error from IF# %d, Slave:%d, FC:%d, StartAddr:%d, ItemCnt:%d", handle, MB_CRC.iSlave, MB_CRC.iFC, MB_CRC.iStartAddr, MB_CRC.iItemCount); } case MBM_ERROR_TIMEOUT: // timeout response { new MB_timeout[TMBM_Timeout_Response]; // structure for timeout response data /* Extracts the information from the "Timeout response" and issues handle for the MBM communication interface (number of the serial interface), Slave address, Modbus function code, start address and item count via the console */ MBM_ParseRespErrTimeout(aResponse, MB_timeout, iLen); #log("MBM timeout from IF# %d, Slave:%d, FC:%d, StartAddr:%d, ItemCnt:%d", handle, MB_timeout.iSlave, MB_timeout.iFC, MB_timeout.iStartAddr, MB_timeout.iItemCount); } } } /* 1 sec. timer is used for the general program sequence */ #callback MainTimer() { // issue state of read timer counter to console #watch("Rx-Timer=%d", readTimer); // When the counter counting down the sec. to the next read out of the Modbus input registers has expired -> if(readTimer <= 0) { // Read request for "REG_COUNT" input registers starting at reg "REG_START_ADDRESS" from slave "SLAVE_ADDRESS" catch(MBM_Read(hMBM1, SLAVE_ADDRESS, MBM_READ_INPUT_REGISTERS, REG_START_ADDRESS, REG_COUNT)); readTimer = READ_INTERVAL; // Resets counter var. to defined read intervall } readTimer--; // Counter counting down the sec. to the next read out } /** * Function that is called up when the device has been prepared for the start of the application by the * "salve" function. I.e. the device is ready for proceeding with the application initialization */ #callback appInit() { // Inits the MBM interface catch(MBM_Init(hMBM1, PORT, BAUDRATE, MODE, MBM_TYPE_RTU)); // Initialisation of a cyclic 1 sec. timer setInterval(MainTimer, 1000); } main() { salve( appInit); // Prepares device for application start (enable extended // debug interface, increase console buffer, say hello) }
    Modbus TCP Example:
    /* Software setup */ const { READ_INTERVAL = 10, // Read interval [sec] SLAVE_ADDRESS = 1, // Adress of the Modbus Slaver (1-247) REG_START_ADDRESS = 0, // Start address of requested data (0 - 65535) REG_COUNT = 3, // Number of Modbus registers to be read out (1-125) } /* Hardware setup */ static sLAN_Setup[TMBM_LANSetup] = [ {192, 168, 10, 101}, /* dummy local IP Address */ {255, 255, 255, 0}, /* dummy SubnetMask Address */ {192, 168, 10, 1}, /* dummy Gateway Address */ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*Mac address, if set to 0 the internal stored mac is used*/ ]; new DeviceIp{} = {192, 168, 10, 100}; //Ip address of the Modbus Slave /* Handle for the MBM-Interface */ new hMBM1; /* Global variables for the remaining time until certain actions are triggered */ new readTimer = READ_INTERVAL; // Sec. until the next read out of the Modbus input registers /* Modbus callback function */ MBM_EvtResponse(handle, iResult, aResponse{}, iLen) { switch(iResult) // Switch the response type { case MBM_OK: // Valid response { new MB_response[TMBM_Ok_Response]; // Structure for valid response data /* Extracts the information from the "Response Ok" and issues handle for the MBM communication interface (number of the serial interface), Slave address, Modbus function code, start address, item count and byte count via the console */ MBM_ParseRespOK(aResponse, MB_response, iLen); #log("MBM received valid response from IF#%d, Slave:%d, FC:%d, StartAddr:%d, ItemCnt:%d, ByteCnt:%d bytes", handle, MB_response.iSlave, MB_response.iFC, MB_response.iStartAddr, MB_response.iItemCount, MB_response.iCount); if(MB_response.iCount>0) // If response includes data { // For the 3 Modbus input registers // Note: A Modbus input register value occupies two bytes in the playload data buffer of the response data for(new i=0; i<(MB_response.iCount);i=i+2) { new iVal; // Temporary memory for the value of an Modbus input register // unpack value from received payload data buffer and issue via console rM2M_Pack(MB_response.payload, i, iVal, RM2M_PACK_GET | RM2M_PACK_BE | RM2M_PACK_S16); #log("Value: %d", iVal); } } } case MBM_ERROR_EXCEPTION: // exception response { new MB_exception[TMBM_Exception_Response]; // structure for exception response data /* Extracts the information from the "Exception response" and issues handle for the MBM communication interface (number of the serial interface), Slave address, Modbus function code, start address, item count and exception code via the console */ MBM_ParseRespErrException(aResponse, MB_exception, iLen); #log("MBM received error exception from IF#%d, Slave:%d, FC:%d, StartAddr:%d, ItemCnt:%d Exception:%d", handle, MB_exception.iSlave, MB_exception.iFC, MB_exception.iStartAddr, MB_exception.iItemCount, MB_exception.iExceptioncode); } case MBM_ERROR_TIMEOUT: // timeout response { new MB_timeout[TMBM_Timeout_Response]; // structure for timeout response data /* Extracts the information from the "Timeout response" and issues handle for the MBM communication interface (number of the serial interface), Slave address, Modbus function code, start address and item count via the console */ MBM_ParseRespErrTimeout(aResponse, MB_timeout, iLen); #log("MBM timeout from IF# %d, Slave:%d, FC:%d, StartAddr:%d, ItemCnt:%d", handle, MB_timeout.iSlave, MB_timeout.iFC, MB_timeout.iStartAddr, MB_timeout.iItemCount); } } } /* 1 sec. timer is used for the general program sequence */ #callback MainTimer() { new iState, iResult; iResult = MBM_TCP_GetConnectionState(hMBM1, SLAVE_ADDRESS, iState) #watch("State=%d", iState) if((iResult >= OK) && (iState != MBM_TCP_STATE_CONNECTED)) return; // issue state of read timer counter to console #watch("Rx-Timer=%d", readTimer); // When the counter counting down the sec. to the next read out of the Modbus input registers has expired -> if(readTimer <= 0) { // Read request for "REG_COUNT" input registers starting at reg "REG_START_ADDRESS" from slave "SLAVE_ADDRESS" catch(MBM_Read(hMBM1, SLAVE_ADDRESS, MBM_READ_INPUT_REGISTERS, REG_START_ADDRESS, REG_COUNT)); readTimer = READ_INTERVAL; // Resets counter var. to defined read intervall } readTimer--; // Counter counting down the sec. to the next read out } /** * Function that is called up when the device has been prepared for the start of the application by the * "salve" function. I.e. the device is ready for proceeding with the application initialization */ #callback appInit() { // Inits the MBM interface catch(MBM_TCP_Init(hMBM1, MBM_INTERFACE_LAN_1, sLAN_Setup)); MBM_TCP_Connect(hMBM1, SLAVE_ADDRESS, DeviceIp); setInterval(MainTimer, 1000); } main() { salve( appInit); // Prepares device for application start (enable extended // debug interface, increase console buffer, say hello) }

    Basic

    M22X:

    MBM_INTERFACE_x: s32

    Interfaces of the device that can be used for Modbus Master communication


    rapidM2M M2/M23:
    MBM_INTERFACE_NONE - No interface
    MBM_INTERFACE_RS232_1 - first RS232 Interface (Modbus RTU/ASCII)
    MBM_INTERFACE_RS485_1 - first RS485 Interface (Modbus RTU/ASCII)
    MBM_INTERFACE_RS232_2 - second RS232 Interface (Modbus RTU/ASCII)
    MBM_INTERFACE_RS485_2 - second RS485 Interface (Modbus RTU/ASCII)
    MBM_INTERFACE_LAN_1 - first LAN interface (Modbus TCP)

    rapidM2M C3xx:
    MBM_INTERFACE_NONE - No interface
    MBM_INTERFACE_RS232_1 - first RS232 Interface (Modbus RTU/ASCII)
    MBM_INTERFACE_RS485_1 - first RS485 Interface (Modbus RTU/ASCII)
    MBM_MODE_xxx:

    MBM Interface Configuration Bits (Bitmask) for serial interfaces

    Number of stop bits
    MBM_MODE_1_STOPBIT - 1 stop bit
    MBM_MODE_2_STOPBIT - 2 stop bits
    Parity
    MBM_MODE_PARITY_NONE - no parity
    MBM_MODE_PARITY_ODD - odd parity
    MBM_MODE_PARITY_EVEN - even parity
    Number of data bits
    MBM_MODE_7_DATABIT - 7 data bits
    MBM_MODE_8_DATABIT - 8 data bits
    Flow control
    MBM_MODE_FLOW_NONE - no flow control
    MBM_MODE_FLOW_RTSCTS - RTS/CTS hand shake
    Duplex mode (RS232 Interface only)
    MBM_MODE_HALF_DUPLEX - half duplex mode
    MBM_MODE_FULL_DUPLEX - full duplex mode
    Termination (rapidM2M C3xx only)
    MBM_MODE_120_OHM_NONE - no load resistance
    MBM_MODE_120_OHM_ACT - 120Ω load resistance
    Biasing (rapidM2M C3xx only)
    MBM_MODE_BIAS_OFF - no biasing resistors
    MBM_MODE_BIAS_ON - biasing resistors activated
    MBM_TYPE_x: s32

    Modbus operating modes

    MBM_TYPE_RTU = 1 - Modbus RTU mode
    MBM_TYPE_ASCII = 2 - Modbus ASCII mode
    For Modbus ASCII mode the max. frame size is defined with 513 bytes according the Modbus specification. Therefore it might be necessary to increase the default buffer sizes to the following recommeded values. See also Advanced_Config.
  • MBM_MAX_MSGSIZE to 513 bytes
  • MBM_FC_R_x: s32

    Modbus read function codes

    MBM_READ_COILS = 01 (0x01) - Read Internal Bits or Physical Coils (Bit access)
    MBM_READ_DISCRETE_INPUTS = 02 (0x02) - Read Physical Discrete Inputs (Bit access)
    MBM_READ_HOLDING_REGISTERS = 03 (0x03) - Read Multiple Internal Registers or Physical Output Registers (16-bit access)
    MBM_READ_INPUT_REGISTERS = 04 (0x04) - Read Physical Input Registers (16-bit access)
    MBM_FC_W_x: s32

    Modbus write function codes

    MBM_FORCE_SINGLE_COIL = 05 (0x05) - Write Single Internal Bits or Physical Coils (Bit access)
    MBM_PRESET_SINGLE_REGISTER = 06 (0x06) - Write Single Internal Registers or Physical Output Registers (16-bit access)
    MBM_FORCE_MULTIPLE_COILS = 15 (0x0F) - Write Multiple Internal Bits or Physical Coils (Bit access)
    MBM_PRESET_MULTIPLE_REGISTERS = 16 (0x10) - Write Multiple Internal Registers or Physical Output Registers (16-bit access)
    MBM_STATE_x: s32

    Current operation state of the MBM interface

    MBM_STATE_IDLE = 0 - Idle
    MBM_STATE_BUSY = -3 - Busy
    MBM_RESULT_x: s32

    Possible responses to a Modbus R/W operation

    MBM_OK = 0 - valid data received from slave
    MBM_ERROR_EXCEPTION = -1 - exception response from slave
    MBM_ERROR_CRC = -2 - CRC-error
    MBM_ERROR_TIMEOUT = -3 - no response within defined timeout (defined by MBM_Init() )
    TMBM_Ok_Response:

    Information extracted from a "OK Response"

    iSlave:s32 - Slave address
    iFC:s32 - Modbus function code (see MBM_FC_R_x or MBM_FC_W_x)
  • MBM_READ_COILS
    • Each bit in the "payload{}" data buffer reflects the status of a coil (1 means "ON" and 0 means "OFF"). The LSB of the first byte in the "payload{}" data buffer reflects the status of the coil addressed in the request. The other coil states follow towards the MSB of this byte and from LSB to MSB in the subsequent bytes. If the number of coils requested was not a multiple of eight, the remaining bits in the final data byte are zero-padded (toward the MSB of the byte). The number of complete bytes in the "payload{}" data buffer is contained in "iCount".

  • MBM_READ_DISCRETE_INPUTS
    • Each bit in the "payload{}" data buffer reflects the status of a input (1 means "ON" and 0 means "OFF"). The LSB of the first byte in the "payload{}" data buffer reflects the status of the input addressed in the request. The other input states follow towards the MSB of this byte and from LSB to MSB in the subsequent bytes. If the number of input requested was not a multiple of eight, the remaining bits in the final data byte are zero-padded (toward the MSB of the byte). The number of complete bytes in the "payload{}" data buffer is contained in "iCount".

  • MBM_READ_HOLDING_REGISTERS
    • The "payload{}" data buffer contains two bytes per requested register, with the binary contents right justified within each byte. For each register the first byte contains the high-order bits, and the second contains the low-order bits (i.e. big endian format is used). "iCount" contains the number of bytes in the "payload{}" data buffer.

  • MBM_READ_INPUT_REGISTERS
    • The "payload{}" data buffer contains two bytes per requested input register, with the binary contents right justified within each byte. For each input register the first byte contains the high-order bits, and the second contains the low-order bits (i.e. big endian format is used). "iCount" contains the number of bytes in the "payload{}" data buffer.

  • MBM_FORCE_SINGLE_COIL
    • payload{} = null
      iCount = 0

  • MBM_PRESET_SINGLE_REGISTER
    • payload{} = null
      iCount = 0

  • MBM_FORCE_MULTIPLE_COILS
    • payload{} = null
      iCount = 0

  • MBM_PRESET_MULTIPLE_REGISTERS
    • payload{} = null
      iCount = 0
    iStartAddr:s32 - Start address of requested/written data
    iItemCount:s32 - Number of requested/written data items
    payload{}:u8 - Data buffer with received Modbus Data
    iCount:s32 - byte count
    TMBM_Exception_Response:

    Information extracted from a "Exception response"

    iSlave:s32 - Slave address
    iErrorcode:s32 - Error code from slave ( >= 0x80 )
    Corresponds to the function code of the faulty request with bit7 set (i.e. 0x80 | MBM_FC). See MBM_FC_R_x and MBM_FC_W_x for the possible function codes
    iExceptioncode:s32 - exception code from slave
    01 = ILLEGAL FUNCTION
    02 = ILLEGAL DATA ADDRESS
    03 = ILLEGAL DATA VALUE
    04 = SERVER DEVICE FAILURE
    05 = ACKNOWLEDGE
    06 = SERVER DEVICE BUSY
    08 = MEMORY PARITY ERROR
    10 = GATEWAY PATH UNAVAILABLE
    11 = GATEWAY TARGET DEVICE FAILED TO RESPOND
    iFC:s32 - Modbus function code (see MBM_FC_R_x or MBM_FC_W_x)
    iStartAddr:s32 - Start address of requested/written data
    iItemCount:s32 - Number of requested/written data items
    TMBM_Timeout_Response:

    Information extracted from a "Timeout response"

    iSlave:s32 - Slave address
    iFC:s32 - Modbus function code (see MBM_FC_R_x or MBM_FC_W_x)
    iStartAddr:s32 - Start address of requested/written data
    iItemCount:s32 - Number of requested/written data items
    TMBM_CRC_Response:

    Information extracted from a "CRC-error response"

    iSlave:s32 - Slave address
    iFC:s32 - Modbus function code (see MBM_FC_R_x or MBM_FC_W_x)
    iStartAddr:s32 - Start address of requested/written data
    iItemCount:s32 - Number of requested/written data items
    MBM_DATA_TYPE_x:

    Possible data types / Byte orders

    MBM_DATA_TYPE_BYTE - 8-bit unsigned
    MBM_DATA_TYPE_WORD - 16-bit unsigned
    MBM_DATA_TYPE_WORD_S - 16-bit signed
    MBM_DATA_TYPE_DWORD_S - 32-bit signed
    MBM_DATA_TYPE_FLOAT - 32-bit float

    MBM_DATA_TYPE_LE - Use little endian
    MBM_Init(&handle, iInterface, iBaudrate, iMode, iMBtype, iTimeout=1000)

    Initialize the MBM interface in RTU or ASCII mode

    (see Interface_Selection for more details)
    handle : s32 - Empty handle for a MBM communication interface
    iInterface : s32 - serial interface that should be used for the MBM communication (use MBM_INTERFACE_x)
    iBaudrate : s32 - Baud rate to be used
    iMode : s32 - MBM interface configuration (e.g 7/8 Data-bit, Stopbit yes/no, Parity yes/no, etc. use MBM_MODE_xxx)
    iMBtype : MBM_TYPE_x - Modbus operating mode (Modbus RTU / ASCII)
    iTimeout : s32 - Modbus timeout (i.e. max. slave response time)
    >=100 - Timeout [ms] (min = 100, max = 10000)
    returns : s32
    OK - if successful
    ERROR_FEATURE_LOCKED - Serial interface of the device is locked
    ERROR - If one of the following errors occurs
  • Interface is not supported
  • Interface already initialized
  • Invalid baudrate value
  • Invalid timeout value
  • Invalid MBM_TYPE selection
  • Invalid Rx/Tx buffer settings
  • SC16IS741 initialization failed
  • MBM_Read(handle, iSlave, iFC, iStartAddr, iItemCount=1)

    Send a read request to a Modbus slave

    handle : s32 - Handle of a MBM interface (Initialized by MBM_Init() )
    iSlave : s32 - Slave address (1 - 247)
    iFC : MBM_FC_R_x - Modbus function code
    iStartAddr : s32 - Start address of requested data (0 - 65535)
    iItemCount : s32 - Number of requested data items
    coils: 1 - 2000 coils
    registers: 1 - 125 registers
    returns : s32
    > = 0 - number of actually sent bytes (Read command sent to the Modbus slave)
    MBM_STATE_BUSY - Interface is currently busy
    ERROR_FEATURE_LOCKED - Serial interface of the device is locked
    ERROR - If one of the following errors occurs
  • Interface is not initialized
  • Invalid slave address value
  • Invalid function code value
  • Invalid start address value
  • Invalid coil/register count value
  • TCP: MBM_TCP_Connect() not yet called
  • MBM_Write(handle, iSlave, iFC, const data{}, iStartAddr, iItemCount=1)

    Write data to a Modbus slave

    handle : s32 - Handle of a MBM interface (Initialized by MBM_Init() )
    iSlave : s32 - Slave address (1 - 247)
    iFC : MBM_FC_W_x - Modbus function code
    data{} : u8 - Data buffer to write
    iStartAddr : s32 - Address from which to start writing the data (0 - 65535)
    iItemCount : s32 - Number of data items to be sent. Not needed for single item write operation.
    coils: 1 - 1968 coils
    registers: 1 - 123 registers
    returns : s32
    > = 0 - number of actually sent bytes
    MBM_STATE_BUSY - Interface is currently busy
    ERROR_FEATURE_LOCKED - Serial interface of the device is locked
    ERROR - If one of the following errors occurs
  • Interface is not initialized
  • Invalid slave address value
  • Invalid function code value
  • Invalid start address value
  • Invalid coil/register count value
  • Message buffer too small, increase MBM_MAX_MSGSIZE.
  • TCP: MBM_TCP_Connect() not yet called
  • MBM_Close(handle)

    Closes a MBM interface

    Interface can be re-opended again with MBM_Init().
    handle : s32 - Handle of a MBM interface (Initialized by MBM_Init() )
    returns : s32
    OK - if successful
    ERROR_FEATURE_LOCKED - Serial interface of the device is locked
    ERROR - Interface is not initialized
    MBM_GetState()

    Get the current operation state of the MBM interface

    returns : MBM_STATE_x - Current operation state
    MBM_EvtResponse(handle, iResult, data{}, iLen)

    Called every time when

  • data has been successfully sent to the Modbus slave,
  • data has been received from to the Modbus slave or
  • an error has occurred.
  • handle : s32 - Handle of a MBM interface (Initialized by MBM_Init() )
    iResult : MBM_RESULT_x - Type of the response
    data{} : u8 - Data buffer with structured data depending on the type of the response
    MBM_OK: call library function MBM_ParseRespOK()
    MBM_ERROR_EXCEPTION: call library function MBM_ParseRespErrException()
    MBM_ERROR_TIMEOUT: call library function MBM_ParseRespErrTimeout()
    MBM_ERROR_CRC: call library function MBM_ParseRespErrCRC()
    iLen : s32 - Number of bytes in the data buffer

    Recommended callback handling structure:
    /* Modbus callback function */ MBM_EvtResponse(handle, iResult, aResponse{}, iLen) { switch(iResult) { case MBM_OK: // Valid response { new MB_response[TMBM_Ok_Response]; // Structure for valid response MBM_ParseRespOK(aResponse, MB_response, iLen); // Parsing of valid response // Further processing } case MBM_ERROR_EXCEPTION: // Exception response { new MB_exception[TMBM_Exception_Response]; // Structure for exception response MBM_ParseRespErrException(aResponse, MB_exception, iLen); // Parsing of exception response // Further processing } case MBM_ERROR_CRC: // CRC-error { new MB_CRC[TMBM_CRC_Response]; // Structure for CRC-error response MBM_ParseRespErrCRC(aResponse, MB_CRC, iLen); // Parsing of CRC-error response // Further processing } case MBM_ERROR_TIMEOUT: // Timeout response { new MB_timeout[TMBM_Timeout_Response]; // Structure for timeout response MBM_ParseRespErrTimeout(aResponse, MB_timeout, iLen); // Parsing of timeout response // Further processing } } }
    MBM_ParseRespOK(const data{}, unpackedData[TMBM_Ok_Response], iLen)

    Extracts the information from a "Response Ok"

    data{} : u8 - Data buffer from MBM_EvtResponse() callback
    unpackedData : TMBM_Ok_Response - Structure for storing the information extracted from a "Response Ok"
    iLen : s32 - Number of bytes in the data buffer (should be taken from MBM_EvtResponse())
    returns : s32
    OK - if successful
    ERROR - Passed number of bytes is to small for a valid "Response Ok"

    Use rM2M_Pack() to extract the single values from the "payload{}" data buffer contained in the TMBM_Ok_Response structure. Note that Modbus register are storted in big endian format. I.e. Type flag "RM2M_PACK_BE" must be set when using rM2M_Pack(). Alternatively you can also use the library function MBM_UnpackValue().
    MBM_ParseRespErrException(const data{}, unpackedData[TMBM_Exception_Response], iLen)

    Extracts the information from a "Exception response"

    data{} : u8 - Data buffer from MBM_EvtResponse() callback
    unpackedData : TMBM_Exception_Response - Structure for storing the information extracted from a "Exception response"
    iLen : s32 - Number of bytes in the data buffer (should be taken from MBM_EvtResponse())
    returns : s32
    OK - if successful
    ERROR - Passed number of bytes is too small for a valid "Exception response"
    MBM_ParseRespErrTimeout(const data{}, unpackedData[TMBM_Timeout_Response], iLen)

    Extracts the information from a "Timeout response"

    data{} : u8 - Data buffer from MBM_EvtResponse() callback
    unpackedData : TMBM_Timeout_Response - Structure for storing the information extracted from a "Timeout response"
    iLen : s32 - Number of bytes in the data buffer (should be taken from MBM_EvtResponse())
    returns : s32
    OK - if successful
    ERROR - Passed number of bytes is too small for a valid "Timeout response"
    MBM_ParseRespErrCRC(const data{}, unpackedData[TMBM_CRC_Response], iLen)

    Extracts the information from a "CRC-error response"

    data{} : u8 - Data buffer from MBM_EvtResponse() callback
    unpackedData : TMBM_CRC_Response - Structure for storing the information extracted from a "CRC-error response"
    iLen : s32 - Number of bytes in the data buffer (should be taken from MBM_EvtResponse())
    returns : s32
    OK - if successful
    ERROR - Passed number of bytes is too small for a valid "CRC-error response"
    MBM_PackValue(data{}, iOffset, iType, Float:fValue, Float:fMBmin=0.0, Float:fMBmax=0.0, Float:fVmin=0.0, Float:fVmax=0.0)

    Function to write a single value to a data buffer, which then can be sent to a Modbus slave using the "MBM_Write" function.

    data{} : u8 - Data buffer, which is later to be sent to a Modbus Salve
    iOffset : s32 - Byte offset within the data buffer
    iType : MBM_DATA_TYPE_x - Data type of the value to be written to the buffer / Byte order (Default Big Endian)
    fValue : Float - Value that should be written in the data buffer

    Optional scaling function (default: no scaling):
    (Set "fMBmin", "MBmax", "fVmin" and "fVmax" to values unequal "0" to activate scaling)
    y = k * x + d
    x = (y - d) / k
    data = (fValue -fVmin) / ( (fVmax - fVmin) / (fMBmax - fMBmin) ) + fMBmin

    fMBmin : Float - Modbus Min
    fMBmax : Float - Modbus Max
    fVmin : Float - Value Min
    fVmax : Float - Value Max
    MBM_UnpackValue(const data{}, iOffset, iType, Float:fMBmin=0.0, Float:fMBmax=0.0, Float:fVmin=0.0, Float:fVmax=0.0)

    Function to extract a single value from the "payload{}" data buffer contained in the TMBM_Ok_Response structure after data was received from the modbus slave device.

    data{} : u8 - "payload{}" data buffer contained in a TMBM_Ok_Response structure
    iOffset : s32 - Byte offset within the data buffer
    iType : MBM_DATA_TYPE_x - Data type of the value to be read from the buffer / Byte order (Default Big Endian)

    Optional scaling function (default: no scaling):
    (Set "fMBmin", "MBmax", "fVmin" and "fVmax" to values unequal "0" to activate scaling)
    y = k * x + d
    y = (delta y / delta x) * x + d
    return value = ((fVmax - fVmin) / (fMBmax - fMBmin)) * (data - fMBmin) + fVmin

    fMBmin : Float - Modbus Min
    fMBmax : Float - Modbus Max
    fVmin : Float - Value Min
    fVmax : Float - Value Max

    returns : Float - Extracted a single value
    MBM_ReadyCallback(res, sId[TIOCtrl_Id]=[0])

    IO Controller Ready (Callback for C3_Init() used in MBM_Init())

    res - OK if successfull, otherwise ERROR if
  • IO Controller not responding
  • initialization of the Modbus Interface failed
  • Id[TIOCtrl_Id] - IO Controller ID information
    Function is called if IO Controller was responding after calling C3_Init() (used in MBM_Init()) or if IO Controller unsolicited restart was detected (probably caused by IO Controller Firmware Exception).

    This function only exists on rapidM2M C3xx devices!

    MBM_SysValuesCallback(sSysValues[TIOCtrl_SysValue])

    IO Controller System Values are available (Callback for IOCtrl_GetSysValues())

    sSysValues[TIOCtrl_SysValue] - IO Controller System Values

    This function only exists on rapidM2M C3xx devices!

    M23X:

    MBM_INTERFACE_x: s32

    Interfaces of the device that can be used for Modbus Master communication


    rapidM2M M2/M23:
    MBM_INTERFACE_NONE - No interface
    MBM_INTERFACE_RS232_1 - first RS232 Interface (Modbus RTU/ASCII)
    MBM_INTERFACE_RS485_1 - first RS485 Interface (Modbus RTU/ASCII)
    MBM_INTERFACE_RS232_2 - second RS232 Interface (Modbus RTU/ASCII)
    MBM_INTERFACE_RS485_2 - second RS485 Interface (Modbus RTU/ASCII)
    MBM_INTERFACE_LAN_1 - first LAN interface (Modbus TCP)

    rapidM2M C3xx:
    MBM_INTERFACE_NONE - No interface
    MBM_INTERFACE_RS232_1 - first RS232 Interface (Modbus RTU/ASCII)
    MBM_INTERFACE_RS485_1 - first RS485 Interface (Modbus RTU/ASCII)
    MBM_MODE_xxx:

    MBM Interface Configuration Bits (Bitmask) for serial interfaces

    Number of stop bits
    MBM_MODE_1_STOPBIT - 1 stop bit
    MBM_MODE_2_STOPBIT - 2 stop bits
    Parity
    MBM_MODE_PARITY_NONE - no parity
    MBM_MODE_PARITY_ODD - odd parity
    MBM_MODE_PARITY_EVEN - even parity
    Number of data bits
    MBM_MODE_7_DATABIT - 7 data bits
    MBM_MODE_8_DATABIT - 8 data bits
    Flow control
    MBM_MODE_FLOW_NONE - no flow control
    MBM_MODE_FLOW_RTSCTS - RTS/CTS hand shake
    Duplex mode (RS232 Interface only)
    MBM_MODE_HALF_DUPLEX - half duplex mode
    MBM_MODE_FULL_DUPLEX - full duplex mode
    Termination (rapidM2M C3xx only)
    MBM_MODE_120_OHM_NONE - no load resistance
    MBM_MODE_120_OHM_ACT - 120Ω load resistance
    Biasing (rapidM2M C3xx only)
    MBM_MODE_BIAS_OFF - no biasing resistors
    MBM_MODE_BIAS_ON - biasing resistors activated
    MBM_TYPE_x: s32

    Modbus operating modes

    MBM_TYPE_RTU = 1 - Modbus RTU mode
    MBM_TYPE_ASCII = 2 - Modbus ASCII mode
    For Modbus ASCII mode the max. frame size is defined with 513 bytes according the Modbus specification. Therefore it might be necessary to increase the default buffer sizes to the following recommeded values. See also Advanced_Config.
  • MBM_MAX_MSGSIZE to 513 bytes
  • MBM_FC_R_x: s32

    Modbus read function codes

    MBM_READ_COILS = 01 (0x01) - Read Internal Bits or Physical Coils (Bit access)
    MBM_READ_DISCRETE_INPUTS = 02 (0x02) - Read Physical Discrete Inputs (Bit access)
    MBM_READ_HOLDING_REGISTERS = 03 (0x03) - Read Multiple Internal Registers or Physical Output Registers (16-bit access)
    MBM_READ_INPUT_REGISTERS = 04 (0x04) - Read Physical Input Registers (16-bit access)
    MBM_FC_W_x: s32

    Modbus write function codes

    MBM_FORCE_SINGLE_COIL = 05 (0x05) - Write Single Internal Bits or Physical Coils (Bit access)
    MBM_PRESET_SINGLE_REGISTER = 06 (0x06) - Write Single Internal Registers or Physical Output Registers (16-bit access)
    MBM_FORCE_MULTIPLE_COILS = 15 (0x0F) - Write Multiple Internal Bits or Physical Coils (Bit access)
    MBM_PRESET_MULTIPLE_REGISTERS = 16 (0x10) - Write Multiple Internal Registers or Physical Output Registers (16-bit access)
    MBM_STATE_x: s32

    Current operation state of the MBM interface

    MBM_STATE_IDLE = 0 - Idle
    MBM_STATE_BUSY = -3 - Busy
    MBM_RESULT_x: s32

    Possible responses to a Modbus R/W operation

    MBM_OK = 0 - valid data received from slave
    MBM_ERROR_EXCEPTION = -1 - exception response from slave
    MBM_ERROR_CRC = -2 - CRC-error
    MBM_ERROR_TIMEOUT = -3 - no response within defined timeout (defined by MBM_Init() )
    TMBM_Ok_Response:

    Information extracted from a "OK Response"

    iSlave:s32 - Slave address
    iFC:s32 - Modbus function code (see MBM_FC_R_x or MBM_FC_W_x)
  • MBM_READ_COILS
    • Each bit in the "payload{}" data buffer reflects the status of a coil (1 means "ON" and 0 means "OFF"). The LSB of the first byte in the "payload{}" data buffer reflects the status of the coil addressed in the request. The other coil states follow towards the MSB of this byte and from LSB to MSB in the subsequent bytes. If the number of coils requested was not a multiple of eight, the remaining bits in the final data byte are zero-padded (toward the MSB of the byte). The number of complete bytes in the "payload{}" data buffer is contained in "iCount".

  • MBM_READ_DISCRETE_INPUTS
    • Each bit in the "payload{}" data buffer reflects the status of a input (1 means "ON" and 0 means "OFF"). The LSB of the first byte in the "payload{}" data buffer reflects the status of the input addressed in the request. The other input states follow towards the MSB of this byte and from LSB to MSB in the subsequent bytes. If the number of input requested was not a multiple of eight, the remaining bits in the final data byte are zero-padded (toward the MSB of the byte). The number of complete bytes in the "payload{}" data buffer is contained in "iCount".

  • MBM_READ_HOLDING_REGISTERS
    • The "payload{}" data buffer contains two bytes per requested register, with the binary contents right justified within each byte. For each register the first byte contains the high-order bits, and the second contains the low-order bits (i.e. big endian format is used). "iCount" contains the number of bytes in the "payload{}" data buffer.

  • MBM_READ_INPUT_REGISTERS
    • The "payload{}" data buffer contains two bytes per requested input register, with the binary contents right justified within each byte. For each input register the first byte contains the high-order bits, and the second contains the low-order bits (i.e. big endian format is used). "iCount" contains the number of bytes in the "payload{}" data buffer.

  • MBM_FORCE_SINGLE_COIL
    • payload{} = null
      iCount = 0

  • MBM_PRESET_SINGLE_REGISTER
    • payload{} = null
      iCount = 0

  • MBM_FORCE_MULTIPLE_COILS
    • payload{} = null
      iCount = 0

  • MBM_PRESET_MULTIPLE_REGISTERS
    • payload{} = null
      iCount = 0
    iStartAddr:s32 - Start address of requested/written data
    iItemCount:s32 - Number of requested/written data items
    payload{}:u8 - Data buffer with received Modbus Data
    iCount:s32 - byte count
    TMBM_Exception_Response:

    Information extracted from a "Exception response"

    iSlave:s32 - Slave address
    iErrorcode:s32 - Error code from slave ( >= 0x80 )
    Corresponds to the function code of the faulty request with bit7 set (i.e. 0x80 | MBM_FC). See MBM_FC_R_x and MBM_FC_W_x for the possible function codes
    iExceptioncode:s32 - exception code from slave
    01 = ILLEGAL FUNCTION
    02 = ILLEGAL DATA ADDRESS
    03 = ILLEGAL DATA VALUE
    04 = SERVER DEVICE FAILURE
    05 = ACKNOWLEDGE
    06 = SERVER DEVICE BUSY
    08 = MEMORY PARITY ERROR
    10 = GATEWAY PATH UNAVAILABLE
    11 = GATEWAY TARGET DEVICE FAILED TO RESPOND
    iFC:s32 - Modbus function code (see MBM_FC_R_x or MBM_FC_W_x)
    iStartAddr:s32 - Start address of requested/written data
    iItemCount:s32 - Number of requested/written data items
    TMBM_Timeout_Response:

    Information extracted from a "Timeout response"

    iSlave:s32 - Slave address
    iFC:s32 - Modbus function code (see MBM_FC_R_x or MBM_FC_W_x)
    iStartAddr:s32 - Start address of requested/written data
    iItemCount:s32 - Number of requested/written data items
    TMBM_CRC_Response:

    Information extracted from a "CRC-error response"

    iSlave:s32 - Slave address
    iFC:s32 - Modbus function code (see MBM_FC_R_x or MBM_FC_W_x)
    iStartAddr:s32 - Start address of requested/written data
    iItemCount:s32 - Number of requested/written data items
    MBM_DATA_TYPE_x:

    Possible data types / Byte orders

    MBM_DATA_TYPE_BYTE - 8-bit unsigned
    MBM_DATA_TYPE_WORD - 16-bit unsigned
    MBM_DATA_TYPE_WORD_S - 16-bit signed
    MBM_DATA_TYPE_DWORD_S - 32-bit signed
    MBM_DATA_TYPE_FLOAT - 32-bit float

    MBM_DATA_TYPE_LE - Use little endian
    MBM_Init(&handle, iInterface, iBaudrate, iMode, iMBtype, iTimeout=1000)

    Initialize the MBM interface in RTU or ASCII mode

    (see Interface_Selection for more details)
    handle : s32 - Empty handle for a MBM communication interface
    iInterface : s32 - serial interface that should be used for the MBM communication (use MBM_INTERFACE_x)
    iBaudrate : s32 - Baud rate to be used
    iMode : s32 - MBM interface configuration (e.g 7/8 Data-bit, Stopbit yes/no, Parity yes/no, etc. use MBM_MODE_xxx)
    iMBtype : MBM_TYPE_x - Modbus operating mode (Modbus RTU / ASCII)
    iTimeout : s32 - Modbus timeout (i.e. max. slave response time)
    >=100 - Timeout [ms] (min = 100, max = 10000)
    returns : s32
    OK - if successful
    ERROR_FEATURE_LOCKED - Serial interface of the device is locked
    ERROR - If one of the following errors occurs
  • Interface is not supported
  • Interface already initialized
  • Invalid baudrate value
  • Invalid timeout value
  • Invalid MBM_TYPE selection
  • Invalid Rx/Tx buffer settings
  • SC16IS741 initialization failed
  • MBM_Read(handle, iSlave, iFC, iStartAddr, iItemCount=1)

    Send a read request to a Modbus slave

    handle : s32 - Handle of a MBM interface (Initialized by MBM_Init() )
    iSlave : s32 - Slave address (1 - 247)
    iFC : MBM_FC_R_x - Modbus function code
    iStartAddr : s32 - Start address of requested data (0 - 65535)
    iItemCount : s32 - Number of requested data items
    coils: 1 - 2000 coils
    registers: 1 - 125 registers
    returns : s32
    > = 0 - number of actually sent bytes (Read command sent to the Modbus slave)
    MBM_STATE_BUSY - Interface is currently busy
    ERROR_FEATURE_LOCKED - Serial interface of the device is locked
    ERROR - If one of the following errors occurs
  • Interface is not initialized
  • Invalid slave address value
  • Invalid function code value
  • Invalid start address value
  • Invalid coil/register count value
  • TCP: MBM_TCP_Connect() not yet called
  • MBM_Write(handle, iSlave, iFC, const data{}, iStartAddr, iItemCount=1)

    Write data to a Modbus slave

    handle : s32 - Handle of a MBM interface (Initialized by MBM_Init() )
    iSlave : s32 - Slave address (1 - 247)
    iFC : MBM_FC_W_x - Modbus function code
    data{} : u8 - Data buffer to write
    iStartAddr : s32 - Address from which to start writing the data (0 - 65535)
    iItemCount : s32 - Number of data items to be sent. Not needed for single item write operation.
    coils: 1 - 1968 coils
    registers: 1 - 123 registers
    returns : s32
    > = 0 - number of actually sent bytes
    MBM_STATE_BUSY - Interface is currently busy
    ERROR_FEATURE_LOCKED - Serial interface of the device is locked
    ERROR - If one of the following errors occurs
  • Interface is not initialized
  • Invalid slave address value
  • Invalid function code value
  • Invalid start address value
  • Invalid coil/register count value
  • Message buffer too small, increase MBM_MAX_MSGSIZE.
  • TCP: MBM_TCP_Connect() not yet called
  • MBM_Close(handle)

    Closes a MBM interface

    Interface can be re-opended again with MBM_Init().
    handle : s32 - Handle of a MBM interface (Initialized by MBM_Init() )
    returns : s32
    OK - if successful
    ERROR_FEATURE_LOCKED - Serial interface of the device is locked
    ERROR - Interface is not initialized
    MBM_GetState()

    Get the current operation state of the MBM interface

    returns : MBM_STATE_x - Current operation state
    MBM_EvtResponse(handle, iResult, data{}, iLen)

    Called every time when

  • data has been successfully sent to the Modbus slave,
  • data has been received from to the Modbus slave or
  • an error has occurred.
  • handle : s32 - Handle of a MBM interface (Initialized by MBM_Init() )
    iResult : MBM_RESULT_x - Type of the response
    data{} : u8 - Data buffer with structured data depending on the type of the response
    MBM_OK: call library function MBM_ParseRespOK()
    MBM_ERROR_EXCEPTION: call library function MBM_ParseRespErrException()
    MBM_ERROR_TIMEOUT: call library function MBM_ParseRespErrTimeout()
    MBM_ERROR_CRC: call library function MBM_ParseRespErrCRC()
    iLen : s32 - Number of bytes in the data buffer

    Recommended callback handling structure:
    /* Modbus callback function */ MBM_EvtResponse(handle, iResult, aResponse{}, iLen) { switch(iResult) { case MBM_OK: // Valid response { new MB_response[TMBM_Ok_Response]; // Structure for valid response MBM_ParseRespOK(aResponse, MB_response, iLen); // Parsing of valid response // Further processing } case MBM_ERROR_EXCEPTION: // Exception response { new MB_exception[TMBM_Exception_Response]; // Structure for exception response MBM_ParseRespErrException(aResponse, MB_exception, iLen); // Parsing of exception response // Further processing } case MBM_ERROR_CRC: // CRC-error { new MB_CRC[TMBM_CRC_Response]; // Structure for CRC-error response MBM_ParseRespErrCRC(aResponse, MB_CRC, iLen); // Parsing of CRC-error response // Further processing } case MBM_ERROR_TIMEOUT: // Timeout response { new MB_timeout[TMBM_Timeout_Response]; // Structure for timeout response MBM_ParseRespErrTimeout(aResponse, MB_timeout, iLen); // Parsing of timeout response // Further processing } } }
    MBM_ParseRespOK(const data{}, unpackedData[TMBM_Ok_Response], iLen)

    Extracts the information from a "Response Ok"

    data{} : u8 - Data buffer from MBM_EvtResponse() callback
    unpackedData : TMBM_Ok_Response - Structure for storing the information extracted from a "Response Ok"
    iLen : s32 - Number of bytes in the data buffer (should be taken from MBM_EvtResponse())
    returns : s32
    OK - if successful
    ERROR - Passed number of bytes is to small for a valid "Response Ok"

    Use rM2M_Pack() to extract the single values from the "payload{}" data buffer contained in the TMBM_Ok_Response structure. Note that Modbus register are storted in big endian format. I.e. Type flag "RM2M_PACK_BE" must be set when using rM2M_Pack(). Alternatively you can also use the library function MBM_UnpackValue().
    MBM_ParseRespErrException(const data{}, unpackedData[TMBM_Exception_Response], iLen)

    Extracts the information from a "Exception response"

    data{} : u8 - Data buffer from MBM_EvtResponse() callback
    unpackedData : TMBM_Exception_Response - Structure for storing the information extracted from a "Exception response"
    iLen : s32 - Number of bytes in the data buffer (should be taken from MBM_EvtResponse())
    returns : s32
    OK - if successful
    ERROR - Passed number of bytes is too small for a valid "Exception response"
    MBM_ParseRespErrTimeout(const data{}, unpackedData[TMBM_Timeout_Response], iLen)

    Extracts the information from a "Timeout response"

    data{} : u8 - Data buffer from MBM_EvtResponse() callback
    unpackedData : TMBM_Timeout_Response - Structure for storing the information extracted from a "Timeout response"
    iLen : s32 - Number of bytes in the data buffer (should be taken from MBM_EvtResponse())
    returns : s32
    OK - if successful
    ERROR - Passed number of bytes is too small for a valid "Timeout response"
    MBM_ParseRespErrCRC(const data{}, unpackedData[TMBM_CRC_Response], iLen)

    Extracts the information from a "CRC-error response"

    data{} : u8 - Data buffer from MBM_EvtResponse() callback
    unpackedData : TMBM_CRC_Response - Structure for storing the information extracted from a "CRC-error response"
    iLen : s32 - Number of bytes in the data buffer (should be taken from MBM_EvtResponse())
    returns : s32
    OK - if successful
    ERROR - Passed number of bytes is too small for a valid "CRC-error response"
    MBM_PackValue(data{}, iOffset, iType, Float:fValue, Float:fMBmin=0.0, Float:fMBmax=0.0, Float:fVmin=0.0, Float:fVmax=0.0)

    Function to write a single value to a data buffer, which then can be sent to a Modbus slave using the "MBM_Write" function.

    data{} : u8 - Data buffer, which is later to be sent to a Modbus Salve
    iOffset : s32 - Byte offset within the data buffer
    iType : MBM_DATA_TYPE_x - Data type of the value to be written to the buffer / Byte order (Default Big Endian)
    fValue : Float - Value that should be written in the data buffer

    Optional scaling function (default: no scaling):
    (Set "fMBmin", "MBmax", "fVmin" and "fVmax" to values unequal "0" to activate scaling)
    y = k * x + d
    x = (y - d) / k
    data = (fValue -fVmin) / ( (fVmax - fVmin) / (fMBmax - fMBmin) ) + fMBmin

    fMBmin : Float - Modbus Min
    fMBmax : Float - Modbus Max
    fVmin : Float - Value Min
    fVmax : Float - Value Max
    MBM_UnpackValue(const data{}, iOffset, iType, Float:fMBmin=0.0, Float:fMBmax=0.0, Float:fVmin=0.0, Float:fVmax=0.0)

    Function to extract a single value from the "payload{}" data buffer contained in the TMBM_Ok_Response structure after data was received from the modbus slave device.

    data{} : u8 - "payload{}" data buffer contained in a TMBM_Ok_Response structure
    iOffset : s32 - Byte offset within the data buffer
    iType : MBM_DATA_TYPE_x - Data type of the value to be read from the buffer / Byte order (Default Big Endian)

    Optional scaling function (default: no scaling):
    (Set "fMBmin", "MBmax", "fVmin" and "fVmax" to values unequal "0" to activate scaling)
    y = k * x + d
    y = (delta y / delta x) * x + d
    return value = ((fVmax - fVmin) / (fMBmax - fMBmin)) * (data - fMBmin) + fVmin

    fMBmin : Float - Modbus Min
    fMBmax : Float - Modbus Max
    fVmin : Float - Value Min
    fVmax : Float - Value Max

    returns : Float - Extracted a single value
    MBM_ReadyCallback(res, sId[TIOCtrl_Id]=[0])

    IO Controller Ready (Callback for C3_Init() used in MBM_Init())

    res - OK if successfull, otherwise ERROR if
  • IO Controller not responding
  • initialization of the Modbus Interface failed
  • Id[TIOCtrl_Id] - IO Controller ID information
    Function is called if IO Controller was responding after calling C3_Init() (used in MBM_Init()) or if IO Controller unsolicited restart was detected (probably caused by IO Controller Firmware Exception).

    This function only exists on rapidM2M C3xx devices!

    MBM_SysValuesCallback(sSysValues[TIOCtrl_SysValue])

    IO Controller System Values are available (Callback for IOCtrl_GetSysValues())

    sSysValues[TIOCtrl_SysValue] - IO Controller System Values

    This function only exists on rapidM2M C3xx devices!

    M2EASYIOT:

    MBM_INTERFACE_x: s32

    Serial interfaces of the device that can be used for Modbus Master communication

    MBM_INTERFACE_NONE - No interface
    MBM_INTERFACE_RS232_1 - first RS232 Interface
    MBM_INTERFACE_RS485_1 - first RS485 Interface
    MBM_INTERFACE_RS485_2 - second RS485 Interface (isolated)
    To be able to use the second RS485 interface the add-on PCB is needed and the "easyiot-base-mt" library needs to be included.
    MBM_MODE_xxx:

    MBM Interface Configuration Bits (Bitmask)

    Number of stop bits
    MBM_MODE_1_STOPBIT - 1 stop bit
    MBM_MODE_2_STOPBIT - 2 stop bits
    Parity
    MBM_MODE_PARITY_NONE - no parity
    MBM_MODE_PARITY_ODD - odd parity
    MBM_MODE_PARITY_EVEN - even parity
    Number of data bits
    MBM_MODE_7_DATABIT - 7 data bits
    MBM_MODE_8_DATABIT - 8 data bits
    Flow control
    MBM_MODE_FLOW_NONE - no flow control
    MBM_MODE_FLOW_RTSCTS - RTS/CTS hand shake
    Duplex mode (RS232 Interface only)
    MBM_MODE_HALF_DUPLEX - half duplex mode
    MBM_MODE_FULL_DUPLEX - full duplex mode
    Termination (first RS485 Interface only)
    MBM_MODE_120_OHM_NONE - no load resistance
    MBM_MODE_120_OHM_ACT - 120Ω load resistance
    MBM_TYPE_x: s32

    Modbus operating modes

    MBM_TYPE_RTU = 1 - Modbus RTU mode
    MBM_TYPE_ASCII = 2 - Modbus ASCII mode
    For Modbus ASCII mode the max. frame size is defined with 513 bytes according the Modbus specification. Therefore it might be necessary to increase the default buffer sizes to the following recommeded values. See also Advanced_Config.
  • MBM_MAX_MSGSIZE to 513 bytes
  • MBM_FC_R_x: s32

    Modbus read function codes

    MBM_READ_COILS = 01 (0x01) - Read Internal Bits or Physical Coils (Bit access)
    MBM_READ_DISCRETE_INPUTS = 02 (0x02) - Read Physical Discrete Inputs (Bit access)
    MBM_READ_HOLDING_REGISTERS = 03 (0x03) - Read Multiple Internal Registers or Physical Output Registers (16-bit access)
    MBM_READ_INPUT_REGISTERS = 04 (0x04) - Read Physical Input Registers (16-bit access)
    MBM_FC_W_x: s32

    Modbus write function codes

    MBM_FORCE_SINGLE_COIL = 05 (0x05) - Write Single Internal Bits or Physical Coils (Bit access)
    MBM_PRESET_SINGLE_REGISTER = 06 (0x06) - Write Single Internal Registers or Physical Output Registers (16-bit access)
    MBM_FORCE_MULTIPLE_COILS = 15 (0x0F) - Write Multiple Internal Bits or Physical Coils (Bit access)
    MBM_PRESET_MULTIPLE_REGISTERS = 16 (0x10) - Write Multiple Internal Registers or Physical Output Registers (16-bit access)
    MBM_STATE_x: s32

    Current operation state of the MBM interface

    MBM_STATE_IDLE = 0 - Idle
    MBM_STATE_BUSY = -3 - Busy
    MBM_RESULT_x: s32

    Possible responses to a Modbus R/W operation

    MBM_OK = 0 - valid data received from slave
    MBM_ERROR_EXCEPTION = -1 - exception response from slave
    MBM_ERROR_CRC = -2 - CRC-error
    MBM_ERROR_TIMEOUT = -3 - no response within defined timeout (defined by MBM_Init() )
    TMBM_Ok_Response:

    Information extracted from a "OK Response"

    iSlave:s32 - Slave address
    iFC:s32 - Modbus function code (see MBM_FC_R_x or MBM_FC_W_x)
  • MBM_READ_COILS
    • Each bit in the "payload{}" data buffer reflects the status of a coil (1 means "ON" and 0 means "OFF"). The LSB of the first byte in the "payload{}" data buffer reflects the status of the coil addressed in the request. The other coil states follow towards the MSB of this byte and from LSB to MSB in the subsequent bytes. If the number of coils requested was not a multiple of eight, the remaining bits in the final data byte are zero-padded (toward the MSB of the byte). The number of complete bytes in the "payload{}" data buffer is contained in "iCount".

  • MBM_READ_DISCRETE_INPUTS
    • Each bit in the "payload{}" data buffer reflects the status of a input (1 means "ON" and 0 means "OFF"). The LSB of the first byte in the "payload{}" data buffer reflects the status of the input addressed in the request. The other input states follow towards the MSB of this byte and from LSB to MSB in the subsequent bytes. If the number of input requested was not a multiple of eight, the remaining bits in the final data byte are zero-padded (toward the MSB of the byte). The number of complete bytes in the "payload{}" data buffer is contained in "iCount".

  • MBM_READ_HOLDING_REGISTERS
    • The "payload{}" data buffer contains two bytes per requested register, with the binary contents right justified within each byte. For each register the first byte contains the high-order bits, and the second contains the low-order bits (i.e. big endian format is used). "iCount" contains the number of bytes in the "payload{}" data buffer.

  • MBM_READ_INPUT_REGISTERS
    • The "payload{}" data buffer contains two bytes per requested input register, with the binary contents right justified within each byte. For each input register the first byte contains the high-order bits, and the second contains the low-order bits (i.e. big endian format is used). "iCount" contains the number of bytes in the "payload{}" data buffer.

  • MBM_FORCE_SINGLE_COIL
    • payload{} = null
      iCount = 0

  • MBM_PRESET_SINGLE_REGISTER
    • payload{} = null
      iCount = 0

  • MBM_FORCE_MULTIPLE_COILS
    • payload{} = null
      iCount = 0

  • MBM_PRESET_MULTIPLE_REGISTERS
    • payload{} = null
      iCount = 0
    iStartAddr:s32 - Start address of requested/written data
    iItemCount:s32 - Number of requested/written data items
    payload{}:u8 - Data buffer with received Modbus Data
    iCount:s32 - byte count
    TMBM_Exception_Response:

    Information extracted from a "Exception response"

    iSlave:s32 - Slave address
    iErrorcode:s32 - Error code from slave ( >= 0x80 )
    Corresponds to the function code of the faulty request with bit7 set (i.e. 0x80 | MBM_FC). See MBM_FC_R_x and MBM_FC_W_x for the possible function codes
    iExceptioncode:s32 - exception code from slave
    01 = ILLEGAL FUNCTION
    02 = ILLEGAL DATA ADDRESS
    03 = ILLEGAL DATA VALUE
    04 = SERVER DEVICE FAILURE
    05 = ACKNOWLEDGE
    06 = SERVER DEVICE BUSY
    08 = MEMORY PARITY ERROR
    10 = GATEWAY PATH UNAVAILABLE
    11 = GATEWAY TARGET DEVICE FAILED TO RESPOND
    iFC:s32 - Modbus function code (see MBM_FC_R_x or MBM_FC_W_x)
    iStartAddr:s32 - Start address of requested/written data
    iItemCount:s32 - Number of requested/written data items
    TMBM_Timeout_Response:

    Information extracted from a "Timeout response"

    iSlave:s32 - Slave address
    iFC:s32 - Modbus function code (see MBM_FC_R_x or MBM_FC_W_x)
    iStartAddr:s32 - Start address of requested/written data
    iItemCount:s32 - Number of requested/written data items
    TMBM_CRC_Response:

    Information extracted from a "CRC-error response"

    iSlave:s32 - Slave address
    iFC:s32 - Modbus function code (see MBM_FC_R_x or MBM_FC_W_x)
    iStartAddr:s32 - Start address of requested/written data
    iItemCount:s32 - Number of requested/written data items
    MBM_DATA_TYPE_x:

    Possible data types / Byte orders

    MBM_DATA_TYPE_BYTE - 8-bit unsigned
    MBM_DATA_TYPE_WORD - 16-bit unsigned
    MBM_DATA_TYPE_WORD_S - 16-bit signed
    MBM_DATA_TYPE_DWORD_S - 32-bit signed
    MBM_DATA_TYPE_FLOAT - 32-bit float

    MBM_DATA_TYPE_LE - Use little endian
    MBM_Init(&handle, iInterface, iBaudrate, iMode, iMBtype, iTimeout=1000)

    Initialize the MBM interface in RTU or ASCII mode

    (see Interface_Selection for more details)
    handle : s32 - Empty handle for a MBM communication interface
    iInterface : s32 - serial interface that should be used for the MBM communication (use MBM_INTERFACE_x)
    iBaudrate : s32 - Baud rate to be used
    iMode : s32 - MBM interface configuration (e.g 7/8 Data-bit, Stopbit yes/no, Parity yes/no, etc. use MBM_MODE_xxx)
    iMBtype : MBM_TYPE_x - Modbus operating mode (Modbus RTU / ASCII)
    iTimeout : s32 - Modbus timeout (i.e. max. slave response time)
    >=100 - Timeout [ms] (min = 100, max = 10000)
    returns : s32
    OK - if successful
    ERROR_FEATURE_LOCKED - Serial interface of the device is locked
    ERROR - If one of the following errors occurs
  • Interface is not supported
  • Interface already initialized
  • Invalid baudrate value
  • Invalid timeout value
  • Invalid MBM_TYPE selection
  • Invalid Rx/Tx buffer settings
  • SC16IS741 initialization failed
  • MBM_Read(handle, iSlave, iFC, iStartAddr, iItemCount=1)

    Send a read request to a Modbus slave

    handle : s32 - Handle of a MBM interface (Initialized by MBM_Init() )
    iSlave : s32 - Slave address (1 - 247)
    iFC : MBM_FC_R_x - Modbus function code
    iStartAddr : s32 - Start address of requested data (0 - 65535)
    iItemCount : s32 - Number of requested data items
    coils: 1 - 2000 coils
    registers: 1 - 125 registers
    returns : s32
    > = 0 - number of actually sent bytes (Read command sent to the Modbus slave)
    MBM_STATE_BUSY - Interface is currently busy
    ERROR_FEATURE_LOCKED - Serial interface of the device is locked
    ERROR - If one of the following errors occurs
  • Interface is not initialized
  • Invalid slave address value
  • Invalid function code value
  • Invalid start address value
  • Invalid coil/register count value
  • TCP: MBM_TCP_Connect() not yet called
  • MBM_Write(handle, iSlave, iFC, const data{}, iStartAddr, iItemCount=1)

    Write data to a Modbus slave

    handle : s32 - Handle of a MBM interface (Initialized by MBM_Init() )
    iSlave : s32 - Slave address (1 - 247)
    iFC : MBM_FC_W_x - Modbus function code
    data{} : u8 - Data buffer to write
    iStartAddr : s32 - Address from which to start writing the data (0 - 65535)
    iItemCount : s32 - Number of data items to be sent. Not needed for single item write operation.
    coils: 1 - 1968 coils
    registers: 1 - 123 registers
    returns : s32
    > = 0 - number of actually sent bytes
    MBM_STATE_BUSY - Interface is currently busy
    ERROR_FEATURE_LOCKED - Serial interface of the device is locked
    ERROR - If one of the following errors occurs
  • Interface is not initialized
  • Invalid slave address value
  • Invalid function code value
  • Invalid start address value
  • Invalid coil/register count value
  • Message buffer too small, increase MBM_MAX_MSGSIZE.
  • TCP: MBM_TCP_Connect() not yet called
  • MBM_Close(handle)

    Closes a MBM interface

    Interface can be re-opended again with MBM_Init().
    handle : s32 - Handle of a MBM interface (Initialized by MBM_Init() )
    returns : s32
    OK - if successful
    ERROR_FEATURE_LOCKED - Serial interface of the device is locked
    ERROR - Interface is not initialized
    MBM_GetState()

    Get the current operation state of the MBM interface

    returns : MBM_STATE_x - Current operation state
    MBM_EvtResponse(handle, iResult, data{}, iLen)

    Called every time when

  • data has been successfully sent to the Modbus slave,
  • data has been received from to the Modbus slave or
  • an error has occurred.
  • handle : s32 - Handle of a MBM interface (Initialized by MBM_Init() )
    iResult : MBM_RESULT_x - Type of the response
    data{} : u8 - Data buffer with structured data depending on the type of the response
    MBM_OK: call library function MBM_ParseRespOK()
    MBM_ERROR_EXCEPTION: call library function MBM_ParseRespErrException()
    MBM_ERROR_TIMEOUT: call library function MBM_ParseRespErrTimeout()
    MBM_ERROR_CRC: call library function MBM_ParseRespErrCRC()
    iLen : s32 - Number of bytes in the data buffer

    Recommended callback handling structure:
    /* Modbus callback function */ MBM_EvtResponse(handle, iResult, aResponse{}, iLen) { switch(iResult) { case MBM_OK: // Valid response { new MB_response[TMBM_Ok_Response]; // Structure for valid response MBM_ParseRespOK(aResponse, MB_response, iLen); // Parsing of valid response // Further processing } case MBM_ERROR_EXCEPTION: // Exception response { new MB_exception[TMBM_Exception_Response]; // Structure for exception response MBM_ParseRespErrException(aResponse, MB_exception, iLen); // Parsing of exception response // Further processing } case MBM_ERROR_CRC: // CRC-error { new MB_CRC[TMBM_CRC_Response]; // Structure for CRC-error response MBM_ParseRespErrCRC(aResponse, MB_CRC, iLen); // Parsing of CRC-error response // Further processing } case MBM_ERROR_TIMEOUT: // Timeout response { new MB_timeout[TMBM_Timeout_Response]; // Structure for timeout response MBM_ParseRespErrTimeout(aResponse, MB_timeout, iLen); // Parsing of timeout response // Further processing } } }
    MBM_ParseRespOK(const data{}, unpackedData[TMBM_Ok_Response], iLen)

    Extracts the information from a "Response Ok"

    data{} : u8 - Data buffer from MBM_EvtResponse() callback
    unpackedData : TMBM_Ok_Response - Structure for storing the information extracted from a "Response Ok"
    iLen : s32 - Number of bytes in the data buffer (should be taken from MBM_EvtResponse())
    returns : s32
    OK - if successful
    ERROR - Passed number of bytes is to small for a valid "Response Ok"

    Use rM2M_Pack() to extract the single values from the "payload{}" data buffer contained in the TMBM_Ok_Response structure. Note that Modbus register are storted in big endian format. I.e. Type flag "RM2M_PACK_BE" must be set when using rM2M_Pack(). Alternatively you can also use the library function MBM_UnpackValue().
    MBM_ParseRespErrException(const data{}, unpackedData[TMBM_Exception_Response], iLen)

    Extracts the information from a "Exception response"

    data{} : u8 - Data buffer from MBM_EvtResponse() callback
    unpackedData : TMBM_Exception_Response - Structure for storing the information extracted from a "Exception response"
    iLen : s32 - Number of bytes in the data buffer (should be taken from MBM_EvtResponse())
    returns : s32
    OK - if successful
    ERROR - Passed number of bytes is too small for a valid "Exception response"
    MBM_ParseRespErrTimeout(const data{}, unpackedData[TMBM_Timeout_Response], iLen)

    Extracts the information from a "Timeout response"

    data{} : u8 - Data buffer from MBM_EvtResponse() callback
    unpackedData : TMBM_Timeout_Response - Structure for storing the information extracted from a "Timeout response"
    iLen : s32 - Number of bytes in the data buffer (should be taken from MBM_EvtResponse())
    returns : s32
    OK - if successful
    ERROR - Passed number of bytes is too small for a valid "Timeout response"
    MBM_ParseRespErrCRC(const data{}, unpackedData[TMBM_CRC_Response], iLen)

    Extracts the information from a "CRC-error response"

    data{} : u8 - Data buffer from MBM_EvtResponse() callback
    unpackedData : TMBM_CRC_Response - Structure for storing the information extracted from a "CRC-error response"
    iLen : s32 - Number of bytes in the data buffer (should be taken from MBM_EvtResponse())
    returns : s32
    OK - if successful
    ERROR - Passed number of bytes is too small for a valid "CRC-error response"
    MBM_PackValue(data{}, iOffset, iType, Float:fValue, Float:fMBmin=0.0, Float:fMBmax=0.0, Float:fVmin=0.0, Float:fVmax=0.0)

    Function to write a single value to a data buffer, which then can be sent to a Modbus slave using the "MBM_Write" function.

    data{} : u8 - Data buffer, which is later to be sent to a Modbus Salve
    iOffset : s32 - Byte offset within the data buffer
    iType : MBM_DATA_TYPE_x - Data type of the value to be written to the buffer / Byte order (Default Big Endian)
    fValue : Float - Value that should be written in the data buffer

    Optional scaling function (default: no scaling):
    (Set "fMBmin", "MBmax", "fVmin" and "fVmax" to values unequal "0" to activate scaling)
    y = k * x + d
    x = (y - d) / k
    data = (fValue -fVmin) / ( (fVmax - fVmin) / (fMBmax - fMBmin) ) + fMBmin

    fMBmin : Float - Modbus Min
    fMBmax : Float - Modbus Max
    fVmin : Float - Value Min
    fVmax : Float - Value Max
    MBM_UnpackValue(const data{}, iOffset, iType, Float:fMBmin=0.0, Float:fMBmax=0.0, Float:fVmin=0.0, Float:fVmax=0.0)

    Function to extract a single value from the "payload{}" data buffer contained in the TMBM_Ok_Response structure after data was received from the modbus slave device.

    data{} : u8 - "payload{}" data buffer contained in a TMBM_Ok_Response structure
    iOffset : s32 - Byte offset within the data buffer
    iType : MBM_DATA_TYPE_x - Data type of the value to be read from the buffer / Byte order (Default Big Endian)

    Optional scaling function (default: no scaling):
    (Set "fMBmin", "MBmax", "fVmin" and "fVmax" to values unequal "0" to activate scaling)
    y = k * x + d
    y = (delta y / delta x) * x + d
    return value = ((fVmax - fVmin) / (fMBmax - fMBmin)) * (data - fMBmin) + fVmin

    fMBmin : Float - Modbus Min
    fMBmax : Float - Modbus Max
    fVmin : Float - Value Min
    fVmax : Float - Value Max

    returns : Float - Extracted a single value

    TCP

    M22X:

    MODBUS TCP:
    Modbus TCP is very similar to Modbus RTU. From the programmers perspective there are following major differences:
  • use MBM_TCP_Init() instead of MBM_Init()
  • use MBM_TCP_Connect() to connect to a Modbus TCP slave
  • use MBM_TCP_Disconnect() to disconnect from a Modbus TCP slave
  • Functional principle:
  • MBM_TCP_Init() and MBM_TCP_Connect() may be called consecutively. The library handles this asynchronously, meaning that connecting and reconnecting is handled internally until MBM_TCP_Disconnect() is called.
  • Default Configuration: see MBM Advanced_Config
    TMBM_LANSetup:

    LAN Setup structure for Modbus TCP

    ip{4}:u8 - Local IPv4 Address
    sn{4}:u8 - Subnet Mask
    gw{4}:u8 - Default Gateway
    mac{6}:u8 - MAC Address
    This field must only be filled if a dedicated custom MAC address is required. If this field is empty (default, all bytes 0x00), internal MAC address is used. This MAC address depends on the low level hardware driver (e.g. w5200-microtronics).
    Currently only static IP configuration is supported. Dynamic IP configuration through DHCP server is not (yet) supported.
    All fields within TMBM_LANSetup are big-endian organized, see code example below.
    /* Example for LAN setup structure */ static sLAN_Setup[TMBM_LANSetup] = [ { 192, 168, 10, 101}, /* Local IPv4 Address "192.168.10.101" */ { 255, 255, 255, 0}, /* Subnet Mask "255.255.255.0" */ { 192, 168, 10, 1}, /* Default Gateway "192.168.10.1" */ { 0, 0, 0, 0, 0, 0}, /* use internal MAC Address */ ];
    MBM_TCP_Init(&handle, Interface, sLAN_Setup[TMBM_LANSetup], iTimeout=1000)

    Initialize the MBM interface in TCP mode

    handle : s32 - Empty handle for a MBM communication interface
    Interface : s32 - MBM_INTERFACE_x
    sLAN_Setup : o - LAN Setup structure
    iTimeout : s32 - Modbus timeout (i.e. max. slave response time)
    >=100 - Timeout [ms] (min = 100, max = 10000)
    returns : s32
    OK - if successful
    ERROR - if one of the following errors occurs
  • interface is not supported
  • iTimeout is out of range
  • LAN interface library (e.g. w5200-microtronics) is not available or not supported
  • LAN chip init failed (e.g. due to HW problems)
  • MBM_TCP_Close(handle)

    Closes a MBM interface in TCP mode

    Interface can be re-opended again with MBM_TCP_Init().
    handle : s32 - handle for a MBM communication interface
    returns : s32
    OK - if successful
    ERROR - Interface is not initialized
    MBM_TCP_EVENT_x:

    Modbus TCP events

    MBM_TCP_EVENT_CONNECTED = 1 - Connection established
    MBM_TCP_EVENT_CONNECT_TIMEOUT = 2 - Initial connection request timed out. Unless MBM_TCP_Disconnect() is called, the library will still try to reconnect, even after this Event
    MBM_EvtTcp(handle, iSlave, event, aData{}, iLen)

    Optional Eventhandler that is called if a TCP related event occurs.

    handle : s32 - Handle of a MBM interface (Initialized by MBM_TCP_Init())
    iSlave : s32 - Modbus Slave address (1 - 247)
    event : s32 - Eventcode, see MBM_TCP_EVENT_x
    aData{} - additional data depending on eventcode
    iLen - number of bytes available within aData
    Parameters aData{} and iLen are required to fulfil future requirements with compatible API.
    To enable this callback, define MBM_TCP_EVENT_ENABLE 1 in DDE, see MBM Advanced Library Configuration
    MBM_TCP_Connect(handle, iSlave, ip_addr{4}, iTimeout = 10000, port = 502)

    Connect to a Modbus TCP slave and handle reconnections if required

    handle : s32 - Handle of a MBM interface (Initialized by MBM_TCP_Init())
    iSlave : s32 - Modbus Slave address (1 - 247)
    ip_addr{4} : u8 - IPv4 Slave address
    iTimeout : s32 - TCP Connection timeout in ms
    port : s32 - TCP port to connect to
    TCP port number 502 is standardized by IANA (Internet Assigned Numbers Authority) for Modbus Application protocol.
    returns : s32
    OK - if successful
    ERROR - if one of the following errors occurs
  • interface is not supported or not active
  • Modbus slave address invalid
  • LAN interface library (e.g. w5200-microtronics) is not available or not supported
  • no more free TCP sockets
  • invalid connection state for Modbus Slave (e.g. already connected)
  • MBM_TCP_Connect function is non-blocking. If function returns with OK, connect has only been started. Callback function MBM_EvtTcp() is triggered with eventcode MBM_TCP_EVENT_CONNECTED if TCP connection was established. Callback function is triggered with eventcode MBM_TCP_EVENT_CONNECT_TIMEOUT if connect request timed out.
    MBM_TCP_Disconnect(handle, iSlave)

    Disconnect from Modbus TCP slave

    handle : s32 - Handle of a MBM interface (Initialized by MBM_TCP_Init())
    iSlave : s32 - Modbus Slave address (1 - 247)
    returns : s32
    OK - if successful
    ERROR - if one of the following errors occurs
  • interface is not supported or not active
  • Modbus slave address invalid
  • LAN interface library (e.g. w5200-microtronics) is not available or not supported
  • TMBM_TCP_STATE:
    MBM_TCP_STATE_OFF = 0 - no connection started
    MBM_TCP_STATE_CREATE_SOCKET = 1 - socket creation currently active
    MBM_TCP_STATE_CONNECT_PENDING = 2 - reconnection pending after link down
    MBM_TCP_STATE_CONNECTING = 3 - initial connection pending
    MBM_TCP_STATE_CONNECTED = 4 - device connected
    MBM_TCP_STATE_DISCONNECTING = 5 - device currently disconnecting
    MBM_TCP_STATE_DISCONNECTED = 6 - device disconnected
    MBM_TCP_STATE_LINK_LOST = 7 - Connection has been broken
    MBM_TCP_GetConnectionState(handle, iSlave, &iState)

    Get current TCP Connection State

    handle : s32 - Handle of a MBM interface (Initialized by MBM_TCP_Init())
    iSlave : s32 - Modbus Slave address (1 - 247)
    iState : s32 - TMBM_TCP_STATE - TCP Connection state
    returns : s32
    OK - if successful
    ERROR - if one of the following errors occurs
  • Invalid interface
  • Invalid slave number
  • No LAN Interface driver detected
  • M23X:

    MODBUS TCP:
    Modbus TCP is very similar to Modbus RTU. From the programmers perspective there are following major differences:
  • use MBM_TCP_Init() instead of MBM_Init()
  • use MBM_TCP_Connect() to connect to a Modbus TCP slave
  • use MBM_TCP_Disconnect() to disconnect from a Modbus TCP slave
  • Functional principle:
  • MBM_TCP_Init() and MBM_TCP_Connect() may be called consecutively. The library handles this asynchronously, meaning that connecting and reconnecting is handled internally until MBM_TCP_Disconnect() is called.
  • Default Configuration: see MBM Advanced_Config
    TMBM_LANSetup:

    LAN Setup structure for Modbus TCP

    ip{4}:u8 - Local IPv4 Address
    sn{4}:u8 - Subnet Mask
    gw{4}:u8 - Default Gateway
    mac{6}:u8 - MAC Address
    This field must only be filled if a dedicated custom MAC address is required. If this field is empty (default, all bytes 0x00), internal MAC address is used. This MAC address depends on the low level hardware driver (e.g. w5200-microtronics).
    Currently only static IP configuration is supported. Dynamic IP configuration through DHCP server is not (yet) supported.
    All fields within TMBM_LANSetup are big-endian organized, see code example below.
    /* Example for LAN setup structure */ static sLAN_Setup[TMBM_LANSetup] = [ { 192, 168, 10, 101}, /* Local IPv4 Address "192.168.10.101" */ { 255, 255, 255, 0}, /* Subnet Mask "255.255.255.0" */ { 192, 168, 10, 1}, /* Default Gateway "192.168.10.1" */ { 0, 0, 0, 0, 0, 0}, /* use internal MAC Address */ ];
    MBM_TCP_Init(&handle, Interface, sLAN_Setup[TMBM_LANSetup], iTimeout=1000)

    Initialize the MBM interface in TCP mode

    handle : s32 - Empty handle for a MBM communication interface
    Interface : s32 - MBM_INTERFACE_x
    sLAN_Setup : o - LAN Setup structure
    iTimeout : s32 - Modbus timeout (i.e. max. slave response time)
    >=100 - Timeout [ms] (min = 100, max = 10000)
    returns : s32
    OK - if successful
    ERROR - if one of the following errors occurs
  • interface is not supported
  • iTimeout is out of range
  • LAN interface library (e.g. w5200-microtronics) is not available or not supported
  • LAN chip init failed (e.g. due to HW problems)
  • MBM_TCP_Close(handle)

    Closes a MBM interface in TCP mode

    Interface can be re-opended again with MBM_TCP_Init().
    handle : s32 - handle for a MBM communication interface
    returns : s32
    OK - if successful
    ERROR - Interface is not initialized
    MBM_TCP_EVENT_x:

    Modbus TCP events

    MBM_TCP_EVENT_CONNECTED = 1 - Connection established
    MBM_TCP_EVENT_CONNECT_TIMEOUT = 2 - Initial connection request timed out. Unless MBM_TCP_Disconnect() is called, the library will still try to reconnect, even after this Event
    MBM_EvtTcp(handle, iSlave, event, aData{}, iLen)

    Optional Eventhandler that is called if a TCP related event occurs.

    handle : s32 - Handle of a MBM interface (Initialized by MBM_TCP_Init())
    iSlave : s32 - Modbus Slave address (1 - 247)
    event : s32 - Eventcode, see MBM_TCP_EVENT_x
    aData{} - additional data depending on eventcode
    iLen - number of bytes available within aData
    Parameters aData{} and iLen are required to fulfil future requirements with compatible API.
    To enable this callback, define MBM_TCP_EVENT_ENABLE 1 in DDE, see MBM Advanced Library Configuration
    MBM_TCP_Connect(handle, iSlave, ip_addr{4}, iTimeout = 10000, port = 502)

    Connect to a Modbus TCP slave and handle reconnections if required

    handle : s32 - Handle of a MBM interface (Initialized by MBM_TCP_Init())
    iSlave : s32 - Modbus Slave address (1 - 247)
    ip_addr{4} : u8 - IPv4 Slave address
    iTimeout : s32 - TCP Connection timeout in ms
    port : s32 - TCP port to connect to
    TCP port number 502 is standardized by IANA (Internet Assigned Numbers Authority) for Modbus Application protocol.
    returns : s32
    OK - if successful
    ERROR - if one of the following errors occurs
  • interface is not supported or not active
  • Modbus slave address invalid
  • LAN interface library (e.g. w5200-microtronics) is not available or not supported
  • no more free TCP sockets
  • invalid connection state for Modbus Slave (e.g. already connected)
  • MBM_TCP_Connect function is non-blocking. If function returns with OK, connect has only been started. Callback function MBM_EvtTcp() is triggered with eventcode MBM_TCP_EVENT_CONNECTED if TCP connection was established. Callback function is triggered with eventcode MBM_TCP_EVENT_CONNECT_TIMEOUT if connect request timed out.
    MBM_TCP_Disconnect(handle, iSlave)

    Disconnect from Modbus TCP slave

    handle : s32 - Handle of a MBM interface (Initialized by MBM_TCP_Init())
    iSlave : s32 - Modbus Slave address (1 - 247)
    returns : s32
    OK - if successful
    ERROR - if one of the following errors occurs
  • interface is not supported or not active
  • Modbus slave address invalid
  • LAN interface library (e.g. w5200-microtronics) is not available or not supported
  • TMBM_TCP_STATE:
    MBM_TCP_STATE_OFF = 0 - no connection started
    MBM_TCP_STATE_CREATE_SOCKET = 1 - socket creation currently active
    MBM_TCP_STATE_CONNECT_PENDING = 2 - reconnection pending after link down
    MBM_TCP_STATE_CONNECTING = 3 - initial connection pending
    MBM_TCP_STATE_CONNECTED = 4 - device connected
    MBM_TCP_STATE_DISCONNECTING = 5 - device currently disconnecting
    MBM_TCP_STATE_DISCONNECTED = 6 - device disconnected
    MBM_TCP_STATE_LINK_LOST = 7 - Connection has been broken
    MBM_TCP_GetConnectionState(handle, iSlave, &iState)

    Get current TCP Connection State

    handle : s32 - Handle of a MBM interface (Initialized by MBM_TCP_Init())
    iSlave : s32 - Modbus Slave address (1 - 247)
    iState : s32 - TMBM_TCP_STATE - TCP Connection state
    returns : s32
    OK - if successful
    ERROR - if one of the following errors occurs
  • Invalid interface
  • Invalid slave number
  • No LAN Interface driver detected
  • Expert

    M22X:

    Advanced_Config:
    The settings mentioned in this chapter should only be changed if really required (e.g. memory saving required). To adapt the settings add the following block to the main.dde file.
    rapidM2M M2/M23 (RS232 interfaces only):
    /** ---------------------------------------------------------------------------- * modbus-master-mt: Advanced Config * ----------------------------------------------------------------------------- * * Use this block to adapt the advanced configuration settings: * */ #define MBM_MAX_MSGSIZE 513 // Maximum Modbus message (PDU) size #define MBM_DELAY_BETWEEN_RW_OPS 100 // Time between R/W operations [ms]

    rapidM2M M2/M23 (RS485 interfaces are required):
    /** ---------------------------------------------------------------------------- * modbus-master-mt: Advanced Config * ----------------------------------------------------------------------------- * * Use this block to adapt the advanced configuration settings: * */ #define MBM_MAX_MSGSIZE 513 // Maximum Modbus message (PDU) size #define MBM_DELAY_BETWEEN_RW_OPS 100 // Time between R/W operations [ms] #define SC16IS741_SBUFFER_SIZE 513 // SC16IS741: Set custom send buffer size

    rapidM2M M2/M23 (TCP interface):
    To change the default pins for use with TCP interfaces, add the following block to the main.dde file.
    /** ---------------------------------------------------------------------------- * modbus-master-mt: TCP interface Config * ----------------------------------------------------------------------------- * * Use this block to change pin configuration settings of SPILAN chip * and advanced behaviour of MBM TCP lib * */ #define MBM_PORT_SPILAN 0 // W5200: SPI interface that should be used (0 to DP_SPI_CNT-1) #define MBM_PIN_SPILAN_RST 2 // W5200: GPIO pin for Reset (0 to DP_GPIO_CNT-1) #define MBM_PIN_SPILAN_CS 5 // W5200: GPIO pin for CS (0 to DP_GPIO_CNT-1) #define MBM_PIN_SPILAN_PD 3 // W5200: GPIO pin for PowerDown signal (0 to DP_GPIO_CNT-1) #define MBM_TCP_EVENT_ENABLE 1 // Enable MBM_EvtTcp() callback #define MBM_TCP_SOCKET_RECONNECT_ITV_S 5 // Set reconnect interval when slave closes socket

    rapidM2M EasyIoT:
    /** ---------------------------------------------------------------------------- * modbus-master-mt: Advanced Config * ----------------------------------------------------------------------------- * * Use this block to adapt the advanced configuration settings: * */ #define MBM_MAX_MSGSIZE 513 // Maximum Modbus message (PDU) size #define MBM_DELAY_BETWEEN_RW_OPS 100 // Time between R/W operations [ms]

    rapidM2M C3xx:
    /** ---------------------------------------------------------------------------- * modbus-master-mt: Advanced Config * ----------------------------------------------------------------------------- * * Use this block to adapt the advanced configuration settings: * * Note: IOCTRL_RSxxx_RXLEN and IOCTRL_RSxxx_TXLEN must be set to * the same value as MBM_MAX_MSGSIZE if the corresponding * interface is to be used */ #define MBM_MAX_MSGSIZE 513 // Maximum Modbus message (PDU) size #define MBM_DELAY_BETWEEN_RW_OPS 100 // Time between R/W operations [ms] #define IOCTRL_RS232_RXLEN 513 // Set custom RX-Buffer for RS232 interface #define IOCTRL_RS232_TXLEN 513 // Set custom TX-Buffer for RS232 interface #define IOCTRL_RS485_RXLEN 513 // Set custom RX-Buffer for RS485 interface #define IOCTRL_RS485_TXLEN 513 // Set custom TX-Buffer for RS485 interface
    The maximum protocol data unit (PDU) defined by the Modbus standard
  • for RTU mode is 256 bytes.
  • for ASCII mode is 513 bytes.
  • Debug Config:
    To configure debug mode add the following block to the main.dde file.
    /** ---------------------------------------------------------------------------- * modbus-master-mt: Debug Config * ----------------------------------------------------------------------------- * * Use this block to configure the debug mode: * * 0: No outputs * 1: Output the reasons for error returns of functions * 2: Output error reasons + Extended debug output (e.g. raw data * transmitted via the serial interface) */ #define MBM_DEBUG 0
    MBM_MAX_MSGSIZE -

    Maximum Modbus message (PDU) size [bytes] (default = 256 bytes).

    The RX/TX buffer settings will be adjusted accordingly by the library on rapidM2M EasyIoT/M2/M23 devices. For rapidM2M C3xx devices, the RX/TX buffers must be adjusted manually (see Advanced_Config)
    The maximum protocol data unit (PDU) defined by the Modbus standard
  • for RTU mode is 256 bytes.
  • for ASCII mode is 513 bytes.
  • MBM_DELAY_BETWEEN_RW_OPS -

    Time between R/W operations [ms] (default 100ms)

    M23X:

    Advanced_Config:
    The settings mentioned in this chapter should only be changed if really required (e.g. memory saving required). To adapt the settings add the following block to the main.dde file.
    rapidM2M M2/M23 (RS232 interfaces only):
    /** ---------------------------------------------------------------------------- * modbus-master-mt: Advanced Config * ----------------------------------------------------------------------------- * * Use this block to adapt the advanced configuration settings: * */ #define MBM_MAX_MSGSIZE 513 // Maximum Modbus message (PDU) size #define MBM_DELAY_BETWEEN_RW_OPS 100 // Time between R/W operations [ms]

    rapidM2M M2/M23 (RS485 interfaces are required):
    /** ---------------------------------------------------------------------------- * modbus-master-mt: Advanced Config * ----------------------------------------------------------------------------- * * Use this block to adapt the advanced configuration settings: * */ #define MBM_MAX_MSGSIZE 513 // Maximum Modbus message (PDU) size #define MBM_DELAY_BETWEEN_RW_OPS 100 // Time between R/W operations [ms] #define SC16IS741_SBUFFER_SIZE 513 // SC16IS741: Set custom send buffer size

    rapidM2M M2/M23 (TCP interface):
    To change the default pins for use with TCP interfaces, add the following block to the main.dde file.
    /** ---------------------------------------------------------------------------- * modbus-master-mt: TCP interface Config * ----------------------------------------------------------------------------- * * Use this block to change pin configuration settings of SPILAN chip * and advanced behaviour of MBM TCP lib * */ #define MBM_PORT_SPILAN 0 // W5200: SPI interface that should be used (0 to DP_SPI_CNT-1) #define MBM_PIN_SPILAN_RST 2 // W5200: GPIO pin for Reset (0 to DP_GPIO_CNT-1) #define MBM_PIN_SPILAN_CS 5 // W5200: GPIO pin for CS (0 to DP_GPIO_CNT-1) #define MBM_PIN_SPILAN_PD 3 // W5200: GPIO pin for PowerDown signal (0 to DP_GPIO_CNT-1) #define MBM_TCP_EVENT_ENABLE 1 // Enable MBM_EvtTcp() callback #define MBM_TCP_SOCKET_RECONNECT_ITV_S 5 // Set reconnect interval when slave closes socket

    rapidM2M EasyIoT:
    /** ---------------------------------------------------------------------------- * modbus-master-mt: Advanced Config * ----------------------------------------------------------------------------- * * Use this block to adapt the advanced configuration settings: * */ #define MBM_MAX_MSGSIZE 513 // Maximum Modbus message (PDU) size #define MBM_DELAY_BETWEEN_RW_OPS 100 // Time between R/W operations [ms]

    rapidM2M C3xx:
    /** ---------------------------------------------------------------------------- * modbus-master-mt: Advanced Config * ----------------------------------------------------------------------------- * * Use this block to adapt the advanced configuration settings: * * Note: IOCTRL_RSxxx_RXLEN and IOCTRL_RSxxx_TXLEN must be set to * the same value as MBM_MAX_MSGSIZE if the corresponding * interface is to be used */ #define MBM_MAX_MSGSIZE 513 // Maximum Modbus message (PDU) size #define MBM_DELAY_BETWEEN_RW_OPS 100 // Time between R/W operations [ms] #define IOCTRL_RS232_RXLEN 513 // Set custom RX-Buffer for RS232 interface #define IOCTRL_RS232_TXLEN 513 // Set custom TX-Buffer for RS232 interface #define IOCTRL_RS485_RXLEN 513 // Set custom RX-Buffer for RS485 interface #define IOCTRL_RS485_TXLEN 513 // Set custom TX-Buffer for RS485 interface
    The maximum protocol data unit (PDU) defined by the Modbus standard
  • for RTU mode is 256 bytes.
  • for ASCII mode is 513 bytes.
  • Debug Config:
    To configure debug mode add the following block to the main.dde file.
    /** ---------------------------------------------------------------------------- * modbus-master-mt: Debug Config * ----------------------------------------------------------------------------- * * Use this block to configure the debug mode: * * 0: No outputs * 1: Output the reasons for error returns of functions * 2: Output error reasons + Extended debug output (e.g. raw data * transmitted via the serial interface) */ #define MBM_DEBUG 0
    MBM_MAX_MSGSIZE -

    Maximum Modbus message (PDU) size [bytes] (default = 256 bytes).

    The RX/TX buffer settings will be adjusted accordingly by the library on rapidM2M EasyIoT/M2/M23 devices. For rapidM2M C3xx devices, the RX/TX buffers must be adjusted manually (see Advanced_Config)
    The maximum protocol data unit (PDU) defined by the Modbus standard
  • for RTU mode is 256 bytes.
  • for ASCII mode is 513 bytes.
  • MBM_DELAY_BETWEEN_RW_OPS -

    Time between R/W operations [ms] (default 100ms)

    M2EASYIOT:

    Advanced_Config:
    The settings mentioned in this chapter should only be changed if really required (e.g. memory saving required). To adapt the settings add the following block to the main.dde file.
    rapidM2M M2/M23 (RS232 interfaces only):
    /** ---------------------------------------------------------------------------- * modbus-master-mt: Advanced Config * ----------------------------------------------------------------------------- * * Use this block to adapt the advanced configuration settings: * */ #define MBM_MAX_MSGSIZE 513 // Maximum Modbus message (PDU) size #define MBM_DELAY_BETWEEN_RW_OPS 100 // Time between R/W operations [ms]

    rapidM2M M2/M23 (RS485 interfaces are required):
    /** ---------------------------------------------------------------------------- * modbus-master-mt: Advanced Config * ----------------------------------------------------------------------------- * * Use this block to adapt the advanced configuration settings: * */ #define MBM_MAX_MSGSIZE 513 // Maximum Modbus message (PDU) size #define MBM_DELAY_BETWEEN_RW_OPS 100 // Time between R/W operations [ms] #define SC16IS741_SBUFFER_SIZE 513 // SC16IS741: Set custom send buffer size

    rapidM2M M2/M23 (TCP interface):
    To change the default pins for use with TCP interfaces, add the following block to the main.dde file.
    /** ---------------------------------------------------------------------------- * modbus-master-mt: TCP interface Config * ----------------------------------------------------------------------------- * * Use this block to change pin configuration settings of SPILAN chip * and advanced behaviour of MBM TCP lib * */ #define MBM_PORT_SPILAN 0 // W5200: SPI interface that should be used (0 to DP_SPI_CNT-1) #define MBM_PIN_SPILAN_RST 2 // W5200: GPIO pin for Reset (0 to DP_GPIO_CNT-1) #define MBM_PIN_SPILAN_CS 5 // W5200: GPIO pin for CS (0 to DP_GPIO_CNT-1) #define MBM_PIN_SPILAN_PD 3 // W5200: GPIO pin for PowerDown signal (0 to DP_GPIO_CNT-1) #define MBM_TCP_EVENT_ENABLE 1 // Enable MBM_EvtTcp() callback #define MBM_TCP_SOCKET_RECONNECT_ITV_S 5 // Set reconnect interval when slave closes socket

    rapidM2M EasyIoT:
    /** ---------------------------------------------------------------------------- * modbus-master-mt: Advanced Config * ----------------------------------------------------------------------------- * * Use this block to adapt the advanced configuration settings: * */ #define MBM_MAX_MSGSIZE 513 // Maximum Modbus message (PDU) size #define MBM_DELAY_BETWEEN_RW_OPS 100 // Time between R/W operations [ms]

    rapidM2M C3xx:
    /** ---------------------------------------------------------------------------- * modbus-master-mt: Advanced Config * ----------------------------------------------------------------------------- * * Use this block to adapt the advanced configuration settings: * * Note: IOCTRL_RSxxx_RXLEN and IOCTRL_RSxxx_TXLEN must be set to * the same value as MBM_MAX_MSGSIZE if the corresponding * interface is to be used */ #define MBM_MAX_MSGSIZE 513 // Maximum Modbus message (PDU) size #define MBM_DELAY_BETWEEN_RW_OPS 100 // Time between R/W operations [ms] #define IOCTRL_RS232_RXLEN 513 // Set custom RX-Buffer for RS232 interface #define IOCTRL_RS232_TXLEN 513 // Set custom TX-Buffer for RS232 interface #define IOCTRL_RS485_RXLEN 513 // Set custom RX-Buffer for RS485 interface #define IOCTRL_RS485_TXLEN 513 // Set custom TX-Buffer for RS485 interface
    The maximum protocol data unit (PDU) defined by the Modbus standard
  • for RTU mode is 256 bytes.
  • for ASCII mode is 513 bytes.
  • Debug Config:
    To configure debug mode add the following block to the main.dde file.
    /** ---------------------------------------------------------------------------- * modbus-master-mt: Debug Config * ----------------------------------------------------------------------------- * * Use this block to configure the debug mode: * * 0: No outputs * 1: Output the reasons for error returns of functions * 2: Output error reasons + Extended debug output (e.g. raw data * transmitted via the serial interface) */ #define MBM_DEBUG 0
    MBM_MAX_MSGSIZE -

    Maximum Modbus message (PDU) size [bytes] (default = 256 bytes).

    The RX/TX buffer settings will be adjusted accordingly by the library on rapidM2M EasyIoT/M2/M23 devices. For rapidM2M C3xx devices, the RX/TX buffers must be adjusted manually (see Advanced_Config)
    The maximum protocol data unit (PDU) defined by the Modbus standard
  • for RTU mode is 256 bytes.
  • for ASCII mode is 513 bytes.
  • MBM_DELAY_BETWEEN_RW_OPS -

    Time between R/W operations [ms] (default 100ms)

    MBM_DL

    M22X:

    MBM_DL_MODULE:
    MBM_DL is an implementation provided by Microtronics for an automatic modbus handling which is based on some datalogger applications.
    If used in combination with the data-logger-4ch-mt or the mydataconc3-mt libraries it is enough to follow the steps in MBM_DL_BASIC_SETUP and MBM_DL_POV, if not please also follow the steps in MBM_DL_EXPERT_SETUP.
    MBM_DL_BASIC_SETUP:
    To use MBM_DL the following things need to be added to the DDE:
    defines
    /** ---------------------------------------------------------------------------- * modbus-master-mt: DataLogger Config * ----------------------------------------------------------------------------- * * Use this block to activate and configure the datalogger module of the modbus-master-mt library. * */ #define MBM_DL_USE 1 // 1: Use MBM_DL module (MBM_DL functions and predefined implementation of the MBM_EvtResponse) #define MBM_DL_DEBUG 0 // Debug level of the datalogger module: 0 = Off, 1 = General infos, 2 = all #define MBM_IN_CHANNELS_NUM 20 // Number of modbus input channels #define MBM_OUT_CHANNELS_NUM 12 // Number of modbus output channels #define ACTUAL_OUTPUT_VALUE_MBMOUT_OFFSET 1 // Offset used for the setpoint feature of the server: 3 in case of mydataconc3-mt, 1 else
    config1
    MBMChannelsIn[MBM_IN_CHANNELS_NUM]{ Type u8 edit=99 // see *note1 @Type Format u8 title=%TXT%dbdefs_mbs_mode bitmask=$03 editmask=0=%TXT%dbdefs_mode_bit;1=%TXT%dbdefs_mode_signed;2=%TXT%dbdefs_mode_unsigned;3=%TXT%dbdefs_mode_float default=3 dlorw=skip @Type Bits u8 title="Bits" bitmask=$04 editmask=0=16;1=32 default=1 dlorw=skip @Type WordOrder u8 title=%TXT%dbdefs_mbs_word_order bitmask=$08 editmask=0=HI-LO;1=LO-HI help=%TXT%dbdefsmodbuswordorder_help default=0 dlorw=skip SlaveAddress u8 title=%TXT%dbdefsusercfg_slave_address min=1 max=247 default=1 ModbusFunc u8 title=%TXT%dbdefs_mbs_function editmask=1=FC01;2=FC02;3=FC03;4=FC04 default=3 help="%TXT%dbdefsmodbusreadcoils <br> %TXT%dbdefsmodbusreaddiscreteinputs <br> %TXT%dbdefsmodbusreadholdingregisters <br> %TXT%dbdefsmodbusreadinputregisters" ModbusAddress u16 title=%TXT%dbdefsminiusercfg_modbus_address default=0 Min f32.3 title="0%" default=0 Max f32.3 title="100%" default=100 MBMin f32.3 title=%TXT%dbdefsminiqmodbusmin default=0 MBMax f32.3 title=%TXT%dbdefsminiqmodbusmax default=100 Itf u8 editmask=0=%TXT%off;1=%TXT%dbdefsifmodbus title=%TXT%dbdefsifinterface OverflowMode u8 title=%TXT%dbdefsusercfgfault editmask=0=%TXT%dbdefsusercfgfault4;1=%TXT%dbdefsusercfgfault1 ScaleCfg u8 editmask=0=%TXT%off;1=%TXT%on default=0 title=%TXT%dbdefsminiqscale }
    config2
    MBMAlarme[MBM_IN_CHANNELS_NUM]{ ThresholdAlarmLow f32.6 width=8 default=NAN title=%TXT%ch_alarmhigh_lower help=%TXT%ch_alarmhigh_lower_help ThresholdWarningLow f32.6 width=8 default=NAN title=%TXT%ch_alarmlow_lower help=%TXT%ch_alarmlow_lower_help ThresholdWarningHigh f32.6 width=8 default=NAN title=%TXT%ch_alarmlow_upper help=%TXT%ch_alarmlow_upper_help @ThresholdWarningHigh ThresholdWarningHigh_digital f32.1 editmask=%CHECKBOX%NAN;1 title=%TXT%dbdefscompcfg_triger_alarm_low help=%TXT%dbdefscompcfg_triger_alarm_low_help dlorw=skip ThresholdAlarmHigh f32.6 width=8 default=NAN title=%TXT%ch_alarmhigh_upper help=%TXT%ch_alarmhigh_upper_help @ThresholdAlarmHigh ThresholdAlarmHigh_digital f32.1 editmask=%CHECKBOX%NAN;1 title=%TXT%dbdefscompcfg_triger_alarm_high help=%TXT%dbdefscompcfg_triger_alarm_high_help dlorw=skip Hysteresis f32.6 width=8 default=ALARM_HYSTERESIS_DEFAULT title=%TXT%ch_hyst min=0.0 help=%TXT%field_help_hyst Trigger u16 decpl=0 view=8 edit=99 // see *note1 @Trigger RecordOn u16 decpl=0 bitmask=$0001 editmask=%CHECKBOX% title=%TXT%dbdefscompcfg_triger_record_immediate_on help=%TXT%dbdefscompcfg_triger_record_immediate_on_help dlorw=skip @Trigger Transmission u16 decpl=0 bitmask=$0002 editmask=%CHECKBOX% title=%TXT%dbdefscompcfg_triger_xmit_start help=%TXT%dbdefscompcfg_triger_xmit_start_help dlorw=skip @Trigger Online u16 decpl=0 bitmask=$0004 editmask=%CHECKBOX% title=%TXT%dbdefscompcfg_triger_continous help=%TXT%dbdefscompcfg_triger_continous_help dlorw=skip view=8 edit=8 @Trigger FastRecord u16 decpl=0 bitmask=$0008 editmask=%CHECKBOX% title=%TXT%dbdefscompcfg_triger_record_alternative help=%TXT%dbdefscompcfg_triger_record_alternative_help dlorw=skip @Trigger FastTransItv u16 decpl=0 bitmask=$0080 editmask=%CHECKBOX% title=QX help=%TXT%dbdefscompcfg_triger_do_qx_help dlorw=skip @Trigger DigitalEdge u16 decpl=0 bitmask=$6000 title=%TXT%dbdefsusercfgedge editmask=1=%TXT%dbdefsusercfgedge_rising;2=%TXT%dbdefsusercfgedge_falling;3=%TXT%dbdefsusercfgedge_both default=ALARM_DIGITAL_EDGE_DEFAULT dlorw=skip @Trigger BiggerThan u16 decpl=0 bitmask=$8000 title=" " editmask=0=%TXT%less_or_equal;1=%TXT%greater_or_equal dlorw=skip ThresholdTrigger f32.6 title=%TXT%dbdefscompcfg_triger_level autoedit=22x11 default=NAN HysteresisTrigger f32.6 default=ALARM_HYSTERESIS_TRIGGER_DEFAULT title=%TXT%ch_hyst min=0.0 }
    config3
    MBMChOutCfg[MBM_OUT_CHANNELS_NUM]{ Type u8 edit=99 // see *note1 @Type Format u8 title=%TXT%dbdefs_mbs_mode bitmask=$03 editmask=0=%TXT%dbdefs_mode_bit;1=%TXT%dbdefs_mode_signed;2=%TXT%dbdefs_mode_unsigned;3=%TXT%dbdefs_mode_float default=3 dlorw=skip @Type Bits u8 title="Bits" bitmask=$04 editmask=0=16;1=32 default=1 dlorw=skip @Type WordOrder u8 title=%TXT%dbdefs_mbs_word_order bitmask=$08 editmask=0=HI-LO;1=LO-HI help=%TXT%dbdefsmodbuswordorder_help default=0 dlorw=skip SlaveAddress u8 title=%TXT%dbdefsusercfg_slave_address min=1 max=247 default=1 ModbusFunc u8 title=%TXT%dbdefs_mbs_function editmask=5=FC05;6=FC06;15=FC15;16=FC16 default=16 help="%TXT%dbdefsmodbuswritesinglecoil <br> %TXT%dbdefsmodbuswritesingleregister <br> %TXT%dbdefsmodbuswritemultiplecoils <br> %TXT%dbdefsmodbuswritemultipleregisters" ModbusAddress u16 title=%TXT%dbdefsminiusercfg_modbus_address default=0 Min f32.3 title="0%" default=0 Max f32.3 title="100%" default=100 MBMin f32.3 title=%TXT%dbdefsminiqmodbusmin default=0 MBMax f32.3 title=%TXT%dbdefsminiqmodbusmax default=100 Itf u8 editmask=0=%TXT%off;1=%TXT%dbdefsifmodbus title=%TXT%dbdefsifinterface Flags u8 title="%TXT%mbm_send_on_change" editmask=%CHECKBOX% help="%TXT%mbm_send_on_change_help" ScaleCfg u8 editmask=0=%TXT%off;1=%TXT%on default=0 title=%TXT%dbdefsminiqscale }
    config4
    MBMValuesOut[MBM_OUT_CHANNELS_NUM] f32 title=%TXT%dbdefs_output_value param0=%FFFF0005%actual_output_value_(n+ACTUAL_OUTPUT_VALUE_MBMOUT_OFFSET)
    config8
    MBMItfCfg u8 title="%TXT%dbdefsifmodbus" editmask=0=%TXT%off;2=%TXT%on MBMBaudrate u32 title="%TXT%dbdefsifbaud" editmask=300=300;600=600;1200=1200;2400=2400;4800=4800;9600=9600;19200=19200;38400=38400;57600=57600;115200=115200 default=9600 //dropdown with different baudrates, no mapping, like MUC MBMCharFormat u8 edit=99 // Bit 0..1 TSerial_StopBits, Bit 2..3 TSerial_Parity, Bit 4..5 TSerial_DataBits, Bit 6 TSerial_Termination, Bit 7 TSerial_Bias // see *note1 @MBMCharFormat MBMStopBits u8 title="%TXT%dbdefsifstopbits" bitmask=$03 default=1 editmask=1=1;2=2 dlorw=skip @MBMCharFormat MBMParity u8 title="%TXT%dbdefsifparity" bitmask=$0C default=0 editmask=0=%TXT%dbdefsifparityn;1=%TXT%dbdefsifparityo;2=%TXT%dbdefsifparitye dlorw=skip @MBMCharFormat MBMDatabits u8 title="%TXT%dbdefsifdatabits" bitmask=$30 default=1 editmask=0=7;1=8 dlorw=skip @MBMCharFormat MBMTermination u8 title="%TXT%dbdefsiftermination" bitmask=$40 default=0 editmask=%CHECKBOX% dlorw=skip @MBMCharFormat MBMBias u8 title="Bias" bitmask=$80 default=0 editmask=%CHECKBOX% dlorw=skip MBMResponseTimeout u16 title="Timeout [s]" units=%TXT%seconds decpl=3 vscale=0.001 min=0.1 max=10 default=1 help=%TXT%seconds //Timeout 100 - 10000 ms in sekunden eingeben MBMHoldTime u8 title="%TXT%dbdefsusercfghold" help="%TXT%mbm_hold_time_help" MBMRetry u8 title="%TXT%dbdefsifretry" editmask=0=Off;1=1;2=2;3=3
    configA
    MBMChannelsIn[MBM_IN_CHANNELS_NUM]{ Title ustr.16 title="%TXT%ch_title (n+1)" default="MBMin (n+1)" Unit ustr.8 title=%TXT%ch_unit Mode u8 editmask=1=%TXT%dbdefs_ch_mode_digital;8=%TXT%dbdefs_ch_mode_analog;18=%TXT%dbdefscntday;2=%TXT%dbdefscntint title=%TXT%dbdefsifmode default=8 Decpl s8 title=%TXT%ch_decpl editmask=-1=%TXT%default;0=0;1=1;2=2;3=3;4=4;5=5;6=6 default=-1 } MBMChannelsOut[MBM_OUT_CHANNELS_NUM]{ Title ustr.16 title="%TXT%ch_title (n+1)" default="MBMout (n+1)" Unit ustr.8 title=%TXT%ch_unit Mode u8 editmask=1=%TXT%dbdefs_ch_mode_digital;8=%TXT%dbdefs_ch_mode_analog;18=%TXT%dbdefscntday;2=%TXT%dbdefscntint title=%TXT%dbdefsifmode default=8 Decpl s8 title=%TXT%ch_decpl editmask=-1=%TXT%default;0=0;1=1;2=2;3=3;4=4;5=5;6=6 default=-1 }
    histdata0
    MBMChannelsIn[MBM_IN_CHANNELS_NUM] f32.3 title=%configA%MBMChannelsIn[(n)].Title units=%configA%MBMChannelsIn[(n)].Unit decpl=%configA%MBMChannelsIn[(n)].Decpl chmode=%configA%MBMChannelsIn[(n)].Mode%1=1;8=8;18=2;2=3 ialarm_low=%config2%MBMAlarme[(n)].thresholdalarmlow ialarm_high=%config2%MBMAlarme[(n)].thresholdalarmhigh iwarn_low=%config2%MBMAlarme[(n)].thresholdwarninglow iwarn_high=%config2%MBMAlarme[(n)].thresholdwarninghigh itrigger=%config2%MBMAlarme[(n)].thresholdtrigger hysterese=%config2%MBMAlarme[(n)].hysteresis MBMChannelsOut[MBM_OUT_CHANNELS_NUM] f32.3 title=%configA%MBMChannelsOut[(n)].Title units=%configA%MBMChannelsOut[(n)].Unit decpl=%configA%MBMChannelsOut[(n)].Decpl chmode=%configA%MBMChannelsOut[(n)].Mode%1=1;8=8;18=2;2=3 setpoint=config4;MBMValuesOut[(n)];actual_output_value_(n+ACTUAL_OUTPUT_VALUE_MBMOUT_OFFSET)
    notes
    // *note1: The value of this field is calculated through more than one shadow field. To prevent an update of this field without the consideration of all its shadow fields edit=99 is needed.
    Additionally there is some content to be added to the language file:
    tag en de mbm_hold_time_help Number of measuring cycles for which the last measurement value is held before an error value is written in the channel Anzahl der Messzyklen, für die der letztgültige Messwert gehalten wird, bevor ein Fehlerwert am Kanal ausgegeben wird mbm_send_on_change Send on change bei Änderung senden mbm_send_on_change_help OFF: The configured value is written to the bus on each measurement interval <br> ON: The value is written to the bus once after a change on the next measurement interval OFF: Der eingestellte Stellwert wird im Messintervall zyklisch auf den Bus geschrieben <br> ON: Der Stellwert wird nur einmal nach Änderung im nachfolgenden Messintervall auf den Bus geschrieben
    MBM_DL_EXPERT_SETUP:
    When using this module without one of the before mentioned libraries here are the interfacing functions and when to use them.
  • MBM_DL_SetItfSettings - Everytime a new config is received.
  • MBM_DL_Init - If the device switches in an active mode (e.g normal operation mode) and if you reveice a new config in one of these modes.
  • MBM_DL_Close - If the device switches in a passive mode (e.g. transport mode)
  • MBM_DL_Sample - When the measurement timer has expired to read all configured modbus input channels
  • MBM_DL_SetOutput - When the set output timer has expired to write all configured modbus output channels
  • MBM_DL_IsActive - When you need to wait for the sampling of the modbus input channels or setting of the modbus output channels to finish
  • MBM_DL_UpdateInputCfg - When receiving a new config for all modbus input channels
  • MBM_DL_UpdateOutputCfg - When receiving a new config for all modbus output channels
  • MBM_DL_GetDataValues - When the latest received modbus channel data is needed (e.g. after MBM_DL_IsActive switches back to false, or before writing histdata)
  • MBM_DL_UpdateOutputValues - When receiving new output values for all modbus output channels
  • MBM_DL_SetOutputValue - This function can be used to set a specific modbus output channel to a specific value (e.g. within a callback e.g. Measurement_Done)
  • MBM_DL_SetItfSettings(iMBMInterface, iMBMBaudrate, iMBMCharFormat, iMBMResponseTimeout, iMBMRetryCount, iMBMHoldCount=0)

    Function to configure the modbus interface

    iMBMInterface : u8 - serial interface that should be used for the MBM communication (use MBM_INTERFACE_x)
    iMBMBaudrate : u32 - Baud rate to be used
    iMBMCharFormat : u8 - Flags to configure the interface
    0b00000001 - 1 stop bit
    0b00000010 - 2 stop bits
    0b00000000 - no parity
    0b00000100 - odd parity
    0b00001000 - even parity
    0b00000000 - 7 data bits
    0b00010000 - 8 data bits
    0b00000000 - deactivate termination resistors
    0b01000000 - activate termination resistors
    0b00000000 - deactivate bias resistors
    0b10000000 - activate bias resistors
    iMBMResponseTimeout : u16 - Modbus response timeout [ms]
    min = 100, max = 10000
    iMBMRetryCount : u8 - Number of times it is retried to read/write a modbus input/output before it is skipped
    iMBMHoldCount : u8 - Number of times the last valid data is kept in case of an errors
    MBM_DL_Init()

    Function to initialize the modbus interface with the parameters set via MBM_DL_SetItfSettings. If MBM_DL_SetItfSettings wasn't called beforhand the interface will only be closed.

    MBM_DL_Close()

    Function to close the modbus interface

    MBM_DL_Sample()

    Function to sample all configured modbus input channels

    returns : s32
    < OK - If one of the following errors occurs
  • Interface is not initialized
  • Interface is currently busy
  • = OK - Sampling is starting
    > OK - Power saving is active and sampling will start after interface is opened
    MBM_DL_SetOutput()

    Function to set all configured modbus output channels

    returns : s32
    < OK - If one of the following errors occurs
  • Interface is not initialized
  • Interface is currently busy
  • = OK - Writing is starting
    > OK - Power saving is active and writing will start after interface is opened
    MBM_DL_IsActive()

    Function to check if a read or write action is active

    returns : bool
    true - If sampling modbus input channels or writing modbus output channels is active
    false - else
    MBM_DL_UpdateInputCfg(aInputConfig[DDE_Channel_MBMChannelsIn_dim])

    Function to update the input configuration

    aInputConfig : DDE_Channel_MBMChannelsIn - Array which contains the config for all modbus input channels
    MBM_DL_UpdateOutputCfg(aOutputConfig[DDE_ChannelOutput_MBMChOutCfg_dim])

    Function to update the output configuration

    aOutputConfig : DDE_ChannelOutput_MBMChOutCfg - Array which contains the config for all modbus output channels
    MBM_DL_GetDataValues(aValues[MBM_IN_CHANNELS_NUM + MBM_OUT_CHANNELS_NUM])
    aValues : TYPE_DATA - Array to put all data of the modbus input channels and output channels into
    MBM_DL_UpdateOutputValues(aMBMOutputValues[MBM_OUT_CHANNELS_NUM])

    Function to update the output values

    aMBMOutputValues : s32 - Array which contains all output values for all modbus output channels
    MBM_DL_SetOutputValue(fValue, iMBMOutChannel)

    Function to set a specific output value

    fValue : Float - Value to set the specific modbus output channel to
    iMBMOutChannel : s32 - modbus output channel number on which to set the value
    MBM_DL_POV:
    If you want to use the POV you can do it in 2 ways:
    In combination with another POV
    (e.g. myDataconC3)
    <template lang="pug"> // === this is the PORTAL VIEW's DETAILS representation === .pov-details // Creates the myDataconC3 universal datalogger application details POV .loading-spinner.fa.fa-spinner.fa-spin.fa-3x.fa-fw(v-if='!loaded_') myDataconC3DetailsPOV(v-if="loaded_", :createEMwDef="createEMwDef" :isAppl_="isAppl_" :calcChannelsTabNames="calcChannelsTabNames" :blueprint="blueprint", :data="data", :basic="basic") template(slot="addon-slot-3") MBMDetailsPOV(:blueprint="blueprint" :data="data") table.btn-line(cellspacing='0' cellpadding='0' width='100%') tr td .btn-group button.btn.btn-default(type='button' @click='back') %TXT%cancel button.btn.btn-default(v-if='!newSite_' @click='apply(false)' :disabled='!!saving_') %TXT%apply button.btn.btn-default(type='button' @click='save' :disabled='!!saving_') %TXT%save </template> <script> // Import the myDataconC3DetailsPOV sub-component import { myDataconC3DetailsPOV } from 'mydataconc3-mt'; import { MBMDetailsPOV } from 'modbus-master-mt'; export default { name: "pov-details", mixins: [MDN.vueSiteDetailsMixin], // Registers sub-components components: { myDataconC3DetailsPOV, MBMDetailsPOV }, data() { return { } }, watch: { loaded_() { MDN.siteEditor = this; //------- EVENT controlled --------------------- if (this.PAPI.site_uid) { //not needed in APPL config const siteEditor = this; if (this.basic.device) { const updateBlock = async (eventId) => { if (eventId==='device') { //information about currently assigned device is contained in site object siteEditor.siteController_.loadSite(function(){ if (!siteEditor.siteController_.resultCache.basic.device) Vue.set(siteEditor.basic, 'device', null); else { if (!siteEditor.basic.device || siteEditor.basic.device._uid !== siteEditor.siteController_.resultCache.basic.device._uid) Vue.set(siteEditor.basic, 'device', siteEditor.siteController_.resultCache.basic.device); else //if the device is already there Vue.set(siteEditor.basic.device, 'con', siteEditor.siteController_.resultCache.basic.device.con); } }); } }; AutoReloadSpanOnChange("__id", updateBlock, "device", this.basic.device._uid); } } //------- END EVENT controlled ----------------- }, }, methods: { }, created() { }, mounted() { } } </script> <style lang="less" scoped> // the DETAILS POV style definitions .pov-details { } </style>
    Standalone
    <template lang="pug"> // === this is the PORTAL VIEW's DETAILS representation === .pov-details // Creates the Modbus Master application details POV .loading-spinner.fa.fa-spinner.fa-spin.fa-3x.fa-fw(v-if='!loaded_') MBMDetailsPOV(v-if="loaded_", :blueprint="blueprint", :data="data") table.btn-line(cellspacing='0' cellpadding='0' width='100%') tr td .btn-group button.btn.btn-default(type='button' @click='back') %TXT%cancel button.btn.btn-default(v-if='!newSite_' @click='apply(false)' :disabled='!!saving_') %TXT%apply button.btn.btn-default(type='button' @click='save' :disabled='!!saving_') %TXT%save </template> <script> // Import the MBMDetailsPOV sub-component import { MBMDetailsPOV } from 'modbus-master-mt'; export default { name: "pov-details", mixins: [MDN.vueSiteDetailsMixin], // Registers sub-components components: { MBMDetailsPOV }, data() { return { } }, watch: { loaded_() { MDN.siteEditor = this; //------- EVENT controlled --------------------- if (this.PAPI.site_uid) { //not needed in APPL config const siteEditor = this; if (this.basic.device) { const updateBlock = async (eventId) => { if (eventId==='device') { //information about currently assigned device is contained in site object siteEditor.siteController_.loadSite(function(){ if (!siteEditor.siteController_.resultCache.basic.device) Vue.set(siteEditor.basic, 'device', null); else { if (!siteEditor.basic.device || siteEditor.basic.device._uid !== siteEditor.siteController_.resultCache.basic.device._uid) Vue.set(siteEditor.basic, 'device', siteEditor.siteController_.resultCache.basic.device); else //if the device is already there Vue.set(siteEditor.basic.device, 'con', siteEditor.siteController_.resultCache.basic.device.con); } }); } }; AutoReloadSpanOnChange("__id", updateBlock, "device", this.basic.device._uid); } } //------- END EVENT controlled ----------------- }, }, methods: { }, created() { }, mounted() { } } </script> <style lang="less" scoped> // the DETAILS POV style definitions .pov-details { } </style>
    CONC3_CH_DATA_MBM_x:

    Extension of CONC3_CH_DATA_x

    CONC3_CH_DATA_MBM_IN_FIRST - First Modbus In Channel
    CONC3_CH_DATA_MBM_IN_LAST - Last ModBus In Channel
    CONC3_CH_DATA_MBM_OUT_FIRST - First Modbus Out Channel
    CONC3_CH_DATA_MBM_OUT_LAST - Last ModBus Out Channel

    M23X:

    MBM_DL_MODULE:
    MBM_DL is an implementation provided by Microtronics for an automatic modbus handling which is based on some datalogger applications.
    If used in combination with the data-logger-4ch-mt or the mydataconc3-mt libraries it is enough to follow the steps in MBM_DL_BASIC_SETUP and MBM_DL_POV, if not please also follow the steps in MBM_DL_EXPERT_SETUP.
    MBM_DL_BASIC_SETUP:
    To use MBM_DL the following things need to be added to the DDE:
    defines
    /** ---------------------------------------------------------------------------- * modbus-master-mt: DataLogger Config * ----------------------------------------------------------------------------- * * Use this block to activate and configure the datalogger module of the modbus-master-mt library. * */ #define MBM_DL_USE 1 // 1: Use MBM_DL module (MBM_DL functions and predefined implementation of the MBM_EvtResponse) #define MBM_DL_DEBUG 0 // Debug level of the datalogger module: 0 = Off, 1 = General infos, 2 = all #define MBM_IN_CHANNELS_NUM 20 // Number of modbus input channels #define MBM_OUT_CHANNELS_NUM 12 // Number of modbus output channels #define ACTUAL_OUTPUT_VALUE_MBMOUT_OFFSET 1 // Offset used for the setpoint feature of the server: 3 in case of mydataconc3-mt, 1 else
    config1
    MBMChannelsIn[MBM_IN_CHANNELS_NUM]{ Type u8 edit=99 // see *note1 @Type Format u8 title=%TXT%dbdefs_mbs_mode bitmask=$03 editmask=0=%TXT%dbdefs_mode_bit;1=%TXT%dbdefs_mode_signed;2=%TXT%dbdefs_mode_unsigned;3=%TXT%dbdefs_mode_float default=3 dlorw=skip @Type Bits u8 title="Bits" bitmask=$04 editmask=0=16;1=32 default=1 dlorw=skip @Type WordOrder u8 title=%TXT%dbdefs_mbs_word_order bitmask=$08 editmask=0=HI-LO;1=LO-HI help=%TXT%dbdefsmodbuswordorder_help default=0 dlorw=skip SlaveAddress u8 title=%TXT%dbdefsusercfg_slave_address min=1 max=247 default=1 ModbusFunc u8 title=%TXT%dbdefs_mbs_function editmask=1=FC01;2=FC02;3=FC03;4=FC04 default=3 help="%TXT%dbdefsmodbusreadcoils <br> %TXT%dbdefsmodbusreaddiscreteinputs <br> %TXT%dbdefsmodbusreadholdingregisters <br> %TXT%dbdefsmodbusreadinputregisters" ModbusAddress u16 title=%TXT%dbdefsminiusercfg_modbus_address default=0 Min f32.3 title="0%" default=0 Max f32.3 title="100%" default=100 MBMin f32.3 title=%TXT%dbdefsminiqmodbusmin default=0 MBMax f32.3 title=%TXT%dbdefsminiqmodbusmax default=100 Itf u8 editmask=0=%TXT%off;1=%TXT%dbdefsifmodbus title=%TXT%dbdefsifinterface OverflowMode u8 title=%TXT%dbdefsusercfgfault editmask=0=%TXT%dbdefsusercfgfault4;1=%TXT%dbdefsusercfgfault1 ScaleCfg u8 editmask=0=%TXT%off;1=%TXT%on default=0 title=%TXT%dbdefsminiqscale }
    config2
    MBMAlarme[MBM_IN_CHANNELS_NUM]{ ThresholdAlarmLow f32.6 width=8 default=NAN title=%TXT%ch_alarmhigh_lower help=%TXT%ch_alarmhigh_lower_help ThresholdWarningLow f32.6 width=8 default=NAN title=%TXT%ch_alarmlow_lower help=%TXT%ch_alarmlow_lower_help ThresholdWarningHigh f32.6 width=8 default=NAN title=%TXT%ch_alarmlow_upper help=%TXT%ch_alarmlow_upper_help @ThresholdWarningHigh ThresholdWarningHigh_digital f32.1 editmask=%CHECKBOX%NAN;1 title=%TXT%dbdefscompcfg_triger_alarm_low help=%TXT%dbdefscompcfg_triger_alarm_low_help dlorw=skip ThresholdAlarmHigh f32.6 width=8 default=NAN title=%TXT%ch_alarmhigh_upper help=%TXT%ch_alarmhigh_upper_help @ThresholdAlarmHigh ThresholdAlarmHigh_digital f32.1 editmask=%CHECKBOX%NAN;1 title=%TXT%dbdefscompcfg_triger_alarm_high help=%TXT%dbdefscompcfg_triger_alarm_high_help dlorw=skip Hysteresis f32.6 width=8 default=ALARM_HYSTERESIS_DEFAULT title=%TXT%ch_hyst min=0.0 help=%TXT%field_help_hyst Trigger u16 decpl=0 view=8 edit=99 // see *note1 @Trigger RecordOn u16 decpl=0 bitmask=$0001 editmask=%CHECKBOX% title=%TXT%dbdefscompcfg_triger_record_immediate_on help=%TXT%dbdefscompcfg_triger_record_immediate_on_help dlorw=skip @Trigger Transmission u16 decpl=0 bitmask=$0002 editmask=%CHECKBOX% title=%TXT%dbdefscompcfg_triger_xmit_start help=%TXT%dbdefscompcfg_triger_xmit_start_help dlorw=skip @Trigger Online u16 decpl=0 bitmask=$0004 editmask=%CHECKBOX% title=%TXT%dbdefscompcfg_triger_continous help=%TXT%dbdefscompcfg_triger_continous_help dlorw=skip view=8 edit=8 @Trigger FastRecord u16 decpl=0 bitmask=$0008 editmask=%CHECKBOX% title=%TXT%dbdefscompcfg_triger_record_alternative help=%TXT%dbdefscompcfg_triger_record_alternative_help dlorw=skip @Trigger FastTransItv u16 decpl=0 bitmask=$0080 editmask=%CHECKBOX% title=QX help=%TXT%dbdefscompcfg_triger_do_qx_help dlorw=skip @Trigger DigitalEdge u16 decpl=0 bitmask=$6000 title=%TXT%dbdefsusercfgedge editmask=1=%TXT%dbdefsusercfgedge_rising;2=%TXT%dbdefsusercfgedge_falling;3=%TXT%dbdefsusercfgedge_both default=ALARM_DIGITAL_EDGE_DEFAULT dlorw=skip @Trigger BiggerThan u16 decpl=0 bitmask=$8000 title=" " editmask=0=%TXT%less_or_equal;1=%TXT%greater_or_equal dlorw=skip ThresholdTrigger f32.6 title=%TXT%dbdefscompcfg_triger_level autoedit=22x11 default=NAN HysteresisTrigger f32.6 default=ALARM_HYSTERESIS_TRIGGER_DEFAULT title=%TXT%ch_hyst min=0.0 }
    config3
    MBMChOutCfg[MBM_OUT_CHANNELS_NUM]{ Type u8 edit=99 // see *note1 @Type Format u8 title=%TXT%dbdefs_mbs_mode bitmask=$03 editmask=0=%TXT%dbdefs_mode_bit;1=%TXT%dbdefs_mode_signed;2=%TXT%dbdefs_mode_unsigned;3=%TXT%dbdefs_mode_float default=3 dlorw=skip @Type Bits u8 title="Bits" bitmask=$04 editmask=0=16;1=32 default=1 dlorw=skip @Type WordOrder u8 title=%TXT%dbdefs_mbs_word_order bitmask=$08 editmask=0=HI-LO;1=LO-HI help=%TXT%dbdefsmodbuswordorder_help default=0 dlorw=skip SlaveAddress u8 title=%TXT%dbdefsusercfg_slave_address min=1 max=247 default=1 ModbusFunc u8 title=%TXT%dbdefs_mbs_function editmask=5=FC05;6=FC06;15=FC15;16=FC16 default=16 help="%TXT%dbdefsmodbuswritesinglecoil <br> %TXT%dbdefsmodbuswritesingleregister <br> %TXT%dbdefsmodbuswritemultiplecoils <br> %TXT%dbdefsmodbuswritemultipleregisters" ModbusAddress u16 title=%TXT%dbdefsminiusercfg_modbus_address default=0 Min f32.3 title="0%" default=0 Max f32.3 title="100%" default=100 MBMin f32.3 title=%TXT%dbdefsminiqmodbusmin default=0 MBMax f32.3 title=%TXT%dbdefsminiqmodbusmax default=100 Itf u8 editmask=0=%TXT%off;1=%TXT%dbdefsifmodbus title=%TXT%dbdefsifinterface Flags u8 title="%TXT%mbm_send_on_change" editmask=%CHECKBOX% help="%TXT%mbm_send_on_change_help" ScaleCfg u8 editmask=0=%TXT%off;1=%TXT%on default=0 title=%TXT%dbdefsminiqscale }
    config4
    MBMValuesOut[MBM_OUT_CHANNELS_NUM] f32 title=%TXT%dbdefs_output_value param0=%FFFF0005%actual_output_value_(n+ACTUAL_OUTPUT_VALUE_MBMOUT_OFFSET)
    config8
    MBMItfCfg u8 title="%TXT%dbdefsifmodbus" editmask=0=%TXT%off;2=%TXT%on MBMBaudrate u32 title="%TXT%dbdefsifbaud" editmask=300=300;600=600;1200=1200;2400=2400;4800=4800;9600=9600;19200=19200;38400=38400;57600=57600;115200=115200 default=9600 //dropdown with different baudrates, no mapping, like MUC MBMCharFormat u8 edit=99 // Bit 0..1 TSerial_StopBits, Bit 2..3 TSerial_Parity, Bit 4..5 TSerial_DataBits, Bit 6 TSerial_Termination, Bit 7 TSerial_Bias // see *note1 @MBMCharFormat MBMStopBits u8 title="%TXT%dbdefsifstopbits" bitmask=$03 default=1 editmask=1=1;2=2 dlorw=skip @MBMCharFormat MBMParity u8 title="%TXT%dbdefsifparity" bitmask=$0C default=0 editmask=0=%TXT%dbdefsifparityn;1=%TXT%dbdefsifparityo;2=%TXT%dbdefsifparitye dlorw=skip @MBMCharFormat MBMDatabits u8 title="%TXT%dbdefsifdatabits" bitmask=$30 default=1 editmask=0=7;1=8 dlorw=skip @MBMCharFormat MBMTermination u8 title="%TXT%dbdefsiftermination" bitmask=$40 default=0 editmask=%CHECKBOX% dlorw=skip @MBMCharFormat MBMBias u8 title="Bias" bitmask=$80 default=0 editmask=%CHECKBOX% dlorw=skip MBMResponseTimeout u16 title="Timeout [s]" units=%TXT%seconds decpl=3 vscale=0.001 min=0.1 max=10 default=1 help=%TXT%seconds //Timeout 100 - 10000 ms in sekunden eingeben MBMHoldTime u8 title="%TXT%dbdefsusercfghold" help="%TXT%mbm_hold_time_help" MBMRetry u8 title="%TXT%dbdefsifretry" editmask=0=Off;1=1;2=2;3=3
    configA
    MBMChannelsIn[MBM_IN_CHANNELS_NUM]{ Title ustr.16 title="%TXT%ch_title (n+1)" default="MBMin (n+1)" Unit ustr.8 title=%TXT%ch_unit Mode u8 editmask=1=%TXT%dbdefs_ch_mode_digital;8=%TXT%dbdefs_ch_mode_analog;18=%TXT%dbdefscntday;2=%TXT%dbdefscntint title=%TXT%dbdefsifmode default=8 Decpl s8 title=%TXT%ch_decpl editmask=-1=%TXT%default;0=0;1=1;2=2;3=3;4=4;5=5;6=6 default=-1 } MBMChannelsOut[MBM_OUT_CHANNELS_NUM]{ Title ustr.16 title="%TXT%ch_title (n+1)" default="MBMout (n+1)" Unit ustr.8 title=%TXT%ch_unit Mode u8 editmask=1=%TXT%dbdefs_ch_mode_digital;8=%TXT%dbdefs_ch_mode_analog;18=%TXT%dbdefscntday;2=%TXT%dbdefscntint title=%TXT%dbdefsifmode default=8 Decpl s8 title=%TXT%ch_decpl editmask=-1=%TXT%default;0=0;1=1;2=2;3=3;4=4;5=5;6=6 default=-1 }
    histdata0
    MBMChannelsIn[MBM_IN_CHANNELS_NUM] f32.3 title=%configA%MBMChannelsIn[(n)].Title units=%configA%MBMChannelsIn[(n)].Unit decpl=%configA%MBMChannelsIn[(n)].Decpl chmode=%configA%MBMChannelsIn[(n)].Mode%1=1;8=8;18=2;2=3 ialarm_low=%config2%MBMAlarme[(n)].thresholdalarmlow ialarm_high=%config2%MBMAlarme[(n)].thresholdalarmhigh iwarn_low=%config2%MBMAlarme[(n)].thresholdwarninglow iwarn_high=%config2%MBMAlarme[(n)].thresholdwarninghigh itrigger=%config2%MBMAlarme[(n)].thresholdtrigger hysterese=%config2%MBMAlarme[(n)].hysteresis MBMChannelsOut[MBM_OUT_CHANNELS_NUM] f32.3 title=%configA%MBMChannelsOut[(n)].Title units=%configA%MBMChannelsOut[(n)].Unit decpl=%configA%MBMChannelsOut[(n)].Decpl chmode=%configA%MBMChannelsOut[(n)].Mode%1=1;8=8;18=2;2=3 setpoint=config4;MBMValuesOut[(n)];actual_output_value_(n+ACTUAL_OUTPUT_VALUE_MBMOUT_OFFSET)
    notes
    // *note1: The value of this field is calculated through more than one shadow field. To prevent an update of this field without the consideration of all its shadow fields edit=99 is needed.
    Additionally there is some content to be added to the language file:
    tag en de mbm_hold_time_help Number of measuring cycles for which the last measurement value is held before an error value is written in the channel Anzahl der Messzyklen, für die der letztgültige Messwert gehalten wird, bevor ein Fehlerwert am Kanal ausgegeben wird mbm_send_on_change Send on change bei Änderung senden mbm_send_on_change_help OFF: The configured value is written to the bus on each measurement interval <br> ON: The value is written to the bus once after a change on the next measurement interval OFF: Der eingestellte Stellwert wird im Messintervall zyklisch auf den Bus geschrieben <br> ON: Der Stellwert wird nur einmal nach Änderung im nachfolgenden Messintervall auf den Bus geschrieben
    MBM_DL_EXPERT_SETUP:
    When using this module without one of the before mentioned libraries here are the interfacing functions and when to use them.
  • MBM_DL_SetItfSettings - Everytime a new config is received.
  • MBM_DL_Init - If the device switches in an active mode (e.g normal operation mode) and if you reveice a new config in one of these modes.
  • MBM_DL_Close - If the device switches in a passive mode (e.g. transport mode)
  • MBM_DL_Sample - When the measurement timer has expired to read all configured modbus input channels
  • MBM_DL_SetOutput - When the set output timer has expired to write all configured modbus output channels
  • MBM_DL_IsActive - When you need to wait for the sampling of the modbus input channels or setting of the modbus output channels to finish
  • MBM_DL_UpdateInputCfg - When receiving a new config for all modbus input channels
  • MBM_DL_UpdateOutputCfg - When receiving a new config for all modbus output channels
  • MBM_DL_GetDataValues - When the latest received modbus channel data is needed (e.g. after MBM_DL_IsActive switches back to false, or before writing histdata)
  • MBM_DL_UpdateOutputValues - When receiving new output values for all modbus output channels
  • MBM_DL_SetOutputValue - This function can be used to set a specific modbus output channel to a specific value (e.g. within a callback e.g. Measurement_Done)
  • MBM_DL_SetItfSettings(iMBMInterface, iMBMBaudrate, iMBMCharFormat, iMBMResponseTimeout, iMBMRetryCount, iMBMHoldCount=0)

    Function to configure the modbus interface

    iMBMInterface : u8 - serial interface that should be used for the MBM communication (use MBM_INTERFACE_x)
    iMBMBaudrate : u32 - Baud rate to be used
    iMBMCharFormat : u8 - Flags to configure the interface
    0b00000001 - 1 stop bit
    0b00000010 - 2 stop bits
    0b00000000 - no parity
    0b00000100 - odd parity
    0b00001000 - even parity
    0b00000000 - 7 data bits
    0b00010000 - 8 data bits
    0b00000000 - deactivate termination resistors
    0b01000000 - activate termination resistors
    0b00000000 - deactivate bias resistors
    0b10000000 - activate bias resistors
    iMBMResponseTimeout : u16 - Modbus response timeout [ms]
    min = 100, max = 10000
    iMBMRetryCount : u8 - Number of times it is retried to read/write a modbus input/output before it is skipped
    iMBMHoldCount : u8 - Number of times the last valid data is kept in case of an errors
    MBM_DL_Init()

    Function to initialize the modbus interface with the parameters set via MBM_DL_SetItfSettings. If MBM_DL_SetItfSettings wasn't called beforhand the interface will only be closed.

    MBM_DL_Close()

    Function to close the modbus interface

    MBM_DL_Sample()

    Function to sample all configured modbus input channels

    returns : s32
    < OK - If one of the following errors occurs
  • Interface is not initialized
  • Interface is currently busy
  • = OK - Sampling is starting
    > OK - Power saving is active and sampling will start after interface is opened
    MBM_DL_SetOutput()

    Function to set all configured modbus output channels

    returns : s32
    < OK - If one of the following errors occurs
  • Interface is not initialized
  • Interface is currently busy
  • = OK - Writing is starting
    > OK - Power saving is active and writing will start after interface is opened
    MBM_DL_IsActive()

    Function to check if a read or write action is active

    returns : bool
    true - If sampling modbus input channels or writing modbus output channels is active
    false - else
    MBM_DL_UpdateInputCfg(aInputConfig[DDE_Channel_MBMChannelsIn_dim])

    Function to update the input configuration

    aInputConfig : DDE_Channel_MBMChannelsIn - Array which contains the config for all modbus input channels
    MBM_DL_UpdateOutputCfg(aOutputConfig[DDE_ChannelOutput_MBMChOutCfg_dim])

    Function to update the output configuration

    aOutputConfig : DDE_ChannelOutput_MBMChOutCfg - Array which contains the config for all modbus output channels
    MBM_DL_GetDataValues(aValues[MBM_IN_CHANNELS_NUM + MBM_OUT_CHANNELS_NUM])
    aValues : TYPE_DATA - Array to put all data of the modbus input channels and output channels into
    MBM_DL_UpdateOutputValues(aMBMOutputValues[MBM_OUT_CHANNELS_NUM])

    Function to update the output values

    aMBMOutputValues : s32 - Array which contains all output values for all modbus output channels
    MBM_DL_SetOutputValue(fValue, iMBMOutChannel)

    Function to set a specific output value

    fValue : Float - Value to set the specific modbus output channel to
    iMBMOutChannel : s32 - modbus output channel number on which to set the value
    MBM_DL_POV:
    If you want to use the POV you can do it in 2 ways:
    In combination with another POV
    (e.g. myDataconC3)
    <template lang="pug"> // === this is the PORTAL VIEW's DETAILS representation === .pov-details // Creates the myDataconC3 universal datalogger application details POV .loading-spinner.fa.fa-spinner.fa-spin.fa-3x.fa-fw(v-if='!loaded_') myDataconC3DetailsPOV(v-if="loaded_", :createEMwDef="createEMwDef" :isAppl_="isAppl_" :calcChannelsTabNames="calcChannelsTabNames" :blueprint="blueprint", :data="data", :basic="basic") template(slot="addon-slot-3") MBMDetailsPOV(:blueprint="blueprint" :data="data") table.btn-line(cellspacing='0' cellpadding='0' width='100%') tr td .btn-group button.btn.btn-default(type='button' @click='back') %TXT%cancel button.btn.btn-default(v-if='!newSite_' @click='apply(false)' :disabled='!!saving_') %TXT%apply button.btn.btn-default(type='button' @click='save' :disabled='!!saving_') %TXT%save </template> <script> // Import the myDataconC3DetailsPOV sub-component import { myDataconC3DetailsPOV } from 'mydataconc3-mt'; import { MBMDetailsPOV } from 'modbus-master-mt'; export default { name: "pov-details", mixins: [MDN.vueSiteDetailsMixin], // Registers sub-components components: { myDataconC3DetailsPOV, MBMDetailsPOV }, data() { return { } }, watch: { loaded_() { MDN.siteEditor = this; //------- EVENT controlled --------------------- if (this.PAPI.site_uid) { //not needed in APPL config const siteEditor = this; if (this.basic.device) { const updateBlock = async (eventId) => { if (eventId==='device') { //information about currently assigned device is contained in site object siteEditor.siteController_.loadSite(function(){ if (!siteEditor.siteController_.resultCache.basic.device) Vue.set(siteEditor.basic, 'device', null); else { if (!siteEditor.basic.device || siteEditor.basic.device._uid !== siteEditor.siteController_.resultCache.basic.device._uid) Vue.set(siteEditor.basic, 'device', siteEditor.siteController_.resultCache.basic.device); else //if the device is already there Vue.set(siteEditor.basic.device, 'con', siteEditor.siteController_.resultCache.basic.device.con); } }); } }; AutoReloadSpanOnChange("__id", updateBlock, "device", this.basic.device._uid); } } //------- END EVENT controlled ----------------- }, }, methods: { }, created() { }, mounted() { } } </script> <style lang="less" scoped> // the DETAILS POV style definitions .pov-details { } </style>
    Standalone
    <template lang="pug"> // === this is the PORTAL VIEW's DETAILS representation === .pov-details // Creates the Modbus Master application details POV .loading-spinner.fa.fa-spinner.fa-spin.fa-3x.fa-fw(v-if='!loaded_') MBMDetailsPOV(v-if="loaded_", :blueprint="blueprint", :data="data") table.btn-line(cellspacing='0' cellpadding='0' width='100%') tr td .btn-group button.btn.btn-default(type='button' @click='back') %TXT%cancel button.btn.btn-default(v-if='!newSite_' @click='apply(false)' :disabled='!!saving_') %TXT%apply button.btn.btn-default(type='button' @click='save' :disabled='!!saving_') %TXT%save </template> <script> // Import the MBMDetailsPOV sub-component import { MBMDetailsPOV } from 'modbus-master-mt'; export default { name: "pov-details", mixins: [MDN.vueSiteDetailsMixin], // Registers sub-components components: { MBMDetailsPOV }, data() { return { } }, watch: { loaded_() { MDN.siteEditor = this; //------- EVENT controlled --------------------- if (this.PAPI.site_uid) { //not needed in APPL config const siteEditor = this; if (this.basic.device) { const updateBlock = async (eventId) => { if (eventId==='device') { //information about currently assigned device is contained in site object siteEditor.siteController_.loadSite(function(){ if (!siteEditor.siteController_.resultCache.basic.device) Vue.set(siteEditor.basic, 'device', null); else { if (!siteEditor.basic.device || siteEditor.basic.device._uid !== siteEditor.siteController_.resultCache.basic.device._uid) Vue.set(siteEditor.basic, 'device', siteEditor.siteController_.resultCache.basic.device); else //if the device is already there Vue.set(siteEditor.basic.device, 'con', siteEditor.siteController_.resultCache.basic.device.con); } }); } }; AutoReloadSpanOnChange("__id", updateBlock, "device", this.basic.device._uid); } } //------- END EVENT controlled ----------------- }, }, methods: { }, created() { }, mounted() { } } </script> <style lang="less" scoped> // the DETAILS POV style definitions .pov-details { } </style>
    CONC3_CH_DATA_MBM_x:

    Extension of CONC3_CH_DATA_x

    CONC3_CH_DATA_MBM_IN_FIRST - First Modbus In Channel
    CONC3_CH_DATA_MBM_IN_LAST - Last ModBus In Channel
    CONC3_CH_DATA_MBM_OUT_FIRST - First Modbus Out Channel
    CONC3_CH_DATA_MBM_OUT_LAST - Last ModBus Out Channel

    M2EASYIOT:

    MBM_DL_MODULE:
    MBM_DL is an implementation provided by Microtronics for an automatic modbus handling which is based on some datalogger applications.
    If used in combination with the data-logger-4ch-mt or the mydataconc3-mt libraries it is enough to follow the steps in MBM_DL_BASIC_SETUP and MBM_DL_POV, if not please also follow the steps in MBM_DL_EXPERT_SETUP.
    MBM_DL_BASIC_SETUP:
    To use MBM_DL the following things need to be added to the DDE:
    defines
    /** ---------------------------------------------------------------------------- * modbus-master-mt: DataLogger Config * ----------------------------------------------------------------------------- * * Use this block to activate and configure the datalogger module of the modbus-master-mt library. * */ #define MBM_DL_USE 1 // 1: Use MBM_DL module (MBM_DL functions and predefined implementation of the MBM_EvtResponse) #define MBM_DL_DEBUG 0 // Debug level of the datalogger module: 0 = Off, 1 = General infos, 2 = all #define MBM_IN_CHANNELS_NUM 20 // Number of modbus input channels #define MBM_OUT_CHANNELS_NUM 12 // Number of modbus output channels #define ACTUAL_OUTPUT_VALUE_MBMOUT_OFFSET 1 // Offset used for the setpoint feature of the server: 3 in case of mydataconc3-mt, 1 else
    config1
    MBMChannelsIn[MBM_IN_CHANNELS_NUM]{ Type u8 edit=99 // see *note1 @Type Format u8 title=%TXT%dbdefs_mbs_mode bitmask=$03 editmask=0=%TXT%dbdefs_mode_bit;1=%TXT%dbdefs_mode_signed;2=%TXT%dbdefs_mode_unsigned;3=%TXT%dbdefs_mode_float default=3 dlorw=skip @Type Bits u8 title="Bits" bitmask=$04 editmask=0=16;1=32 default=1 dlorw=skip @Type WordOrder u8 title=%TXT%dbdefs_mbs_word_order bitmask=$08 editmask=0=HI-LO;1=LO-HI help=%TXT%dbdefsmodbuswordorder_help default=0 dlorw=skip SlaveAddress u8 title=%TXT%dbdefsusercfg_slave_address min=1 max=247 default=1 ModbusFunc u8 title=%TXT%dbdefs_mbs_function editmask=1=FC01;2=FC02;3=FC03;4=FC04 default=3 help="%TXT%dbdefsmodbusreadcoils <br> %TXT%dbdefsmodbusreaddiscreteinputs <br> %TXT%dbdefsmodbusreadholdingregisters <br> %TXT%dbdefsmodbusreadinputregisters" ModbusAddress u16 title=%TXT%dbdefsminiusercfg_modbus_address default=0 Min f32.3 title="0%" default=0 Max f32.3 title="100%" default=100 MBMin f32.3 title=%TXT%dbdefsminiqmodbusmin default=0 MBMax f32.3 title=%TXT%dbdefsminiqmodbusmax default=100 Itf u8 editmask=0=%TXT%off;1=%TXT%dbdefsifmodbus title=%TXT%dbdefsifinterface OverflowMode u8 title=%TXT%dbdefsusercfgfault editmask=0=%TXT%dbdefsusercfgfault4;1=%TXT%dbdefsusercfgfault1 ScaleCfg u8 editmask=0=%TXT%off;1=%TXT%on default=0 title=%TXT%dbdefsminiqscale }
    config2
    MBMAlarme[MBM_IN_CHANNELS_NUM]{ ThresholdAlarmLow f32.6 width=8 default=NAN title=%TXT%ch_alarmhigh_lower help=%TXT%ch_alarmhigh_lower_help ThresholdWarningLow f32.6 width=8 default=NAN title=%TXT%ch_alarmlow_lower help=%TXT%ch_alarmlow_lower_help ThresholdWarningHigh f32.6 width=8 default=NAN title=%TXT%ch_alarmlow_upper help=%TXT%ch_alarmlow_upper_help @ThresholdWarningHigh ThresholdWarningHigh_digital f32.1 editmask=%CHECKBOX%NAN;1 title=%TXT%dbdefscompcfg_triger_alarm_low help=%TXT%dbdefscompcfg_triger_alarm_low_help dlorw=skip ThresholdAlarmHigh f32.6 width=8 default=NAN title=%TXT%ch_alarmhigh_upper help=%TXT%ch_alarmhigh_upper_help @ThresholdAlarmHigh ThresholdAlarmHigh_digital f32.1 editmask=%CHECKBOX%NAN;1 title=%TXT%dbdefscompcfg_triger_alarm_high help=%TXT%dbdefscompcfg_triger_alarm_high_help dlorw=skip Hysteresis f32.6 width=8 default=ALARM_HYSTERESIS_DEFAULT title=%TXT%ch_hyst min=0.0 help=%TXT%field_help_hyst Trigger u16 decpl=0 view=8 edit=99 // see *note1 @Trigger RecordOn u16 decpl=0 bitmask=$0001 editmask=%CHECKBOX% title=%TXT%dbdefscompcfg_triger_record_immediate_on help=%TXT%dbdefscompcfg_triger_record_immediate_on_help dlorw=skip @Trigger Transmission u16 decpl=0 bitmask=$0002 editmask=%CHECKBOX% title=%TXT%dbdefscompcfg_triger_xmit_start help=%TXT%dbdefscompcfg_triger_xmit_start_help dlorw=skip @Trigger Online u16 decpl=0 bitmask=$0004 editmask=%CHECKBOX% title=%TXT%dbdefscompcfg_triger_continous help=%TXT%dbdefscompcfg_triger_continous_help dlorw=skip view=8 edit=8 @Trigger FastRecord u16 decpl=0 bitmask=$0008 editmask=%CHECKBOX% title=%TXT%dbdefscompcfg_triger_record_alternative help=%TXT%dbdefscompcfg_triger_record_alternative_help dlorw=skip @Trigger FastTransItv u16 decpl=0 bitmask=$0080 editmask=%CHECKBOX% title=QX help=%TXT%dbdefscompcfg_triger_do_qx_help dlorw=skip @Trigger DigitalEdge u16 decpl=0 bitmask=$6000 title=%TXT%dbdefsusercfgedge editmask=1=%TXT%dbdefsusercfgedge_rising;2=%TXT%dbdefsusercfgedge_falling;3=%TXT%dbdefsusercfgedge_both default=ALARM_DIGITAL_EDGE_DEFAULT dlorw=skip @Trigger BiggerThan u16 decpl=0 bitmask=$8000 title=" " editmask=0=%TXT%less_or_equal;1=%TXT%greater_or_equal dlorw=skip ThresholdTrigger f32.6 title=%TXT%dbdefscompcfg_triger_level autoedit=22x11 default=NAN HysteresisTrigger f32.6 default=ALARM_HYSTERESIS_TRIGGER_DEFAULT title=%TXT%ch_hyst min=0.0 }
    config3
    MBMChOutCfg[MBM_OUT_CHANNELS_NUM]{ Type u8 edit=99 // see *note1 @Type Format u8 title=%TXT%dbdefs_mbs_mode bitmask=$03 editmask=0=%TXT%dbdefs_mode_bit;1=%TXT%dbdefs_mode_signed;2=%TXT%dbdefs_mode_unsigned;3=%TXT%dbdefs_mode_float default=3 dlorw=skip @Type Bits u8 title="Bits" bitmask=$04 editmask=0=16;1=32 default=1 dlorw=skip @Type WordOrder u8 title=%TXT%dbdefs_mbs_word_order bitmask=$08 editmask=0=HI-LO;1=LO-HI help=%TXT%dbdefsmodbuswordorder_help default=0 dlorw=skip SlaveAddress u8 title=%TXT%dbdefsusercfg_slave_address min=1 max=247 default=1 ModbusFunc u8 title=%TXT%dbdefs_mbs_function editmask=5=FC05;6=FC06;15=FC15;16=FC16 default=16 help="%TXT%dbdefsmodbuswritesinglecoil <br> %TXT%dbdefsmodbuswritesingleregister <br> %TXT%dbdefsmodbuswritemultiplecoils <br> %TXT%dbdefsmodbuswritemultipleregisters" ModbusAddress u16 title=%TXT%dbdefsminiusercfg_modbus_address default=0 Min f32.3 title="0%" default=0 Max f32.3 title="100%" default=100 MBMin f32.3 title=%TXT%dbdefsminiqmodbusmin default=0 MBMax f32.3 title=%TXT%dbdefsminiqmodbusmax default=100 Itf u8 editmask=0=%TXT%off;1=%TXT%dbdefsifmodbus title=%TXT%dbdefsifinterface Flags u8 title="%TXT%mbm_send_on_change" editmask=%CHECKBOX% help="%TXT%mbm_send_on_change_help" ScaleCfg u8 editmask=0=%TXT%off;1=%TXT%on default=0 title=%TXT%dbdefsminiqscale }
    config4
    MBMValuesOut[MBM_OUT_CHANNELS_NUM] f32 title=%TXT%dbdefs_output_value param0=%FFFF0005%actual_output_value_(n+ACTUAL_OUTPUT_VALUE_MBMOUT_OFFSET)
    config8
    MBMItfCfg u8 title="%TXT%dbdefsifmodbus" editmask=0=%TXT%off;2=%TXT%on MBMBaudrate u32 title="%TXT%dbdefsifbaud" editmask=300=300;600=600;1200=1200;2400=2400;4800=4800;9600=9600;19200=19200;38400=38400;57600=57600;115200=115200 default=9600 //dropdown with different baudrates, no mapping, like MUC MBMCharFormat u8 edit=99 // Bit 0..1 TSerial_StopBits, Bit 2..3 TSerial_Parity, Bit 4..5 TSerial_DataBits, Bit 6 TSerial_Termination, Bit 7 TSerial_Bias // see *note1 @MBMCharFormat MBMStopBits u8 title="%TXT%dbdefsifstopbits" bitmask=$03 default=1 editmask=1=1;2=2 dlorw=skip @MBMCharFormat MBMParity u8 title="%TXT%dbdefsifparity" bitmask=$0C default=0 editmask=0=%TXT%dbdefsifparityn;1=%TXT%dbdefsifparityo;2=%TXT%dbdefsifparitye dlorw=skip @MBMCharFormat MBMDatabits u8 title="%TXT%dbdefsifdatabits" bitmask=$30 default=1 editmask=0=7;1=8 dlorw=skip @MBMCharFormat MBMTermination u8 title="%TXT%dbdefsiftermination" bitmask=$40 default=0 editmask=%CHECKBOX% dlorw=skip @MBMCharFormat MBMBias u8 title="Bias" bitmask=$80 default=0 editmask=%CHECKBOX% dlorw=skip MBMResponseTimeout u16 title="Timeout [s]" units=%TXT%seconds decpl=3 vscale=0.001 min=0.1 max=10 default=1 help=%TXT%seconds //Timeout 100 - 10000 ms in sekunden eingeben MBMHoldTime u8 title="%TXT%dbdefsusercfghold" help="%TXT%mbm_hold_time_help" MBMRetry u8 title="%TXT%dbdefsifretry" editmask=0=Off;1=1;2=2;3=3
    configA
    MBMChannelsIn[MBM_IN_CHANNELS_NUM]{ Title ustr.16 title="%TXT%ch_title (n+1)" default="MBMin (n+1)" Unit ustr.8 title=%TXT%ch_unit Mode u8 editmask=1=%TXT%dbdefs_ch_mode_digital;8=%TXT%dbdefs_ch_mode_analog;18=%TXT%dbdefscntday;2=%TXT%dbdefscntint title=%TXT%dbdefsifmode default=8 Decpl s8 title=%TXT%ch_decpl editmask=-1=%TXT%default;0=0;1=1;2=2;3=3;4=4;5=5;6=6 default=-1 } MBMChannelsOut[MBM_OUT_CHANNELS_NUM]{ Title ustr.16 title="%TXT%ch_title (n+1)" default="MBMout (n+1)" Unit ustr.8 title=%TXT%ch_unit Mode u8 editmask=1=%TXT%dbdefs_ch_mode_digital;8=%TXT%dbdefs_ch_mode_analog;18=%TXT%dbdefscntday;2=%TXT%dbdefscntint title=%TXT%dbdefsifmode default=8 Decpl s8 title=%TXT%ch_decpl editmask=-1=%TXT%default;0=0;1=1;2=2;3=3;4=4;5=5;6=6 default=-1 }
    histdata0
    MBMChannelsIn[MBM_IN_CHANNELS_NUM] f32.3 title=%configA%MBMChannelsIn[(n)].Title units=%configA%MBMChannelsIn[(n)].Unit decpl=%configA%MBMChannelsIn[(n)].Decpl chmode=%configA%MBMChannelsIn[(n)].Mode%1=1;8=8;18=2;2=3 ialarm_low=%config2%MBMAlarme[(n)].thresholdalarmlow ialarm_high=%config2%MBMAlarme[(n)].thresholdalarmhigh iwarn_low=%config2%MBMAlarme[(n)].thresholdwarninglow iwarn_high=%config2%MBMAlarme[(n)].thresholdwarninghigh itrigger=%config2%MBMAlarme[(n)].thresholdtrigger hysterese=%config2%MBMAlarme[(n)].hysteresis MBMChannelsOut[MBM_OUT_CHANNELS_NUM] f32.3 title=%configA%MBMChannelsOut[(n)].Title units=%configA%MBMChannelsOut[(n)].Unit decpl=%configA%MBMChannelsOut[(n)].Decpl chmode=%configA%MBMChannelsOut[(n)].Mode%1=1;8=8;18=2;2=3 setpoint=config4;MBMValuesOut[(n)];actual_output_value_(n+ACTUAL_OUTPUT_VALUE_MBMOUT_OFFSET)
    notes
    // *note1: The value of this field is calculated through more than one shadow field. To prevent an update of this field without the consideration of all its shadow fields edit=99 is needed.
    Additionally there is some content to be added to the language file:
    tag en de mbm_hold_time_help Number of measuring cycles for which the last measurement value is held before an error value is written in the channel Anzahl der Messzyklen, für die der letztgültige Messwert gehalten wird, bevor ein Fehlerwert am Kanal ausgegeben wird mbm_send_on_change Send on change bei Änderung senden mbm_send_on_change_help OFF: The configured value is written to the bus on each measurement interval <br> ON: The value is written to the bus once after a change on the next measurement interval OFF: Der eingestellte Stellwert wird im Messintervall zyklisch auf den Bus geschrieben <br> ON: Der Stellwert wird nur einmal nach Änderung im nachfolgenden Messintervall auf den Bus geschrieben
    MBM_DL_EXPERT_SETUP:
    When using this module without one of the before mentioned libraries here are the interfacing functions and when to use them.
  • MBM_DL_SetItfSettings - Everytime a new config is received.
  • MBM_DL_Init - If the device switches in an active mode (e.g normal operation mode) and if you reveice a new config in one of these modes.
  • MBM_DL_Close - If the device switches in a passive mode (e.g. transport mode)
  • MBM_DL_Sample - When the measurement timer has expired to read all configured modbus input channels
  • MBM_DL_SetOutput - When the set output timer has expired to write all configured modbus output channels
  • MBM_DL_IsActive - When you need to wait for the sampling of the modbus input channels or setting of the modbus output channels to finish
  • MBM_DL_UpdateInputCfg - When receiving a new config for all modbus input channels
  • MBM_DL_UpdateOutputCfg - When receiving a new config for all modbus output channels
  • MBM_DL_GetDataValues - When the latest received modbus channel data is needed (e.g. after MBM_DL_IsActive switches back to false, or before writing histdata)
  • MBM_DL_UpdateOutputValues - When receiving new output values for all modbus output channels
  • MBM_DL_SetOutputValue - This function can be used to set a specific modbus output channel to a specific value (e.g. within a callback e.g. Measurement_Done)
  • MBM_DL_SetItfSettings(iMBMInterface, iMBMBaudrate, iMBMCharFormat, iMBMResponseTimeout, iMBMRetryCount, iMBMHoldCount=0)

    Function to configure the modbus interface

    iMBMInterface : u8 - serial interface that should be used for the MBM communication (use MBM_INTERFACE_x)
    iMBMBaudrate : u32 - Baud rate to be used
    iMBMCharFormat : u8 - Flags to configure the interface
    0b00000001 - 1 stop bit
    0b00000010 - 2 stop bits
    0b00000000 - no parity
    0b00000100 - odd parity
    0b00001000 - even parity
    0b00000000 - 7 data bits
    0b00010000 - 8 data bits
    0b00000000 - deactivate termination resistors
    0b01000000 - activate termination resistors
    0b00000000 - deactivate bias resistors
    0b10000000 - activate bias resistors
    iMBMResponseTimeout : u16 - Modbus response timeout [ms]
    min = 100, max = 10000
    iMBMRetryCount : u8 - Number of times it is retried to read/write a modbus input/output before it is skipped
    iMBMHoldCount : u8 - Number of times the last valid data is kept in case of an errors
    MBM_DL_Init()

    Function to initialize the modbus interface with the parameters set via MBM_DL_SetItfSettings. If MBM_DL_SetItfSettings wasn't called beforhand the interface will only be closed.

    MBM_DL_Close()

    Function to close the modbus interface

    MBM_DL_Sample()

    Function to sample all configured modbus input channels

    returns : s32
    < OK - If one of the following errors occurs
  • Interface is not initialized
  • Interface is currently busy
  • = OK - Sampling is starting
    > OK - Power saving is active and sampling will start after interface is opened
    MBM_DL_SetOutput()

    Function to set all configured modbus output channels

    returns : s32
    < OK - If one of the following errors occurs
  • Interface is not initialized
  • Interface is currently busy
  • = OK - Writing is starting
    > OK - Power saving is active and writing will start after interface is opened
    MBM_DL_IsActive()

    Function to check if a read or write action is active

    returns : bool
    true - If sampling modbus input channels or writing modbus output channels is active
    false - else
    MBM_DL_UpdateInputCfg(aInputConfig[DDE_Channel_MBMChannelsIn_dim])

    Function to update the input configuration

    aInputConfig : DDE_Channel_MBMChannelsIn - Array which contains the config for all modbus input channels
    MBM_DL_UpdateOutputCfg(aOutputConfig[DDE_ChannelOutput_MBMChOutCfg_dim])

    Function to update the output configuration

    aOutputConfig : DDE_ChannelOutput_MBMChOutCfg - Array which contains the config for all modbus output channels
    MBM_DL_GetDataValues(aValues[MBM_IN_CHANNELS_NUM + MBM_OUT_CHANNELS_NUM])
    aValues : TYPE_DATA - Array to put all data of the modbus input channels and output channels into
    MBM_DL_UpdateOutputValues(aMBMOutputValues[MBM_OUT_CHANNELS_NUM])

    Function to update the output values

    aMBMOutputValues : s32 - Array which contains all output values for all modbus output channels
    MBM_DL_SetOutputValue(fValue, iMBMOutChannel)

    Function to set a specific output value

    fValue : Float - Value to set the specific modbus output channel to
    iMBMOutChannel : s32 - modbus output channel number on which to set the value
    MBM_DL_POV:
    If you want to use the POV you can do it in 2 ways:
    In combination with another POV
    (e.g. myDataconC3)
    <template lang="pug"> // === this is the PORTAL VIEW's DETAILS representation === .pov-details // Creates the myDataconC3 universal datalogger application details POV .loading-spinner.fa.fa-spinner.fa-spin.fa-3x.fa-fw(v-if='!loaded_') myDataconC3DetailsPOV(v-if="loaded_", :createEMwDef="createEMwDef" :isAppl_="isAppl_" :calcChannelsTabNames="calcChannelsTabNames" :blueprint="blueprint", :data="data", :basic="basic") template(slot="addon-slot-3") MBMDetailsPOV(:blueprint="blueprint" :data="data") table.btn-line(cellspacing='0' cellpadding='0' width='100%') tr td .btn-group button.btn.btn-default(type='button' @click='back') %TXT%cancel button.btn.btn-default(v-if='!newSite_' @click='apply(false)' :disabled='!!saving_') %TXT%apply button.btn.btn-default(type='button' @click='save' :disabled='!!saving_') %TXT%save </template> <script> // Import the myDataconC3DetailsPOV sub-component import { myDataconC3DetailsPOV } from 'mydataconc3-mt'; import { MBMDetailsPOV } from 'modbus-master-mt'; export default { name: "pov-details", mixins: [MDN.vueSiteDetailsMixin], // Registers sub-components components: { myDataconC3DetailsPOV, MBMDetailsPOV }, data() { return { } }, watch: { loaded_() { MDN.siteEditor = this; //------- EVENT controlled --------------------- if (this.PAPI.site_uid) { //not needed in APPL config const siteEditor = this; if (this.basic.device) { const updateBlock = async (eventId) => { if (eventId==='device') { //information about currently assigned device is contained in site object siteEditor.siteController_.loadSite(function(){ if (!siteEditor.siteController_.resultCache.basic.device) Vue.set(siteEditor.basic, 'device', null); else { if (!siteEditor.basic.device || siteEditor.basic.device._uid !== siteEditor.siteController_.resultCache.basic.device._uid) Vue.set(siteEditor.basic, 'device', siteEditor.siteController_.resultCache.basic.device); else //if the device is already there Vue.set(siteEditor.basic.device, 'con', siteEditor.siteController_.resultCache.basic.device.con); } }); } }; AutoReloadSpanOnChange("__id", updateBlock, "device", this.basic.device._uid); } } //------- END EVENT controlled ----------------- }, }, methods: { }, created() { }, mounted() { } } </script> <style lang="less" scoped> // the DETAILS POV style definitions .pov-details { } </style>
    Standalone
    <template lang="pug"> // === this is the PORTAL VIEW's DETAILS representation === .pov-details // Creates the Modbus Master application details POV .loading-spinner.fa.fa-spinner.fa-spin.fa-3x.fa-fw(v-if='!loaded_') MBMDetailsPOV(v-if="loaded_", :blueprint="blueprint", :data="data") table.btn-line(cellspacing='0' cellpadding='0' width='100%') tr td .btn-group button.btn.btn-default(type='button' @click='back') %TXT%cancel button.btn.btn-default(v-if='!newSite_' @click='apply(false)' :disabled='!!saving_') %TXT%apply button.btn.btn-default(type='button' @click='save' :disabled='!!saving_') %TXT%save </template> <script> // Import the MBMDetailsPOV sub-component import { MBMDetailsPOV } from 'modbus-master-mt'; export default { name: "pov-details", mixins: [MDN.vueSiteDetailsMixin], // Registers sub-components components: { MBMDetailsPOV }, data() { return { } }, watch: { loaded_() { MDN.siteEditor = this; //------- EVENT controlled --------------------- if (this.PAPI.site_uid) { //not needed in APPL config const siteEditor = this; if (this.basic.device) { const updateBlock = async (eventId) => { if (eventId==='device') { //information about currently assigned device is contained in site object siteEditor.siteController_.loadSite(function(){ if (!siteEditor.siteController_.resultCache.basic.device) Vue.set(siteEditor.basic, 'device', null); else { if (!siteEditor.basic.device || siteEditor.basic.device._uid !== siteEditor.siteController_.resultCache.basic.device._uid) Vue.set(siteEditor.basic, 'device', siteEditor.siteController_.resultCache.basic.device); else //if the device is already there Vue.set(siteEditor.basic.device, 'con', siteEditor.siteController_.resultCache.basic.device.con); } }); } }; AutoReloadSpanOnChange("__id", updateBlock, "device", this.basic.device._uid); } } //------- END EVENT controlled ----------------- }, }, methods: { }, created() { }, mounted() { } } </script> <style lang="less" scoped> // the DETAILS POV style definitions .pov-details { } </style>
    DL4CH_CH_DATA_MBM_x:

    Extension of DL4CH_CH_DATA_x

    DL4CH_CH_DATA_MBM_IN_FIRST - First Modbus In Channel
    DL4CH_CH_DATA_MBM_IN_LAST - Last ModBus In Channel
    DL4CH_CH_DATA_MBM_OUT_FIRST - First Modbus Out Channel
    DL4CH_CH_DATA_MBM_OUT_LAST - Last ModBus Out Channel

    On this page

    MBM - Modbus-Master Library