How to share single wire "Ready"

I'm trying to use Arduino to read a device with UART. This device have 3 wires TX,RX and a READY line to identify when each of the sides are available. With the first two lines TX, RX I don't find any issue (I'm using Newsoftserial lib.) but I don't know how to share this READY line in order I could read the value that the other device could write and write the value that corresponds to Arduino. I mean , if by example , the device write a HIGH value to say that it's ready and my board is not ready I'll need to write a LOW value on the line (.

The "READY" values could be :
ARDUINO side is ready --> READY = HIGH
DEVICE side is ready --> READY = HIGH
ARDUINO side is busy --> READY = LOW
DEVICE side is busy --> READY = LOW

Thanks for your ideas!

Is this second device something you're constructing or does it already exist?

Is something that already exists. Let's say it's a kind of "black box" and I only know the signals that are sent from the device and the signals the device wait for the correct "dialogue".

The point for me now is how to handle this way to use 1 only line to communicate the state of both devices . When I'll write a HIGH value while the device was writing a LOW value , could the device read correctly my value? :-?

Let's say it's a kind of "black box"

Let's not: you really need to know a little bit about what's inside to design your circuit.

It's probably designed to designed to work as a "wire or", with a weak pullup and an open-collector/open drain output that can pull the pin low. It's possible, but unlikely, that it's designed the opposite way, so I'll assume open-drain.

Some micros have open-drain I/O pins, but the Arduino doesn't, so you need two: one input and one output. The output is connected to your input, and the Mystery Machine, through a diode that makes it look equivalent to an open-drain output.

Now you have an input you can read that says either "everybody is ready" (high) or "one/both busy" (low), and an output you can set low to say "I'm busy".

If there's no way to find out what's inside the box, you can experiment by putting a resistor of about 510 Ohms between the Arduino output and the diode. It will probably not stop the handshake from working if the Mystery Machine has an open-drain output, and probably keep the output pins from frying if they turn out to be opposite.

Probably: there's still a small chance of making the handshaking not work, or doing damage, but it skews the odds in your favor.

If you were to change the subject line (you can... just click "modify" for the FIRST post in the thread....) to "How to share single wire "Ready"... it would be much appreciated by people who think of the Dallas trademark "1-Wire" when they see 1-wire... which you post isn't about...

Thanks?

Thanks Ran ,

I try to figure out the "wire or" you proposed , does this corresponds to some these alternatives ?

Regarding the circuit I opened the box and I tried to draw the wiring. I can not identified the diodes so I don't know the type:

Some micros have open-drain I/O pins, but the Arduino doesn't

A way to simulate open drain with a tri-state output is to put the pin in input mode whenever you want the pin to be off. If you are using external pullups, you can simply write a '0' to the pin once at the beginning of your sketch and then use pinMode(pin, OUTPUT) to drive the pin low and pinMode(pin, INPUT) to let it be pulled high or driven low by the opposite end. If you want to use the internal pullup, you'd need to write a '0' following each time you switch the pin to output mode and then write a '1' following each time you switch it to input mode to re-enable the pullup.

Disclamer: I haven't checked the Arduino 'pinMode' code to be sure it doesn't interfere with this approach but I'd be surprised if it did.

Hi cjands40 ,

I wrote the following code, two functions to call in function of the state I need . What I understand is that if I call readyINPUT , I'll prepare the pin for listening the opposite end and this value will only depends on the external device (LOW for busy HIGH for ready). And if I call readyOUTPUT then I put a LOW signal on the line to indicate Arduino is busy. Is that right ?

void readyINPUT()
{
  pinMode(readyPin, INPUT);
  digitalWrite(readyPin,HIGH);
  Serial.println("readyPin is now LISTENING ...");
}

void readyOUTPUT()
{
 pinMode(readyPin, OUTPUT);
 digitalWrite(readyPin,LOW);
 Serial.println("readyPin is now in OUTPUT mode ...");
}