Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/abcc_adaptation/abcc_driver_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@
#define EIP_OBJ_ENABLE 1
#define PRT_OBJ_ENABLE 1
#define MOD_OBJ_ENABLE 1
#define ASM_OBJ_ENABLE 1

#define ABCC_CFG_REMAP_SUPPORT_ENABLED 1
#define ASM_IA_NAME_ENABLE 1
#define ASM_IA_MAX_NUM_ADI_MAPS_ENABLE 1

/*------------------------------------------------------------------------------
** Command response list
Expand All @@ -112,7 +117,9 @@
/*ABCC_ETHERNETIP_OBJ_REVISION_GET_VALUE( "\x44\x43" ),*/ \
/*ABCC_PROFINET_OBJ_VENDOR_ID_GET_VALUE(0xDEAD),*/ \
/*ABCC_PROFINET_OBJ_DEVICE_ID_GET_CBFUNC,*/ \
/*ABCC_PROFINET_OBJ_ORDER_ID_GET_CBFUNC,*/
/*ABCC_PROFINET_OBJ_ORDER_ID_GET_CBFUNC,*/ \
ABCC_ETHERNETIP_OBJ_PROD_INSTANCE_GET_VALUE("\x64\x00\x65\x00\x66\x00", 6), /* Must match assembly mapping object instances */ \
ABCC_ETHERNETIP_OBJ_CONS_INSTANCE_GET_VALUE("\x96\x00\x97\x00", 4), /* Must match assembly mapping object instances */

/*------------------------------------------------------------------------------
** Debug and error macro configuration
Expand Down Expand Up @@ -140,4 +147,4 @@
#define ABCC_CFG_LOG_STRINGS_ENABLED 1
#define ABCC_CFG_LOG_COLORS_ENABLED 1

#endif /* inclusion lock */
#endif /* inclusion lock */
192 changes: 174 additions & 18 deletions src/example_application/abcc_network_data_parameters.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,66 +3,222 @@
** Licensed under the MIT License.
********************************************************************************
** File Description:
** Example of an ADI setup with two simple UINT16 ADIs representing speed and
** Example of an ADI setup using two simple UINT16 ADIs representing speed and
** reference speed of a motor. Both are mapped as cyclical process data
** parameters.
**
** Make sure that the following definitions, if they exist in
** abcc_driver_config.h, are set to the following:
** ABCC_CFG_STRUCT_DATA_TYPE_ENABLED 0
** ABCC_CFG_ADI_GET_SET_CALLBACK_ENABLED 0
**
**
** Example extension: Assembly mapping object
** Utilizing two additional ADI, i.e., a total of four ADI to create 3 different
** write assemblies and 2 different read assemblies.
**
** Make sure that the following definitions in
** abcc_driver_config.h are set to the following:
** ASM_OBJ_ENABLE 1
** ABCC_CFG_REMAP_SUPPORT_ENABLED 1
** ASM_IA_NAME_ENABLE 1
** ASM_IA_MAX_NUM_ADI_MAPS_ENABLE 1
**
** In case of running EtherNet/IP, make sure that EtherNet/IP host object is
** enabled and that instance attributes 7 and 8 are supported. For example,
** entered into ABCC_API_COMMAND_RESPONSE_LIST like this:
** ABCC_ETHERNETIP_OBJ_PROD_INSTANCE_GET_VALUE("\x64\x00\x65\x00\x66\x00", 6), \
** ABCC_ETHERNETIP_OBJ_CONS_INSTANCE_GET_VALUE("\x96\x00\x97\x00", 4)
**
** Corresponding to producing instances 0x0064, 0x0065, and 0x0066, and
** consuming instances 0x0096 and 0x0097.
********************************************************************************
*/

#include "stdint.h"
#include "abcc_api.h"
#include "abp_asm.h"
#include "abcc_application_data_interface.h"

#if ( ABCC_CFG_STRUCT_DATA_TYPE_ENABLED || ABCC_CFG_ADI_GET_SET_CALLBACK_ENABLED )
#if ( ABCC_CFG_STRUCT_DATA_TYPE_ENABLED || ABCC_CFG_ADI_GET_SET_CALLBACK_ENABLED )
#error ABCC_CFG_ADI_GET_SET_CALLBACK_ENABLED must be set to 0 and ABCC_CFG_STRUCT_DATA_TYPE_ENABLED set to 0 in order to run this example
#endif

/*------------------------------------------------------------------------------
** Data holder for the network data parameters (ADI)
**------------------------------------------------------------------------------
*/
uint16_t appl_iSpeed;
uint16_t appl_iRefSpeed;
static uint16_t appl_iSpeed = 0x0000;
static uint16_t appl_iRefSpeed = 0x0000;
static uint16_t appl_iTorque = 0x0000;
static uint16_t appl_iRefTorque = 0x0000;

