You haven't specified requirements on which a suitable protocol is very dependant. If all 'nodes' are peers and can talk to each other you have a whole extra can of worms trying to avoid, detect, and recover from collisions.
Yeah, ive been thinking about that.
The issue of collision detection and avoidance is pushing me towards a master/slave setup.
But i can see some situations where being able to talk between nodes would be useful.
You can get much higher speeds off of a powerline than 200bit. just send the data over the line at a higher frequency at voltage zero point at about 200khz that will give you more than enough data to send. You could even use a cheap radio transmitter...
Before you go too much further with design check to see how they wired the lights, is it loop at the light or loop at the switch (if it is loop at light there will only be 2 wires at the switch) as this will change your design because you need to allow for it.
Also are you going to use switch plates with leds as indication?
Yeah, but a radio transmitter system is much more complex than UPB (universal powerline bus). Im trying to keep this nice and simple so i can build lots of small modules that can fit in the space inside powerpoints and light sockets.
200bit/s is more the minimum speed i know will work. Im pretty sure i can do 300 or 400bit/s
It's just that i've not got to the point where i can physically see just how many possible are possible before things start to fall apart.
(remembering that there are two pulses in one waveform, one in the positive and one in the negative)
4 possible positions for each pules = 2+2=4 bits/cycle = 200bit/s
8 possible positions for each pules = 3+3=6 bits/cycle = 300bit/s
16 possible positions for each pules = 4+4=8 bits/cycle = 400bits/s
Currently i've got a micro generating the pulse at a fixed location and i've confirmed with the scope that the pulse is quite visible on all powerpoints around the house.
You just have to make sure that your circuit board has no reference to neutral or to the house earth.
The part of the circuit that generates the pulse is isolated from everything else with an optotriac so the control logic and I/O is isolated from mains. Currently there is two 1Meg resistors from phase/neutral to the mcu for zero crossing detection but they can be replaced with another opto later on if needed to get complete isolation.
Interesting subject. I hope that you will open project then you have some thing that works
My first concern is 200bit that is slow for 256 ID´s
Not sure why you have room and wall id ?
Yes, opening the project is definitely something i want to do. But im a little worried about inexperienced arduino enthusiast building/playing with them. Since it will work with mains voltages and the entire circuit will be floating.
The room/wall/device id was just to try and split up a big id number into meaningful sections.
It would be easier for a device in room A to talk to another device in room A if the id number has some meaning to it.
I've seen some X10 circuits, they are a bit too big/complex for the size device i want to make.
The component count for UPB (universal powerline bus) is quite small.
I currently have it sending pulses out with just a mcu, a triac, two diodes and an opto triac + a few minor filter caps + resistors.
The way that makes coding the easiest is to escape it. That way when the code sees the end frame marker, it is always an end frame. Note that you also have to escape your escape. It makes it easier to debug if you also modify the escaped character. An example would be if we picked 0x7e as our frame marker and 0x7d as our escape character. We'll modify our escaped character by flipping bit 5, in other words 0x7d -> 0x5d and 0x7e -> 0x5e. So if a message being transmitted has 0x7e in it, it becomes 0x7d 0x5e and if it has 0x7d it becomes 0x7d 0x5d. The following message:
0x00 0x7e 0x01 0x7d 0x02
would be transmitted as:
0x00 0x7d 0x5e 0x01 0x7d 0x5d 0x02 0x7e
Obviously, you'd want to pick your end frame and escape such that they are less likely to occur in your data (if possible).
Yeah, i looked into doing escapes, maybe i didn't understand it, but it seemed that it doesn't really solve the problem, only reduce the likelihood of it happening. The escape code + start code could still happen in your data.
Seems like you can go on forever escaping escapes. hehe.
23bit. let say you can tolerate 4bit header marker (special value), 8 bit checksum, 4bit ending marker, alltogether 39bit, not a good figure, let say add 1bit to checksum (9 bit), so you have 40bits or 5 bytes of data. you may rearrange your packet to align properly into byte or nibble so easier to decode. simpler checksum you can implement odd or even parity (23bit data -> 9bit checksum = ~3bit/parity bit). if you want more bulletproof you can send 2x or 3x of the same packet to increase "integrity", but that can be a paranoia. 5bytes will take 40bits/200bps = 0.2sec, is that acceptable? my 2cnts.
0.2s delay is fine, anything quicker than maybe 0.4s id be happy with.
I'm relativity sure i can get 400bit/s out of the system. 200bit/s is really the minimum that im 99.9% sure will work.
compression is the trick to jam info in smallest bits. some algorithm are out there, or you can simply analyze your data pattern to avoid repeatability. checksum and data integrity on the other hand will make your data bigger or slower. so you have to compromise. the detail of your implementation is yours. hope this help, from software side of view.
Yeah, thanks
and lastly in case the slave device saw or expect corrupted data, you can program it to escape and re-look for another header marker, so you need to choose a really special value for the marker. ie it will not happening in other part of your data stream.
Yeah, It occurred to me last night, that since i have control over the pulses, i can just add a *special* pulse position that denotes the start /end of frame. That way it wont happen in the data at all.