How to change a parameter in an Anybus CompactCom during initialization?

22 Nov 2022

This article shows how to change some parameters in the Anybus CompactCom (ABCC) during initialization. That is done by writing attribute values to Anybus Module Objects using user's custom functions.

 

APPLICABLE PRODUCTS

Anybus CompactCom 30

Anybus CompactCom 40

 

PRE-REQUISITES

Anybus CompactCom 30 / 40

Host Application Example Code V3.x

 

SOLUTION DESCRIPTION

During the SETUP state of the ABCC driver state machine, the Host Application sends commands to the Anybus CompactCom.

You can embed your own custom commands to set some attributes in the Anybus Module Objects during that SETUP state. In the Host Application Example Code ≥ V3.x, this can be done using a 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.

 

Here are the necessary steps to follow:

 

  1. In example_code/appl_abcc_handler.c, write your command function.
  2. Add your functions to the appl_asUserInitCmdSeq[] command sequence.

 

 

EXAMPLE

We want to change the Provider specific information of our ABCC40 module during initialization.

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.

 

kb3_1.png

kb3_2.png

 

Now, let’s apply the two steps we saw earlier.

 

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); 
 

 

FUNCTION IMPLEMENTATION

 

Command function : UpdateProviderInfo()

 

static ABCC_CmdSeqCmdStatusType UpdateProviderInfo(ABP_MsgType* psMsg)
{
ABCC_SetMsgHeader(psMsg,
ABP_OBJ_NUM_ANB,
1,
ABP_ANB_IA_PROVIDER_INFO,
ABP_CMD_SET_ATTR,
2,
ABCC_GetNewSourceId());
ABCC_SetMsgData16(psMsg, 0x300A, 0);
return(ABCC_SEND_COMMAND);
}

 

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 (0x300A) 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.

 

 

COMMAND SEQUENCER

 

Here, we simply add our function to the appl_asUserInitCmdSeq[] command sequence. In the code we can see that appl_asUserInitCmdSeq[] already has a set of handler functions. We simply need to add ours, following the same format. 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.

 

static const ABCC_CmdSeqType appl_asUserInitCmdSeq[] =
{
...
  ABCC_CMD_SEQ(UpdateProviderInfo, NULL),
   ABCC_CMD_SEQ_END()
};

 

 

That’s it!

 

Once we reboot our ABCC40, our functions are also run as part of the appl_asUserInitCmdSeq[] command sequence during the SETUP state, and we are able to change the current Provider specific information of the module. You can see the output on the image below.

 

kb3_3.png

 

Please note that, since we don’t get any response data from the module for that function, we have added our own handler functions to the appl_asUserInitCmdSeq[] command sequence to read out the current value of the Provider specific information attribute before and after changing it.

 

 

ADDITIONAL INFORMATION

It's worth noting that there are already 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 simply customize them if you need to, or use them as inspiration to write up your own functions to set other parameters of the ABCC during initialization.

 

 

RELATED ARTICLES

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 at runtime?