UART Bus?

Go To Last Post
18 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

Does anyone know how many devices could be connected on one UART Bus?

One device is the master, and the others are slaves.

Please advise!

Thanks in advance

Walid

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If only 1 is master and other are slaves, and only the master needs to send stuff to all slaves, then you can connect master TXD to all slave RXDs, if there is a reasonable amount of them (1-10?) with reasonable distance (10cm?)

However, you cannot directly connect TXDs of the slaves together to master RXD for bidirectional communications. A software solution is to keep slave TXD pins not activated as outputs unless slave receives a message which commands it to send something, so it turns the TXD pin as output only when sending.

Another option would be to make a single half-duplex usart open-collector tx/rx wire, but everybody must wait for their turn to talk, even master.

So, based on your question, the answer is either yes, no or maybe. Maybe if you would give us more info what you are trying to do, we could give you more detailed answer.

So basically, UART is not a bus. If you really want to connect N devices together, use I2C maybe, it too has two wires and anyone can be master.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

...and if the devices are 100s metres apart then RS485 comes to mind.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Dear Jepael,

Thanks very much for your kind replay!

Actually, I have around 20 sub-systems (as slave devices) controlled by a main-system (which is the master devise), and all these are contained in one device which is connected with similar devises using RS485 mode-bus.

I setup my design by using RS485 (Max485) with all slaves and masters, inside the subsystems and for the main system, but this is very expensive! Also I had another problem which is: if any one of the master devises in idle mode (e.g. shutdown), and transition data occur, there will be a missing data!!

So, I decide to turn the internal sub-systems to UART interface and keep the external systems on RS485.

The distance between subsystems (inside each one of the external systems) is around 30cm, so we can't use I2C or SPI!

I tried to check the AVR datasheet to find out how many devices could be connected together using UART (droop-point), but I found nothing.

That is the story :)

What would you like to advise?

Thanks in advance & regards,
Walid

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The limit depends on the actual data rate and the capacitance involved. More devices equals more capacitance due to the interconnections and the pin capacitance of the AVR. So higher data rates will be affected more by the greater capacitance. So to answer your question, you need to know some numbers.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Agreed.. Atmel says nothing about it, because they have nothing to say about it.. What matters in this case, is how strong your driver is, how much resistance and capacitance in the wire, and how much of a load each receiver will place on the line.

You're definitely coloring outside the lines, but you may be able to get away with it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

walido81 wrote:
The distance between subsystems (inside each one of the external systems) is around 30cm, so we can't use I2C or SPI!

Why not?
I2C can run much longer than 30cm.

Quote:
Question: What is the maximum distance of the I2C bus?

