Just got a bit of a questions; my goal is to build a device with 2 separate arduinos, connected to and bus powered by 2 separate computers; shared buttons (with LED illumination, controllable would be a bonus, but at least powerable by both EITHER or BOTH arduinos at the same time), shared encoders;
I'd probably want to use 2x Arduino Pro Micros because of the form factor and the chip allowing to compile as a device showing as class compliant MIDI;
I have read quite a bit of (often well founded) criticism of setups that involve more than one arduino, which I do understand; in this particular case (where one set of controls is to redundantly control 2 identical theatrical show machines, so any interdependency between the circuits apart from the same (dumb but reliable) controls switching both arduinos and thus both connected machines), I don't think even if there was a way to use say a secondary USB shield or so to run it all off one arduino, that this would be really desirable - as for redundant control, the more parts of the path are redundant, or the least single points of failure along the line exist, the better.
Sooooo - I would love to avoid intercommunication between the arduinos to KISS, but probably keep the circuits separate? So hardware wise, finding momentary 2 pole switches and encoders might help this? but then, when it comes to powering the LED in the buttons via either or both bus powers, how would that work safely? And is it easily possible of for this to be an actual controlled LED (and what would the solution look like - a latest takes precedence? a lowest or highest takes precedence?)?
I hope I have explained enough for this to make it a doable and worthwhile question to answer :).
Welcome!
Take a look at CAN, that is a two wire differential buss that can communicate with each of the items you mentioned. Code can be identical on each board except for its ID. With this you can add as many additional nodes as you like. Going above 16 is dependent on the transceiver chip but most will work with many more.
CAN is extremely reliable and is used extensively in Automotive and many other industries.
how I would wire up say an LED to receive power from either (or both) of the units; certainly, you'd share GND, but would you share VCC? and further more, while one could conceive putting in a 3rd unit (to interface with leds, buttons, encoders, and send/receive info via CAN to/from the other two units), you'd still need to power said 3rd unit... again, shared GND and VCC, even if the power comes from different USB busses? Ideally, I am after
no external PSU
Power being taken only from the USB Bus power
as long as USB... host? client? is connected, the system works and is powered on; but also works when both are powered.
I'm not quite sure why you think that you need two arduinos to accomplish what you need, but you know your system better than we do.
Is your question then, how to turn on an LED from one or both of the arduinos at the same time? If so, I literally just answered a similar question in another thread. You can drive them with open-collector transistors. So either arduino can turn the LED on, but they both need to agree to turn it off.
Depending on how much current the LED needs, though, you may be able to drive it directly from two pins on two different arduinos without anything extra besides a pair of resistors.
Hi, not quite - 2 show machines, 2 arduinos, one set of buttons/controls; both show machines have the same (QLab) file with the same cues, get advanced/triggered in sync etc. On the output side, you have to switch between the two redundant machines as necessary (audio, video, LX).
Both Arduinos would be able to drive a LED. With some simple logic you can have each control it. You could use a common cathode bi-color where one would drive one color the other the other color. Ground would be common. You would get either color or the combined color.
Gary Fowler has posted a great CAN library that comes with both a transmit and receive sketch. They are written in such a way that you can combine them into one sketch and do your other things. Here is the link. I used external boards (china) for less then a buck and it had the MCP2515 CAN controller and the bus transceiver for less then a buck a few months ago. So far over two dozen have worked without any problems.
I would not using this approach as that will become a load for your laptop. I use a 4 wire cable with two being power and two being can, it works nicely.
@gilshultz , Bicolor would not be my goal - ideally both driving the same LED (to get the same colour). the can bus would still be interesting for negotiating, i.e. if I wanted to make it dimmable, so that if one Arduino gets the signal to PWM it at 50%, the other does the same... but otherwise, I wonder if the CAN bus is even necessary?
re: USB bus power - I power little controllers/LED combos like this all the time from the Mac, never had any issues where too much was drawn; I'd rather eliminate external PSUs where not needed.
@cedarlakeinstruments , thanks for the LED driving example, I shall test it. Can I confirm that the diagram I roughed up below is what you mean? Can I assume that PWM would not work in your example? I guess there would be a danger that the PWM coming from different power sources would not align timing wise...
I also added one momentary push switch and one endless rotary encoder to the mix; Is this safe/workable, as long as they as pictured share common GND? I know that with push switches, I should be able to find multi-pole switches, but with Encoders (though in my mind easily technically possible) I had no luck thus far (just dual shaft, but that is not the desired outcome)... would switches and encoders work when connected as below, or is there any danger of damage to either arduino?
And would it be safer to try and build external de-bouncing rather than software de-bouncing, so that the same result is guaranteed for both arduinos (i.e. would there be a potential of slightly different timing in the arduinos to result in slightly different de-bouncing outcomes when done in software)? example of a de-bouncing circuit I found online: https://www.electroschematics.com/wp-content/uploads/2015/06/rotary-encoder-arduino-wiring.png?resize=305%2C183?w=305
I assume it would be unadvisable and/or unhelpful to connect the VCCs (5V) of both; as at the very least, both arduinos would be powered by one usb connection when only one is active?
So sorry, you two @cedarlakeinstruments and @gilshultz if I was nebulous - yes, the idea with this redundant (in the positive sense of having a backup, rather than in the sense of being superfluous) controller is that either both arduinos are on (i.e. only when they receive power from their respective USB hosts), or a single one of them is on - the idea being, that neither knows nor cares who is active; but WHEN either (or both) are active, they will each (independently) work... if that makes sense.
Sooo, with a couple of 1N4001 in series - between resistor and LED, I thought? - I should be sweet, and able to avoid the two arduinos powering each other parasitically?
And if all the switches are connected as input_pullup, that should mean that whether they are open or not, there should not be parasitic draw - or would I need 1N4001's for each used input pin also?
With the Diode isolation the feedback will be eliminated but the PWM will be the sum of both sources "ON" time and non overlapping "ON" time. Simply stated the led will be on when either or both tell it to be on. Since the units are not synced you may get some interesting patterns such as flickering.
But @gilshultz , with the PWM generator sitting between both Arduinos and the legs, shouldn't it work reliably, as it is not 2 PWM signal, but a single one?
You keep changing the design it will be different. This answer was based on post #10. I suggest you determine what you want, do an inclusive schematic that explains what you want. I do not have time to keep changing as others need help as well.
Thanks @gilshultz , that's fair, and appreciated your help. FWIW, I feel I am there now, with how I am going to build it, the discussions helped me to clarify what I needed and what is possible. Apologies for using resources for something that was not fully fledged out.