PLC and CANBUS interface

Join Date
Dec 2019
Location
Vojvodina
Posts
3
Hello, I am fairly new to PLC programming and i have a problem connecting two devices. Mainly my problem is how to read data from the RFID which is connected to my PLC via CANopen field bus interface. I need to read the RFID tag from it and then open a garage door. It is done with serial communication in mind so basically i need to send correct information to RFID then RFID sends the value of the tag back. I know how to do serial communication between two ports on PLC but not through CANopen field bus so i am a little stuck. My question is how to make it work in Codesys? I am currently using Codesys v3.5.4, PLC CECC-S and my RFID is in the link bellow.

RFID:
https://docdro.id/KhNKbVf

https://docdro.id/4HabEHD

CECC-S

https://www.festo.com/net/SupportPortal/Files/573539/CECC-D_LK_S_2018-04b_8060506g1.pdf
 
Aleksandarm1116, hello!
Looking at your RFID device, it is not CANopen. Instead it uses ISO15693-3, which is some RFID specific protocol. It details quite clearly in your doc I think the strings to send and receive. As a side note, CANopen and ISO15693-3 both use CANbus, but so does DeviceNet.

I think instead of CANopen, you need to use the CAN Low Level Library.

This is given the cute name CL2, because it has two Ls.
Here is its documentation
https://help.codesys.com/webapp/idx-CAA_CanL2_Extern-lib;product=CAA_CanL2_Extern

Here is an example project.
https://store.codesys.com/can-bus-example.html

Good luck, I think it is perhaps not the easiest nor most rewarding challenge.
 
How do i create a message that i need to send it via CL2? I know there is a function called CreateMessage
CL2.CreateMessage(
hDriver := CAA.HANDLE,
cobID := CL2I.COBID,
usiLength := 2,
xRTR := FALSE,
x29bitID := FALSE,
peError := ADR(eError)

);
witch is called but i don't know how to use it to create a custom message that i need to send it to my RFID i need to send this string 0x1B, ‘R’, 0x01. And the return message that i get from RFID is stored in buffer.

Also there is a function which i don't quite understand
IF hMsg <> CAA.gc_hINVALID THEN
//Get message data pointer
pData := CL2.GetMessageDataPointer(hMessage := hMsg, peError := ADR(eError));
IF pData <> CAA.gc_pNULL THEN
//initialize message data
pData^[0] := 16#81;
pData^[1] := 16#0;
END_IF
it is initialising message data i have found it on codesys help site. Can someone explain it to me? Do i need that function in my code to handle the message data?
 
Last edited:

Similar Topics

Hello everyone! I have a Schneider M241 as master of a CAN network with several encoders and whatnot, everything is working fairly well. Now...
Replies
3
Views
1,693
I'm trying to set up a network of Sauer-Danfoss Plus +1 controllers (CANBUS), and I have to have numerous units very far apart from each other ( >...
Replies
2
Views
2,892
HI i would like to know how to get a variable that will store the amount of times a program has been executed. The issue is I have 3 DBs for 1 FB...
Replies
2
Views
50
I haven't encountered problems connecting to a PLC through VM Ware but I am with this particular machine. I'm running Windows 7 on a Windows 10...
Replies
5
Views
91
Hello, As part of our project, we are using an M241 controller. This controller interfaces with an industrial computer and a router via a switch...
Replies
2
Views
43
Back
Top Bottom