> > On Fri, 13 Aug 1999, Byron A Jeff wrote: > > > > On Thu, 12 Aug 1999, Byron A Jeff wrote: > > > > > > > > > > > > > How about CSMA/CD? > > > > > > > > It's not clear if the physical layer of RS-485 allows for multiple trans mitters > > > > or what happens if multiple transmitters transmit different bits. > > > > > > If you are doing half-duplex RS-485, you just tie the UART tx line > > > (inverted) to the RS-485 driver's R/W pin and tie the tx pin on the driver > > > to ground. That way, the driver will only transmit when it wants to send a > > > 0. A collision is defined when one transmitter is sending a 0 and another > > > transmitter wants the line to be floating (i.e. it is sending a 1). There > > > is an appnote on this somewhere (National Semi i think). Collisions can be > > > detected in hardware with by: UART framing error, UART missing stop bit, > > > UART parity error or in SW with CRC errors in the frames. > > > > Wire-OR. That's an interesting idea. I'd be interested in the latency betwee n > > my scheme and true collisions. > > That's what I (almost) did. In my case, the physical layer also performed > arbitration (some of the datalink layer trickled down). After the last > byte of a message was transmitted, the active master would enter an > arbitration mode. This consisted of extending the stop bit for a > pre-defined interval and then asserting an 'arbitration edge'. All > potential masters monitored this edge with a hardware input-capture pin. > After the edge was initiated, the active master would relinquish control > by tri-stating its transmitter. The RS-485 termination resistors, which > are necessary for reliable long-distance communications, were configured > such that they would also passively maintain the DC level of the RS-485 > differential pair in the 'active low' state or the state to which the > arbitration edge drove the bus. > > Now each master was preassigned an ID. This ID was used to determine an > 'arbitration slot' or a time period that the masters would wait after the > arbitration edge to attempt arbitration. An output compare module was > programmed to generate the "I want the bus" edge. Finally, a master > ascertained whether it had won arbitration by comparing when it sent the > bus request to when the bus really went active. If the bus went active due > to his request, then he was the winner. If the bus went active before his > request then another master won. > > The comm rate was 38.4k baud, the arbitration slots were about 20uS, there > were upto 32 nodes. This schem worked reliably for more than 300 meters of > copper and 1500 meters of fiber. If it weren't for propogation delays > through opto-couplers (the RS485 bus was optically isolated) the distances > could be extended even more... Scott, I'm unclear on one thing. This seems to be almost the same scheme I came up with originally (which makes me happy because now I know it'll work). But how do the UARTS react to channel activity? Also how did you prevent starvation? It seems the lower ID'ed masters could swamp the channel. That's why I went to a primary/secondary ID where after successfull transmission a station went to its secondary ID until either it got the slot or until no other primaries wanted to transmit. BAJ >