Reputation: 173
I have connected a Wago PFC200 750-8204 between two Components which communicates via CAN bus in order to receive the messages and for further processing. My approach was to implement it in codesys 2.3 with the WagoCanLayer2_02.lib library but i fail with the readind the canbus. The Code.
open(BAUDRATE := 500000 ,ENABLE := TRUE );
can11BitFrame(
CAN_ID:= 16#380,
CAN_BUFFER:= FALSE,
ENABLE:= TRUE,
READ_FRAME:= frame,
DATA=> data);
Have you any idea how i can solve this and have you code examples?
Upvotes: 0
Views: 1541
Reputation: 67
I can't comment so I have to answer (although it's probably too late anyway).
Assuming that the CAN interface is initialized and working and that your can11BitFrame
is a CAN_RX_11BIT_FRAME
instance, the following should work:
can11BitFrame(
CAN_ID := 16#380,
CAN_BUFFER := FALSE,
CAN_PORT := 0, (* not sure if this is really necessary here *)
ENABLE := TRUE,
READ_FRAME := frame);
data := can11BitFrame.DATA;
or maybe
IF can11BitFrame.error = CAN_RECEIVE_OK THEN
data := can11BitFrame.DATA;
END_IF
And you have to set frame
to true
each time you want to read the message.
I have no idea if and how the DATA => data
is supposed to work (I am using FUP here). As far as I know. in ST you have to execute the function block first and can then access the output parameters.
Upvotes: 1