Hot answers tagged

55

This is a very good question. As a general rule, CAN requires a transceiver for every node: 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 ...


26

You need to be familiar with Transmission Line Theory to understand the deeper physics in play here. That said, here's the high-level overview: How important termination is to your system is almost exclusively determined by how long the bus wires are. Here length is determined in terms of wavelengths. If your bus is shorter than one wavelength over 10, the ...


20

From Controller Area Network Physical Layer Requirements CAN is an open collector technology – the protocol could not work otherwise. This means that the recessive state of a CAN transceiver is not actively driven. The termination resistors together with transceiver input capacitance and cable capacitance create an RC time-constant discharge when an ...


19

The CAN pins do not have fixed pin assignments. Instead you are able to select which of the "Remappable Pins" you wish to use (RP0 through RP15). If you refer to page 180 of the datasheet, specifically the table titled "REGISTER 11-16" (RPINR26: Peripheral Pin Select Input Register 26), it details the register used to select the CAN RX pin location (C1RXR). ...


18

That type of CAN bus is intended to implemented by a twisted pair of wires. The transmission line impedance of unspecified twisted pair isn't exact, but 120 Ω is going to be close most of the time for the relatively large wires commonly used for CAN. The resistors also have another function in CAN. You can think of CAN as a open collector bus ...


17

Per Olin Lathrop's suggestion, I'll expand on bit-stuffing. CAN uses NRZ coding, and is therefor not happy with long runs of ones or zeroes (It loses track of where the clock edges ought to be). It solves this potential problem by bit-stuffing. When transmitting, if it encounters a run of 5 successive ones or zeros it inserts a bit of the other polarity, ...


17

If there is no ISR defined, the location for the jump instruction in the interrupt vector will either be null, it may be a jump to an exception routine, it may jump to the beginning of the program, or it may contain a "return from interrupt" (e.g. RTI) instruction. Here is a disassembly of an interrupt table for an ATMega 16 processor showing three unused ...


17

No. The differential signalling is performing as intended. No. As long as the "common mode voltage" does not exceed the ratings of the transceiver. And the maximum DC ratings, which for a CAN transceiver like the MCP2551 is -42 V to +42 V. The twisted pair cable and the differential signalling mode make the single-end signals look like gibberish ...


16

Clearing up some misunderstandings will probably help. First, your data is a 16-bit value. There's no "overflows" and "actual data" -- the 16 bits are just divided into two 8-bit pieces (bytes). To get the right binary value, you need to concatenate the bytes. In C, you can do it by starting with unsigned values and using bitwise operators, like this: ...


15

It's included in the cost of the parts. It's a lot easier to collect money from a few IC makers than from every person who makes a product using those parts.


15

The shortest CAN frame is 55 bit times, so in the very worst case situation with a completely saturated bus consisting of one data byte frames (which is not really realistic for a CAN bus with any sort of useful performance) you will be receiving a frame every 220 µS (55 / 250000). The cheapest ST microcontroller that has a CAN controller is the ...


14

You can do that, but what you'll get on your CAN bus will be UART using CAN voltage levels. You have to supply the MCP2551 with CAN protocol messages if you want to communicate with CAN devices on your bus. Same for listening: CAN messages are so different from the UART format that the UART won't know what to do with them. You'll have at least frame errors ...


13

Do some time domain reflectometry, a useful video to this process is probably one from w2aew. He shows it with a coax, but it should work with anything that has a somewhat consistent impedance. In short: Inject a pulse with a short risetime into the cable terminate the cable with a potentiometer that has the range of suspected impedance (like 200Ω) Watch ...


12

I couldn't find any reference that gave a definitive answer. But looking at a few datasheets, I don't think so. USB is looking at the presence or absence of a change in voltage. Whereas CANBus is looking at the voltage itself. Here is an example of a USB transmission: The ones and zeros are coded depending on whether or not there is a transition. As ...


12

