I need a message bus

Hi guys!

I need to comunicate several devices through a logical message bus, and I have several challenges:

  • The physical layer will be a combination of radio and wire (2 wires). Some devices can connect directly by a wire, others will not, and I am thinking about using XBee shields (ZigBee).
  • There will be several masters and several slaves.
  • The protocol must resolve collisions.
  • The communication must be safe (every message sent is received) and secure (encrypted).
  • The architecture is mesh.
  • The message structure will be "Device address + Instruction + Data" (several bytes long).

Any guidelines to help?

Thank you!

  • The protocol must resolve collisions.

A protocol is a description of intention. The description can not resolve collisions. The implementation of that description/protocol may, or may not, be able to resolve collisions. Doing so is not easy.

  • The communication must be safe (every message sent is received) and secure (encrypted).

How will you know if a message is sent? How will you ensure that a master re-sends a request that fails to get through, or that a slave re-sends a reply that fails to get through? Which node will be responsible for all the checking?

Is encryption REALLY necessary? Encryption/decryption typically requires more resources than the Arduino has. What kind of data are you sending that requires encryption? Would sending the data in binary, rather than ASCII, work?

  • The message structure will be "Device address + Instruction + Data" (several bytes long).

Source address or destination address? How will the end-of-packet be identified?

Thank you for your response!!

PaulS:

  • The protocol must resolve collisions.

A protocol is a description of intention. The description can not resolve collisions. The implementation of that description/protocol may, or may not, be able to resolve collisions. Doing so is not easy.

You are right, collisions will happen, as in Ethernet, but I need this to be transparent to upper layers... And developers. I wish I will even create a lib. :slight_smile:

PaulS:

  • The communication must be safe (every message sent is received) and secure (encrypted).

How will you know if a message is sent? How will you ensure that a master re-sends a request that fails to get through, or that a slave re-sends a reply that fails to get through? Which node will be responsible for all the checking?

I am thinking in a "Take the bus / send message / receive confirmation / release the bus" mechanism (somehow like Ethernet http://www.javvin.com/protocolEthernet.html). If receiver is dead, abort after 3 tries.
I am thinking about using NewSoftSerial as a lower layer, because of the interrupt feature, but if it is too heavy it will be necesary to adapt it or code something from scratch.

PaulS:
Is encryption REALLY necessary? Encryption/decryption typically requires more resources than the Arduino has. What kind of data are you sending that requires encryption? Would sending the data in binary, rather than ASCII, work?

No, it is not. I have already dismissed that requirement.

PaulS:

  • The message structure will be "Device address + Instruction + Data" (several bytes long).

Source address or destination address? How will the end-of-packet be identified?

[/quote]
Fixed size packets: "Dest @ + Source @ + Fixed size data" (instruction is not relevant here)

Thanks you!

(2 wires)

Two signal wires or two wires including earth return?

How fast?


Rob

Signal + return. About 100kbps would be nice.

I'm working on something at the moment but it's not that fast, needs two signal wires, and is only single master. Apart from that it's perfect :slight_smile:

100kbps on one wire, offhand I can't think of a PHY layer that will do that except of course Ethernet.

There are 1000s of proprietary protocols around maybe one of them will do this. But I assume you want to DIY or at least get something open source.


Rob

Hi Rob,
RS485 supports long lines and high baud rates in noisy environments with 2 wires. Check this out:

I have used this chip and protocol for many years and their performance is superior!

I will try to develop an Ethernet-like protocol (but simpler) on top of that phy layer.

Thanks!

BTW: "2B OR NOT 2B is not a question, it's FF"... EXCELLENT!!

Yep I know about 485, in fact that's what I'm using.

Signal + return.

I thought this meant 1 signal line.

With most 485 transceivers I don't think it's practical to detect clashes at the bit level which is a nice feature because the clash can be made non-destructive, ie the winner carries on and there's no loss of data.

I was doing bit-level detection but decided that byte-level detection was good enough, this means that by the time a clash is detected the damage is done and both transmitters will have to try again.

In my single-master protocol this is not very important, it might be for you though depending on how many masters there are and the frequency they want bus access.

What's the application?


Rob