Home automation network protacol

Discussion in 'Computing and Networks' started by Dyslexicbloke, Apr 17, 2017.

  1. Dyslexicbloke

    Thread Starter Well-Known Member

    Sep 4, 2010
    528
    34
    Folks,
    I am no network master but have a reasonable understanding of some of the basic issues and would like to find/design a network specifically for a home automation project.

    I don't want to get into hardware in this thread but it is likely going to use RS485 modules in true hardware layer so I do not want to be mucking about with colossian detection.

    Obviously I could simply go with modbus, or similar, but that by definition has a single point of failure which I would like to avoid.
    I could also use modbus and have some sort of token passing code to allow multiple masters to take control as needed that is likely to add significant overhead with respect to development.
    However in both these cases lack of a master, for whatever reason, would stop all data transfer and the master, or worse the current master, would effectively have to control everything.

    What I want to achieve, at a high level, is a multi node network in a star topology, preferably with the ability to have more than one node on a given leg.
    Each node would 'Own' one/some addresses/devices for which it alone could transmit status data. However all nodes would listen to the bus continually scanning for status changes that they may need to act on.
    A physical device could be split across nodes, perhaps with a device address common to all nodes and an address prefix per node.

    Considder a lamp dimmer, potentially with multiple points of control and/or implimentation.
    The lamp is a device on a node or nodes.
    Each input is a device on a node.
    A command, perhaps ramp to level, would be broadcast by a command device.
    Any node owning that device would excited the command and report it's status.
    Any node mapped to manage that device, other than the originator of the original command, would update its command status.

    Simple ... Alas not at all

    There needs to be a way to 'schedule' data transmissions or everything will simply try to talk simultaneously and the system will fail.
    The schedule needs to adapt to the number of nodes and devices automatically, without simply having a huge predefined address space that for the most part would be unoccupied.
    High level code will be required to decide what to do when there is a conflict of a device fails to respond.

    My gut is telling me that a command device should probably only ever issue a transient action request and that device status should be handled separately but I realise that there may be other applicable models.

    SO...
    Having said all that I Know that this simple description of what is more a wish list than a plan for a protocol is going to need some serious thought. What I am hoping is that there is some model that I am currently unaware of that will do this, the benefit being that all, and there will be many, problems will already have been considered.

    I want to implimentation the scheme using Arduino hardware but at this stage I expect that that is of little conciquence.

    Thoughts people,
    Am I missing something fundamental?
    Is there a better/different approach?
    Is there a name for a system that consists of many devices all with their own agenda sharing access to a broadcast data pool?
    Is anything commercial working this way? (I suspect that Clipsal CBus may be)

    Feel free to be frank, I am under no illusions here, just because I want this thing to be relatively simple doesn't mean that it is possible.

    Cheers,
    Al
    .
     
  2. MrChips

    Moderator

    Oct 2, 2009
    13,943
    4,033
    There already exists a home automation protocol called X10 which uses either power line or wireless transmission.

    RS-485 works well in industrial applications over medium and long distances up to 4000ft (1000m).
    RS-485 is not designed for star configuration. It is better suited for party-line networks. Nodes are connected via short stubs off the main line.

    What you are describing, a network without a master, is called peer-to-peer networking. In order to do that you will have to muck about with collision detection.

    Collision will occur. To handle collision, a node will attempt to transmit. When a collision is detected, the node will back off and re-transmit after random delay. The random delay time increases on every additional attempt. You can also incorporate a priority scheme where lower priority devices have to wait longer before additional attempts to transmit.
     
  3. wayneh

    Expert

    Sep 9, 2010
    13,200
    4,027
    If you haven't made your make-versus-buy decision, I'd recommend "buy". There are already a number of home automation schemes on the market (I use HomeKit) and these have already solved many of the problems you may not have even thought of yet. You can buy accessories that are compatible with these established protocols. If you want to make your own, there's a lot of work ahead of you.
     
  4. Dyslexicbloke

    Thread Starter Well-Known Member

    Sep 4, 2010
    528
    34
    Priorities seems like a plan but I was thinking more along the lines of some sort of stack... to schedule transmissions.
    Assuming I said I don't want you have to muck about with custom hardware, if possible, so collision detection would likely be a problem.

    I am aware of the 485 serial topology and appreciate that star is an issue because terminating, to reduce reflections, would reduce the bus impediance quickly place into a very small practical limitations on the number of nodes.

    Like it or not I may have to use some sort of hub to buffer legs even if it is essentially transparent to data.

    I initially considder a common address space where every device essentially chimed in at the appropriate time and every cycle included all possible addresses but that would be very slow or would not have much Headroom for expansion...
    It may however be possible to use the scheme to identify connected nodes and their TX data length.

    The point is I essentially want all data to be broadcast to anything that is listening. That is easy enough with a little planning regards packet construction but the key will be how a device knows when it is safe to broadcast, without some central control, a master, asking if to do so.

    I am wondering if every device could maintain a list of active devices and only broadcast when it's time slot was scheduled.
    A device quiet for a few cycles could be bumped from the list, the issue would be how to add a device, particularly if more than one was trying to join the group... Hence there thought RE fixed timeslot for device active broadcast and a broadcast schedule, containing only active devices, maintained by all devices...

    I can't help thinking that this must have been done though...

    Of course if I use a hardware layer that can detect collision's sending 'my address' first and aborting the TX when the bit I monitor isn't the bit I sent could work but I suspect there would be timing issues with many devices pulling bits down simultaneously.

    I am pretty sure my goal is valid and reasonable but I definitely don't have a handle on the methodology. (Yet)

    Al
     
  5. Dyslexicbloke

    Thread Starter Well-Known Member

    Sep 4, 2010
    528
    34
    Buy is definitely an option... I have not made any decision yet but this far I haven't found any contenders that will work with my budget.
    (Mostly because they are typically nice packages solutions.)

    I live off grid so some of my loads are DC, some of my nodes will have very specific functionality not typically found in 'standard' products.
    I would want, for example, to have my charge controller and ventilation systems talking to each other.
    Obviously this will need code specific to my application which is well beyond the scope of this question but what they say and what they do with that information is secondary the way they physically communicate.

    If there is a product that will give me low level access to an address space that exists on 'some' nodes on a network and will distribute changes made by any node to all nodes I would jump at it even at a modest cost.
    I am under no illusions here RE complexity and an off the shelf solution is attractive in many ways provided it isn't driving my system design and limiting my options.

    Al
     
  6. Dyslexicbloke

    Thread Starter Well-Known Member

    Sep 4, 2010
    528
    34
    I just looked at both Homekit and X10 neither of which are going to work for me.

    Perhaps I am making this too complicated....
    I work with PLC's for a living and I am well aware that I could, relatively easily, have a single central controller and many 'dumb' slaves that reported status and acted on commands.
    I suppose what I want to avoid is the requirement to make small changes taking client the entire system and the obvious issue of the master controller being a single point of failure.

    I could even have autonomous slaves that modified there behaviour based on a command set, which is much more robust and probably the better option but it doesn't detract from the issue that without the master everything becomes isolated...

    Just typing this I find myself wondering about a master that would only handle the network traffic and I guess could even fail over to a second master of the bus went quiet.

    Is that perhaps a better model? Everything could still listen to everything but only devices commanded to talk by the communication master would be talking...

    Al
     
  7. Dyslexicbloke

    Thread Starter Well-Known Member

    Sep 4, 2010
    528
    34
    I am pretty sure I will go with I2C, probably slightly modified to add a broadcast address.
    The standard supports multi-master and uses almost the mechanism I envisaged, at a device level to handle master conflicts.

    I am closing this thread to ask a more specific question RE signal levels.

    Thanks all...
     
Loading...