how to switch between data connections

Hi, how are y'all doing today?

I'm working on a project that needs two arduino's to use the same screen.

Is there any way to switch between 30 pins without a massive relay board?

Sort of like this:

10 LCD screen pins
l
l
-- missing variable x --
l l
l l
10 pins of Arduino#1 10 pins of Arduino#2

Does someone have a possible solution? Please?

You could connect all the pins of Arduino#1 and all the pins of Arduino #2 to the display and make all of #2 pins inputs while you're writing to the display with #1. Do the opposite when you want to drive the display with #2. You must be sure to set the pins as inputs before you set the other Arduino pins as outputs.

You can set these pins as inputs or outputs easily with little code by writing to the port registers directly. See this: https://www.arduino.cc/en/Reference/PortManipulation

Have one control the screen and the other communicates with the first to give it its data. Serial is good for this. I2C is a little more complex but often worth the learning experience.

Artistblock307:
I'm working on a project that needs two Arduinos to use the same screen.

Ah! The XY problem yet again! :roll_eyes:

Perfectly possible but completely unnecessary.

In line with what MorganS said, re-think your project so that either one Arduino does if all, or simply make one control the display and the other forward the information to it.

Paul__B:
Ah! The XY problem yet again! :roll_eyes:

Perfectly possible but completely unnecessary.

In line with what MorganS said, re-think your project so that either one Arduino does if all, or simply make one control the display and the other forward the information to it.

I have to agree at a first glance, but what exactly are you doing? Why do you need two? What boards are they?
I2C and serial are great ideas to allow them to communicate.
-Otherwise-
If you want to use the two to control the screen (i.e. don't want to use communication) I would try wiring a appropriately sized diode into each board to screen connection. This way when Arduino 1 sends an output it will go to the screen but be blocked from going to the corresponding pin on Arduino 2.
Hope I helped

You could also introduce a third Arduino - call it the "display controller" and have the other two Arduinos communicate with it using a serial bus or similar.

data bus selector
http://www.nxp.com/documents/data_sheet/74HC_HCT244.pdf

or a data transceiver
http://www.nxp.com/documents/data_sheet/74HC_HCT245_Q100.pdf

Just do what I suggested in post #2. It's called Wired OR and done all the time in logic circuits. When you set Arduino pins to input they are tri-stated, neither sinking or sourcing current.

You could dedicate another pin on each Arduino connected to a switch if you want to control the data flow remotely and/or synchronize the two Arduinos. In this case you want the Arduino that is to become the active driver to wait 100 ms or so to give the other Arduino plenty of time to set it's pins to tristate (input) before the new active driver sets it's pins as outputs.

Why use a complicated solution for a simple problem?

Get two screens.

pegwatcher:
Just do what I suggested in post #2. It's called Wired OR and done all the time in logic circuits. When you set Arduino pins to input they are tri-stated, neither sinking or sourcing current.

That's not wired or, its a tri-state bus and requires co-ordination between nodes to prevent
both driving the bus simultaneously (which could cause hardware damage).

Wired-or is when you have open-drain outputs both sourcing and a pull-down resistor on the
shared data line.

People usually use wired-AND and open-drain outputs sinking to ground, but its the same
principle and there is no danger or hardware damage since both node drive the same way
they cannot fight each other.

Follow the advice of using a single microcontroller to control the display, everyone does it this
way because its simpler and more logical.

pegwatcher:
Just do what I suggested in post #2. It's called Wired OR and done all the time in logic circuits. When you set Arduino pins to input they are tri-stated, neither sinking or sourcing current.
...
Why use a complicated solution for a simple problem?

Because as you yourself unwittingly go on to point out, it is everything but a simple problem due on the one hand to the fact that you must in fact use either a data switch or an actual wired-OR as you must avoid contention between two driving Arduinos and on the other hand, you must in any case provide "handshake" between the two in order for the display to be reset each time it is changed over.

And there's the rub. If you have in any case to have agreement between the two Arduinos, then the simple solution is to ditch the display switching and simply send the data to be displayed from one to the other according to an agreed protocol. Even more relevant if the Arduinos - and display - are not adjacent.

Or - reconsider why you felt the need to use a second Arduino in the first place. This was almost certainly unnecessary - unless they are separated from each other, in which case yet again you clearly do not want to extend the display wiring. :grinning:

First, it can be Wired OR and is also called Tri-Stating. You can use a pullup or pulldown resistor plus diode with it just as with open collector or open emitter, which makes it Wired OR. In this application, I don't see that a resistor is needed, except possibly to pull down/up an Enable line to disable it during transition. And I see no need to Reset the display if you disable it momentarily with the Enable pin. That would depend upon the display itself.

Second, there must be assurance that only one device is active, no different than with discrete logic. That is a simple thing to do, whether it is designing with discrete logic or with software. They can be synchronized with a switch, as I suggested, or better with a switch plus handshaking. Not a big problem!

This is the way I would do it, and I have done a lot of design with both discrete and imbedded systems. I have used Tri-state devices extensively and Atmel has provided us with Tri-state, which is very nice.

From this article: http://www.ni.com/white-paper/3544/en/#toc3 "Tristate devices are very useful when you want to allow more than one device to drive the same signal, but you want to ensure that only one device is driving the signal at any time."

That is, of course, what I'm suggesting; allowing more than one device to drive the same signal.

First, it can be Wired OR and is also called Tri-Stating

They are two different things. That's why there are two different names. Re-read MarkT's post.

Read on. I said Wired-Or with the addition of resistors and diodes. Tri-state and Wired OR are usually used for the same reason and are close cousins. In some literature, two or more 3state outputs wired together is called a Wired-OR output. Just semantics in this case, as I see it. Either could be used here, but Atmel provides us with Tri-state, not O.C.

One of the solutions mentioned here was to use I2C between Two computers. I2C also relies on Tri_State.

No. I2C is not tri-state.

If you read the I2C standard it says on page 7 that it's wired-AND. I prefer to think of it as wired-OR because the bus is drawn LOW when any of the devices becomes active (a OR b OR c OR...) but technically the bus is HIGH when (a AND b AND c AND ...) are all HIGH.

Yes, it's Wired And, designed to be used with open drains. Since we don't have open drains, we use TriState (pinMode(x,INPUT) which allows a resistor to pull it up. Works just the same as in open drain. That's why I say Tristate can be used as wired OR (wired AND) in this case, and often is. I still say tying the outputs of two Arduinos together to control a device is Wired OR, only the resistors are missing.

Actually I have never seen a Wired OR, but Wired AND is usually called Wired OR, which I prefer also.

Wired-NOR might be more descriptive.

The function is OR-ed, and the resultant logic is negative.

Well what I had in mind was to make multipurpose portable arduino, as redundant as that sounds.

IN OTHER WORDS giving an arduino a GUI so that it looks more like a raspberry pi and less like a circuit board with an on/off switch.

I'm going to build it with atmega1284 arduino's for the extra ram space and I want to fit the second arduino with bitlash or something so I can prototype on the go. It'll be multipurpose because I'm not going to completely finalize it as I want to make it shield compatible.

So now that I've explained my project I would like to thank everyone for the project ideas, tri-state based communication seems to be a great idea. At least for the multipurpose part of the project. But now that I've had to think about it arduino#1 would be the master device
and arduino#2 could be interchangeable as long as it could fit on a shield. Now since I'm pretty new at this, can some one at least point me towards some example code where it shows how to push data through an arduino to an lcd or at least explain it. Please?

-Artistblock