multi-master with CAN transceiver and UART

Thread Starter

bug13

Joined Feb 13, 2012
1,753
Hi guys

What do you think of the idea of designing a multi-master network with CAN transceiver and UART? Obviously I need to implement my own protocol.

The reason I want to use CAN over RS485 is CAN have dominant bit and recessive bit. The reason I want to implement my own protocol is that I want to be able to send more than 8 bytes of data.

Any flows with this idea??
 

Papabravo

Joined Feb 24, 2006
12,695
UARTs lack many special features of a CAN controller that makes a CAN Network robust. If you were willing to design a custom a UART in an FPGA then maybe this would be a reasonable undertaking. I think for what you are proposing the gains are small and the effort is substantial. Using a framentation protocol on a CAN network is the way to solve the problem of larger frames.
 

Sensacell

Joined Jun 19, 2012
2,518
RS-485 buses are simple, cheap and reliable.
The protocol can be very simple- but the devil is in the details.

it all depends on the speed and latency requirements.

What are you trying to build?
 

Thread Starter

bug13

Joined Feb 13, 2012
1,753
UARTs lack many special features of a CAN controller that makes a CAN Network robust. If you were willing to design a custom a UART in an FPGA then maybe this would be a reasonable undertaking. I think for what you are proposing the gains are small and the effort is substantial. Using a framentation protocol on a CAN network is the way to solve the problem of larger frames.
I understand that UART lack many special features. If we see past that, and I can implement my own protocol (I do have experience in this area), will that still be a good option regarding physical layer of the protocol?
 

nsaspook

Joined Aug 27, 2009
6,595
I understand that UART lack many special features. If we see past that, and I can implement my own protocol (I do have experience in this area), will that still be a good option regarding physical layer of the protocol?
My only question is why would you need to implement your own protocol when so many robust and proven examples exist?
 

Thread Starter

bug13

Joined Feb 13, 2012
1,753
RS-485 buses are simple, cheap and reliable.
The protocol can be very simple- but the devil is in the details.

it all depends on the speed and latency requirements.

What are you trying to build?
From what I see, CAN is cheaper (or I am looking at the wrong place). Also CAN has dominant bit and recessive bit, which make it better for multi master network.

And both RS485 and CAN in my application need to implement my own protocol anyway, I would think CAN is better because of the advantage mention above?

In my application, it doesn't need real time, and 9600bps is a lots for me.

I like to think my firmware skills are better than my hardware skills. I am more happy to let CAN deal with when more than one master driving the line high and low at the same time, rather designing hardware to tolerate this in a RS485 bus. Hope I am explaining it clear, otherwise, let me know I will explain it in another way.
 

dendad

Joined Feb 20, 2016
3,167
I'd go with RS485 myself. I reckon it is more robust and can be used over longer distances. Cheaper too.
And, as you are going to do your own protocol anyway, the bits do not matter. You write what you want.
 

Thread Starter

bug13

Joined Feb 13, 2012
1,753
I'd go with RS485 myself. I reckon it is more robust and can be used over longer distances. Cheaper too.
And, as you are going to do your own protocol anyway, the bits do not matter. You write what you want.
I thought if go with RS485, I will need to actively manage the avoidance and collision? As you really don't want to have more than one master sending 1 and 0 at the same time? And CAN deal with it already in the transceiver?

I thought both CAN and RS485 is differential and similar distances, assuming same baud rate?
 

Thread Starter

bug13

Joined Feb 13, 2012
1,753
As I understand it, the CAN network has a recommended max length of 40M where as RS485 can happily run well over 1200M.

Have you seen these, for isolated networks?
https://www.mornsun-power.com/html/product.html?gclid=EAIaIQobChMIhsuZ9tmh5QIVkRWPCh1wgg9gEAAYASABEgIuD_D_BwE
I am typing on my phone so I can’t look up the references.

CAN 40M is base on 1Mbps, rs485 1200M is only about 70Kbps.

if you look at CAN at 125Kbps, it should be about 500M. rs485 is 112Kbps for about 600M. So they are similar.
 

Papabravo

Joined Feb 24, 2006
12,695
As I understand it, the CAN network has a recommended max length of 40M where as RS485 can happily run well over 1200M.

Have you seen these, for isolated networks?
https://www.mornsun-power.com/html/product.html?gclid=EAIaIQobChMIhsuZ9tmh5QIVkRWPCh1wgg9gEAAYASABEgIuD_D_BwE
That is at 1 Mbps with no opto-isolator delay. With transceivers you can go 500M @ 125 kbps. @bug13 The problem is at the transceiver-UART interface where you need to detect another station's dominant bit over your recessive bit and abort the transmission(even in the middle of a frame), to gain any utility from multi-master mode. If you don't do this you dominant bits will bust everybody else's transmissions; everybody will have to back off, and now you have to implement something like the Ethernet backoff procedure. Do you have the design chops to do that? If you want to crack your nut on this problem then be my guest, but let me go on record as being of the opinion that it will be a complete waste of time. Use CAN with fragmentation or use RS-485, with token passing, and collision avoidance. I know we all fall in love with things we invent, but sometimes you just need to listen to good advice from those who have gone before you.
 
