53
\$\begingroup\$

There are a number of CAN modules built into microcontrollers these days. The PIC18F2480 is an example of that. Is that microcontroller (with built-in CAN) capable of driving a CAN bus on its own or is an external CAN transceiver/controller required?

I believe CAN has both a software and hardware layer and by the looks of it these CAN-enabled microcontrollers appear to have just the software, but it does not state that it can or cannot drive the CAN bus as is.

I'm looking to connect more than six microcontrollers through a CAN bus and would like to know if I need a transceiver across all of them or whether the built-in stuff can handle the communication from a software and hardware perspective.

Assume that I'll have necessary termination resistors and other small discrete components (caps, resistors, etc.)

\$\endgroup\$
0

5 Answers 5

77
\$\begingroup\$

This is a very good question. As a general rule, CAN requires a transceiver for every node:

enter image description here

However, under certain circumstances, you can actually get away without any transceivers! Those circumstances are:

  • Short bus length (much less than 1 meter)
  • Preferably all microcontrollers are on the same PCB, or stack of PCBs.
  • The bit rate is low
  • The environment isn't too electrically noisy

These aren't hard rules. You might get away with maximum bit rate (1MB/s) if you have a really short bus (10cm).

To achieve this, you need to know a little about what the transceiver does. Like most transceivers, they can output a high or a low to the bus (representing 1 and 0), but the 0 can dominate a 1. I.E. If two transceivers try to speak at the same time, and one is saying 1 and the other is saying 0, then the 0 will win. We can re-create the same situation simply using diodes:

Simple CAN

See the Seimens application note AP2921: On-Board Communication via CAN without Transceiver

But here's something even more interesting: The PIC actually has hardware support for transceiverless CAN!

CIOCON Register

You can configure the CAN TX pin so that is behaves in exactly the same way as the transceiver. This means you can wire up the CAN bus without the diodes. You'll still need the resistor though.

Simpler CAN

\$\endgroup\$
6
  • 2
    \$\begingroup\$ Absolutely fantastic reply. I greatly appreciate the time you took to reply. I might have to go with the transceiver because there might be alot of electrical noise, and though everything will be housed in a "box" they will be on multiple pcbs. Thanks again! \$\endgroup\$
    – efox29
    Commented Apr 24, 2012 at 12:47
  • \$\begingroup\$ @efox29 - You're welcome. It's certainly better to go with transceivers if you can. \$\endgroup\$ Commented Apr 24, 2012 at 15:16
  • \$\begingroup\$ That transceiverless setup was new to me and looks very interesting for setting up a simple network of controllers over longer distances. Nice! \$\endgroup\$
    – 0x6d64
    Commented Jun 24, 2012 at 13:48
  • 1
    \$\begingroup\$ If I understand correctly, it looks like the PIC's "pin will be tri-state when recessive" setting is equivalent to an open-drain configuration. This might work on other microcontrollers (like an STM32) if the CAN TX pin is configured as open-drain rather than push-pull. Like the PIC, no diodes required. \$\endgroup\$
    – JimFred
    Commented Jun 29, 2015 at 20:15
  • 3
    \$\begingroup\$ Note that this will work if all the devices on the bus use the same configuration, and use a single-wire CAN bus. If you want to interface with anything else that is actually "real" ISO CAN and uses a two-wire bus, this mode won't work. \$\endgroup\$
    – Jon Watte
    Commented Jul 22, 2017 at 5:40
14
\$\begingroup\$

The LPC11Cxx family of microcontrollers (ARM Cortex-M0 based) include the CAN transceiver on-chip.

\$\endgroup\$
7
  • 3
    \$\begingroup\$ Yes. Right. OP asks about PIC18. This isn't really helpful. \$\endgroup\$ Commented Apr 24, 2012 at 14:15
  • 8
    \$\begingroup\$ @FedericoRusso he gives an example with the PIC18, and timrorr has given a solution with built-in driver. What's wrong with that? \$\endgroup\$
    – clabacchio
    Commented Apr 24, 2012 at 14:18
  • 3
    \$\begingroup\$ @FedericoRusso you're right, but before he says that the PIC is an example; an alternative solution, even if may not be a direct answer, can solve his problem, and I leave the decision to the OP, as I think it's useful to know that some uC have this feature \$\endgroup\$
    – clabacchio
    Commented Apr 24, 2012 at 14:25
  • 10
    \$\begingroup\$ @FedericoRusso - Don't be so anal. This answer is very interesting. \$\endgroup\$ Commented Jun 24, 2012 at 13:21
  • 2
    \$\begingroup\$ @FedericoRusso - If the question has been well answered to the OP's satisfaction, and someone mentions some interesting related information, sure, why not? \$\endgroup\$ Commented Jun 24, 2012 at 15:46
11
\$\begingroup\$

You need a CAN transceiver chip between the CPU and the CAN bus. Check out the MCP2551.

Update 17 Aug 2017:

I'm at the Microchip Masters conference right now. I was told flat out by Microchip engineers that one of the new parts that resulted from the Atmel acquisition is both cheaper and better than the MCP2551.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Microchip is recommending the 2561 over the 2551 now. NXP has also some interesting CAN chips. Most MCUs need a transceiver. \$\endgroup\$
    – user106330
    Commented Dec 16, 2016 at 22:16
  • \$\begingroup\$ Also consider the MCP2562 which is has a Vio pin for 3.3V / 1.8V \$\endgroup\$
    – theGtknerd
    Commented Mar 17, 2021 at 15:33
9
\$\begingroup\$

Yes, you need a tranceiver. The CAN pins on the micro are receive and transmit. The CAN bus itself uses a twisted-pair with differential signalling on two wires called HIGH and LOW.

One of the transceiver's jobs is to take the logic level you present on the TX pin an turn it into CAN bus signals:

  • a logic '1' is represented by not driving the bus, so the HIGH and LOW lines "float" to 2.5V - called a "recessive bit" in CAN terminology.
  • a logic '0' is represented by driving the HIGH line high and the LOW line low - called a "dominant bit" as it will override any recessive bits being transmitted.

The other is to take what is on the bus, and turn it back into a logic-level to send back from the RX pin to your micro.

\$\endgroup\$
0
5
\$\begingroup\$

Analog devices has an example CAN transceiver circuit using a differential amplifier.
I haven't tried this, am just aware of it. Also interested if it could be implemented with an op-amp

analog's circuit

The advantages of using dedicated IC CAN transceiver is they will handle arbitration for you and you don't have to worry about interfering with the bus. If you are only observing the bus and it's not a fault critical environment, the circuit may be fine. While the mcp2551 is very popular, there are many options for interface chips.

A new evolution are the System Base type of chips which include voltage regulation, power modes, and ESD protection from the bus.

Like timorr said above, NXP's LCP11C24 is unique in that the processor includes CAN transceiver. A demo board with this is only $19. Another low cost solution is to use the $9.38 Cypress PSoC5 demo board, the CY8CKIT-059. The PSoC5 doesn't have a CAN controller; it goes one further: the controller is implemented in the FPGA-like universal blocks. The controller's registers are configured via the IDE's GUI, making filtering and R&D pretty easy.

A key method I have found when perusing data sheets is the mcu TTL is labeled CAN-Tx and CAN-Rx while the transceivers' data lines to the bus are always labelled CAN-H and CAN-L. I dislike the diagrams in the other answer where TxRx are shown connected to the bus; this goes against convention and contributes to confusion.

\$\endgroup\$

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