UART TO RS485 CONTROL FLOW - Page 1
Forum section: electronics / projects

author: minhtrinhtu81
author_rank: Newbie
timestamp: April 16, 2025, 01:48:30 am
content: Hi everyone, I am designing an isolated USB to RS485 converter using the CH340K and ISO3082DWR as the main components.To control the Driver/Receiver, I’m using a PNP BJT that activates whenever TX starts transmitting. At that moment, the DE/RE pins are enabled by the TX signal.I would like to know if this circuit will work as intended. Can the response time of the BJT keep up with this setup? Also, is it possible to adjust the resistor values to achieve a faster response?I attached a picture below.PS: The baudrate I am trying to achieve is 115200 to 2000000

author: PCB.Wiz
author_rank: Super Contributor
timestamp: April 16, 2025, 04:57:48 am
content: Quote from: minhtrinhtu81 on April 16, 2025, 01:48:30 amYes, that is a common setup.You need to prebias the RS485 as nothing sending floats all drivers.Quote from: minhtrinhtu81 on April 16, 2025, 01:48:30 amIt is unusual to drive the base from 100r, that's a lot of base current!A little storage time is ok, as that simply drives for longer within a passive bit time. That just needs to be less than any slave turnaround time.The attached example has 10k base drive.Here are my spice notes from checking this a while ago - suggests switching PNP parts like 3906 are better. 3906+10k sims ok for 2MbdCode:BC857 10k 3k3Trelease = 1.316usTenable = 102usSST3906 10k 3k3Trelease = 390.2nsTenable = 52.9ns2SAR523EB 10k 3k3Trelease = 645nsTenable = 60.95nsDTA014TUB ROHM 10k RET PNPTrelease = 1.234usTenable = 47.4ns

author: minhtrinhtu81
author_rank: Newbie
timestamp: April 16, 2025, 07:06:03 am
content: Can I see where that document came from? I’d like a closer look, as I noticed that RS485 has an idle state, which makes driving only TX unreliable.

author: langwadt
author_rank: Super Contributor
timestamp: April 16, 2025, 09:52:59 am
content: use a CH340E instead? afaict it has a tnow pin to control a rs485 transciever

author: PGPG
author_rank: Frequent Contributor
timestamp: April 16, 2025, 10:03:50 am
content: Quote from: minhtrinhtu81 on April 16, 2025, 01:48:30 amFor me these (both) are not good solutions specially for 2000000.RS485 driver is designed to drive both states (0 nad 1) with the same 'force'. In your circuit you switch driver on only for sending 0 and when 1 is to be send you switch driver off.Driver should be switched on for the whole time byte is send, and it should be switched on prior the first start bit is send. We use RS485 since 90s and never send '1' as 'Hi-Z'.Switching driver on prior sending start bit ensures that this first slope propagates through line as all other slopes. First slope is important as receivers use it to set time moments they read consecutive bits. The higher the speed the more important it is, I think.For 115200 (we use) we switch driver on 2us before start bit is send.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: April 16, 2025, 10:25:51 am
content: Quote from: minhtrinhtu81 on April 16, 2025, 07:06:03 amIt’s from STC MCU data sheets, used on their eval boards too.There are fail safe RS485 parts that have an offset threshold, and you also bias the bus.Some designers use CAN transceivers for RS485-like networks where only RX & TX are available.

author: langwadt
author_rank: Super Contributor
timestamp: April 16, 2025, 11:55:15 am
content: Quote from: PCB.Wiz on April 16, 2025, 10:25:51 amCAN is basically "open collector" RS485

author: pqass
author_rank: Super Contributor
timestamp: April 16, 2025, 01:55:09 pm
content: I was just exploring transistor turn-off delay yesterday; to extend a clock pulse. See the attached waveforms.YELLOW is a 100KHz 5V CMOS logic-level pulse (500ns wide) into a 1.2K base resistor of a 2N3702 (PNP). (Your 100R R2 is too low. Did you mean 1K?)GREEN is on the collector. The collector resistor is 2.2K just like your R9.Turn-on delay (not shown) is <20ns and rise-time is 36ns. HOWEVER, notice the turn-off delay is >1us! This is due tostorage chargewhich can be reduced (see link). I tried a few transistors both NPN and PNP and they fall between 1-2us delay.BUT, if your intent is only to enable the transmitter on LOW bits then, as is, it won't work because @2Mbps the bit-time is 500ns and the off delay keeps the transmitter enabled for the next two bits. Even at 115.2Kbps with bit-time of 8.6us the next bit will be partially transmitted (glitch). However, adding a small cap (100pf?) across the base resistor (see link) will work to remove this off delay.If your intent is to only enable the transmitter for just the 10-bit character then you'll need a precise pulse timer (triggered on falling start bit) but then it wouldn't be able to adapt to different clock rates. Using another UART control pin is the better choice.

author: nali
author_rank: Frequent Contributor
timestamp: April 16, 2025, 02:23:51 pm
content: Even if you don't have a spare GPIO to enable the transceiver you've got the RTS line right there on the CH340 which should do the job. I think you'll need to invert it though.

author: John B
author_rank: Frequent Contributor
timestamp: April 17, 2025, 02:38:45 am
content: In cases where you don't have a microcontroller hardware method of toggling the RE/DE before sending data, a circuit I've used is an LMC555 as a resettable monostable arrangement, meaning it holds the driver enable high for around 90us after the trigger pin transitions from low to high. I was using a 115200 baud.I also used an LM393 as a crude delay, with both comparators giving around 400ns total delay. This allowed the driver pin to be enabled before data was sent.The datasheet for the 485 driver listed a setup time at worst 70ns between enabling the driver and sending data.