Sorry if I was a bit vague in the description of the project. I wasn't trying to be lazy or secretive. I made the questions in a more generic way because I have interest in knowing the feasibility and problems of this particular solution (using a shared single pin to sync multiple arduinos) for other future projects. The current project I'm working on is already functional. This idea was just an optimization, and a way for me learn some new stuff.
Here is a more complete description os this particular project:
I'm helping a friend build a modular music sequencer. There are different modules with buttons, knobs, leds, etc... There is a server module that processes everything, all the other modules are connected in a chain. The communication is being done using serial. The modules have different ID's. When the server sends a message, all modules listen. When one of the inputs on any of the modules changes, it sends a message to the server. As we can't have all the TX connected together, each module has a 2 channel mux. When not transmitting, each module sends to the server what is coming from the next module. When a module wants to transmit, it toggles the mux while transmitting so it sends to the server it's own data. The only problem here is when two modules transmit at the same time, only the one closer to the server would get through. I know the typical ways to deal with this using software, like time division multiplexing, or the server pooling the different modules one by one. Since in these modules, the most usual situation would be only one of them transmiting at a single time, I didn't like these solutions. I opted for each module just sending the message asap, reducing the lag, then resend the message if an ACK is not received from the server within a timeout period, standard stuff. This way most messages arrive fast, and only a few collide but are also re-sent eventually.
Tbh the system probablly works well enough as it is now. As I mentioned, the next idea is an optimization but most important for me is a way to explore some things I'm less confident about (I'm a programmer and used to some low-level programming, but less confident about electronic stuff like impedances, electric noise, dimensioning the components, if we should use a pull-up or pull-down, that sort of stuff). Some of the answers posted here already gave me some good tips about some of these things.
So my idea was to have a "BUSY" pin so that all the modules would know if the transmission line was busy or not. While there is still the possibility of a colision, the chances are much lower like this. They would have to try and transmit within a couple clock cycles of each other right? When they want to transmit but see the line is busy, they don't hang and just wait for the line to be free, they will do other stuff and come back to check the line later. Since they are doing these verifications out of sync, I think the probability of a collision will be really low.
So from the answers you guys provided:
- I should use a pull-up and not a pull-down.
- It's OK to have multiple pins as outputs connected together as long as they are all set as low before changing from input to output. (when I mentioned I was afraid of a possible short was because I wasn't sure doing this was safe).
- In this case I don't need resistors between every pin in the chain.
I just have a question now about the pull-up resistor.
Your pulldown resistor determines the impedance of the signal. How low it should be depends on how many inductive loads or motors or mains wires or welding devices are nearby.
The rule of thumb is 10k for a signal that is on the same pcb board, 4k7 for something that is attached to the Arduino board, and down to 1k for long shielded Cat5 wires. So if you choose 470 Ω, then it should work in a normal situation.
So in the first like you're saying that the value should be lower the more interference is around, if I understood correctly.
You confused me with the values though, since you mentioned "down to 1k" for long wires but then you suggest a value even lower. Is this because I don't have shielded cables? Or because I will have multiple small cables between boards instead of a big one?
Thank you for all the tips and suggestions so far. :)