This depends on the load of the bus and the speed you run at. In typical applications, the length is a few meters (9-12ft). The maximum capacitive load has been specified (see also the electrical Spec's in the I2C FAQ). Another thing to be taken into account is the amount of noise picked up by long cabling. This noise can disturb the signal transmitted over the bus so badly that it becomes unreadable.

The length can be increased significantly by running at a lower clock frequency. One particular application - clocked at about 500Hz - had a bus length of about 100m (300ft). If you are careful in routing your PCB's and use proper cabling (twisted pair and/or shielded cable), you can also gain some length.

If you need to go far at high speed, you can use an active current source instead of a simple pull-up resistor. Philips has a standalone product for this purpose. Using a charge pump also reduces "ghost signals" caused by reflections at the end of the bus lines.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

walido81 wrote:
The distance between subsystems (inside each one of the external systems) is around 30cm, so we can't use I2C or SPI!

Why not?
I²C can run much longer than 30cm and has a mximum of 112 nodes on the same bus.
I²C is a very common bus inside televisions where a lot of IC's are connted to the bus and with longer distances than 30cm across several PCBs. IIRC Philips Semiconductor (now NXP) originally inveted the I²C for bus communication inside televisions.
Some large systems use I²C repeaters or multiplexers because of long lenghts and many nodes.

You can find a lot of documentation and application notes about I²C at NXP's website: http://www.nxp.com/#/pip/pip=[pf...|pp=[t=pfp,i=41735]|

http://en.wikipedia.org/wiki/I²C

http://www.esacademy.com/faq/i2c...

Quote:
Question: What is the maximum distance of the I2C bus?

This depends on the load of the bus and the speed you run at. In typical applications, the length is a few meters (9-12ft). The maximum capacitive load has been specified (see also the electrical Spec's in the I2C FAQ). Another thing to be taken into account is the amount of noise picked up by long cabling. This noise can disturb the signal transmitted over the bus so badly that it becomes unreadable.

The length can be increased significantly by running at a lower clock frequency. One particular application - clocked at about 500Hz - had a bus length of about 100m (300ft). If you are careful in routing your PCB's and use proper cabling (twisted pair and/or shielded cable), you can also gain some length.

If you need to go far at high speed, you can use an active current source instead of a simple pull-up resistor. Philips has a standalone product for this purpose. Using a charge pump also reduces "ghost signals" caused by reflections at the end of the bus lines.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Since this is all in the same device, you could use a simpler bus driver chip for the master USART Tx (for example from the 74HC family). You may not need any RS485, unless you really need the differential bus plus/minus wiring for noise immunity or unless you have different power supply voltages between the master an slaves. A "typical" RS485 driver chip will handle at least 32 loads, however you must check the RS485 chip data sheet to know for sure.

If you have a single power supply you should be able to have the master USART Tx output drive multiple parallel bus driver inputs. Then each bus driver output would only go to a few USART Rx input pins. For example 4 bus drivers could feed 5 USART Rx input pins each for 20 USARTS total (each slave USART Rx pin would not need its own interface chip). This would split up the master Tx capacitance loads.

Then if the slaves need to Tx back to the master another tri-state bus driver under the slave or master control (i.e. the tri-state enable pin control) could connect the salve USART Tx outputs back to the master USART Rx input. All the tri-state bus driver outputs would be wired together, but only the single enabled output would ever drive the master USART Rx input pin. While this slave to master setup is simpler and less expensive, it does prevent the master USART from reading back its own Tx data to detect collisions and slaves cannot hear each other send USART data back to the master. These may or may not be a problem depending on what your design requires.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
I²C can run much longer than 30cm and has a mximum of 112 nodes on the same bus.
And I have seen systems using SPI over hundreds of metres, in fact serial data using SPI was (is??) running Wetmead hospital nurse call system when it was built about 30 years ago. It used to be the largest hospital in the southern hemisphere.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Mike B wrote:
Since this is all in the same device, you could use a simpler bus driver chip for the master USART Tx (for example from the 74HC family). You may not need any RS485, unless you really need the differential bus plus/minus wiring for noise immunity or unless you have different power supply voltages between the master an slaves. A "typical" RS485 driver chip will handle at least 32 loads, however you must check the RS485 chip data sheet to know for sure.

If you have a single power supply you should be able to have the master USART Tx output drive multiple parallel bus driver inputs. Then each bus driver output would only go to a few USART Rx input pins. For example 4 bus drivers could feed 5 USART Rx input pins each for 20 USARTS total (each slave USART Rx pin would not need its own interface chip). This would split up the master Tx capacitance loads.

Then if the slaves need to Tx back to the master another tri-state bus driver under the slave or master control (i.e. the tri-state enable pin control) could connect the salve USART Tx outputs back to the master USART Rx input. All the tri-state bus driver outputs would be wired together, but only the single enabled output would ever drive the master USART Rx input pin. While this slave to master setup is simpler and less expensive, it does prevent the master USART from reading back its own Tx data to detect collisions and slaves cannot hear each other send USART data back to the master. These may or may not be a problem depending on what your design requires.

Thanks...

Could you please provide a block diagram for this idea?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am looking for same kind of solution.

I am trying to connect more than 10 slave devices on same bus. I am going to use the system on a vehicle as data collection terminal, especially for temperature, humidity. Is it possible to use I2C on a big truck for 20 mt. long? Or I have to build an algorithm for addressable RS232 bus?

Can you suggest some informative examples or any design ideas?

Thanks...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

m.ilem wrote:

I am trying to connect more than 10 slave devices on same bus. I am going to use the system on a vehicle as data collection terminal, especially for temperature, humidity. Is it possible to use I2C on a big truck for 20 mt. long? Or I have to build an algorithm for addressable RS232 bus?

Sounds like the perfect job for CANbus.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But none of my devices provide CANbus...

I use mega64 as master device, and going to choose one of tiny AVRs as slave (sensor) controllers.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Will the MCP2515 SPI-CAN device do you for? Though I have heard reports they can be a little tricky at times. Haven't used one myself though.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

damien_d wrote:
m.ilem wrote:

I am trying to connect more than 10 slave devices on same bus. I am going to use the system on a vehicle as data collection terminal, especially for temperature, humidity. Is it possible to use I2C on a big truck for 20 mt. long? Or I have to build an algorithm for addressable RS232 bus?

Sounds like the perfect job for CANbus.

Doesn't it sound more like a perfect job for LIN-bus rather than the more expensive and faster CAN-bus?
LIN-bus was designed to interface automotive sensors, because CAN-bus is too expensive for simple sensor interfacing.
LIN (Local Interconnect Network):
http://en.wikipedia.org/wiki/Loc...
http://www.freescale.com/webapp/...

LIN Bus – A Cost-Effective Alternative to CAN: http://www.xilinx.com/publicatio...

Atmel has several application notes about LIN-bus for AVR: http://www.atmel.com/dyn/product...

If you don't want to run new wires for the LIN-bus, now you can even use LIN over the 12V or 24V battery power-line. This is called DC-LIN and requires special power-line LIN-transceivers: http://www.yamar.com/DC-LIN.html

Using LIN Over Powerline Communication to Control Truck and Trailer Backlights: http://www.yamar.com/Truck-Trail...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Doesn't it sound more like a perfect job for LIN-bus rather than the more expensive and faster CAN-bus?

I'd like to try LIN for some of my AVR apps (remote industrial sensors) instead of crystal & RS485, but it doesn't appear as if the LIN/automotive models are going to be readily available to common people, at reasonable prices. Sigh.

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AndersAnd wrote:
Doesn't it sound more like a perfect job for LIN-bus rather than the more expensive and faster CAN-bus?

I'm convinced. Pending, of course, OP's data requirements.

Not something I've looked at closely... maybe I should one day.

CAN should be getting cheaper now that it's come off patent in most countries (1988 IIRC), but I'm impressed at the low BOM of LIN.

-- Damien