Dorin Dogaroiu wrote: > >I am thinking of using RS-485 for hooking together some home automation > >bits which all can Tx & Rx. The Rx bit is easy but what if two or more > >devices try to Tx at the same time ? Collission detection is obviously > >required but am unsure of how to implement it on serial line. There will > >be no "master" in the system so a polling arangement is out. I did have > Speaking about RS485, I dont't know how you detect the colosion ( multyple > active transmitters )> You can try for example to receive the transmitted > data at the transmitting station and check it to see if it was transmitted > correctly . If you're communication is half-duplex (which I guess is almost always the case when there are more than two nodes present), then you can use the Rx/Tx line for both communications and for arbitration. I can't go into details, but the gist of the idea is: 1) Talking node transmits its message. 2) At the end of the message the talking node switches control from the UART to a general purpose I/O. 3) After keeping the comm line at the same level as the stop bit for some predefined time, the talker can initiate an arbitration state by driving the line low. Then the talker can tri-state the comm driver and allow passive termination resistances to maintain the state of the comm line. 4) The listeners catch the transition marking the beginning of the arbitration. 5) Now the tricky part: Fight for the bus. There are a number of ways to do this. Probably the simplest is to pre-assign a time slot in which a device may drive the comm line. If a node has a message to transmit, then it will drive the comm bus during its time slot. Higher priority nodes can be given time slots closer to the start of the arbitration edge. The first node to drive the bus wins. If no node wishes to talk, then the last talking node can win the bus by default and send some sort of sustaining message to keep the bus alive. If you make the inactive period of the arbitration interval greater than one byte time, then it is very easy for unsynchronized nodes to hop on the bus. This whole scheme only works if your 485 driver is a bidirectional one like the LTC485, DS3695 or the infinite other equivalent pin outs. There is a control pin on this device that can disable the transmitter. Suffice it to say that I have proof that this scheme works for RS485 (or is EIA485 now?) when the baud rate is 38.4k and the distances are a half of a kilometer (I didn't have enough wire to test longer distances - although a fiber optic link into the network did increase the lenght to over a kilometer). Scott -- __o I buy pizza instead of gas. \< (*)/(*)