Hello Mike. Wish you Happy New Year ! :-)
{Quote hidden}> If you really need to know if all *other* devices are outputting high
> except one, a possible method is to sense current flow from the bus to
> the OC pin with an external discrete transistor:
>
> +5V----|
> | Rp
> Rp *-------PIC Sense In
> | |/c
> Bus---*---| NPN
> | |\e
> |-R1--*------PIC OC In/Out
>
> R1 provides a path to guarantee that OC In reads low when the bus is low.
> It should be about the same resistance as Rp.
>
> If some other device is outputting a low (holding the bus at ground
> potential) the transistor will never turn on. Sense In will read high.
> If no other device is outputting a low except the PIC, the transistor
> turns on, and Sense In will read low. Sense In will read high when the
> PIC is outputting high in either case. While the PIC is outputting high,
> the OC In/Out pin can be read to determine the level on the bus.
There are also another idea how to make open-drain with only one PIC
pin.
Let us look at diagram below:
1. PIC pin is set as input
1a. Bus=HIGH => PIC pin=HIGH too (transistor in active mode)
1b. Bus=LOW => PIC pin=LOW too (transistor in saturation)
2. PIC pin is set as output
2a. PIC pin=HIGH => Bus=free (transistor is off)
2b. PIC pin=LOW => Bus=LOW (transistor in saturation)
Bus
|
|
|/c
+5v--R1--| NPN
|\e
|
R2
|
PIC in/out pin
R1 & R2 resistance resulting from Bus specification and
type of transistor and may vary from 5KOhm to 500KOhm .
WBR Dmitry.