CANopen Slave Protocol Stack 
Version 7.04.00
Loading...
Searching...
No Matches
CANopen Device Profile CiA 404

The add-on module CANopen Device Profile CiA 404 allows the integration of measuring devices as specified in CiA 404-1.

Module version

The module version is defined by COS_DS404_VERSION_MAJOR and COS_DS404_VERSION_MINOR. Please refer to the history for changes between different versions.

Configuration

The module is configured by setting of the following symbols inside the cos_conf.h file:

DefineDescription
COS_DS404_AInumber of analog inputs
COS_DS404_AI_FILTERsupport filter for analog inputs inputs
COS_DS404_AI_SCALINGsupport scaling for analog inputs
COS_DS404_AOnumber of analog outputs

The profile allows to support different data types. By means of the following symbols one or multiple data types can be selected. The symbols are located inside the cos_conf.h file:

DefineDescription
COS_DS404_DT_FLOATsupport data type float, refer to eCO_DT_REAL32
COS_DS404_DT_INT16support data type int16_t, refer to eCO_DT_INTEGER16
COS_DS404_DT_INT32support data type int32_t, refer to eCO_DT_INTEGER32

Interface to application

Use the header file cos404.h to get access to the CANopen Device Profile CiA 404 API.

#include "cos404.h"
CiA 404 - Device profile for measuring devices and closed-loop controllers .

Analog inputs

Each analog input channel is initialized by calling Cos404_AI_Init() prior to CosMgrStart(). An example initialization routine is located inside the cos404_app_ai.c file.

Analog inputs are read by the application and forwarded to the protocol stack by means of either Cos404_AI_SetFV_Int16(), Cos404_AI_SetFV_Int32() or Cos404_AI_SetFV_Real32(), depending on the supported data type.

If dynamic PDO mapping is supported (COS_PDO_MAPPING > 0) the default mapping can be set inside the CosPdoComSetup() function, as shown in the following example:

void CosPdoComSetup(void)
{
// .. other code ..
//------------------------------------------------------------------------------------
// TPDO1 - SYNC-driven PDO
//
atsTrmPdoComG[0].ubTransType = ePDO_TYPE_SYNC_1;
//------------------------------------------------------------------------------------
// TPDO1 - map object 7130:01h
//
CosPdoTrmMapEnable(0, 0); // disable current mapping for TPDO1
CosPdoTrmMapAdd( 0, 0 ,0x71300110); // add object 6000:01h, length = 16 bit
CosPdoTrmMapEnable(0, 1); // enable current mapping for TPDO1
// .. other code ..
}
@ ePDO_TYPE_SYNC_1
Definition cos_pdo.h:160
void CosPdoComSetup(void)
Setup application specific PDO communication parameter.
uint8_t CosPdoTrmMapEnable(uint8_t ubPdoNumberV, uint8_t ubMapNumberV)
uint8_t CosPdoTrmMapAdd(uint8_t ubPdoNumberV, uint8_t ubMapIdxV, uint32_t ulMapEntryV)
CosPdoCom_ts atsTrmPdoComG[]

Analog outputs

Analog outputs are written by the application by means of either Cos404_AO_SetPV_Int16(), Cos404_AO_SetPV_Int32() or Cos404_AO_SetPV_Real32(), depending on the supported data type.

If dynamic PDO mapping is supported (COS_PDO_MAPPING > 0) the default mapping can be set inside the CosPdoComSetup() function, as shown in the following example:

void CosPdoComSetup(void)
{
// .. other code ..
//------------------------------------------------------------------------------------
// RPDO1 - event-driven PDO, profile specific
//
//------------------------------------------------------------------------------------
// RPDO1 - map object 6200:01h
//
CosPdoRcvMapEnable(0, 0); // disable current mapping for RPDO1
CosPdoRcvMapAdd( 0, 0 ,0x73000110); // add object 7300:01h, length = 16 bit
CosPdoRcvMapEnable(0, 1); // enable current mapping for RPDO1
// .. other code ..}
uint8_t CosPdoRcvMapAdd(uint8_t ubPdoNumberV, uint8_t ubMapIdxV, uint32_t ulMapEntryV)
@ ePDO_TYPE_EVENT_PROFILE
Definition cos_pdo.h:190
CosPdoCom_ts atsRcvPdoComG[]
uint8_t CosPdoRcvMapEnable(uint8_t ubPdoNumberV, uint8_t ubMapNumberV)

CiA 404 files

FileDescription
cos404.hCiA 404 - Generic definitions
cos404ai.hCiA 404 - Analog inputs
cos404ao.hCiA 404 - Analog outputs