Multiple UART on AVR controller - Page 1
Forum section: electronics / projects

author: slowe
author_rank: Newbie
timestamp: July 30, 2021, 10:14:22 am
content: Hello everyone,I am carrying out a communication project, with RS232 / RS485 and USB, we come to communicate with a micro controller to turn on relays. Programming level I have no problem, and the project works. I am going to print a PCB and I would like to check that everything is fine, secure, etc ...Technical informations :- The 3 interfaces (RS232 RS485 USB) are connected to the same TX and RX of the uC, because only one means of communication is used, the other 2 are not connected. It is only to be more flexible in terms of my equipment- For RS232: only channel 1 is used, do I have to connect the pins of channel 2 of the chip to something or can I leave them floating?- For the RS485, Is it well connected?- For USB, an external power is used so I use the VUSB pin to force reset FT232RLAVR side:- I connected the TX pin of the uC to the RX pins of the interfaces via a resistor, I added a pull-up resistor, each interface will receive the info but as only one will be connected the others should not cause problems yes ?- For the RX of the uC it is connected to an AND gate. On this AND gate I have 3 inputs, these are the TX pins of the interfaces, as soon as an interface has a low level it will be transmitted. I added a pull-up resistor on each TX of the interfaces, it is good ?Precision :- I absolutely must have everything on the same UART. So no "change uC ...." please !- I am using an ATMega328pb

author: razvan784
author_rank: Regular Contributor
timestamp: July 30, 2021, 10:25:56 am
content: You seem to have Tx and Rx swapped in several places, such as the 232 and 485 chips - you have more than one logic output driving the same line.Edit: also, you forgot to add a digital output to change the direction of the 485 bus.

author: slowe
author_rank: Newbie
timestamp: July 30, 2021, 10:55:12 am
content: Exact you are right I have just reversed for the 232 and the 485, the usb is good I checked !"you have more than one logic output driving the same line." What do you mean ? If it's for the RX / TX it's done on purpose, as I explained, only one cable will be connected at a time it will be RS232 OR RS485 OR USB, never more than one at the same time , and code level, I am obliged to keep only this line there.And no, this is a MAX13487E with automatique direction bus, So normally there is no need for a pin to control this

author: voltsandjolts
author_rank: Unknown
timestamp: July 30, 2021, 12:51:54 pm
content: Hmm, Maxim. Yuk.Hmm, autodetection. Yuk.I would recommend you build in an option for a standard transciever with direction control.Always nice to have a plan B, especially with Maxim.

author: slowe
author_rank: Newbie
timestamp: July 30, 2021, 12:59:52 pm
content: very well I put my first assembly, this one, is it good level protection etc ...? What is the best ?

author: slowe
author_rank: Newbie
timestamp: July 30, 2021, 02:11:12 pm
content: UPDATE FIRST POST WITH NEW SCHEMATIC

author: razvan784
author_rank: Regular Contributor
timestamp: July 30, 2021, 07:56:35 pm
content: The SMAJ series TVSs have quite high capacitance, which is not a problem for serial lines but may cause USB communication to be unreliable or fail completely. There are low capacitance TVSs or ESD diodes that are specially designed for USB applications or for high-speed digital lines.On the DE/RE line you may want a pull-down resistor instead of a pull-up, so it defaults to disabling the 485 driver.

author: slowe
author_rank: Newbie
timestamp: August 02, 2021, 07:22:25 am
content: Quote from: razvan784 on July 30, 2021, 07:56:35 pmOk I found the TPD2EUSB30A, but it is not available on Farnell, I don't find same chip....Ok for DE/RE

author: slowe
author_rank: Newbie
timestamp: August 03, 2021, 09:13:59 am
content: And there you have it, I finished the card with a lot of advice I received!So I worked hard on the diagram for:- Have a correct power supply,- Protect RS485 / RS232 and USB- Combine the 3 interfaces on a single UARTThanks everyone!

author: Bassman59
author_rank: Super Contributor
timestamp: August 03, 2021, 06:01:50 pm
content: Quote from: voltsandjolts on July 30, 2021, 12:51:54 pmWhile everyone agrees that Maxim the company sucks balls, their various RS232 transceiver/level-shifter chips are widely second-sourced. I've used the MAX3232 from TI in a few designs.