Last edited:

Thread Starter

bug13

Joined Feb 13, 2012
1,753
That is at 1 Mbps with no opto-isolator delay. With transceivers you can go 500M @ 125 kbps. @bug13 The problem is at the transceiver-UART interface where you need to detect another station's dominant bit over your recessive bit and abort the transmission(even in the middle of a frame), to gain any utility from multi-master mode. If you don't do this you dominant bits will bust everybody else's transmissions; everybody will have to back off, and now you have to implement something like the Ethernet backoff procedure. Do you have the design chops to do that? If you want to crack your nut on this problem then be my guest, but let me go on record as being of the opinion that it will be a complete waste of time. Use CAN with fragmentation or use RS-485, with token passing, and collision avoidance. I know we all fall in love with things we invent, but sometimes you just need to listen to good advice from those who have gone before you.
I am simply doing my research and asking for others opinions, and maybe ask some questions if I don’t understand something.

I do, however implement a few very simple multiple masters networking protocols with back off techniques similar to Ethernet.

Token passing properly not suitable for my application, as the number of nodes are unknown. Nodes can be added and removed anytime by an installer.

Any advices and suggestions are welcome! :)
 

Papabravo

Joined Feb 24, 2006
12,695
...

Token passing properly not suitable for my application, as the number of nodes are unknown. Nodes can be added and removed anytime by an installer.

...
ah...but you can develop a token passing protocol that will adapt to nodes being added and deleted, similar to the old ARCNET protocol. The number of nodes might be limited by physical layer restrictions before protocol restrictions. RS-485 is generally limited to about 32 nodes because the impedance of the cable system gets too low, so that the transmit levels have trouble exceeding the receiver thresholds on long cable systems. CAN is probably also limited to maybe 64 nodes for similar reasons having to do with the differential impedance of the CAN transceiver. More modern transceivers than the 82C251 may have improved this situation. If it makes you happier, think of a CAN controller as a UART with 64 bit (8 byte).

https://en.wikipedia.org/wiki/ARCNET
https://www.codeproject.com/Articles/1172598/My-Understanding-of-ArcNet-Protocol

It may not seem like it, but I am trying to help you.

Another indispensable feature of CAN is the Mask and Match Registers and Multiple Message Objects. I really think it will be better for you if you can do some message filtering in hardware. If your processor has to field receive interrupts for every character of every message you're going to have precious little processor time left for your application. So let us say that your UART is a fancy one with DMA capability, you still have to look at every message, EVEN the ones you don't care about.

BTW -- what data rates are we talking here?
 
Last edited:

Thread Starter

bug13

Joined Feb 13, 2012
1,753
ah...but you can develop a token passing protocol that will adapt to nodes being added and deleted, similar to the old ARCNET protocol. The number of nodes might be limited by physical layer restrictions before protocol restrictions. RS-485 is generally limited to about 32 nodes because the impedance of the cable system gets too low, so that the transmit levels have trouble exceeding the receiver thresholds on long cable systems. CAN is probably also limited to maybe 64 nodes for similar reasons having to do with the differential impedance of the CAN transceiver. More modern transceivers than the 82C251 may have improved this situation. If it makes you happier, think of a CAN controller as a UART with 64 bit (8 byte).

https://en.wikipedia.org/wiki/ARCNET
https://www.codeproject.com/Articles/1172598/My-Understanding-of-ArcNet-Protocol

It may not seem like it, but I am trying to help you.

Another indispensable feature of CAN is the Mask and Match Registers and Multiple Message Objects. I really think it will be better for you if you can do some message filtering in hardware. If your processor has to field receive interrupts for every character of every message you're going to have precious little processor time left for your application. So let us say that your UART is a fancy one with DMA capability, you still have to look at every message, EVEN the ones you don't care about.

BTW -- what data rates are we talking here?
Never aware of ARCNET, I will look into it.
8 Bytes are waaayyyyy to small, 128 bytes is better, that's why I want to look into implementing my own protocol.
9600 is fast enough for my application.
The newer RS485 chip I looked at, they usually have like 1/8 load, so in theory I can have 256 nodes for one line, hopefully they have something like this for CAN, thanks for bring this up, I almost forgot about it.
 

Papabravo

Joined Feb 24, 2006
12,695
Never aware of ARCNET, I will look into it.
8 Bytes are waaayyyyy to small, 128 bytes is better, that's why I want to look into implementing my own protocol.
9600 is fast enough for my application.
The newer RS485 chip I looked at, they usually have like 1/8 load, so in theory I can have 256 nodes for one line, hopefully they have something like this for CAN, thanks for bring this up, I almost forgot about it.
In the fragmentation protocol we used there was one overhead byte for 7 data bytes. So 256 bytes in a fragmented frame would be 36 frames of 7 data plus one overhead byte, plus one frame of 4 data bytes and one overhead byte. With today's multi object CAN controllers you can automate this process easily.

http://kom.aau.dk/~jdn/edu/doc/fieldbus/devicenet/v1Ch4.PDF
Read the section on the fragmentation of I/O messages.
 
Last edited:
Top