Results 1 to 6 of 6

Thread: CAN Rx Deciphering

  1. #1
    Join Date
    May 2016
    Location
    Netherlands
    Posts
    3

    Default CAN Rx Deciphering

    I want my PLC CR.0020 to intercept one particular CAN message and act accordingly.
    This must be the minimal bare CAN functionality and I am so surprised I can?t find examples in my tutorials:


    In Functional Block Diagrams I want to evaluate Byte number 6 of a CAN message.


    CAN1RECEIVE; sure, but HOW TO DECIPHER / unpack the 8 bytes from this particular CAN 1 MESSAGE:

    ID Bytes Byte0 Byte1 Byte2 Byte3 Byte4 Byte5 Byte6 Byte7
    1553 7 Flags(1) MaxIac(2) MaxVdc(3) MaxIdc(4) (?)


    A magic word or a link to a tutorial is highly appreciated,

    -paul-

  2. #2
    Join Date
    May 2009
    Location
    Minneapolis, MN
    Posts
    299

    Default

    You can do this 2 ways.
    1. Assign an array to DATA, abData : ARRAY [0..7] OF BYTE. Then you can call out abData[x] where x is the individual bytes.
    2. BrusaLaadt.DATA[x] where x is the individual bytes.

  3. #3
    Join Date
    May 2016
    Location
    Netherlands
    Posts
    3

    Default CAN Rx directed

    Thank you, Erik; with option 2 it is simple now:



    But CR doesn't receive any of the bytes. Do you see something else going wrong here:



    The third picture shows what is happening on the bus that makes me conclude I need another Codesys hint from you. Looking forward to that,



    -paul-

  4. #4
    Join Date
    May 2009
    Posts
    87

    Default

    The CONFIG input variable of CAN1_RECEIVE should not be constantly set TRUE. It only needs to be TRUE for one cycle to configure/initialize the FB.

    Also, I don't think you want to keep the CLEAR input variable constantly TRUE either since it's used to delete the data buffer/queue.

  5. #5
    Join Date
    May 2009
    Location
    Minneapolis, MN
    Posts
    299

    Default

    What cvrettacos said. Make the CLEAR = init1. You are clearing the bytes of data you recievce on every PLC scan.

  6. #6
    Join Date
    May 2016
    Location
    Netherlands
    Posts
    3

    Default

    Thanks a lot gentlemen: it works when both input were set to init1. My project floats again.
    -paul-

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •