I am planning to use this UART-to-RS485 module :- http://www.elecrow.com/uart-ttl-to-rs485-twoway-converter-p-1545.html. This module is bidirectional and uses a single pair of differential signal to transmit/receive data. My question is how is the chip deciding whether it has to transmit data from TXD to A+ B- or from A+ B- to RXD?. Shouldn't there be 2 pair of differential signals, one pair for TX and the other pair for RX? What is happening in this module??
More than likely it switches into transmit mode when TXD becomes active and a diode and capacitor "latch" that first transmit edge and hold that voltage "active" for longer than at least one byte.
I see a little surface mount diode on the PCB (D1) and quite possibly this is what I'm referring to. I have seen this trick done before and the only disadvantage is that when the TX session ends there might be a few milliseconds to wait before the RX direction is restored (due to the capacitor discharging).
I found this on the web as a partial circuit: -
When receiving, TX0 is active high thus forcing a low on DE (as expected). When TX0 goes low it rapidly discharges C0 and sets up the direction port for transmitting. When transmitting and TX data changes state, C0 remains largely discharged although ultimately R3 will slowly (relatively speaking) re-charge it but not until some time after the last transmit byte has been sent. Values shown i.e. 22k and 1000pF are dependent on baud rate.
I reverse engineered the exact board pictured in the asker's post. The resistor and capacitor values are not what are there on the board - I selected them for my own circuit. However the schematics is almost accurate - "almost" because I have added a 120 ohms impedance matching resistor and capacitors on the A+, B- lines.
Working with DineshT's circuit as a starting point, I had an EE friend of mine work from that circuit as well as a sample of one of these boards. Our boards were purchased from Drok, who is a reseller on Amazon. The primary reason for reverse engineering the boards was to ensure they were RoHS compliant. If that is not important, the Drok boards work perfectly fine. The Drok boards had atypical spacing between the pins, which for compatibility, we kept. As noted elsewhere, ground on the right side is not connect to EARTH on the right side. There is an LDO voltage regulator that allows one of these to work with 5V and 3.3V Arduino and other boards. The RS-485 chip we used is nicely speced.