Two Arduinos Talking On Digital Ins/Outs

I posted earlier about having 2 arduinos talk "Serial", but am thinking now to simply wire three common wires between the two of them and have them speak back and forth much in the same way a Multiplexer is triggered by three digital ports. 0 0 0 = 0 0 0 1 = 1 0 1 0 = 2 etc etc 1 1 1 = 7. One would read the information(signal) and would have the digital pins programmed to Read and the other would send the information and have the corresponding digital pins programmed to Write High/Low depending on what number to send.
I am pretty sure this will work and am excited to try it as I think the speed at which the two can communicate will be rather....well...speedy.

My question is about the wiring of the two together....should I put a resistor to ground on one side or should it be ok to tie the grounds of the two arduinos together and to ground and simply put a wire from one digital OUT on one arduino to the digital IN on the other.

Looking forward to some thoughts about the wiring of this one. Definately not new stuff....hopefully its not too boring for someone to reply.

-arduiYES

silly question...i just answered it myself...10k resistors to ground on the recieving side.

NewSoftSerial could be used, using just two pins (and ground) with wires between the TX and RX pins on the two Arduinos would allow bi-directional communication of more complex data.

My question is about the wiring of the two together....should I put a resistor to ground on one side or should it be ok to tie the grounds of the two arduinos together and to ground and simply put a wire from one digital OUT on one arduino to the digital IN on the other.

Tying the grounds is required if the boards are powered from different power sources, if they are both powered from the same source, say USB power from the same PC then the ground wire is not required.

In theory you can just wire a digital output pin directly to a digital input pin without needing pullup or pulldown resistors. However for safety sakes you should use a series current limiting resistor between the pins in case of software errors or bugs where both pins might become outputs and one is high and the other is low. That would result in a short circuit and damage both output pins. A 1k ohm series resistor would be cheap insurance against brain farts. :wink:

Lefty

between the TX and RX pins

I know Paul knows what he means by this, but with "fresh, niave, eyes", I wonder if a little clarification might be helpful?

With NewSoftSerial, you could dedicate (almost) any four pins (two on each Arduino) to the task of handling the comms between the Arduinos. I would avoid using D0 or D1, so that THEY can be left dedicated to the Ardino's communication with the big PC being used to program the Arduino.

Paul's suggestion is probably The Way To Go, if you just want to get the Arduinos talking.

If you want to have some fun, for instance with your "3 bit parallel data link", add one or two "handshake" lines, to "clock" the data transfer....

RTS: A line FROM sender, TO receiver... when it goes high, it is "saying" "Ready to Send"
CTS: A line FROM receiver TO sender.... "Clear To Send".

They can be used quite subtly to synchronize the activity in the two Arduinos. In the following, I'm assuming that the sending Arduino is set up to do some complex data capture job. The whole thing is dedicated to serving as some kind of sensor.

The receiving Arduino's job is "everything else"... deciding WHEN to ask sending Arduino to go off and fetch datum, and doing "stuff" with it after it has been fetched. It might not be the BEST convention to adopt, but in the following, I am having both lines go HIGH to be "saying" what their name implies.

I'm also assuming, for sake of simplicity (much more complex things are possible) that the "reading" from the sensor will be an integer from the range 0 to 15, inclusive, which is 0000 - 1111 in binary.

We'll start with both lines low, AFTER system has initialized, and after any previous cycle completed....

Sending Arduino Receiving Arduino

------------------ Starts process by sending CTS high long enough that

                    • Sending Arduino should have seen it, and then sends low again.

Begins to capture datum.
When datum captured...
Puts first bit of data on data line, i.e., maked it high or low
Waits a very brief time to let voltage on data line stabilize
Sends RTS high until...

------------------ Receiving computer reads the bit on the data line, and

                    • Waits a very brief time to let voltage on data line stabilize,
                    • Sends CTS high again

Waits to see CTS high,
Changes data line to show second bit,
Waits briefly,
Sends RTS low until....

------------------ Receiving computer reads the bit on the data line, and

                    • Waits a very brief time to let voltage on data line stabilize,
                    • Switches CTS back to low

Waits to see CTS low,
Changes data line to show third bit,
Waits briefly,
Sends RTS low until....

... etc!

Simple plan.
Have fun making it work!

I gather this is the "three pins" you mentioned in the other thread.

It will work but needs five pins to transfer only 3 bits of data, not very efficient but should be pretty fast.


Rob

