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

CANbus Baud rate issue

2018-10-22
2018-10-28
  • johnfarrugia - 2018-10-22

    I've been running a Pi3 with sp13 and Canbus at 250k for a few months now without issue. I've had to extend my network and have decided to lower the rate to 100k.
    I switched the modules and then the codesys master and found that once I make the change, codesys stops transmitting packets. It will recieve packets but not transmit them.
    If i bring up the interface using ifconfig, I can see that the can0 interface is receiving messages but not transmitting any. I add a sniffer to the network and connect at 100k and can confirm that the modules are transmitting at 100k but the master is not sending messages over the network. As soon as I change the slaves and the master within codesys back to 250k, then codesys transmits messages again. I've included the log file but there is nothing abnormal about it.

    Any idea what would cause codesys to stop transmitting messages at different baudrates?

    log.xml [38.51 KiB]

     
  • johnfarrugia - 2018-10-23

    I've been able to narrow the issue down to codesys. With the network set to 100kbs I can send and receive can messages using the cansend can0 and candump can0 commands without any issue. However, Codesys will receive all can messages but will never transmit a message. If i use the Ifconfig command. The RX count increases but the TX count only increases when I use the CANsend command.
    If I change the baudrate of the field modules to 250kbs and then change the baud rate in codesys to 250kbs, codesys sends and receives CAN messages correctly. So with only a change of the CAN network baud rate, codesys only works at 250kbs and nothing else.

    Any idea what could cause this?

    See the attached log file

    log.xml [234.18 KiB]

     
  • johnfarrugia - 2018-10-23

    I am dead in the water here any help would be appreciated!

     
  • johnfarrugia - 2018-10-25

    Any Help Edwin?

     
  • eschwellinger

    eschwellinger - 2018-10-26

    Hi,
    not really, sorry have no hardware(Pi with CAN) to check...

    BR
    Edwin

     
  • johnfarrugia - 2018-10-26

    Has anyone used CANbus with a pi running at something other than 250kb/s?

     
  • johnfarrugia - 2018-10-28

    So I am continue to try an trouble shoot this issue.

    I've replace the pi
    I've replaced all the MCP2515 boards
    I've tested different pi images

    All produce the same results. Using the CAN socket utility, I can send and receive packets on any CANbus baudrate. However, through codesys, I can receive CANbus packets on every baudrate but can only transmit when the CANbus baudrate is 250kb/s.

    I've used the pi CAN utility to confirm codesys is changing the CANbus baudrate using sudo ip -s -d link show can0

    Everything I do points to some issue within Codesys.

    Has anyone experienced this issue with different Canbus baud rate settings?

     
  • johnfarrugia - 2018-10-28

    So I finally figured it out!

    I was using a low level CanBus init instruction in my code that set the baudrate to 250 even though the canbus master was set at a different speed. Once I set my init instruction to 100kb/s it worked just fine.

     

Log in to post a comment.