> Well, I'm still working on my home automation terminal, and have come to the
> point where I need to decide on a protocol to use for talking on the rs-485
> network.
>
> Preferably, I would like it to be multi-master, half duplex and have collision
> detection. I know of only one easy method for collision detection, which is to
> send the start character first, then the priority code, MSB first. In the low
> points of the priority code, I need to check the line to see if another node is
> driving the line high, and thus has a higher priority code than me, and I cease
> transmitting.
>
> I'm using a PIC with a USART, but for this kind of prioritizing I'm assuming I
> have to bit bang at least the priority code, after which point (if I still have
> control) I can use the UART to transmit the rest of the message.
>
> ie. I have two devices that both see the line available, wait the required byte
> time to make sure it stays available, and then both start transmitting at once:
> ___________ ___
> A ___| 1 1 1 |_0_| 1 |_0___0___0__...
>
> _______ ___________ ___
> B ___| 1 1 |_0_| 1 1 1 |_0_| 1 |...
>
> The first byte is the priority code of the two devices trying to transmit.
> Device B can tell the third bit that not only is another device transmitting at
> the same time as it, but it has a higher code (since the most significant bit is
> first). Device B then never transmits the 4th bit, and instead waits for the
> other device to complete its transmission, and processes whatever it needs to
> process if the other transmission is intended for it. It then increments its
> priority code, and tries again. Device A never notices anything unusual about
> the line.
>
> The only problem is when two devices choose the same priority code. I suppose I
> could put the address of the device after the priority code, MSB first, and then
> the device with the higher address wins the conflict.
>
> I'm wondering who has dealt with this issue before, and whether I'm overlooking
> a simpler or better method of dealing with this issue.
>
> Thanks!
>
> -Adam
>
> Home Automation Terminal pictures and description (soon code and schematic) at:
>
http://ubasics.com/adam/electronics/ha/
> 15 buttons, 16x2 LCD, PIC16c66 & rs-232 (soon to be rs-485)
> All parts from Digikey or Radio Shack (ie, easily obtainable from many sources,
> if Radio Shack carries it, chances are your local electronics store carries it!)
>
> Other PIC resources:
>
http://ubasics.com/adam/pic/
>