/*------------------------------------------------------------------------------
** Min, max and default value for appl_aiUint16
** Network data parameters (ADI) properties (min, max, default values)
**------------------------------------------------------------------------------
*/
static AD_UINT16Type appl_sUint16Prop = { { 0, 0xFFFF, 0 } };
static AD_UINT16Type appl_sSpeedProp = { { 0, 0xFFFF, 0x0000 } };
static AD_UINT16Type appl_sRefSpeedProp = { { 0, 0xFFFF, 0x0000 } };
static AD_UINT16Type appl_sTorqueProp = { { 0, 0xFFFF, 0x0000 } };
static AD_UINT16Type appl_sRefTorqueProp = { { 0, 0xFFFF, 0x0000 } };

/*-------------------------------------------------------------------------------------------------------------
** 1. iInstance | 2. pabName | 3. bDataType | 4. bNumOfElements | 5. bDesc | 6. pxValuePtr | 7. pxValuePropPtr
**--------------------------------------------------------------------------------------------------------------
/*
** The ADI entry list (AD_AdiEntryType):
** ----------------------------------------------------------------------------------------------------------------------------
** | 1. iInstance | 2. pabName | 3. bDataType | 4. bNumOfElements | 5. bDesc | 6.pxValuePtr | 7. pxValuePropPtr | 8. psStruct |
** ----------------------------------------------------------------------------------------------------------------------------
*/
const AD_AdiEntryType ABCC_API_asAdiEntryList[] =
{
{ 0x1, "SPEED", ABP_UINT16, 1, AD_ADI_DESC___W_G, { { &appl_iSpeed, &appl_sUint16Prop } } },
{ 0x2, "REF_SPEED", ABP_UINT16, 1, AD_ADI_DESC__R_S_, { { &appl_iRefSpeed, &appl_sUint16Prop } } }
{ 0x1, "SPEED", ABP_UINT16, 1, AD_ADI_DESC___W_G, { { &appl_iSpeed, &appl_sSpeedProp } } },
{ 0x2, "REF_SPEED", ABP_UINT16, 1, AD_ADI_DESC__R_SG, { { &appl_iRefSpeed, &appl_sRefSpeedProp } } },
Comment thread
AnJoha marked this conversation as resolved.
{ 0x3, "TORQUE", ABP_UINT16, 1, AD_ADI_DESC___W_G, { { &appl_iTorque, &appl_sTorqueProp } } },
{ 0x4, "REF_TORQUE", ABP_UINT16, 1, AD_ADI_DESC__R_SG, { { &appl_iRefTorque, &appl_sRefTorqueProp } } }
};

/*
** Default map (AD_MapType):
**-------------------------------------------------------------
** | 1. AdiIndex | 2. Direction | 3. NumElem | 4. StartIndex |
**-------------------------------------------------------------
*/
const AD_MapType ABCC_API_asAdObjDefaultMap[] =
{
{ 1, PD_WRITE, AD_MAP_ALL_ELEM, 0 }, /* Speed */
{ 2, PD_READ, AD_MAP_ALL_ELEM, 0 }, /* RefSpeed */
{ AD_MAP_END_ENTRY }
};

#if ASM_OBJ_ENABLE

#if !ABCC_CFG_REMAP_SUPPORT_ENABLED
#error "Remap support must be enabled for this example."
#endif

#if !ASM_IA_NAME_ENABLE
#error "Assembly instance names must be supported for this example."
#endif

#if !ASM_IA_MAX_NUM_ADI_MAPS_ENABLE
#error "Max number of ADI maps must be supported for this example."
#endif

/*------------------------------------------------------------------------------
** Map all adi:s in both directions
** Example assembly write maps.
**------------------------------------------------------------------------------
** 1. AD instance | 2. Direction | 3. Num elements | 4. Start index |
*/
const AD_MapType ABCC_API_asAsmWriteSpeedTorque[] =
{
{ 1, PD_WRITE, AD_MAP_ALL_ELEM, 0 }, /* Speed */
{ 3, PD_WRITE, AD_MAP_ALL_ELEM, 0 }, /* Torque */
{ AD_MAP_END_ENTRY }
};

const AD_MapType ABCC_API_asAsmWriteSpeed[] =
{
{ 1, PD_WRITE, AD_MAP_ALL_ELEM, 0 }, /* Speed */
{ AD_MAP_END_ENTRY }
};

const AD_MapType ABCC_API_asAsmWriteTorque[] =
{
{ 3, PD_WRITE, AD_MAP_ALL_ELEM, 0 }, /* Torque */
{ AD_MAP_END_ENTRY }
};

