10
\$\begingroup\$

I am planning on using CAN bus in an industrial automation application, however I'm having a hard time deciding how to implement the network layer. Does anyone here have any recommendations for a higher layer protocol to use over CAN that provides guidelines for how to assign message IDs and how to format data packets? Should I develop my own proprietary network layer or implement an existing standard like CANopen?

\$\endgroup\$
7
\$\begingroup\$

You will definitely want to choose a standard network layer. I've seen some cases where people have rolled their own, and frequently the protocol is inefficient, and in the end it's a waste of time. A proven network layer provides basic functionality to solve most of the problems you'll likely face in networking with an embedded device, and that will save you precious time and money in the end.

I have familiarity with CANopen, so I'll put a bit of an explanation in here and it might help you decide if that's the way you want to go. If it doesn't fit what you need to do, I'd look at something else.

CANopen is very data centric. All CANopen slave nodes (things you control from a master node, like sensors or motor drivers) provide a dictionary that contains all configuration, control and data-acquisition data you need to read/write to get your job done. You can then read/write these objects individually via the SDO (service data object) mechanism, or read/write these objects periodically in timed CAN message transmissions via the PDO (producer data object) mechanism. Startup, shutdown, and reset, and heartbeat/node-malfunction detection are provided from NMT services, as well as a node ID assignment service (if you wish to use it). To implement a device using an embedded CANOpen library, you basically setup an object dictionary, setup PDOs to periodically send/receive data updates, and write user code that behaves based on those data entries. There are other things CANopen provides, but that is the bulk of it. Read this book for more info.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ The book talks about an implementation of CANopen called MicroCANopen. What implementation of CANopen do you use? \$\endgroup\$ – mjh2007 Oct 1 '10 at 18:31
  • 1
    \$\begingroup\$ @mjh2007 - We rolled our own, since it needed to be used in conjunction with another protocol. \$\endgroup\$ – J. Polfer Oct 1 '10 at 21:58
  • \$\begingroup\$ "CANOpen" -> "CANopen" \$\endgroup\$ – Peter Mortensen Sep 23 '12 at 22:07
7
\$\begingroup\$

I write code to access the CAN bus on GM cars, which uses a mostly proprietary network layer. Have you looked into OpenCAN? I would choose an open standard such as CANOpen or even OpenCAN. It really depends on the level of control and flexibility you want in your automation environment.

| improve this answer | |
\$\endgroup\$
  • 8
    \$\begingroup\$ there's an OpenCAN as well as CANOpen? aiggh! horrid naming. \$\endgroup\$ – Jason S Oct 2 '10 at 2:17
  • 1
    \$\begingroup\$ @Jason, I blame microsoft. \$\endgroup\$ – Kortuk Oct 2 '10 at 14:35
5
\$\begingroup\$

There have been great answers. I do not know what micro you use, but here are links to some info from microchip.

J1939 library

DeviceNet™ Group 2 Slave Firmware for PIC18 with CAN

CANopen

They each have code and a basic datasheet letting you know what you need to implement them.

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ Actually I use Microchip so that's very helpful. Thanks! \$\endgroup\$ – mjh2007 Oct 4 '10 at 12:29
  • 1
    \$\begingroup\$ Those are all for the pic18. It seems with CANopen you have a master that modifies settings on the others, for most of what my use of canbus includes, this fits perfectly. \$\endgroup\$ – Kortuk Oct 4 '10 at 14:13
  • \$\begingroup\$ Do you use the Microchip library to implement CANopen? \$\endgroup\$ – mjh2007 Oct 4 '10 at 19:43
  • 1
    \$\begingroup\$ In the process of implementing it, it is a slow process because it requires many different people to commit for me to make a system change. I will update you when it is implemented if that will help. \$\endgroup\$ – Kortuk Oct 4 '10 at 20:48
  • 1
    \$\begingroup\$ @mjh2007, I stopped working for the processor and the students taking over decided as many had before not to use the previous hardware and purchase something they were more comfortable with. Yet again no progress on that professors project, but that happens when a professor does not know what is going on and just lets people change everything once a year. \$\endgroup\$ – Kortuk Jan 11 '12 at 15:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.