Share Serial1

Hi
I want to electronically share a serial port (TX and RX)
My uC will communicate using RS485 and a wireless transceiver at the same time.
I’m using a Master/Slave protocol (Modbus), so no collision may occur.
The tx pin of the uC can manage two rx pins, but the problem comes with the rx pin of the uC.
How can I mix two tx pins in one rx pin?
I’m thinking about OR gate.
What do you think?
Thanks

The best solution is to use a microcontroller that has more hardware UARTs.

Pieter

If your schematic is correct (two MAX485 are used), you don't need any gate you simply have to use separate pins for RE and DE on both chips (so you need 4 pins to select each separately). If RE is high RO will be tri-stated so no collision occur.

Hi Pylon. The schematic is not 100% correct, it is only an approximation.

I'm using a USB to RS485 module in a Raspberry Pi. It works perfect. This module also has its Tx and Rx pins available. Those pins (Tx Rx) are between the USB-to-Serial and the Serial-to-RS485 ICs.

My plan is to take Tx data to feed both Serial-to-RS485 and Serial-to-Wireless. But I don't know how to drive USB-to-Serial Rx pin with two different Tx pins.

Thanks a lot.

jose_francisco: The schematic is not 100% correct, it is only an approximation.

Then make one that is 100% correct and post it.

It is crazy to ask for advice with inadequate information.

...R

Sorry
I only wanted to simplify the question.

Image from Reply #5 so we don’t have to download it. See this Simple Image Guide

91210e68c2584520d0e3a46f0f74fb03e276dde9.jpg

…R

The serial system idles HIGH. So if you want to connect several slave inputs to a single master serial port you need to put a pullup resistor on the Rx pin of the master and put a diode after the Tx pin on each slave so that the idle HIGH of the slave is prevented from reaching the master but the slave can pull the master LOW.

You will also need to ensure that only one slave can talk at any one time.

...R

You diagram still misses the connections of DE and RE. If these are correctly driven you don't need any additional circuitry. Maybe they are already connected on your module but then you should update your schematic to show the actual wiring.

This is the USB-RS485 module I’m using. I don’t know how DE and RE are connected.
My plan is to use TX and RX pins (you can see them in the image attached) to feed a HC-12 module.
I think that TX pin from HC-12 can’t be directly connected to RX pin on USB-RS485 module. HC-12 may try to drive low the signal and at the same time the RS485 IC may tray to drive it high.
Am I right?
Thanks.

Robin2: I can’t upload images to hosting services from this pc. Sorry.

Image from Reply #9 so we don’t have to download it. See this Simple Image Guide

365c2de6effbfe3e81195cdf20b8b4a00c897634.jpg

…R

It seems that this model has the RE/DE signals connected to the TX. This way I don't see a possibility to solve your problem other than the suggestion of PieterP to buy an Arduino with more hardware serial ports.

pylon: It seems that this model has the RE/DE signals connected to the TX. This way I don't see a possibility to solve your problem other than the suggestion of PieterP to buy an Arduino with more hardware serial ports.

Why woudn't my suggestion work? (Reply #7).

...R

Hi Robin2.

Something like this? (attached file)
I will try it.
11kohm + 21N4001 ?

Thanks

sch.jpg

Hello Any advice about resistor value and diode type? Thanks

I would use a 4700 ohm resistor (or 5600 ohms) and any small diode will do - for example a 1N4001

...R