/*------------------------------------------------------------------------------
** Example assembly read maps.
**------------------------------------------------------------------------------
*/
const AD_MapType ABCC_API_asAdObjDefaultMap[] =
const AD_MapType ABCC_API_asAsmReadSpeedTorque[] =
{
{ 1, PD_WRITE, AD_MAP_ALL_ELEM, 0 },
{ 2, PD_READ, AD_MAP_ALL_ELEM, 0 },
{ 2, PD_READ, AD_MAP_ALL_ELEM, 0 }, /* RefSpeed */
{ 4, PD_READ, AD_MAP_ALL_ELEM, 0 }, /* RefTorque */
{ AD_MAP_END_ENTRY }
};

const AD_MapType ABCC_API_asAsmReadTorque[] =
{
{ 4, PD_READ, AD_MAP_ALL_ELEM, 0 }, /* RefTorque */
{ AD_MAP_END_ENTRY }
};

/*------------------------------------------------------------------------------
** Assembly mapping instances.
**------------------------------------------------------------------------------
*/
const ASM_InstanceType ABCC_API_sAsmWriteSpeedTorque =
{
ABP_ASM_IA_DESC_WRITE | ABP_ASM_IA_DESC_STATIC | ABP_ASM_IA_DESC_PD_MAPPABLE,
ABCC_API_asAsmWriteSpeedTorque,
"Write speed + torque",
sizeof( ABCC_API_asAsmWriteSpeedTorque ) / sizeof( AD_MapType ) - 1
Comment thread
AnJoha marked this conversation as resolved.
};

const ASM_InstanceType ABCC_API_sAsmWriteSpeed =
{
ABP_ASM_IA_DESC_WRITE | ABP_ASM_IA_DESC_STATIC | ABP_ASM_IA_DESC_PD_MAPPABLE,
ABCC_API_asAsmWriteSpeed,
"Write speed",
sizeof( ABCC_API_asAsmWriteSpeed ) / sizeof( AD_MapType ) - 1
};

const ASM_InstanceType ABCC_API_sAsmWriteTorque =
{
ABP_ASM_IA_DESC_WRITE | ABP_ASM_IA_DESC_STATIC | ABP_ASM_IA_DESC_PD_MAPPABLE,
ABCC_API_asAsmWriteTorque,
"Write torque",
sizeof( ABCC_API_asAsmWriteTorque ) / sizeof( AD_MapType ) - 1
};

const ASM_InstanceType ABCC_API_sAsmReadSpeedTorque =
{
ABP_ASM_IA_DESC_READ | ABP_ASM_IA_DESC_STATIC | ABP_ASM_IA_DESC_PD_MAPPABLE,
ABCC_API_asAsmReadSpeedTorque,
"Read reference speed + reference torque",
sizeof( ABCC_API_asAsmReadSpeedTorque ) / sizeof( AD_MapType ) - 1
};

const ASM_InstanceType ABCC_API_sAsmReadTorque =
{
ABP_ASM_IA_DESC_READ | ABP_ASM_IA_DESC_STATIC | ABP_ASM_IA_DESC_PD_MAPPABLE,
ABCC_API_asAsmReadTorque,
"Read reference torque",
sizeof( ABCC_API_asAsmReadTorque ) / sizeof( AD_MapType ) - 1
};

/*------------------------------------------------------------------------------
** Array of all assembly mapping instances.
**------------------------------------------------------------------------------
*/
const ASM_InstanceType* ABCC_API_aasAsmInstances[] =
{
&ABCC_API_sAsmWriteSpeedTorque,
&ABCC_API_sAsmWriteSpeed,
&ABCC_API_sAsmWriteTorque,
&ABCC_API_sAsmReadSpeedTorque,
&ABCC_API_sAsmReadTorque
};

const ASM_InstanceType** ABCC_API_CbfGetAsmInstances( void )
{
return( ABCC_API_aasAsmInstances );
}

UINT16 ABCC_API_CbfGetNumAsmInstances( void )
{
return( sizeof( ABCC_API_aasAsmInstances ) / sizeof( ASM_InstanceType* ) );
}
#endif /* ASM_OBJ_ENABLE */


UINT16 ABCC_API_CbfGetNumAdi( void )
{
return( sizeof( ABCC_API_asAdiEntryList ) / sizeof( AD_AdiEntryType ) );
}

/*------------------------------------------------------------------------------
** Example - electric motor control loop
** Example - electric motor speed control loop
**------------------------------------------------------------------------------
*/
void ABCC_API_CbfCyclicalProcessing()
Expand Down Expand Up @@ -95,4 +251,4 @@ void ABCC_API_CbfCyclicalProcessing()
*/
appl_iSpeed = 0;
}
}
}