Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

LED as a pullup?

Status
Not open for further replies.
Hold on, backup.....

????
This is not a photo diode folks.
Its a green LED. Sunlight has nothing to do with it.
The circuit showing the photo diode is the INTERNAL circuit of the MID400 optoisolator from the data sheet, not my circuit.

Look at the circuit in the original post. U6 is the MID400 optoisolator. Pins 1&3 are the input (AC). When AC is present, it drives output pin 7 low, sending a signal to GPIO #RA0 of the PIC (not shown). It also lights the plain green LED.

The question was: do I also need the 10K pullup resistor, or would the LED and series resistor do the job of pulling up RA0 to a level that the PIC would recognize as high when the AC was not present.
 
You need the pull-up.

LEDs are photodiodes. In bright light they will generate a microamp or so, and the voltage will rise to about what Vf would be at one microamp in the dark.

So if you don't want a circuit that works differently when you put the lid on, use the resistor.

I have had a PIC input operate from an LED in sunlight. It was connected between ground and the PIC input, and the lower threshold for some PIC inputs may make that easier than if the LED is used as a pull up.

Wait, do you mean the a regular LED acts as a photodiode when not powered? if so, disregard what I said right there ^^^
 
Last edited:
This a clip from the PIC datasheet.

If you dont believe me, you are welcome to come and visit and see it working...

The tea/coffee and doughnuts will be on me.:)

Hi Eric correct me if I'm wrong but from your picture it says that PIC inputs which have a schmitt buffer need 0.8*VDD for a valid input state?

For a 5v input you would need (0.8*5) = 4v for a logic high.

Therefore it's probably a lot safer and more reliable for the OP to leave the 10k in.
 
Yes. There is hardly any current at all available, but you can see the voltage with a DMM.

hi Diver,
I think the point you are overlooking is the high impedance input of a PIC pin, leakage current into a input is in the order of 1uA to 5uA.
Lets assume 5uA, so with an applied voltage of 5V, that equates to a 1megR input.

This 1meg is in effect the load resistor for the reversed biassed LED, so the LED leakage current develops a voltage across the 1meg.

This is how many opto detector are used ie: in reverse current leakage mode.

There is a voltage developed across the LED due to light falling on it, but the leakage current combined with the high resistance 'load' is dominant.

As I have explained I took the trouble to carry a number of tests, with various coloured LED's and CMOS input devices, both in dark and light conditions.
A high was detected in every configuration.

Hi Gobbledok,
I would agree that if the circuit operation is in a critical circuit, the low cost of a 10K is a good investment.

The point that others keep raising in saying it will NOT work without the 10K, is incorrect
 
hi Diver,
I think the point you are overlooking is the high impedance input of a PIC pin, leakage current into a input is in the order of 1uA to 5uA.
Lets assume 5uA, so with an applied voltage of 5V, that equates to a 1megR input.

This 1meg is in effect the load resistor for the reversed biassed LED, so the LED leakage current develops a voltage across the 1meg.

This is how many opto detector are used ie: in reverse current leakage mode.

There is a voltage developed across the LED due to light falling on it, but the leakage current combined with the high resistance 'load' is dominant.

As I have explained I took the trouble to carry a number of tests, with various coloured LED's and CMOS input devices, both in dark and light conditions.
A high was detected in every configuration.

Hi Gobbledok,
I would agree that if the circuit operation is in a critical circuit, the low cost of a 10K is a good investment.

The point that others keep raising in saying it will NOT work without the 10K, is incorrect

I don't see how the LED can be reverse biased when the anode is connected to the positive, although the OP had that at the bottom of the diagram.

I quite agree that it may work without the 10k, but then CMOS circuits may work without any pull up.

The specified leakage current of a CMOS input like a PIC is not what is expected, it is a maximum. 5 µA is so small that most users don't care if it is that or smaller, so the manufacturers won't bother finding out if it is in fact far less than that, which it often is. Also, a simple resistor to ground is a very poor model as the leakage could be positive or negative.

I put together the attached circuit. The inverter is a 74AHC1G04 and the LEDs are HSMY-C170, which are yellow.

When the supply voltage is above 2.5 V, the output LED is off.

At a supply voltage between 1.7 and 2.5 V, the output LED will light if the input LED is illuminated. The higher the supply voltage, the more light that is needed to turn on the output LED.

Connecting a DMM to the input makes it work differently. The input voltage still falls when more light falls on the LED.

The LED is only producing about 0.2 µA. The maximum leakage for the inverter is 0.1 µA at 25 °C

I think that at 5 V, PIC inputs will always be high enough with most LEDs. However, the maximum input high voltage can be as high as 4 V with a 5 V supply, and the LED can easily generate the 1 V needed to keep the voltage below 4 V, so it might not work.
 

Attachments

  • simpleled.pdf
    1.3 KB · Views: 194
Last edited:
hi diver,
Perhaps the term reverse biassed I used is misleading, I should have said relative to the voltage generation of the LED when illuminated.

