CAN interface
Almost all CANopen masters from Beckhoff offer the so-called CAN interface. The CAN interface is a Layer-2 implementation of the CAN interface. It enables any desired CAN telegrams to be received and transmitted. The higher-level protocol is not important here, i.e. all CAN-based protocols can be used; however the protocol part must then be implemented in the PLC.
A detailed description of the CAN interface can be found at:
https://download.beckhoff.com/download/document/io/infrastructure-components/can-interface_en.pdf
Any CAN data can be sent via the CAN interface. There is a choice between 11-bit identifier (CAN 2.0A) or 29-bit identifier (CAN 2.0B).
Message structure with 29-bit support
- Length (0..8)
- CobId
- Bit 0-28: 11-bit identifier / 29-bit identifier
- Bit 30: RTR
- Bit 31: 0: normal message (11-bit identifier), 1: extended message (29-bit identifier)
- Data[8]
Send data: In "NoOfTxMessages" enter the number of data you want to send from the Tx buffer. If the buffer has capacity for 10 entries, the maximum number of telegrams that can be send consecutively is 10. "Length" defines the number of PDO data bytes (maximum 8 bytes). Fill in the data and enter the identifier of the CAN message in "codId". Now increment the TxCounter value.
Sample code: Sending messages from the PLC
if Outputs.TxCounter = Inputs.TxCounter then
for i=0 to NumberOfMessagesToSend do
Outputs.TxMessage[i] = MessageToSend[i];
End_for
Outputs.NoOfTxMessages = NumberOfMessagesToSend;
Outputs.TxCounter := Outputs.TxCounter + 1;
end_if
Sample code: Receiving messages from the PLC
if Outputs.RxCounter <> Inputs.RxCounter then
for i := 0 to (Inputs.NoOfRxMessages-1) do
MessageReceived[i] := Inputs.RxMessage [i];
End_for
Outputs.RxCounter := Outputs.RxCounter+1;
end_if