Dominant is 0. Recessive is 1. Dominant applies to 0 because if two arbitration ID's are being transmitted at the same time and the first 4 bits are the same and the fifth is 0 for one of them and 1 for the other, the ID with the 0 will end up being transmitted. Transmission of the message with the larger arbitration ID will be tried again after the other ...


12

Each beginning has its end. This can't be answered, because the question is not correct. What you have is the transmission line - a twisted pair that has two ends, and that's the place where the termination has to be done. You can't choose the end of the bus, since there are only two of them.


11

I think implementing the CAN protocol in firmware only will be difficult and will take a while to get right. It is not a good idea. However, your prices are high. I just checked, and a dsPIC 33FJ64GP802 in QFN package sells for 3.68 USD on microchipdirect for 1000 pieces. The price will be lower for real production volumes. The hardware CAN peripheral ...


11

Section 6.1 of the CAN spec: BIT ERROR: A unit that is sending a bit on the bus also monitors the bus. A BIT ERROR has to be detected at that bit time, when the bit value that is monitored is different from the bit value that is sent. An exception is the sending of a ’recessive’ bit during the stuffed bit stream of the ARBITRATION FIELD or ...


11

If you are using a third-party CAN controller chip, then they will have paid the licensing fee. The original patents related to the way the controller worked, so the vendor requires a license in order to sell a controller chip without infringing the patents. However, the original CAN 2.0 specification was published in 1991, so the patents (sorry I can't ...


11

It doesn't matter which nodes are at the ends, but it does matter that the terminators are at each end. The bus is a transmission line. To keep edges from reflecting at the ends of the cable, the cable has to be terminated with its characteristic impedance. The common standard for CAN is twisted pair with 120 Ω impedance. You therefore need 120 &...


10

Turns out the answer should have been obvious from the waveforms above. When TX goes low, so does RX. But when TX goes high, RX takes more than 1us to rise again. That's more than a whole bit time! CAN cannot work under these conditions. The reason RX lags behind TX would have been obvious with a proper oscilloscope, rather than a simple logic analyser. ...


10

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


10

A CAN bus is multi-master and automatically arbitration free. The whole point is that you don't need a single master or main controller to take care of everything. Each message that is sent has a priority, and higher priority messages trump lower priority ones (a lower priority message will wait until there isn't a high priority message being sent). So there ...


10

In addition to the perfectly accurate answer given elsewhere, it may also be useful to consider the lower level meanings of the phrases dominant and recessive. In both CAN and LIN at the physical layer the bus "floats" to a particular state when no nodes are communicating. This is the recessive state. Any node which drives a dominant bit will override this ...


10

From a professional point of view, this is a critical problem. Missing termination will cause energy bouncing back at the end which isn't terminated. This could lead to strange random noise on the line, such as for example transients or random pulses that seem like ok binary pulses, but with wrong voltage levels etc. CAN Hi and Lo don't necessarily behave ...


9

You "read on a forum" somewhere that the CAN bus needs resistors? Seriously!!? This is a integral part of your design. If you are going to use CAN, you need to understand it, which means reading the relevant documentation. Spearson is right but for the wrong reason. A differential CAN bus as you likely have (you didn't say what interface chip you are ...


9

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


9

You don't need int to store those values - a simple int8_t will do. int8_t can store from -128 to +127. Then just place int8_t A in data[0], int8_t B in data[1] (cast them to uint8_t) and set the length to 2. Read them from there at the other end as uint8_t (cast them to int8_t), and Robert's your mother's brother. You don't even need to restrict it to ...


9

CAN does not have a formalized physical-layer specification for conductor colors, or things like connector type or pin-out. There are common practices (like using a 9-pin D-sub connector) but no official standard. Vehicles these days also tend to have multiple CAN buses, so colors will, of course, vary to keep the different buses straight. I have seen ...


Only top voted, non community-wiki answers of a minimum length are eligible