Supported platforms: CODESYS 2.3, CODESYS 3.5
This function creates a connection between producer and consumer. The receive and transmit COB-IDs can be same or different.
The connection is point-to-point and it consists of a producer and a consumer.
The connection is two-way, and both producer and consumer can start transmitting messages at any time they want.
When the connection is created as a consumer, the receive buffer size is set to 254 bytes and the transmit buffer size is set to 15 bytes.
When the connection is created as a producer, the buffer sizes are set vice versa. The buffer sizes are unbalanced to optimize RAM reservation.
That is the only difference between the producer and the consumer.
|
Since only TPDO COB-IDs is usually used for PDO communication, both COB-IDs can use RPDO space of the CANopen device.
|
Input variable name |
Data type |
Description |
i_Producer |
BOOL |
TRUE = Producer (e.g. control unit) or FALSE = Consumer (e.g. display) |
i_CAN_Drv |
BYTE |
|
i_RxCobID |
WORD |
Receive COB-ID |
i_TxCobID |
WORD |
Transmit COB-ID |
Data type |
Description |
BYTE |
Connection ID |
Example for event producer (control unit):
Definitions: |
|
G_DataConnection: BYTE; |
|
Init: |
|
EL_Init(0,0); (*Add data connection for this control unit*) G_DataConnection:=DT_AddDataConnection( i_Producer:=TRUE, i_CAN_Drv:=G_CANVXD_CAN1, i_RxCobID:=16#302, i_TxCobID:=16#202); ELT_AddProducerToEventLog(i_ConnectionID:=G_DataConnection); |
|
Example for event consumer (logging display):
Definitions: |
|
G_Device1DataConnection: BYTE;
G_Device1EventData:ARRAY[0..1] OF EL_EventData:= (Configuration:=14, EventType:=0) (* Event 'Event0': Log=TRUE,Popup=TRUE*), (Configuration:=14, EventType:=0) (* Event 'Event1': Log=TRUE,Popup=TRUE*);
|
|
Init: |
|
IF 92160 > G_NVRAM_EVENT_LOG_SIZE THEN EL_Init(i_pEventLog:=ADR(G_NVRAMEventLogPointer),i_SizeOfEventLog:=G_NVRAM_EVENT_LOG_SIZE); ELSE EL_Init(i_pEventLog:=ADR(G_NVRAMEventLogPointer),i_SizeOfEventLog:=92160); END_IF
(*Add data connection for control unit 'EPEC_CU2020'*) G_Device1DataConnection:=DT_AddDataConnection( i_Producer:=FALSE, i_CAN_Drv:=G_CANVXD_CAN1, i_RxCobID:=16#202, i_TxCobID:=16#302);
(*Add other devices's event data... *) (*Control unit 'EPEC_CU2020' event data*) ELT_AddConsumerToEventLog(i_ConnectionID:=G_Device1DataConnection,i_source:=2); EL_AddEventData(i_Source:=2, i_pEventData:=ADR(G_Device1EventData), 2, 0);
|
|
Input variable name |
Data type |
Description |
i_Producer |
BOOL |
TRUE = Producer (e.g. control unit) or FALSE = Consumer (e.g. display) |
i_itfCANChannel |
CANVXD_API.ICANVXD |
CAN channel |
i_RxCobID |
WORD |
Receive COB-ID |
i_TxCobID |
WORD |
Transmit COB-ID |
Data type |
Description |
BYTE |
Connection ID |
Example for event producer (control unit):
Definitions: |
|
G_DataConnection: BYTE; |
|
Init: |
|
EL_Init(0,0); (*Add data connection for this control unit*) G_DataConnection:=DT_AddDataConnection( i_Producer:=TRUE, i_itfCANChannel:=G_CAN1_Channel, i_RxCobID:=16#301, i_TxCobID:=16#201); ELT_AddProducerToEventLog(i_ConnectionID:=G_DataConnection); |
|
Example for event consumer (logging display):
Definitions: |
|
G_Device1DataConnection: BYTE;
G_Device1EventData: ARRAY[0..1] OF EL_EventData := [(Configuration := 14, EventType := 0), (Configuration := 14, EventType := 0)]; |
|
Init: |
|
IF 65529 > G_NVRAM_6107_EVENT_LOG_SIZE THEN EL_Init(i_pEventLog:=ADR(G_NVRAM_6107_EventLogPointer),i_SizeOfEventLog:=G_NVRAM_6107_EVENT_LOG_SIZE); ELSE EL_Init(i_pEventLog:=ADR(G_NVRAM_6107_EventLogPointer),i_SizeOfEventLog:=65529); END_IF
(*Add data connection for control unit 'EPEC_CU2'*) G_Device1DataConnection:=DT_AddDataConnection( i_Producer:=FALSE, i_itfCANChannel:=G_CAN1_Channel, i_RxCobID:=16#201, i_TxCobID:=16#301);
(*Add other devices's event data... *) (*Control unit 'EPEC_CU2' event data*) ELT_AddConsumerToEventLog(i_ConnectionID:=G_Device1DataConnection,i_source:=2); EL_AddEventData(i_Source:=2, i_pEventData:=ADR(G_Device1EventData), 2, 0);
|
|
-
Source file Topic000712.htm
Last updated 4-Sep-2025