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

Can Bus API Raspberry Pi cyclic send and receive

matthew
2021-08-29
2021-09-01
  • matthew - 2021-08-29

    Hey, I have successfully got the Can Bus API running on the Pi and can send and receive a message. I need to send multiple updates of motor position every 2ms and receive motor encoder position and velocity at the same frequency. There are also other motor stats and commands that need to be sent and received but not cyclically. Here is a reference of the Can Bus Commands https://docs.google.com/spreadsheets/d/1VWHshxOOnxZyKf5IjVzg1VQMbh7cPu5BULljX7UZJ8g/edit#gid=0

    I don't quite understand how the API works, I'm using the mask receive and set the 29bit mask of the message to be received and have the message processor FB and method to receive the data of the 29bit mask. In order to receive multiple messages do I need a new message processor FB and method for every message or is there a way to call it once and receive all messages and then filter them? Does the method have to be called from a FB or can it be called directly?

    Can I send multiple CAN messages using the CAN Sender every cycle or timer every 2ms to execute the sender? Note I have RT Kernel on the PI and can achieve 500us cycle time. But I normally run at 1ms tasks. Do I use 30x different senders with different 29bit IDs on each sender? I also have 5x times different motors to control with different node Ids. So quite a lot of messages to handle and I don't know the best way to handle this with the API. Thanks

     
  • TimvH

    TimvH - 2021-09-01

    As far as I can remember, the Message Processor is called for each message which is received which matches your filter.

    For the sending of the messages, probably you have to create different senders, because it returns true when it is sent. I'm not sure if this is set immediately or could take a cycle, but you can probably easily test this if you already have it running.

     

Log in to post a comment.