How to program a simple CANopen layer

前端 未结 7 577
离开以前
离开以前 2020-12-25 15:08

We have a robot project where the motor controllers use CANopen for communication. I need to communicate with these motor controllers using a master microcontroller. The pro

7条回答
  •  暖寄归人
    2020-12-25 16:05

    Since this seems to be a topic of general interest - I agree that understanding the full original specs can be a somewhat painful experience. So here is a suggestion for "get your drive going", as opposed to "implementing the whole thing":

    • Check if your CANopen drives can be operated via the CiA 402 standard objects and for performance reasons it would be perfectly fine to NOT configure and use PDOs, and you don't really need heartbeat, a.s.o. It's usually switching the drive's state machine (object 6040h, control word), setting operation mode (object 6060h), and setting additional parameters like "profile position velocity".

    • Then implement expedited SDO transfers only. (See http://en.wikipedia.org/wiki/CANopen.) SDO download is for writing/changing an object in your drive. SDO upload is for reading an object.

    • I suggest to take a PC software that can read and write SDOs and has a CAN Bus Monitor. (Our Kickdrive Zero freeware can do that, but really, any other PC tool for CANopen should work.) Do some example reads and writes for the data types and objects you need. Look how this translates into frames on a CAN level. For basic integer data types, it's always just one frame for the request, one for the answer.

    • Now build a simplistic protocol stack on your microcontroller that can send the SDO download/upload requests and process the answers.

    Disclaimer - the above is not even close to "implementing CANopen", or "supporting CANopen", or even "CANopen compliant". It's about "make your drive move ASAP and without third-party code". Which is sometimes the right thing to do.

提交回复
热议问题