Author Topic: Multiple UART on AVR controller  (Read 1621 times)

0 Members and 1 Guest are viewing this topic.

Offline sloweTopic starter

  • Newbie
  • Posts: 6
  • Country: fr
Multiple UART on AVR controller
« on: July 30, 2021, 10:14:22 am »
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 FT232RL


AVR 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

« Last Edit: July 30, 2021, 02:10:51 pm by slowe »
 

Offline razvan784

  • Regular Contributor
  • *
  • Posts: 90
  • Country: ro
Re: Multiple UART on AVR controller
« Reply #1 on: July 30, 2021, 10:25:56 am »
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.
« Last Edit: July 30, 2021, 10:28:10 am by razvan784 »
 

Offline sloweTopic starter

  • Newbie
  • Posts: 6
  • Country: fr
Re: Multiple UART on AVR controller
« Reply #2 on: July 30, 2021, 10:55:12 am »
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
« Last Edit: July 30, 2021, 12:39:26 pm by slowe »
 

Offline voltsandjolts

  • Supporter
  • ****
  • Posts: 2300
  • Country: gb
Re: Multiple UART on AVR controller
« Reply #3 on: July 30, 2021, 12:51:54 pm »
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.
 

Offline sloweTopic starter

  • Newbie
  • Posts: 6
  • Country: fr
Re: Multiple UART on AVR controller
« Reply #4 on: July 30, 2021, 12:59:52 pm »
very well I put my first assembly, this one, is it good level protection etc ...? What is the best ?

« Last Edit: July 30, 2021, 01:50:24 pm by slowe »
 

Offline sloweTopic starter

  • Newbie
  • Posts: 6
  • Country: fr
Re: Multiple UART on AVR controller
« Reply #5 on: July 30, 2021, 02:11:12 pm »
UPDATE FIRST POST WITH NEW SCHEMATIC
 

Offline razvan784

  • Regular Contributor
  • *
  • Posts: 90
  • Country: ro
Re: Multiple UART on AVR controller
« Reply #6 on: July 30, 2021, 07:56:35 pm »
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.
 

Offline sloweTopic starter

  • Newbie
  • Posts: 6
  • Country: fr
Re: Multiple UART on AVR controller
« Reply #7 on: August 02, 2021, 07:22:25 am »
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.

Ok I found the TPD2EUSB30A, but it is not available on Farnell, I don't find same chip....

Ok for DE/RE
« Last Edit: August 02, 2021, 07:28:10 am by slowe »
 

Offline sloweTopic starter

  • Newbie
  • Posts: 6
  • Country: fr
Re: Multiple UART on AVR controller
« Reply #8 on: August 03, 2021, 09:13:59 am »
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 UART

Thanks everyone!
 

Offline Bassman59

  • Super Contributor
  • ***
  • Posts: 2501
  • Country: us
  • Yes, I do this for a living
Re: Multiple UART on AVR controller
« Reply #9 on: August 03, 2021, 06:01:50 pm »
Hmm, Maxim. Yuk.
Always nice to have a plan B, especially with Maxim.

While 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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf