Supported platforms: CODESYS 2.3, CODESYS 3.5

 

CANopenPDO (FB)

Description

CODESYS 2.3CODESYS 2.3

This function block defines PDOs according to CANopenPDO.Init action.

 

 

CODESYS 3.5CODESYS 3.5

This function block implements inteface CANVXD_API.IReceiveCallback.

 

Limitations

RTR (Remote Transmission Request) is not supported.

 

Inputs

Input variable name

Data type

Description

i_pDevice

POINTER TO CANopenDev

Pointer to the device

i_PDONumber

WORD

PDO's order number

i_PDOType

CANopenPDOType

Type of PDO:

ReceivePDO or TransmitPDO

i_COB_ID

DWORD

Bit 31 PDO does not exist

Bit 30 no RTR allowed

Bit 29 29-bit ID

Bit 28-11 0 for 11-bit ID

Bit 10-0 COB-ID

i_TransmissionType

BYTE

0 = Not supported

1..240 = Cyclic synchronous

254 = Triggered (with i_TriggerSend)

255 = Asynchronous i.e. event controlled

i_InhibitTime

WORD

Minimum time that has to elapse between transmitted messages. Unit:1=100 μs

i_Reserved

BYTE

Reserved in DS301

i_EventTime

WORD

Event time in ms

i_Mapping

ARRAY [0..G_CANOPEN_NUMBER_OF_LAST_PDO_MAP] OF DWORD

PDO's mapping parameters.

i_Mappings

BYTE

Number of mappings

i_TriggerSend

BOOL

If TRUE and transmission type is 254, PDO is sent even data is not changed. Input is set FALSE after sending.

i_RejectTooShortMessages

BOOL

If TRUE, messages with lower DLC than expected, are rejected. Note that when a message is rejected, the o_RpdoCount and o_RpdoTimeStamp are still affected.

* The variables marked with grey background are PDO's communication parameters.

Outputs

CODESYS 2.3CODESYS 2.3

Output variable name

Data type

Description

o_RpdoCount

DWORD

Number of received PDOs. Added only if device in operational mode.

o_RpdoTimeStamp

DWORD

Time stamp for latest  received PDO. Updated only if device operational mode. Value is set by usage of the CODESYS TIME() function.

o_TpdoCount

DWORD

Number of sent TPDOs. Added only if device in operational mode.

o_TpdoTimeStamp

DWORD

Time stamp for lates sent TPDO. Updated only if device operational mode. Value is set by usage of the CODESYS TIME() function.

o_LastReceivedLength

BYTE

Length of the latest received PDO

o_TimeoutActive

BOOL

RPDO mappings set to zero due to timeout

 

 

CODESYS 3.5CODESYS 3.5

Output variable name

Data type

Description

o_RpdoCount

DWORD

Number of received PDOs. Added only if device in operational mode.

o_RpdoTimeStamp

DWORD

Time stamp for latest  received PDO. Updated only if device operational mode. Value is set by usage of the CODESYS TIME() function.

o_TpdoCount

DWORD

Number of sent TPDOs. Added only if device in operational mode.

o_TpdoTimeStamp

DWORD

Time stamp for lates sent TPDO. Updated only if device operational mode. Value is set by usage of the CODESYS TIME() function.

o_LastReceivedLength

BYTE

Length of the latest received PDO

o_Error

CANopenErrors

CANopenErrors

 

 

Actions

CODESYS 2.3CODESYS 2.3

Action name

Description

Init

Set function block's default data.

Function adds PDO of given type to device. Mapping must be given in advance to CANopenPDO.Mapping array.

 

The init will add subindexes according to the given number of mappings.

 

The function adds the following indexes:

 (16#1400 or 16#1800)+PDONumber (PDO communication)

 (16#1600 or 16#1A00)+PDONumber (PDO mapping)

 

Before calling the action, PDO must be connected to device.

 

ReceiveCAN_MSG

PDO receive handler for COB-ID.

Copies the received PDO for the CANopenPDO FB's  internal use.

SetComms

Sets PDO's communication parameters. Called from Init and

POU CANopenPDOChangeCommunication

SetMapping

Sets PDO's mapping parameters and an internal datapointer to mapped data. Called from Init and POU CANopenPDOChangeMap.

TxRx

Handles data which is stored in MSG. Stores data to mapping indexes.

In case of RPDO, the action reads received PDO's and copies data to indexes. If RPDO event time is <> 0 then timeout is monitored. Mapping data is set to zero when RPDO is in timeout.

In case of TPDO, the action copies data from indexes and sends PDO if transmit conditions are met.

 

 

CODESYS 3.5CODESYS 3.5

Action name

Description

Init

Set function block's default data.

Function adds PDO of given type to device. Mapping must be given in advance to CANopenPDO.Mapping array.

 

The init will add subindexes according to the given number of mappings.

 

The function adds the following indexes:

 (16#1400 or 16#1800)+PDONumber (PDO communication)

 (16#1600 or 16#1A00)+PDONumber (PDO mapping)

 

Before calling the action, PDO must be connected to device.

 

 

 

 

Methods

 

CODESYS 3.5CODESYS 3.5

Method name

Description

Receive

PDO receive method.

 

 

Example code

CODESYS 2.3

 

CODESYS 3.5

 

 

 

Source file Topic000197.htm

Last updated 21-Feb-2025