Go Down

Topic: Multiple serial devices to one Arduino Uno? (Read 3650 times) previous topic - next topic

naut

greets

I'm looking for a way to have an Arduino (Uno) handle multiple UART/Serial streams, only with one RX port, i.e. without using SoftwareSerial. What ways are there to achieve this?

I need this capability for receiving (and perhaps mixing) MIDI data from multiple devices.

thanks

kebo

You can't have multiple devices on a serial bus simultaneously. You can however put multiple device on a master/slave RS-485 bus. The RS485 device then switch on and off the bus as needed.  It would require introducing an rs485 driver chip (a MAX485 for example) on the arduino's TX and RX line and controlling the driver's direction with another output pin. You would also need to have access to the communication protocols of the other devices as well.
kevin

naut


naut

Another Q:

I have two Attiny 2313 IC's, they have UART and USI ports. I was thinking perhaps I could use them as serial buffers and use the USI for the link to the Uno.

Can the Uno toggle between the two 2313's (like it would do with SPI by using slave select), and this way get any incoming serial data from one chip at a time?

oric_dan

#4
Oct 30, 2013, 08:47 pm Last Edit: Oct 30, 2013, 08:50 pm by oric_dan Reason: 1

greets

I'm looking for a way to have an Arduino (Uno) handle multiple UART/Serial streams, only with one RX port, i.e. without using SoftwareSerial. What ways are there to achieve this?

I need this capability for receiving (and perhaps mixing) MIDI data from multiple devices.

thanks

I don't know anything about MIDI, however, I do think you can connect multiple devices to one Rx,Tx line, as long as you can have 1 master device, and all the rest are slave devices - meaning they are smart enough to transmit only when directly commanded to do so by the master. This would involve the slave devices each having a unique address for filtering received commands, done via software.

Then, for hookup, you run Tx from the master to Rx on all the slaves, and you take the Tx pins from the slaves and wire-AND them together to feed to Rx on the master. Wire-ANDing should be doable either with diodes and a pullup-R, or else using 74LS or 74HC chips. It might work, :-).

naut

Quote
I don't know anything about MIDI,


Musical Instrument Digital Interface, basically it's serial communication at 31250 Baud rate.

Quote
MIDI is an asynchronous serial interface. The baud rate is 31.25 Kbaud (+/- 1%). There is 1 start bit, 8 data bits, and 1 stop bit (ie, 10 bits total), for a period of 320 microseconds per serial byte.


http://www.gweep.net/~prefect/eng/reference/protocol/midispec.html

Quote
I do think you can connect multiple devices to one Rx,Tx line, as long as you can have 1 master device, and all the rest are slave devices - meaning they are smart enough to transmit only when directly commanded to do so by the master.


nope, midi devices normally transmit data without being instructed from another device, e.g. when you're playing a midi piano keyboard, that's why I was thinking of using some kind of buffering. If I'm not mistaken the max485 chip has no buffering capability so I thought of using attiny2313.

I thought about UART to I2C conversion but the prob with I2C is that the master can only receive data from one slave device at one time, so again you'd need some kind buffering, and if you're e.g. playing a midi piano keyboard to one input of the midi merger and playing a sequencer to another input, you need this whole circuit/code to work fast. And afaik a slave device can not (over I2C bus)  tell the master device to start listening to it.

Midi messages are 10bits long (except SysEx messages), so the Uno could toggle between the two midi inputs, as soon as it sees a Start Bit it would stop the toggle and continue to listen until the Stop Bit then if there is more data coming, it would continue to listen to the same input port, if there is no more data coming it would begin to toggle again, and so on....

Sys Ex would be dealt with a bit differently.

That's how I imagine the rough structure now.

Quote
Then, for hookup, you run Tx from the master to Rx on all the slaves, and you take the Tx pins from the slaves and wire-AND them together to feed to Rx on the master. Wire-ANDing should be doable either with diodes and a pullup-R, or else using 74LS or 74HC chips. It might work, :-).


Could not find a good explanation on the net about wire ANDing. If I understand correctly you mean to use AND gates for selecting which slave device the master Uno is listening to?

zoomkat

Some discussion that might be of interest.

http://forum.arduino.cc/index.php?topic=175851.msg1305132#msg1305132
Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

oric_dan

Re MIDI, if you cannot control the output flow from the multiple devices, then you'll need to use a hardware multiplexer, and have the master switch between datastreams, eg,
http://www.allaboutcircuits.com/worksheets/mux.html


Some discussion that might be of interest.
http://forum.arduino.cc/index.php?topic=175851.msg1305132#msg1305132

That actually describes a wired-OR ckt, and it's not gonna work for "logic-level" RS232, which is normally high and goes active-low for signalling. The OR works for active-high. The following shows the difference,
http://en.wikipedia.org/wiki/Wired_logic_connection

With wired-OR, any input sitting high will force the output to stay high, despite the level of the other inputs. With wired-AND, any signal going low will bring the output low, even while all the other inputs stay high. And as I mentioned previously, the assumption is there is a means to limit only one input from signalling [low] at a time, such as use of slave addressing via software.

naut


Re MIDI, if you cannot control the output flow from the multiple devices, then you'll need to use a hardware multiplexer, and have the master switch between datastreams, eg,
http://www.allaboutcircuits.com/worksheets/mux.html


Yep, but you'd still need each midi input to have some kind of memory buffering, otherwise incoming bytes from one midi input will be lost while the master is listening to another midi input.

oric_dan



Re MIDI, if you cannot control the output flow from the multiple devices, then you'll need to use a hardware multiplexer, and have the master switch between datastreams, eg,
http://www.allaboutcircuits.com/worksheets/mux.html


Yep, but you'd still need each midi input to have some kind of memory buffering, otherwise incoming bytes from one midi input will be lost while the master is listening to another midi input.

You can't have it both ways. You can't listen to 2 Midis simultaneously, using just 1 Rx channel like in your original post. You have to use one of the several other methods mentioned. I would get a chip with multiple UARTs, ie not a Uno.

Go Up