Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] multiple devices on same UART bus in PIC or Atmega

Status
Not open for further replies.

Electro nS

Full Member level 6
Full Member level 6
Joined
Mar 9, 2013
Messages
324
Helped
49
Reputation
98
Reaction score
48
Trophy points
1,308
Visit site
Activity points
3,818
hey guys , i want to control 3 devices and send them the same data in the same time , the devices may or maynot reply. (can be enabled or disabled )

what i am sending is just a string every 1ms . can i connect the three devices to the same UART port ?? if not why ? and what if the devices are only receiving and the main controller is sending .

please see the attached diagram and reply . ( and NO soft serial ideas)




if this works is there any need for current limiting resistors ??? or any type of protection ??
 

You just need to make sure that one and only one of the slaves is transmitting at one time; the other two need to have their outputs tristated. Are these all on the same PCB? You might want to look at I2C or SPI.
 
thanks buddy for the fast reply

no they are not on the same PCB , and you are right I2C and SPI might be better options , actually i will be using RS485 later but now i have to work in this method. (this is a test for prototype )

So to make sure i got this straight : 1- if the slaves are receiving only , everything works normally and the three slaves receive the MASTER message simultaneously.
2- if one slaves needs to transmit , the others need to be tristate on their TX pins.

CORRECT if i am wrong
 

right. Are you using RS-232 or something else? Pay attention to the input resistance of your receivers.
 

i am using RS232 protocol ( TTL levels 5v ) from micro to micro . No MAX232 converters . do i need to worry about input resistance of my receivers in this case? if yes what should i do ? add 1k between master and each receiver ???!!
 

Hello!

The trick is that UART is meant to be 1 to 1. But you could consider a kind of protocol
allowing to use multi slaves. Give each slave an ID, and provide a broadcast address.
If you want to talk to a special ID:

- Send a message beginning with ID (which will be ignored by non-id slaves).
- Broadcast a stop message.

But indeed, you should consider RS485.

Dora.
 
Hello!

The trick is that UART is meant to be 1 to 1. But you could consider a kind of protocol
allowing to use multi slaves. Give each slave an ID, and provide a broadcast address.
If you want to talk to a special ID:

- Send a message beginning with ID (which will be ignored by non-id slaves).
- Broadcast a stop message.

But indeed, you should consider RS485.

Dora.

thanks Dora for your explanation and you are 100% right by using software solution.

but when you talked about using an ID protocol , you didnot comment on the hardware . So i am assuming you are confirming that it is possible to receive by multiple slaves on the same port .

regards
 

Hello!

thanks Dora for your explanation and you are 100% right by using software solution.

but when you talked about using an ID protocol , you didnot comment on the hardware .
So i am assuming you are confirming that it is possible to receive by multiple slaves on the same port .

regards

Well, to be frank, I have never tried to do that with RS232, neither with UART directly, but I see no
technical reason that could prevent it to work. At least as long as you don't have zillions of receivers
on the same UART. I suppose there is a physical limit to the number of hart RX that a single TX can
drive without relaying it. But let's suppose you have a reasonable number of receivers, I'm sure
it can work at least for single sender to multiple receivers.
Now, there is a slight problem if you want it to be bidirectional:

Suppose you have 3 devices, A, B and C. We will note the Tx and Rx AT, AR, BR, BR, CT, CR.

If you want to send message to any device seamlessly, you should connect:

-> AT to BR and CR
-> BT to AR and CR
-> CT to AR and BR

In this case, you have AT = BR = CR (from line 1)
But you have also CR = AR = BT (from line 2)
And since CT is also AR (from line 3)

then you end up with all the RX and TX connected together which might create some problems.

At least, you have to disable any Tx which is not allowed at a certain time. Like if you have
10 people in one room, distribute speech right and forbid 2 people to talk at the same time.

That will be tricky to design, but I'm sure it's possible.

Dora.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top