EmbeddedRelated.com
Forums
Memfault Beyond the Launch

pictures of CAN communication?

Started by Mike Noone April 24, 2006
Mike Noone <nleahcim@gmail.com> wrote:

> I looked through the resistors I have on hand and they're most very > large (in the Ks) so my choices were limited. I found a stash of 80.6 > ohms that I use with LEDs, so I tried putting one of those on the > AT91SAM7X256 board. It seems to work a whole lot better, though I'm > still getting odd results that I do not understand.
Those aren't due to the resistor values. 80 Ohms is not perfect, but close enough. Your logic analyzer will quite certainly not be able to spot the the backlash from such slightly off termination, anyway.
> it repeats that message forever. If you notice the M1 to M2 length, it > seems to nearly match with the expected 500Khz frequency (1/2.086252E-6 > = 479.3Khz). I believe this is due to an aproximation I had to do due > to the odd frequency the AT91 chip is running at.
Approximation is bad news. Being off by 20/500 = 4% between CAN controllers' t_q clocks means pretty much guaranteed failure on CAN bus. Depending on your bus timing parameters, you'll want to be off by less than 1% --- and the longer the bus, the closer the match has to be. If remotely possible design all CAN t_q lengths on the bus to be the same. It can be necessary to use a separate CAN controller with its own quartz to this end, if you don't have a choice for the CPU's main clock. This really would be a good time for you to step back from the hardware for a while; sit down with the CAN spec or a CAN textbook, and learn your way through it. Don't just read it, work it. You could start with your oscilloscope trace and actually parse it by hand. Find out what each and every bit of that signal means. If you don't invest in this learning, you risk getting yourself even deeper into a situation where you're creating problems faster than you solve them. -- Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de) Even if all the snow were burnt, ashes would remain.
Roberto Waltman wrote:
> Mike Noone <mnoone.uiuc.edu@127.0.0.1> wrote: >> Roberto Waltman wrote: >>>> When don't you need a terminating resistor? >>> You always need the terminating resistors in a CAN network, not in >>> *individual* nodes. Normally they would be installed in the two nodes >>> that are farther apart, at opposite ends of a network segment. >>> >>From what you and Peter are saying - normally a CAN bus is just one long >> pair of wires with nodes along the way, and then resistors at the two ends. > > Correct. The nodes can be connected to the main trunk with stubs of no > more than few inches, so what you describe below will most likely > work. >
J1939 says the stub can be up to 1 meter. Is this true for an CAN buses? Based on my non-EE reading of that spec He could be OK with 1 resistor on each his left most and right most connector. No?
>> The way I designed it on my system, I have one primary board using an >> AT91SAM7X256, and then there are 6 connectors on this board, going to 6 >> different CAN devices. So each connector has +6V, +3.3V, GND, CANH, and >> CANL on it. Each CAN device is about 10cm away from the connector. Is there >> a good solution for this, while maintaining the individual connectors? >> Would it work for me to just add a resistor on the AT91SAM7X256 board, and >> then add a resistor on one of the 6 other boards? Alternatively, I could >> pull the CAN wires from the connectors and just run one long wire that goes >> between all 6 nodes and then to the main board. > > This will probably be better. In a system I was involved with some > time ago, the CAN bus connecting several devices was an (open) loop, > beginning and ending in the same board, with nodes "hanging" from it > at different locations. > > Remember that the purpose of the termination Rs is not just to provide > the correct impedance to avoid reflections, etc. as it seems you > believed originally. Their main function is to "pull" the voltage in > the CANH/L lines together when no node is driving them. > > The "dominant" state is CANH driven high, (obviously) CANL driven low. > The "recessive" level is both lines at the same voltage, via the > terminating resistors and all drivers in high-Z condition. > > Now going back to your setup, it may work as is, if you put a > termination resistor (1/2 the value) in the main board only. > (it may be necessary to experiment with different bit rates) > but you may run into trouble if you need in the future to add more > nodes farther away than the current ones. > > > > >> Then, it would be a clear >> call where I'd put the other terminating resistor. Would that be best?
Neil <NeilKurzm@worldnet.att.net> wrote:
> Roberto Waltman wrote:
> > Correct. The nodes can be connected to the main trunk with stubs of no > > more than few inches, so what you describe below will most likely > > work. > > > J1939 says the stub can be up to 1 meter. Is this true for an CAN buses?
I'll assume you meant "for all CAN buses"... Not really. J1939 is not about all CAN buses, but only about those up to 250 kb/s. For faster buses, 1 meter stubs would be trouble, especially if they're really just that: stubs, cables directly coupled the bus line, without any impedance compensation. It's called CAN "bus", as opposed to a ring, star, tree or network, for a reason. Cabling it otherwise is possible, but you have to be quite careful to avoid nasty problems with signal reflections at the T joints.
> Based on my non-EE reading of that spec He could be OK with 1 resistor > on each his left most and right most connector. No?
Probably. His bus is so short that at 500 kb/s he may even get away with using only *one* terminator, anywhere on the bus. That's because his entire bus cabling combined appears to be shorter than 1 meter. -- Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de) Even if all the snow were burnt, ashes would remain.
Hans-Bernhard Broeker wrote:
> Neil <NeilKurzm@worldnet.att.net> wrote: >> Roberto Waltman wrote: > >>> Correct. The nodes can be connected to the main trunk with stubs of no >>> more than few inches, so what you describe below will most likely >>> work. >>> >> J1939 says the stub can be up to 1 meter. Is this true for an CAN buses? > > I'll assume you meant "for all CAN buses"... > > Not really. J1939 is not about all CAN buses, but only about those up > to 250 kb/s. For faster buses, 1 meter stubs would be trouble, > especially if they're really just that: stubs, cables directly coupled > the bus line, without any impedance compensation. > > It's called CAN "bus", as opposed to a ring, star, tree or network, > for a reason. Cabling it otherwise is possible, but you have to be > quite careful to avoid nasty problems with signal reflections at the T > joints. > >> Based on my non-EE reading of that spec He could be OK with 1 resistor >> on each his left most and right most connector. No? > > Probably. His bus is so short that at 500 kb/s he may even get away > with using only *one* terminator, anywhere on the bus. That's because > his entire bus cabling combined appears to be shorter than 1 meter. > >
Thanks. After my current project my 1st J1939 is next. I hope I have picked up enough here to avoid the easy mistakes.
http://forum.microchip.com/tm.aspx?m=156898



http://forum.microchip.com/upfiles.aspx/14132/7D0C88B65D2D4772896FB4BB1A8D8153.JPG




Memfault Beyond the Launch