Go Down

Topic: Share Serial1 (Read 399 times) previous topic - next topic

jose_francisco

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

PieterP

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

Pieter

pylon

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.

jose_francisco

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.

Robin2

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
Two or three hours spent thinking and reading documentation solves most programming problems.

jose_francisco

Sorry
I only wanted to simplify the question.

Robin2

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



...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Robin2

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

Two or three hours spent thinking and reading documentation solves most programming problems.

pylon

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.

jose_francisco

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.

Robin2

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



...R
Two or three hours spent thinking and reading documentation solves most programming problems.

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.

Robin2

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
Two or three hours spent thinking and reading documentation solves most programming problems.

jose_francisco

Hi Robin2.

Something like this? (attached file)
I will try it.
1*1kohm + 2*1N4001 ?

Thanks

jose_francisco

Hello
Any advice about resistor value and diode type?
Thanks

Go Up