• No results found

Initialization of the CAN-bus and setup of objects .1 CM_Init(): Setting up a CAN open-node

K.2.3 Function blocks and functions under PROSYD 1131 .1 Introduction

K.2.3.2 Initialization of the CAN-bus and setup of objects .1 CM_Init(): Setting up a CAN open-node

This function is used as an alternative to the previous function COPINIT().

The parameterization of the network node is to be carried out with the function CM_Init():

• node number

• CANopen-slave or CANopen-manager

• type of network guarding

• type of error handling

• type of SYNC-handling

Only then will the CANopen – stack be set up.

Function : CM_Init()

1131-Library: CANopen401.LIB

Application: in CANopen-slave or in CANopen-manager Function symbol:

Function input Data type Description

NodeId BYTE node-Id of CAN-node;

range of values 1..32

CanSpeed WORD transmission rate (acc. to CiA):

KBD_1000

NodeType BYTE type of network node:

0 = CANopen–slave

04 - 68 280 000/A

Version 1.0.0 Page K-41

Function input Data type Description

>= 2 reserved

GuardType BYTE type of guarding:

0 = no guarding

1 = guarding by master6 10 = heartbeat producer

20 = heartbeat producer + consumer

EmcyType BYTE type of error handling:

0 = no emergency message

1 = emergency message – producer 10 = emergency message producer + consumer7

(note: in the data structure TSysOut.

en_emergency the emergency messages to be output are filtered)

SyncTime WORD type of SYNC-handling (permissible synchronization):

0 : no Sync

< 25 : not permissible

>= 25 : Sync-time (should be a multiple of the AWP(application program) cycle time)

Function output Data type Description

ErrorState INT 0 = OK

< 0 error number (see Chapter K.2.4)

Example:

Figure K.7 Use of CM_INIT()

NOTE:

After successfully calling CM_Init(), the device is initialized as a CANopen-node. This forms the basis for all further steps regarding the CANopen-network (see also Table K.20).

NOTE:

In the case of a new implementation, the function CM_Init() is to be absolutely preferred to the function COPINIT().

6 only in the case of CANopen-slave

7 only in the case of CANopen-manager

04 - 68 280 000/A

Version 1.0.0 Page K-42

K.2.3.2.2 COPINIT(): Setting up a CANopen-node – DcP/DcE-compatible

NOTE:

This function was used in digsy®compact and continues to be available for compatibility reasons. However, in the case of new implementations it is advisable to use always CM_Init().

The parameterization of the CANopen–node is to be effected with the function COPINIT().

Function : COPINIT()

1131-Library: CANopen401.LIB

Application: in CANopen-slave or if an older, already existing implementation is to be adopted.

Function symbol:

Function input Data type Description

NodeId BYTE node-Id of CAN-node;

range of values 1..32

CanSpeed WORD transmission rate (acc. to CiA):

KBD_1000 KBD_500 KBD_250 KBD_125 KBD_100 KBD_50 KBD_20 KBD_10 KBD_800

Function output Data type Description

ErrorState BOOL TRUE = OK

FALSE = error when setting up CANopen

Example:

Figure K.8 Use of COPINIT() COPINIT NodeId CanSpeed

04 - 68 280 000/A

Version 1.0.0 Page K-43

K.2.3.2.3 COBADD() : Setting up a new entry in the object directory:

The function COBADD() is available for setting up further CANopen object-directory-entries:

ATTENTION:

The objects have to be set up prior to the CANopen-initialization.

Function : COBADD()

1131-Library: CANopen401.LIB

Application: CANopen-slave or CANopen-manager Function symbol:

Function input Data type Description

Index WORD CANopen – Index

SubIndex BYTE CANopen – Subindex

Attribute WORD ATTR_RW,

ATTR_RO,

in the case of PDOs: extension "PDO_MAP "

to be added: e.g., ATTR_RW + PDO_MAP

DataType WORD -BOOLEAN

-INTEGER8

DataLen BYTE object size in bytes:

