I've been looking into working with CAN Bus. But much of what I'm finding is pretty old info. Does anyone have current experience with this? What hardware works well? Is there any library code that goes with it? Etc.
Many thanks in advance!
-jim lee
I've been looking into working with CAN Bus. But much of what I'm finding is pretty old info. Does anyone have current experience with this? What hardware works well? Is there any library code that goes with it? Etc.
Many thanks in advance!
-jim lee
Have you tried the ATMEL site? There are AVR's with CAN built in and docs for it.
CAN be an automotive standard, I would expect that it was settled solid long ago.
The most recent version is 2.0. It was publicly documented in 1991. Anything between then and now is up-to-date.
Various protocols have been published since then. But, I assume you will be rolling your own protocol.
Different transceivers have been introduced since then. But, I have only ever seen the basic two wire ones in the wild.
Anything with a Microchip bus controller and a Microchip transceiver is a good choice.
The clock is important. Make certain the vendor uses a crystal with good specifications.
I believe Atmel has some Xplained boards with a CANBUS AVR processor.
I believe the Atmel SAM processors include a CANBUS controller. I vaguely recall an effort to develop an Arduino library for the Arduino boards that use a SAM processor. Check Paul Stoffregen's website.
It's a great real-time data bus protocol. Although it has been designed for automotive industry (all cars those days will have at least one CAN Bus), it's widely used in factory automation, aircraft industry, lifts... and believe or not some coffee machines.
Physically it's a very reliable differential bus, resilient to external interference. Different from RS485 it also implements additional layers, including messga framing, CRC, retry, priorities, etc. The developer needs only to define the message ids and the content, the controller will make sure it gets delivered to the Bus and get an ack back.
Other aspect is there's no need for a master, you just publish and consume data from the Bus.
Spark fun and seeed studio both have libraries not sure if they are the same or not.
The Arduino Playground has 3 links to CAN topics/code/shield/chip.
Hutkikz:
Spark fun and seeed studio both have libraries not sure if they are the same or not.
They are both examples for CAN Bus shields with the MCP2515, which seems to be the last available SPI to CAN interface chip on the market.
There are some other shields of this type from other companies. All include the MCP2515 and a transceiver chip, which converts logic level to a differential CAN signal.
I don't know if there are Arduinos based on AVR chips with integrated CAN, like the AT90CAN, or libraries for using them from the Arduino IDE.
Arduinos with integrated CAN are the Due (two CAN interfaces) and the Teensy 3.x (one CAN on 3.2 and 3.5, two CAN on 3.6).
For both there are Arduino libraries, the one for the Teensy is included in the IDE package for the teensy.
Note that Due and Teensy still need a transceiver chip for creating the differential signal. And Due and Teensy 3.6 are not 5V tolerant and need 3.3V transceivers like SN65HVD230, or a transceiver with 3.3V and 5V inputs like MCP2562.
And Due and Teensy 3.6 are not 5V tolerant and need 3.3V transceivers like SN65HVD230, or a transceiver with 3.3V and 5V inputs like MCP2562.
Or logic leveling circuits or a chip like the 74HC4050?
GoForSmoke:
Or logic leveling circuits or a chip like the 74HC4050?
Yes, but most of this transceivers are small 8 pin ICs. A 4050 would more than double the needed size.
The only advantage of some 5V transceivers is that they are available as DIP package. The most modern types are SMD only and need a breakout board, if they are used on breadboard.
The Arduino DUE has native CAN pins. Colin, who posts here as colin80, has created a great library for that. You still need to have the transciever chip as the Due pins can't produce the differential signalling required by the CAN standard.
The Teensy series has up to two CAN buses per chip. Once again, a transciever is necessary.
ArduFE:
Yes, but most of this transceivers are small 8 pin ICs. A 4050 would more than double the needed size.The only advantage of some 5V transceivers is that they are available as DIP package. The most modern types are SMD only and need a breakout board, if they are used on breadboard.
I wasn't aware of size size restrictions, only what can and can't be done. The 4050 is smaller than any 6 voltage dividers I can make out of through-hole resistors. However note that you can put a 4050 and two 8 pin chips into a 40-pin narrow socket and still have 8 holes left over. That socket doesn't necessarily have to be mounted on a PCB.
GoForSmoke:
I wasn't aware of size size restrictions...
Some / most / all CANBUS transceivers also include amenities like short circuit protection, high voltage protection, and bus isolation.
For those interested, here's a list of CAN Transceivers that have an additional VIO so you can use it with non-5V tolerant MCUs:
| Microchip | MCP2562-I/SN |
|---|---|
| Atmel | ATA6561-GAQW |
| TI | SN65HVD256 |
| ON Semiconductor | NCV7351D13 |
I've worked with all but the TI one, they need to follow the same specs and are compatible to each other.
You basically supply 5V for the CAN_H and CAN_L lines (VIN) + the Logic level Voltage (3.3V, 2.5V, 1.8V, etc) for the TX/RX (VIO). Those transceivers can be used together with a MCP2515 running at 3.3V, to connect for example to a RPI, or directly connected to an ARM MCU which already has built-in CAN Controller(s) but is not 5V tolerant.
musskopf:
I've worked with all but the TI one,
Ah, I wasn't aware of this TI type. Collin meantions on his library page only the TI ISO1050, which has isolation between CAN and logic sides.
Another tranceiver with logic VIO is the TJA1051T/3 (or ....K/3).
But I have good results with the 3.3 V only types like SN65HVD230 or SN65HVD234, too.