0

I have a project in which several Arduinos will be running independent programs. I would like to use an Arduino Mega as the main controller. It will receive input from a variety of switches, as well as data input from 2 Arduino Unos and 3 Arduino Nanos.

Each Nano will run a basic collection of switches and LED displays.

Each Arduino Uno will be connected to a 2 axis joystick and will have several button inputs from the joystick, as well as several 7 segment Led displays and several LED indicator displays.

The Mega would need to gather information of at least 16 bytes from each slave at highest possible speed, and be able to transfer at least 16 bytes to each slave at the same rate. I would also need the clock signal for all devices to default to the Mega.

What would be the best way to begin setting up the program logic to get these boards to interact in a smooth manner without a lot of lag in communication between boards?

Also, what would be the limitations on speed with this sort of com setup between the boards?

If more setup or function information is needed I can add description, just didn't want this post to be overly lengthy.

9
  • running independent programs .... your description says otherwise
    – jsotola
    Apr 6, 2018 at 5:32
  • I would use SPI. It uses 4 pins on slaves and 3 pins on master plus one pin on master for every slave (slave select). You can use ICSP header 2x3 connector for firm connection.
    – Juraj
    Apr 6, 2018 at 6:47
  • 1
    You could use I2C if the distances are short. For longer distances RS485 is the (wired) norm. Or use one of the many wireless technologies around. nRF24L01+ is cheap and well supported. Or ESP8266 and WiFi if you can't use SPI.
    – Majenko
    Apr 6, 2018 at 9:27
  • 1
    Could you clarify your specifications? When you say the information gathering should happen "at the highest possible speed", it's difficult to come up with a solution, since you may be unwilling to make certain compromises in speed that would make the system work better as a whole. So first set the goal/target data rate and work from there. For an Uno to monitor the joystick, button inputs, and multiple 7-segment displays, your communication speed must be limited. If all your devices are on a common bus, each slave will have to provide it's data in turn, etc. Apr 6, 2018 at 12:19
  • 1
    One advantage of RS485 is that you can make 3 independent buses using the UARTS 1, 2 and 3 of the Mega, and still keep UART 0 for debugging. Then you have 3 times the throughput, as the UARTs can work in parallel. Apr 6, 2018 at 13:55

1 Answer 1

4

Why do you need so many Arduinos, Nanos and a Mega? You want to read/control 2 joysticks, some switches and some LED. If you do this using a multi-processor environment then you are adding a significant overhead to the processing and the development time which you can probably do without.

So, could you connect everything to a Mega, do you have enough IO pins? If not would the use of GPIO expander ICs, I2C devices, etc help solve this issue.

Connecting the joysticks via interrupts will allow a more responsive system, can you do this?

Is an Arduino even the best platform for this? What about an ESP32 or PI?

You want to minimise the comms overhead, so a star network would be better than a ring.
Serial is going to be the lowest programming overhead solution, but by far the slowest. Using WIFI via an ESP8266 is going to be the simpelist and you can hand off some of the processing to the ESP.

12
  • I will have to answer your questions in multiple comments due to character limit. Apr 7, 2018 at 3:24
  • 1) The different Arduinos are used because each micro-controller will be running a separate panel of the project and have it's own program running. (Nano 1 for instance only deals with the ships Power systems. It accepts input data from the Mega when other ship systems are activated. It runs 3-12 segment bar-graphs, 7 indicator LED's, and 6 toggle switches. The processor only needs to calculate current system power usage and emergency states, so not a heavy processing load.) Apr 7, 2018 at 3:31
  • Arduino Unos along with a USB shield are used to control each joystick individually and change the "position" of the ship, which is displayed via 3 separate 7 segment displays. Additionally the Uno's program will deal with weapons fire, in particular counting how many missiles were fired, and display that number on a second 7 segment display. (this is a pilot and co-pilot setup, co pilot takes control of ship positioning during docking procedures) Also the toggle switches and indicator lights for thrust and weapons are each dedicated to the Uno's. Apr 7, 2018 at 3:35
  • so as far as the number of Arduino's, I think I've minimized it well enough. I don't want the program complexity and length to overwork any individual processor, or overflow the memory capacity. Apr 7, 2018 at 3:36
  • 2) Simply making all the different components and systems connect via expansions to a single mass processor doesn't seem to be the solution, but perhaps I'm wrong, might need more clarification on how that could work. Apr 7, 2018 at 3:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.