Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The application appl/goal_mb/01_simple_io demonstrates the usage of the GOAL Modbus Stack. It defines data regions for specific data types, opens up a Modbus instance and creates objects.

It also initializes Device Detection to access CM Variables to set Interface Configuration like IP Address.

Data Regions

The application uses the function goal_mbCfgDataRegionDefine to define accessable regions for specific data types.

Data Type

Region

GOAL_MB_DATA_COIL

1000 to
1049

GOAL_MB_DATA_HOLD_REG

3000 to
3049

Note

This function only restricts regions used by Coils and Holding Registers. Other Data Types must be handled by the application itself.

Data Objects

The application creates objects as following:

Data Type

Name(s)

Address(es)

Coil

APPL_COIL_1

1000

Coil

APPL_COIL_2

1001

Discrete Input

APPL_DISC_INPUT_1 to
APPL_DISC_INPUT_XX10

2000 -to
2009

Holding Register

APPL_HOLD_REG_1

3000

Holding Register

APPL_HOLD_REG_2

3001

Input Register

APPL_INPUT_REG_XX3050-30591 to
APPL_INPUT_RES_10

3050 to
3059

Application Logic

The application provides a generic callback handler, which handles events like received read-requests or write-requests and connection-related events. Handles callback IDs are the following:

  • GOAL_MB_CB_ID_APPL_READY

  • GOAL_MB_CB_ID_DATA_READ

    • the called function appl_readRequestProcess provides the discrete inputs, input- and holding registers and returns random values and LED states to the requested objects.

  • GOAL_MB_CB_ID_DATA_WRITE

    • the called function appl_writeRequestProcess handles write requests for a holding register, setting the written value to target specific LED registers.

  • GOAL_MB_CB_ID_CONNECT_REQUEST

  • GOAL_MB_CB_ID_CONNECT_RELEASE

  • GOAL_MB_CB_ID_LED_CHANGED

Available Callback IDs are listed here.

There is also an application loop implemented, which mirrors application coils every 100 ms.