detecting low voltage with PIC

Rajinder

Jan 30, 2016
568
Joined
Jan 30, 2016
Messages
568
Hi,
I have a Pic micro that drives a LED. The circuit is 3V3 through a 270R resistor, to the anode if the LED and the cathode is connected to a I/O line of the PIC. So a logic 0 lights the LED, a logic 1 keeps it off.
Can I connect this cathode / PIC IO line to another PIC microcontroller input line to monitor the state if the LED. The monitoring PIC would simple detect for a 0 i.e. when the LED is on.
Is there anything else to consider?
Best regards, Raj
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
Yes, you can connect an input of one PIC to an output of another PIC.

Bob
 

Rajinder

Jan 30, 2016
568
Joined
Jan 30, 2016
Messages
568
Thanks. Do I need to add any additional circuitry to the PIC that will be monitoring the LED voltage at its cathode? Or can it just be a straight connection?
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
Assuming this is not going through a long wire, you can connect them directly. The only caveat is that a programming error could have both pins as outputs and at opposite logic levels, perhaps destroying that output drivers in the PICs. To prevent that, use a resistor on the order of 1K between them.

If they are connected via a meters long wire, you would need a 330Ω or so resistor across the input to avoid large voltages induced in the wire.

Bob
 

Rajinder

Jan 30, 2016
568
Joined
Jan 30, 2016
Messages
568
Thanks Bob. Is the 1K only used to limit current? Similarly I am not sure on the understanding of the 330R, why this value for longer cables?
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
The 1K is only there to limit current if both ports accidentally become outputs. That would limit the current to 5mA which is well within their sink / source capability.

When you have a long cable, a voltage can be induced in the cable by your AC power for example. The voltage can be high enough to trigger an input, which is very high impedance. But it cannot produce much current. The 330Ω resistor will keep the voltage spikes suppressed, because the induced voltage is not capable of providing much current. Say it can provide 100uA. Then the 330Ω resistor would limit the voltage across it to

V = I R
V = 100E-6 * 330 = 0.033 V.

The value of the resistor is pulled from the air. It might need to be even lower depending on how much noise is picked up by the long wire.

Using a twisted pair (better) or shielded cable(best) would also help in the case of a long distance.

Bob
 
Top