Project with wireless communication and several Arduinos

Hi everyone,

I'm currently working on a project but I'm not a programmer and it's been a while since my last Arduino experiments so I forgot a lot about coding. I'm on the newbie side of the mountain. That's why I'm asking for your help.

I would like to make 8 machines controlled by Arduino that I would program to be triggered at certain times along a timeline(concurrently with a sound file). I intend to use DC motors, stepper motors, servos, solenoids, etc., according to my needs.

Here is a simple schematic of the setup I want to build:


Beautiful drawing, isn't it?

As you can see I would like to have an Arduino "master" which would trigger the programmed sequences of all the Arduino "slaves" simultaneously (and if possible, the audio file as well for an even more precise sync with my machines) . After some research I thought to orient myself on wireless with RF transmitter / receiver modules such as nrf24l01 +. They seem fairly simple and flexible to use. But I have never worked with this kind of module so I have no idea how to use them the way I want.

Small addition, I would like to have a led that lights up at the same time machines are triggered, for each one of them, but I don't think this is not the most difficult part to achieve.

Could you help me with the code (the simplest, the better) for this project please?

I will come back to you soon to show you my machines' codes to ask you if they're well optimized for my needs. I also have a couple of questions about their power supplies but I don't know if it's the right place to ask them(?).

Thanks a lot in advance.

Saynomore:
Could you help me with the code (the simplest, the better) for this project please?

First figure out what exactly you want to do. Then bit by bit start doing the code. Start with one Arduino, get it to blink an LED. That's what everyone starts with (and I still use it often as the first program on a new platform: see that your programmer works, and that the chip works). Then try to operate a stepper with it. Then add a solenoid. Then add another motor or so. Make it work all together.

When that's done, you can think of adding a second Arduino. Get it to do what it should do, figure out how the communication between the two works.

By then it's going to be quite straightforward to add more and more modules.

Most of your intended equipment needs the proper hardware drivers as well, motors and the like can not be powered by the Arduino directly. You need to have some kind of switch in between. What exactly depends again on your actual parts.

Why do you want that many Arduinos in the first place? What is it that you try to do?

Obviously a Python fan, nudge-nudge wink-wink?

(See my reply here today :wink: )

@wvmarle

I took Arduino courses but it was a while back.
I know how to make my led and motors work (and I'm pretty much ok with this part of the code, unless maybe for optimization, hence my last sentence).

I will figure it out myself for the LED part I guess, but since I've read that some libraries (like the stepper library) are blocking code, I didn't know if it could be an issue or not.

My biggest question mark is on the RF communication in the case of this project. I've read quite a lot about these modules but I have no idea how I can achieve what I want.

Also, I know that most motors need to have an external power supply. My questions about this subject are more along these lines: can I power, with the same power supply, an Arduino, one or two motors (given they require 9v) and a guitar preamp (without buzz or hum (regulated power supply maybe?))?

I need 8 distinct machines that would work independently away from each other.

@kenwood120sprint

$ vim Monty.py

#!/usr/bin/python

# Monty python program

print ("eh? eh? eh? Know what I mean, know what I mean?");

^.^

Also, nice reply you got there. I didn't expect that... :wink:

This Simple nRF24L01+ Tutorial should help get you started.

You need to define precisely what you mean by "simultaneously". For example would a 50 millisecond gap between triggering the the first and last matter?

Assuming it would, then you probably need to make all the "slaves" act on a single message from the master. That is perfectly feasible but to do so you will need to disable the acknowledgement process to avoid all 8 slaves saying "Yeah, I got it" at the same time. And, of course, that means that the master cannot know that they all did get the message. You will need to experiment to see if the system would be sufficiently reliable. By the way this issue is not specific to the nRF24.

If you do need the reliability of acknowledgements then the master must send to each slave in turn and you will need to do some experiments to figure out how long that would take - probably a few millisecs per slave.

...R

@Robin2 Thanks a lot for this tutorial! I didn't find it via Google. It looks great, I will study that.

About your question, I don't think a 50ms gap between the first and last trigger matters. It's unnoticeable for the human ear and this is all about sound.
That said, I'm curious to know why the master needs to know if the slaves get the start message properly. Is it because it will try again if they don't get it?

Also, do you know if this module can interfere with audio stream (speakers)?

And last thing, do you think it's feasible to launch an audio file in sync with these slaves?

Thanks again for your help. I really appreciate it.

Saynomore:
About your question, I don't think a 50ms gap between the first and last trigger matters. It's unnoticeable for the human ear and this is all about sound.

Are you sure about that?
We can hear the difference in arrival time of sound between the left and right ear - which is how we can tell where a sound is coming from. That's less than 50 ms time difference. 50 ms that's 16.5 meters for sound, you can hear echos at shorter than 8 meters.
To play sounds in sync, I'm afraid you have to do much better than that.

Saynomore:
That said, I'm curious to know why the master needs to know if the slaves get the start message properly. Is it because it will try again if they don't get it?

The master doesn't need to know. But if the acknowledgement system is enabled (as it is by default) the master will perform a number of retries if it fails to get an acknowledgement. However, for your purposes, those retries might just be unnecessarily wasting time.

Also, do you know if this module can interfere with audio stream (speakers)?

That depends on whether the audio stream (or the system carrying it) is susceptible to interference from 2.4GHz wireless. I suspect not.

And last thing, do you think it's feasible to launch an audio file in sync with these slaves?

I simply don't know. You would need to do experiments.

Building on what @wvmarie has said, it is not even clear that the right thing to do is to have them in exact sync because that might might mean a listener would be receiving the sounds from the 8 speakers very slightly out of phase.

I suspect we have an XY Problem here. Please tell us what you are actually trying to make.

...R

Robin2:
Building on what @wvmarie has said, it is not even clear that the right thing to do is to have them in exact sync because that might might mean a listener would be receiving the sounds from the 8 speakers very slightly out of phase.

That's another thing indeed.
How do they do that with big pop concerts, where there are many extra rows of speakers, for the people further down the field? Are they in sync with the ones at the stage, or delayed to be in sync with the sound of the main speakers? Both would give odd effects (either sound out of sync - but the stage speakers may be inaudible, or the visuals of the performers out of sync as sound takes a while to get to you).
I assume OP is looking at smaller setups but it's the same problem.

@Robin2 Thanks for these clarifications.

@wvmarle The "Haas effect" occurs when the delay is above 50ms but I don't think it's a real issue here. And you were right, it's for a small setup, in a small room, for a small audience.

That said, if I can get a "zero" latency response, it's better (because I will also have a bit of latency from my audio interface).

To reply to both of you, and because I don't want this post to fall into the XY problem:
I will compose an octophonic musical piece which will be played on those 8 speakers. I will make these machines to play during the piece at some points of its timeline (and get their sounds to my audio interface to feed them in the same 8 speakers). That's why I need them in sync together and also with my audio file at launch so everything play simultaneously. That's pretty much it.

My questions are justified, I just don't know enough about wireless communication and slave/master programmation. I'm sorry if you feel that I'm wasting your time.

Isn't it much easier (plus much better sound quality) to do this wired?

So no Arduinos with MP3 shield or so, but good quality sound equipment instead. Proper wiring from there directly to the speakers. No worries about programming, delays, etc.

@wvmarle The machines' audio outputs will be wired. But I try to have the less wiring possible. I'll already have to put, for each machines, the audio output wire, the arduino/preamp power supply and maybe some 12v power supply for some motors. And I don't even count the wires of each speaker. That's already a lot. That's why I was thinking to wireless launch.

Also, I have to go from the machines through my audio interface to the speakers. And I have to work with 24bit WAV file (and Arduino shields don't support this as far as I know).

But any suggestion to simplify this setup is very welcome of course.

Wiring shouldn't be that bad as you could just have one table full of equipment with a bunch of wiring behind it, one power cable in, eight speaker cables out. That should take care of your sound playback and sync problems.

24-bit WAV doesn't sound exactly compatible with Arduino, nor does high-end audio playback in general. Arduinos are great to read sensors and switch on/off stuff accordingly.

a device that

receives a signal
alters that signal
sends the signal back to the sender

is a transponder.

@wvmarle Thanks for this suggestion but I want my machines to be near each speaker. I can't (and don't want to) have everything in the same place in the middle...

About high-end audio playback, I already figured out that I can't have a module on the Arduino reading a 24bit file correctly. I was hoping that maybe there was a way to trigger it in my laptop, but it might not be possible, I don't know.

@Geek Emeritus Ok.