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\$

3 Answers 3

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.

\$\endgroup\$
3
  • \$\begingroup\$ The book talks about an implementation of CANopen called MicroCANopen. What implementation of CANopen do you use? \$\endgroup\$
    – mjh2007
    Commented Oct 1, 2010 at 18:31
  • 1
    \$\begingroup\$ @mjh2007 - We rolled our own, since it needed to be used in conjunction with another protocol. \$\endgroup\$
    – J. Polfer
    Commented Oct 1, 2010 at 21:58
  • \$\begingroup\$ "CANOpen" -> "CANopen" \$\endgroup\$ Commented Sep 23, 2012 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.

\$\endgroup\$
2
  • 8
    \$\begingroup\$ there's an OpenCAN as well as CANOpen? aiggh! horrid naming. \$\endgroup\$
    – Jason S
    Commented Oct 2, 2010 at 2:17
  • 1
    \$\begingroup\$ @Jason, I blame microsoft. \$\endgroup\$
    – Kortuk
    Commented Oct 2, 2010 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.

\$\endgroup\$
5
  • 1
    \$\begingroup\$ Actually I use Microchip so that's very helpful. Thanks! \$\endgroup\$
    – mjh2007
    Commented Oct 4, 2010 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
    Commented Oct 4, 2010 at 14:13
  • \$\begingroup\$ Do you use the Microchip library to implement CANopen? \$\endgroup\$
    – mjh2007
    Commented Oct 4, 2010 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
    Commented Oct 4, 2010 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
    Commented Jan 11, 2012 at 15:34

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