How will the receiver know when the three bits are valid to be read? A fourth line indicating "good data" is required. Having a serial interface lets you send a couple of bytes with some smarts around the data. Even if it's just the three bits repeated so the receiver can compare the 2 half bytes and say, Yes, good data.

Sender: sends 2 bytes, first indicates new message, 2nd is the data: 00010001
Receiver: send back the inverse of the data:11101110
Sender ANDs the two together, gets 00000000, knows messege was received, sends next, or waits for data message from the Receiver.

Or it could be a burst of bytes.

having a bit of continued difficulty with this one....i have it all wired and installed and am getting a reading of only 20 ohms between the wires connected between the digital ins/outs and ground. wow. i guess thats drawing more than an amp. im a bit confused as to how to wire this circuit.

what i had are 4 wires from pin 13,12,11,&10 on one arduino going to pin 13,12,11&10 on another. each of these wires was connected also through a 10k resistor to ground. 13 & 12 on one are input, 13 and 12 on the other are output and vice versa for 11 & 10.

with what i had, i put the voltmeter (reading ohms/resistance) between 13 and ground...got like 13 ohms. wow. did the same with 12,11&10 and got 20 ohms each. wow wow wow. that strikes me as dangerous. i wonder if i fried something and if i did....will have to go from there.

i returned to this posting to check the replies and see if i fully understood everything....and i have a question.

question is, if i implement lefty`s solution of a current limiting resistor in the wire between each pin in (arduino A) to pin out (arduino B) four times, and remove the 10k resistors to ground...and remove the connection of these wires to ground....and simply put pin to pin, so to speak, is this going to be a tamed beast that will give me more or less what i want/need?

what i desire is, for example, digital pin 10 from arduino A goes HIGH, digital pin 10 (set for input) on arduino B reads HIGH state.

(side note- - i unsoldered the 1k resistors for both boards on pin 13 connected between the led and pin.) all 4 pins (well 8 pins actually) should be alike at this point....electrically speaking.

perhaps someone could make it simple for me....and draw a circuit diagram that shows exactly how this should look.
ie---what i have now.
ardA dig pin 10 ----(wire)---(1k resistor)---(wire)---ardB dig pin 10

do i need a ground on that? didnt seem to be utilizing that path to ground before....ive got the 1k resistors in hand, and a deadline of tomorrow for this part of the project. really need some support on this question. hopefully i`ll get it. cheers.

Thanks for the info.

vvoodoo==spam?
Watch this space

ardA dig pin 10 ----(wire)---(1k resistor)---(wire)---ardB dig pin 10

That's fine, no need for GND.

between 13 and ground...got like 13 ohms

But was one of the pins set as an output? You can't really measure that properly and anyway with the above circuit you don't need to.

It doesn't sound like a hardware problem, I think you need to post some code.


Rob

How far apart are the arduinos?

Here's a data point for comparison:

I have pairs of them sending/receiving serially at 4800 over 4 conductor security wire (22/4, has aluminum outer shield also that is not connected to anything - I suppose connecting it to the power supply ground at one end would help - I can rework one end of the cables to do that at some point). The 4 wires are 12V, 12V return, Tx out and what I called Tx return, but is really just another ground. There is a 7805 regulator at the receive end to make 5v for the promini there. (the receiving promini controls 6 transistors to turns sets of LEDs on/off from 12V).
Lines are not twisted or anything. Bought a 500' roll at Home Depot, unspooled it to the lengths I needed and soldered on DB9 connectors with plastic backshells to connect to boxes.
The wire has lengths of ~40' for the shortest runs, and closer to 100' for the longer ones (boxes are mounted 7' up on a wall - so 7' down, across the width of the room, down the length of the room, across the width of the room, and back up the wall).
This is Tx to Rx from one Promini to another. No resistors in the path at all.

arduiYES your inputs should be high resistance, but your outputs shpu;d be low resistance. So when one of the Arduinos is set to pinMode(pin, OUTPUT) then the resistance measured to ground will be low when you also set digitalWrite(pin, LOW).

BTW its not a good idea to use an ohm meter this way. When the Arduino thats set to pinMode(pin, OUTPUT) is also set to digitalWrite(pin, HIGH) then its a low resistance to +5V which could damage your meter.

Its better to use a volt meter and look for 0v or +5v. Or for convenience run a 220 ohm to 1k ohm resistor from each pin to an LED so you can watch them talk to each other.