UART Multiplexer with FIFO Buffer

Hi
I would like to make a UART Multiplexer where u use one pin to connect to various devices
I tend to use CD4052(Dual 4-Channel) for this but....

when a channel is already in use and other channel tends to send message it just leaves it out.
I would like to have a way to add a FIFO buffer to store the data and give it out on the specific channel active.
The data sent is not more than 48 bytes.

So main question is how to add a FIFO Buffer (any specific IC or any other way of storing) and how to check if data is present in buffer and send it out on command.

And the Hardware i would like to use is Arduino Uno(or Leonardo for testing) and Upgrade to a bit powerful one for later on developments

Use a Mega. It has 4 serial channels.
Buffing serial can be done by using shift registers being 48 bits deap or more if You can find such. Cascading less deap registers is possible but You end up with a mountain of circuits.

Something to read, Universal Asynchronous Receiver/Transmitter (UART) - ESP32 - — ESP-IDF Programming Guide latest documentation when messing around. Take a look at the application examples for such things as "Transmitting and receiving data in two separate FreeRTOS tasks over the same UART", which might be of interest.

And a FIFO buffer is easy with a ESP32 running freeRTOS. The freeRTOS Queues and ringbuffer are available.

No, the main question is how many ICs and junk are you willing to add before you realize that a microprocessor with enough power would be cheaper and easier?

What are the baud rates and how many sources?

a7

I found this IC RSB6505 and this one Tl16C752C which is a FIFO buffer of 64bytes.

And i dont have a good experience of Shift register so any guides on how to make one or use one.

Using a MEGA is fine but it has lots of extra pins which i dont require.

Thats a good one can i try the Same with RTOS on other MCU's. Is the multi tasking done on a single core or u need more.

I would like to keep at simple resource level and have more out of something small and have additional features by adding few small IC's.

The baudrate are most probably fixed at 9600.
And the no of sources are changing from min 4 to max 8.

If You feel confident using them, go ahead. Personally I support a Mega. Much easier.

You are not obliged to create work for every pin.

Give them some time and learn how they work.

That's not what You're aiming at.

The ESP32 has 2 processors, the main processor has 2 cores. freeRTOS works on both cores of the main processor.

There is also a TL16C754 - which has 4 UARTs with 64 byte buffers. It's not cheap - Mouser UK want around 15 GBP. These chips are parallel access, so address and data lines.

There are quad UARTs with an SPI interface - like the MAX14830. The docs say that each UART has a 128 word FIFO. There are likely others too.

You might find that SparkFun or similar have a breakout board for one of them.

However, they are likely to be costly. If you really need 8 UARTs, then a cheap solution may be to use a couple of the MEGA2560 Mini boards that can be found on the likes of AliExpress for around 10 GBP delivered.

I dont know if the IC's are Effective for my application

I would like to use Atmega2560 but then still i would be having only 3 hardware serial
i would like to also know if the Hardware Serial already has FIFO Buffer or Do They FIFO Buffer

I will need to look into Shift Register

Okk so If i Run Two Seperate task and have them scan each uart(for instance)

i remember seeing one project where u can connect 14 RS232 port on a single arduino uno and recognize them by their device ID set by DIP Switches.

I guess these chips come at price for the application
.
Can i use 8 Software Serial Ports on Arduino Mega and have check each and every port for data and then forward this data to PC

No. Only one software serial can listen at a time. So a good chance on data loss / corruption.

Thats the only thing i wanna prevent Data Loss / Data Corruption.

How Do i Over Come This Single Thing

The hardware serial ports each have a 1 byte buffer if I recall. The software library implements a 32 byte buffer in memory for each serial port.

64 bytes for AVR :wink: Not sure about other architectures.

Depending on the stuff sending serial using the handshake signals of RS232, CTS (Clear to Send), RTS (Ready to Send) and more, You could use one single channel to receive RS232 after You enable that unit to send. That puts the demand on the sending devices to hold the breath until allowed to send.
8 device select lines would be needed. Some electronical multiplexing of the incoming RS232 would be needed.

But i Guess we need to be listening to the port so that i can use the buffer if i am not wrong and we can listen to only one at a time even if we switching multiple channels.

Is it better to consider a Board like Teensy 4.0/4.1 which has 8 Hardware Serial Ports

Probably yes. I'm however not familiar with them.

As far as I can see, you never clearly stated how many you actually need.