0

Suppose I have a simple LED driving circuit i.e. an LED and a resistor in series which is driven by a pin of a microcontroller. Now I set the frequency of this pin to say 1Khz, will the LED flash with the same frequency?

There might be capacitances in LED but I assume them to be small to have any affect or I may even be wrong(Oh and yes the capacitance would just vary the rise and fall times but it is good to be sure ). What are the possible parameters which vary the frequency of LED?

Thankyou for your valuable time

Jasser
  • 398
  • 1
  • 3
  • 18
  • What do you mean frequency? A red LED flashing at 1000 times per second will still be red if it is the question. It will only affect its intensity. – lucas92 Apr 25 '16 at 14:46
  • I mean if I set say 500hz continuously from the pin of microcontroller then will the LED be flashing with same frequency or would it vary @lucas92 – Jasser Apr 25 '16 at 14:49
  • So you ask if you switch the LED on and of a thousand times per second, would it go on and off a thousand times per second? – PlasmaHH Apr 25 '16 at 14:52
  • @PlasmaHH With all respect I dont understand where is the confusion in my question? – Jasser Apr 25 '16 at 14:54
  • 5
    I think everyone's assuming there's more to the question because it's simple and the answer is "yes". – pjc50 Apr 25 '16 at 14:56
  • 3
    You should probe it at the oscilloscope, I checked many LEDs datasheets and there is no mention of their speed. At very high frequencies, the LED won't react fast enough and will output a DC signal due to internal capacitance. But I doubt you should use a LED for this type of application. – lucas92 Apr 25 '16 at 14:57
  • 1
    Practically, the only factors that will change the behavior of the circuit is your code - if you're using fancy macros to set the frequency to "1 kHz" but your clock frequency defines are wrong... or your math is wrong... or you are doing something weird with your timing.... – W5VO Apr 25 '16 at 15:02
  • Oh, so LED's are not good at higher frequencies and I think the frequency at which the output is a constant DC signal will depend on the type of LED. Also do you mean to capture the light emitted by LED and then measure it on a oscilloscope? @lucas92 – Jasser Apr 25 '16 at 15:05
  • @Jasser: Because if that indeed is the question, it would be the same as "If I crossed that street, would I be on the other side?" And qualify for "This question does not show any research effort; it is unclear or not useful" – PlasmaHH Apr 25 '16 at 15:10
  • I meant to measure the voltage at the LED and see if it is still a square wave. At higher frequencies, the harmonics of the wave will get filtered and you will only get the DC component of the signal (for square wave : VDD/2). – lucas92 Apr 25 '16 at 15:20
  • @PlasmaHH Not _everyone_ knows about the requirements for a linear system. I don't think it's obvious to a layman that external passive components are incapable of changing the frequency of an input signal. – pipe Apr 25 '16 at 15:31
  • No problem if this is a low quality question, since I have the answer of my question. Also it's good to know about things which you don't know or be sure about it. If it's low quality for someone then they are free to downvote me. @PlasmaHH This question is yes might be easy for you but what about people like me who are not sure about the parameters which are involved in the question I asked. – Jasser Apr 25 '16 at 15:32
  • @pipe Thankyou for your answer and you said in the comment "external passive components are incapable of changing the frequency of an output signal". There might be some things which go into manufacturing an LED which might form some unwanted frequency changing circuits. So I thought to ask the parameters which gets involved... – Jasser Apr 25 '16 at 15:41
  • thankyou everybody for your help and @pipe it is not necessary that the one who doesn't know should always be a layman :). – Jasser Apr 25 '16 at 16:06
  • I think I took your words seriously but yes you were right I should know some basic things as pointed out by pjc. I will see that this is not repeated in future @PlasmaHH ;) – Jasser Apr 25 '16 at 16:10

2 Answers2

4

That's correct. The LED will flash at the same speed as you toggle the pin, which in turn will be related to the frequency of the microcontroller.

Everyone's confused because they know something that you don't - you can't change frequency just like that! No passive or active device can do it. You mention capacitance (doesn't really exist in a LED but let's go with it) and you're correct. They will only change the rise/fall times. If the capacitance gets too high, you will see an effect where the LED will not have time to rise up to the high level until the microcontroller tries to make it low again, causing all the "toggling" to disappear and you will eventually end up with a voltage in between low and high, with some ripple.

The device that affects the frequency is just the microcontroller and its oscillator.

pipe
  • 13,748
  • 5
  • 42
  • 72
  • 1
    RE: "No passive or active device can do it."... You can essentially make a frequency doubler with just a diode (whether you consider a diode to be a passive or an active device is a matter of semantics). For that matter, any nonlinear device, whether passive or active, is going to generate harmonics. – The Photon Apr 25 '16 at 16:11
2

At 1kHz 50% duty cycle (500usec on/500usec off) the light emitted will follow the port pin output very closely.

Once you get into the sub-microsecond region you may start to see differences based on capacitance and effects due to the LED itself not responding instantly (something like scores or tens of nanoseconds if the LED is driven hard). The junction capacitance will vary with forward voltage, like any other diode, and it's typically in the tens of pF for a small LED.

See also this question and the chosen answer.

Spehro Pefhany
  • 376,485
  • 21
  • 320
  • 842