This article shows how to change some parameters in the Anybus CompactCom (ABCC) at runtime. That is done by writing attribute values to Anybus Module Objects using user's custom functions.
Anybus CompactCom 30
Anybus CompactCom 40
Anybus CompactCom 30 / 40
Host Application Example Code V3.x
While you can embed your own custom commands to set some attributes in the Anybus Module Objects during its initialization, you may also choose to set some parameters at runtime.
In the Host Application Example Code ≥ V3.x, this can be done by implementing your own command sequence.
Note, however, that only attributes with a Set or Get/Set access rights can be changed, since we will be sending a Set_Attribute command for that purpose.
Attributes with only a Get access right cannot be overridden.
That implementation can be carried out in the example_code/appl_abcc_handler.c file.
Here are the necessary steps to follow:
- Define your command sequence.
- Implement the handler functions of the sequence.
- Call your command sequence in the application at the desired runtime state.
We want to change the Provider specific information of our ABCC40 module during the WAIT_PROCESS state..
In Chapter 12 of the ABCC40-Software Design guide, we see that the Provider specific information is the 11th Attribute of Instance #1 in the Anybus Object (01h). The default value of that attribute is 0x0000.
Now, let’s apply the three steps we saw earlier.
COMMAND SEQUENCE DEFINITION
The command sequence we are going to implement is appl_asUserRunCmdSeq.
The function we are going to implement is UpdateProviderInfo(), therefore, it needs to be part of our forward declarations.
static ABCC_CmdSeqCmdStatusType UpdateProviderInfo(ABP_MsgType* psMsg);
And since for the Set_Attribute command, there is no response data from the module, we put a NULL in place of the response handler for our command function in the appl_asUserRunCmdSeq command sequence.
static const ABCC_CmdSeqType appl_asUserRunCmdSeq =
static ABCC_CmdSeqCmdStatusType UpdateProviderInfo(ABP_MsgType* psMsg)
ABCC_SetMsgData16(psMsg, 0xCAFE, 0);
As you can see in the command function, the command used is the Set_Attribute service (ABP_CMD_SET_ATTR), which points to the Anybus object (ABP_OBJ_NUM_ANB), Instance #1, Attribute 11 (ABP_ANB_IA_PROVIDER_INFO). Notice that ABCC_SetMsgHeader() sets the input arguments to the ABCC message header correctly and he data (0xCAFE) is copied to the message data buffer separately using ABCC_SetMsgData16().
Note that, just like ABCC_SetMsgData16(), other functions like ABCC_SetMsgData8(), ABCC_SetMsgData32(), ABCC_SetMsgData64() and ABCC_SetMsgString() are also available for usage, depending of the data type of the attributes you want to write.
CALLING THE COMMAND SEQUENCE
if (appl_eAnbState = ABP_ANB_STATE_WAIT_PROCESS)
Once we reboot our ABCC40, our new command sequence, appl_asUserRunCmdSeq is called at runtime during the WAIT_PROCESS state, and we are able to change the current Provider specific information of the module. You can see the output on the image below.
Please note that, since we don’t get any response data from the module for that function, we have added other handler functions to the appl_asUserRunCmdSeq command sequence to read out the current value of the Provider specific information attribute before and after changing it.
It's worth noting that there are several functions implemented in the appl_asUserInitCmdSeq command sequence to set some network specific configuration parameters (node address, IP address, etc) of the module during its initialization. Therefore, you can use them as inspiration to write up your own functions, and add them to a custom command sequence that you can call at runtime to set other parameters of the ABCC.
How to read out information from an Anybus CompactCom during initialization?
How to read out information from an Anybus CompactCom at runtime?
How to change a parameter in an Anybus CompactCom during initialization?