Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

CodeSYS CL2 library internal error for CAN on (Raspberry Pi + MCP2515)

Kalyani-K
2019-07-12
2021-06-30
  • Kalyani-K - 2019-07-12

    Hello everyone,

    My aim is to establish CAN bus network using Raspberry Pi + MCP2515, programmed in CodeSYS.

    On the hardware's side, I have connected the SPI pins of MCP2515 to the corresponding SPI pins of Raspberry Pi. As for the INT pin, I have connected it to GPIO25 (this comes after many posts mentioned the use of pin 25 for INT).
    The GND and VCC for MCP2515 are connected to GND and 3.3V pin on Raspberry Pi.
    I have seperately soldered a 5V connection to TJA1050 by etching out the bridging capacitor.

    On the Linux side, I downloaded CAN utils, enabled corresponding overlays, and got the CANbus to working. It is fully functional.
    I monitor the messages using PCAN USB Pro.

    Now, the real problem is with CodeSYS library.
    Everytime I attempt to configure the driver, the CL2 library either throws an "INTERNAL ERROR" or a "NO DRIVER" error!
    I loaded every possible CMPManager file, every CodeSYSConfig file on Linux. However, the problem still persists.

    I just don't understand what the real problem is.

    Can somebody throw some light??
    I will be greatly indebted.

     
  • Kalyani-K - 2019-07-12

    Now, the Runtime info on CodeSYS says that a command can't be executed.
    Can somebody tell me what's going on?

    IMG: forcodesysforum.jpg

     
  • eschwellinger

    eschwellinger - 2019-07-14

    did you add in /etc/CODESYSControl_User.cfg

    [CmpSocketCanDrv]
    ScriptPath=/opt/codesys/scripts/
    ScriptName=rts_set_baud.sh
    

    the sript is:

    \#!/bin/sh
    BITRATE=`expr $2 \\* 1000`
    ifconfig $1 down
    echo ip link set $1 type can bitrate $BITRATE
    ip link set $1 type can bitrate $BITRATE
    ifconfig $1 up
    

    should be in /opt/codesys/scripts/rts_set_baud.sh
    and need to be executable.
    sudo chmod +x /opt/codesys/scripts/rts_set_baud.sh

    BR
    Edwin

     
  • Kalyani-K - 2019-07-18

    Edwin,

    I added everything you mentioned.
    And, my Can bus works!

    Thanks so much!!!

     
  • alexmserra - 2021-06-29

    Good morning everyone, could someone help me with a project where I use a Raspberry pi 3 with codesys and Powerlink Communication and now I need to add a canbus communication but I don't even know how I could add a driver for example usb-Can or some other device ? could someone help me with this question?

     
    • Ingo

      Ingo - 2021-06-30

      I have only theoretical knowledge. But, what you need is a Socket CAN
      driver for your CAN device. The interface of the socket can driver then
      needs to be up, wehn the runtime starts.

      The rest should work, I guess.

       

Log in to post a comment.