CANopen Slave Documentation
Version 6.16.04
Loading...
Searching...
No Matches
CANopen Device Profile CiA 401

The add-on module CANopen Device Profile CiA 401 allows the integration of generic I/O modules as specified in CiA 401-1.

Module version

The module version is defined by COS_DS401_VERSION_MAJOR and COS_DS401_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:

COS_DS401_DI

number of digital input blocks, one block has 8 individual digital inputs

COS_DS401_DO

number of digital output blocks, one block has 8 individual digital outputs

COS_DS401_AI

number of analog inputs

COS_DS401_AO

number of analog outputs

Interface to application

Use the header file cos401.h to get access to the CANopen Device Profile CiA 401 API.

#include "cos401.h"

Digital inputs

Digital inputs are read by the application and passed to the protocol stack by means of Cos401_DI_Set(). 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 - event-driven PDO, profile specific
//
//------------------------------------------------------------------------------------
// TPDO1 - map object 6000:01h
//
CosPdoTrmMapEnable(0, 0); // disable current mapping for TPDO1
CosPdoTrmMapAdd( 0, 0 ,0x60000108); // add object 6000:01h, length = 8 bit
CosPdoTrmMapEnable(0, 1); // enable current mapping for TPDO1
// .. other code ..
}
CosPdoCom_ts atsTrmPdoComG[]
@ ePDO_TYPE_EVENT_PROFILE
Definition cos_pdo.h:190
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)
uint8_t ubTransType
Definition cos_pdo.h:224

Digital outputs

Digital outputs are set by the protocol stack by means of Cos401_DO_Set(). 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 ,0x62000108); // add object 6200:01h, length = 8 bit
CosPdoRcvMapEnable(0, 1); // enable current mapping for RPDO1
// .. other code ..
}
uint8_t CosPdoRcvMapAdd(uint8_t ubPdoNumberV, uint8_t ubMapIdxV, uint32_t ulMapEntryV)
CosPdoCom_ts atsRcvPdoComG[]
uint8_t CosPdoRcvMapEnable(uint8_t ubPdoNumberV, uint8_t ubMapNumberV)

Analog inputs

Analog inputs are read by the application and passed to the protocol stack by means of Cos401_AI_SetProcessValue16(). 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 ..
//------------------------------------------------------------------------------------
// TPDO2 - event-driven PDO, profile specific
//
//------------------------------------------------------------------------------------
// TPDO2 - map object 6401:01h
//
CosPdoTrmMapEnable(1, 0); // disable current mapping for TPDO2
CosPdoTrmMapAdd( 1, 0 ,0x64010110); // add object 6401:01h, length = 16 bit
CosPdoTrmMapEnable(1, 1); // enable current mapping for TPDO2
// .. other code ..
}

Analog outputs

Analog outputs are set by the protocol stack by means of Cos401_AO_Set(). 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 ..
//------------------------------------------------------------------------------------
// RPDO2 - event-driven PDO, profile specific
//
//------------------------------------------------------------------------------------
// RPDO2 - map object 6411:01h
//
CosPdoRcvMapEnable(1, 0); // disable current mapping for RPDO1
CosPdoRcvMapAdd( 1, 0 ,0x64110110); // add object 6411:01h, length = 16 bit
CosPdoRcvMapEnable(1, 1); // enable current mapping for RPDO1
// .. other code ..
}

CANopen Device Profile CiA 401 files

cos401di.h

CiA 401 - Digital inputs

cos401do.h

CiA 401 - Digital outputs

cos401ai.h

CiA 401 - Analog inputs

cos401ao.h

CiA 401 - Analog outputs