beckhoff TwinCAT 3 — 11.1.6 Use of a filter

CAN | CAN Interface Since COB ID, length and RTR bit are coded in one word in the 11-bit identifier, the following example is helpful for decoding the data from the word. Select a structure here in which to store the decoded data. IF RXCounter_Out RXCounter_In THEN FOR I := 0 TO (NoOfTxMessages-1) DO stCANInterfaceMessageValue[i].Lengh:=WORD_TO_BYTE(stCANInterfaceMessage[i].CobID) AND 16#0F; stCANInterfaceMessageValue[i].RTR:=stCANInterfaceMessage[i].CobID.4; stCANInterfaceMessageValue[i].CobID :=ROR(stCANInterfaceMessage[i].CobID,5) AND 16#07FF; stCANInterfaceMessageValue[i].Data := stCANInterfaceMessage[i].Data; CASE stCANInterfaceMessageValue[i].CobID OF 16#318: COB318:=COB318+1; 16#718:

COB718:=COB718+1; 16#1CD: COB1CD:=COB1CD+1; memcpy(ADR(TempValue),ADR(stCANInterfaceMessage[i].Data[6]),2); 16#1ED: COB1ED:=COB1ED+1; ELSE COBALLOther:=COBAllOther+1; END_CASE End_for RXCounter_Out:=RXCounter_In; END_IF Message structure when using the 29-bit identifier The message structure when using the 29-bit identifier consists of the length [2 bytes] of the COB ID [4 bytes] and the 8 bytes of data. Lenght: Length of the data (0…8) The COB ID has the following structure: Bit 0-28: 29-bit identifier Bit 30: RTR Bit 31: ◦0: 11-bit identifier, ◦1:

29-bit identifier Message structure when using the 29-bit identifier 11.1.6 Use of a filter | Use of a filter If you don't wish to receive all the telegrams in the CAN interface, there is an option to set filters. This reduces the number of CAN telegrams in the CAN interface and thus permits only those telegrams that are actually required. I/O 36 Version: 2.3.0