0
\$\begingroup\$

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

\$\endgroup\$
15
  • \$\begingroup\$ 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. \$\endgroup\$
    – lucas92
    Apr 25, 2016 at 14:46
  • \$\begingroup\$ 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 \$\endgroup\$
    – Jasser
    Apr 25, 2016 at 14:49
  • 5
    \$\begingroup\$ I think everyone's assuming there's more to the question because it's simple and the answer is "yes". \$\endgroup\$
    – pjc50
    Apr 25, 2016 at 14:56
  • 3
    \$\begingroup\$ 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. \$\endgroup\$
    – lucas92
    Apr 25, 2016 at 14:57
  • 1
    \$\begingroup\$ 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.... \$\endgroup\$
    – W5VO
    Apr 25, 2016 at 15:02

2 Answers 2

4
\$\begingroup\$

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.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – The Photon
    Apr 25, 2016 at 16:11
2
\$\begingroup\$

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.

\$\endgroup\$
1
  • \$\begingroup\$ Thank you for the answer and the link you pointed out to! \$\endgroup\$
    – Jasser
    Apr 25, 2016 at 16:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.