Introduction into RS-485 and CAN Bus
After playing with micro controllers for a bit it gets clear that at some stage you want to control things at a distance. Doing this can very quickly get complicated and expensive. For the particular projects I wanted to control wireless was not an option as it was too expensive per node and the environments were too noisy for wireless(lots of electronic interference).
The first option I looked at was RS-485. RS-482 is a very useful standard for communicating over long distances. It does however have a few limitations.
RS-485 Limitations:
- It’s not full-duplex out of the box. It usually works on the master/slave principle where the master drives the requests and the slaves listen and only reacts when called upon.
- Fault correction is done in software, taking valuable processing cycles.
- No Collision detection, hence the reason for having a master at all times. (Preventing nodes from talking out-of-order.)
The other option I looked at was Cab-Bus. Can Bus was originally designed for use in automobiles, its benefits was that it reduced the weight of cars by getting rid of parallel lines of cables linking each part of the car. It stands for Controller Area Network and solves most of the problems RS-485 has. It has Fault/Collision detection and can handle multiple devices talking at the same time. RS-485 only works on the Physical layer where CAN works on both the physical and data layer of the OSI model removing load from the micro controller.
For more details on comparing the two standards I recommend the following white paper on the topic: artikel_20105_can-vs-rs485_e
CAN bus can be a little slower and more expensive but it offers a more robust solution that does not take valuable processing cycles from small micro controllers.
Lets get to business
So I decided to give CAN bus a go and started looking online for options. I found a few CAN shields online but they all seemed very expensive and also realized I needed at least two units to make it viable.
Most of the designs included two main components:
- MCP2551 Datasheet – This handles the physical layer connecting to the medium that will carry the signals.
- MCP2515 Datasheet – This handles the Data layer and connects to the MCP2551 and a micro controller via SPI.
Based on the above layout I designed my own little CAN bus breakout board and it works really well.
Features of my design:
- Its Arduino Compatible and plugs straight into the SPI pins.
- It uses RJ45 connectors making it easy to recycle old network cables. It also has screw terminals for use with any available cables.
- External Power Input/Output. This neat option makes it easy to power controllers on the other end of the cable. Same idea as Power Over Ethernet.
- Two of these little boards are about the same price as a single Arduino CAN Bus shield.
Example Code:
Seeed Studio has created a nice library that is compatible with this breakout : https://github.com/Seeed-Studio/CAN_BUS_Shield
Very interesting again!
Hi,
Are you willing to open source the design files? (Eagle I hope) because I’d like to modify slightly to remove ethernet cable support and include headers for a Nano and use in a marine application for my boat.
Hi Pete,
Go for it. I use Kicad and can go and lookup the design files if you want. http://blog.protoneer.co.nz/wp-content/uploads/2014/03/CanBusBreakout.jpg its actually a very simple design and will be easy to convert to a Nano sheild.
Thanks for the jpg, I’ll keep in touch