-BOOLEAN :=1

04 - 68 280 000/A

Version 1.0.0 Page K-44

Function input Data type Description

-UNSIGNED8:=1

DefValue POINTER TO

BYTE

pointer to default value ZERO, if not available

Object POINTER TO

BYTE pointer to the current data object

TransType WORD TYPE_TX

TYPE_RX

Function output Data type Description

ErrorState BOOL 0 = not executed

1 = prepared

It is possible to set up objects in the index area 2000H to 5FFFH, 6000h..9FFFh as well as the indices 100Ch, 100Dh, 1016H and 1017H.

In this connection, however, it has to be taken into account that PDOs are only defined and mapped in the area of the %QW, %IW and %MW. For this purpose, the extension PDO_MAP is to be additionally inserted in the input word Attribute. Objects which are to be transferred only by means of SDO can be defined in any storage area whatever.

If an object is to have several subindices, it has to be taken into account that a subindex 0 is defined with the number of the further subindices. The consistency of complex objects (i.e., with several subindices) is not checked by the system.

SDOs can be defined in any storage area with the DataLen := DOMAIN. An SDO, however, is limited to 255 bytes.

ATTENTION:

An SDO defined as a data type DOMAIN can transfer a maximum of 255 bytes.

Example:

Figure K.9 Use of COBADD()

04 - 68 280 000/A

Version 1.0.0 Page K-45

K.2.3.2.4 CM_AddNode(): Setting up the node list

To be able to set up further CANopen-nodes it is necessary to make their characteristics known to the CAN-manager or other CANopen-nodes. For each SDO-server in a node the SDO-client belonging to it is set up with this function, in this connection the number of the handle is equal to the node number.

Function : CM_AddNode() 1131-Library: CANopen401.LIB

Application: CANopen-slave or CANopen-manager Function symbol:

Function input Data type Description

node_no BYTE 0 – ill. node number

1-32 number of the node

>32 – ill. node number

mode BYTE 0 := no guarding mechanism in the case of this node

BIT0 : =1 : node guarding BIT1 : =1 : heartbeat BIT4-BIT7 : reserved

guardtime WORD guard-time or heartbeat-time in [ms]

lifetime BYTE life time factor

Function output Data type Description

ErrorState INT 0 = OK

< 0 = error numbers

NOTE:

The guardtime and lifetime entered with CM_AddNode() have to correspond with the values of the node to be set up. Within the scope of this function these values are not transferred to the CANopen-node node_no belonging to it.

The following objects of the object directory are influenced by this function:

COBADD node_no mode guardtime lifetime

04 - 68 280 000/A

Version 1.0.0 Page K-46

Mode Guardtime Lifetime

Nodeguarding 16#100C 16#100D

Heartbeat

16#1017 := guardtime * lifetime or if lifetime := 0:

16#1617 := guardtime * 1

Table K.9 Objects of the object directory belonging to CM_AddNode()

NOTE:

If, prior to calling the function CM_AddNode(), SDO-channels with the same handle were set up with the function SDOADD(), they are eliminated by the function CM_AddNode() and its own handle is set up instead.

Example: Setting up the CANopen-slave 3 for nodeguarding and the SDO-channel

Figure K.10 Use of CM_AddNode()

04 - 68 280 000/A

Version 1.0.0 Page K-47

K.2.3.2.5 CM_Reset():CM_Reset(): Resetting the network settings of the control unit

With this function all static variables of the firmware are reset to the default values. This becomes necessary, if a node is to be initialized anew with CM_Init() or CM_AddNode().

Function : CM_Reset() 1131-Library: CANopen401.LIB Application: CANopen-Manager Function symbol:

Function input Data type Description

wMode WORD reserved

Function output Data type Description

ErrorState INT 0 = OK

< 0 = error numbers

NOTE:

Objects set up with COBADD() are not reset by this function.

Example:

Figure K.11 Use of CM_Reset() CM_Reset wMode

04 - 68 280 000/A

Version 1.0.0 Page K-48

Related documents