We agree that most CMOS input will work without the 10K, this is the point I was trying to make.

Personally I would have the 10K pull up and I would not connect a led and series resistor in that way across an input.

You keep stressing the voltage generating properties of the LED, in the circuit configuration used by the OP it is small compared to the leakage current effect thru the LED into the CMOS input.

We agree on the main point, the input will pull up without the 10K, but the 10K is important if you want to maintain a reasonable noise margin on the PIC input.

Eric
 
hi diver,
You keep stressing the voltage generating properties of the LED, in the circuit configuration used by the OP it is small compared to the leakage current effect thru the LED into the CMOS input.
Eric

Hello Eric,

I agree on all your other points, but I am not convinced that there is any leakage current though the LED and into the CMOS input. Leakage could equally be from the CMOS input.

Also, although the LED only generates tenths of microamps, I am fairly sure that the actual leakage on a PIC input is often extremely low, far lower than the specification. I'm sure you've seen, as I have, floating inputs just sitting low or high for minutes at a time, with only stray capacitance holding them there. With only a few 10s of pF of stray capacitance, to hold a voltage for minutes means that the current must be in the picoamp range.

The open-circuit LED voltage is what matters, and currents are as near zero in these conditions as makes no difference.
 
hi Diver,
During the next few days I will try to make up more accurate test jigs and run trials, when complete I will post the results.

Hopefully we can then put this to bed.
Eric
 
So, considering everyone else is taking time to prototype this, I figure I should as well.
I set up the MID400 circuit without the pic. With just the series resistor and LED, the output was only pulled up to 3.5V when the MID400 is in the off state (Vcc=5v).
Of course, adding the 10K resistor pulls it up th the 5V rail.
So it's Vcc less the 1.5Vf of the LED. I don't have a PIC handy, but I cant see how the high impedance input of the PIC would change the circuit much.

EDIT: If I'm reading the datasheet correctly for the PIC18F4620, at Vcc=5V it would consider anything over 2V on RA1 to be high, so I *should* be fine.

PS, I fixed the schematic in the OP so that Vcc is at the top, per convention. Sorry for the confusion.
 
Last edited:
Mark_R,

The 10 k resistor can't hurt. Equally well, when nothing is driving the LED, the voltage can't get below about 3.5 V, as the LED starts conducting, and so with an input high voltage of 2 V you'll be fine. On the TTL level inputs, the switching point is far closer to the negative rail than the positive rail, so with your arrangement it'll be fine. I had problems when I had the LED between the input and ground.
 
Vf

Here is a close look at Vf on one LED.
As can be seen there is forward current at very low voltages. That's why it works.
 

Attachments

  • Vf.PNG
    Vf.PNG
    73.4 KB · Views: 200
the datasheet indicates the output state is pulled high when there is no line voltage, so you do not need a pull-up, as the input line of the PIC is not left floating, before connecting to the PIC Input, remove the LED and the diode, if in case you need them, then you can add these to an output port of the PIC, and modify the source code so that the LED is switched ON when the input is low and vice-versa.
 
the datasheet indicates the output state is pulled high when there is no line voltage, so you do not need a pull-up, as the input line of the PIC is not left floating, before connecting to the PIC Input, remove the LED and the diode, if in case you need them, then you can add these to an output port of the PIC, and modify the source code so that the LED is switched ON when the input is low and vice-versa.

hi,
The output of the MID400 is open collector, so a pull up is required.
 

Attachments

  • AAesp01.gif
    AAesp01.gif
    8.6 KB · Views: 193
Last edited:
Here is a close look at Vf on one LED.
As can be seen there is forward current at very low voltages. That's why it works.

Hi Diver,
Looking at Ron's simulation results and the fact the OP says it works without the 10K, I will not carry out any further tests.

Eric

EDIT:
Added this pdf, explains the PIC's input pin types
 

Attachments

  • Smith_halfChp4.pdf
    504.4 KB · Views: 481
Last edited:
Hi Diver,
Looking at Ron's simulation results and the fact the OP says it works without the 10K, I will not carry out any further tests.

Eric

EDIT:
Added this pdf, explains the PIC's input pin types

Thanks everyone for your contribution to this topic.

Eric; What book is the .PDF from?
 
Thanks everyone for your contribution to this topic.

Eric; What book is the .PDF from?

hi Mark.
Had some trouble locating the complete ebook,

So I used smith_halfChp4 in Google, with a different chapter number extension.

eg: smith_halfChp3 which brought up the previous chapter, attached.

This method should find the remaining chapters...

EDIT: tried 2 and 5 , no luck!
 

Attachments

  • Smith_halfChp3.pdf
    729.3 KB · Views: 415
Last edited:
hi Mark.
Had some trouble locating the complete ebook,

So I used smith_halfChp4 in Google, with a different chapter number extension.

eg: smith_halfChp3 which brought up the previous chapter, attached.

This method should find the remaining chapters...

EDIT: tried 2 and 5 , no luck!

Thank you !
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top