> > Hello, > I am building a PIC network and i pretend to use RS485 chips. I > will use the built in UART to drive them but i need a way to detect > collisions and network idle state, what i think i should do it's when i > send a byte from the UART, or pretend to send it, i monitor the line with > another pin (neither TX or RX) looking for diferent bits. Something link > this: > > --- > | ------- Is this ok or am i forgeting something. I > Tx|----->| |-- never used RS485 chips before, they go down > | | RS485 | when more then one drive the line? > Rx|<--+--| |-- > | | ------- > |<-- > | > --- > > Antonio Almeida Antonio, This is a tough tough job. Unless you have some ultra high bandwith requirements, I'd think twice about the collision detection route. A couple of alternatives: 1) primary-secondary: The primary controller controls the bus. Secondaries can only speak when spoken to. The primary can grant the secondary the RS485 bus temporarily so that it can communicate. IEEE 488 is an example of this scheme IIRC. 2) Token passing: Formulate a logical ring where a token is passed from node to node. When a node has the token it has the bus and can send data where it wants. Once the node is finished it passes the token to the next node. 3) TDM: Time division multiplexing. Treat the line as a bus where everyone has a seat. For each frame everyone can fill their own seat with data. Requires a timer for each node so they'll know where their seat is relative to the beginning of the frame. Most collision detection schemes operate in hardware. Software solution are tough and littered with race conditions. Just my opinion. BAJ