Tell me more ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

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.)

share|improve this question
3  
+1 To compensate for the unfair downvote. – Telaclavo Apr 24 '12 at 9:45
1  
@Telaclavo, upvote because the question is well researched, not because someone thought it was not. – Kortuk Jun 24 '12 at 15:38

4 Answers

up vote 22 down vote accepted

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

share|improve this answer
2  
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! – efox29 Apr 24 '12 at 12:47
@efox29 - You're welcome. It's certainly better to go with transceivers if you can. – Rocketmagnet Apr 24 '12 at 15:16
That transceiverless setup was new to me and looks very interesting for setting up a simple network of controllers over longer distances. Nice! – 0x6d64 Jun 24 '12 at 13:48
@0x6d64 - If you need it long, don't forget to use a low bit rate, and slew rate limit the edges. – Rocketmagnet Jun 24 '12 at 22:55

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.

share|improve this answer
Thanks! Thats what i needed to know. – efox29 Apr 24 '12 at 12:46

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

share|improve this answer
1  
Yes. Right. OP asks about PIC18. This isn't really helpful. – Federico Russo Apr 24 '12 at 14:15
2  
@FedericoRusso he gives an example with the PIC18, and timrorr has given a solution with built-in driver. What's wrong with that? – clabacchio Apr 24 '12 at 14:18
@clabacchio: "My question is, is that uC (with built in CAN) capable of driving a CAN bus on its own". He refers clearly to the PIC18. – Federico Russo Apr 24 '12 at 14:21
@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 – clabacchio Apr 24 '12 at 14:25
2  
@FedericoRusso - Don't be so anal. This answer is very interesting. – Rocketmagnet Jun 24 '12 at 13:21
show 2 more comments

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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