Newbie here, howdy! I searched for info on setting up a serial data bus for multiple devices and found nothing. I would like to connect my AVR to more than one “device” and communicate with all via serial data transmission. Before diving in, I’m just trying to wrap my head around the concept of how this stuff works.
If I connect multiple devices (they could be other AVRs, for example) to the serial data lines on my controller, can I use an output pin to “signal” the other device to transmit its data? Would this make it possible to connect more than one device to the same serial data line and then “select” the device with which I want communicate? The idea is that communication occurs with only one device at a time, but all devices share a common set of wires.
Again, just looking for more info on concepts. I’m not ready to dive in and start coding just yet. I’m still at the block diagram stage of my design so I need to know how different blocks can actually communicate and work together first.
I think I found the answer to my own question. Rather than deal with the USART (which appears to be mainly for communicating with a PC?), I should be able to use a serial SPI interface. If I connect several AVRs together with one configured as Master and the rest as Slave, I should be able to connect all of them to a single 3-wire SPI data bus. Then, the master AVR would use the Slave Select output to signal each AVR in turn to transmit its data over the bus.
I am not looking for 2-way communication. I only wish the main or master controller to “poll” the slave controllers and ask them to transmit their data.
Does all this sound right? THANKS!
PS What if I did need 2-way communication between all devices on a shared bus?
It should work, you could also create a more complex protocol and put a slave address field into a data packet sent through the SPI, this would save you multiple chip select lines.
star-art:
I think I found the answer to my own question. Rather than deal with the USART (which appears to be mainly for communicating with a PC?), I should be able to use a serial SPI interface. If I connect several AVRs together with one configured as Master and the rest as Slave, I should be able to connect all of them to a single 3-wire SPI data bus. Then, the master AVR would use the Slave Select output to signal each AVR in turn to transmit its data over the bus.
I am not looking for 2-way communication. I only wish the main or master controller to “poll” the slave controllers and ask them to transmit their data.
Does all this sound right? THANKS!
PS What if I did need 2-way communication between all devices on a shared bus?
Polling and multi-drop is what RS-485 is all about. q.v.
It is possible to diode-OR RS232 devices together.
SPI, of course, is intended for very short distances, unless you condition the signals.
Thanks, guys! I am learning and taking notes. ALL this stuff is new to me. I’ve never even attempted serial com before.
I need to make several modules that perform different functions and tie them to a “master” module that gathers and reports all the information in a single serial data stream. All this can end up in the same physical case, or in separate cases within inches of each other. They won’t be spread all over the place.
The reason I plan to make separate modules is a) I am just learning how to do stuff, b) I’d like to keep each function as simple as possible, and c) since I am totally new at this, I’d like to be able to test each function independently in case of problems.
I realize an experienced person might find a way to combine a lot of functions into a single system. That might be more cost effective and efficient. But, for a newbie, I’d prefer to break it all down and then take things one step at a time. . .