Built-in Examples / Blink - measure frequency

Hi, I've created the led blinking example of the starter kit:


I have measured the voltage and frequency between the GND and pin 13. And I get a correct ~14mV and ~146 kHz value (I've set the delays to a lower value).
But if I make the same measurement on the led

I get ~13-14 mV and zero Hz frequency.
Why do I measure zero Hz when I measure on the led compared to the measurement when I do it on the GND + pin 13. How the 220 ohm resistor makes this difference?

An LED is not a linear device. That is the voltage across it is almost constant, irrespective of the current through it.

The resistor makes the circuit look like it is being driven by a constant current circuit.

If you want to measure the frequency at the LED then you need to measure the current through the LED and not the voltage.

Do you know how to measure current? Do not use a meter set to current as the meter will look like a short circuit.

You must break the circuit at the resistor LED junction, and insert the current terminals between this junction.

Thanks a lot. I tried to measure the current. I am still shown zero Hz.
I've played with it a lot, and I think the reason may be the limitation of my meter.
I do not have an oscilloscope, so I purely depend on what value is shown by the meter.

I think this exercise generates a square wave.

I have measured the voltage on the LED using DC measurement, and when the pin 13 is set to HIGH, the meter shows 2 V DC between the two legs of the LED, and about .5 mV when LOW. So I thinks in theory the frequency should be measurable by examining the voltage.

So probable getting zero Hz is not because there is no linear connection between the V and the current flowing as the voltage fluctuate between 0 and 2 V DC measured across the LED.

Can you post your code please?
What are you using to measure the frequency? If a multimeter have you checked the specs to see how to use it?

how is that correct?

I've reproduced the 14 mVrms/146.7 kHz, this one produces these values:

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on (HIGH is the voltage level)
  delayMicroseconds(1);                    // wait for a second
  //delay(50);
  digitalWrite(LED_BUILTIN, LOW);   // turn the LED off by making the voltage LOW
  delayMicroseconds(1);                      // wait for a second
  //delay(50);
}

In theory this should ideally produce about 500 kHz. Probable you get 146 kHz because some other limitations. And it is not really relevant to the question why it is 146 instead of 500.

I use a multimeter (extol 8831251), it has a measurement range from 1 Hz to 5 MHz below 36 V.

Here are some values I measure:

  • if I use 50 ms delays:
    • on the LED: ~1 Vrms, 0 Hz
    • between the pin 13 and GND: ~2.2 Vrms, ~10 Hz (9.963)
  • if I use 20 ms delays:
    • on the LED: ~1 Vrms, 0 Hz
    • between the pin 13 and GND: ~2.3 Vrms, ~25 Hz (24.94 Hz)

Try removing that delay completely.
I think that you will find the frequency doesn't change.

delayMicroseconds(1) has no effect.

It is the time taken to execute digitalWrite() that is determining the frequency.

1 Like

Yes, you are right, it stays at 146.7 kHz. Probable some limitation of SW/HW.

This function works very accurately in the range 3 microseconds and up. We cannot assure that delayMicroseconds will perform precisely for smaller delay-times.

But if you try delayMicroseconds(2) then the frequency will be lower.

Here are the numbers with 3 microseconds delays:

  • between the pin 13 and GND: ~11 mVrms, 96.64 kHz

4: ~14 mVrms, 80.86 kHz

5: ~11 mVrms, 69.51 kHz

10: 14 mVrms, 40.85 kHz (the meter shows 0 Hz on the legs of the LED)

But back to the topic :slight_smile: ... so the topic is why I measure zero Hz on the LED why I measure correct (or maybe better to say reasonable values) between the pin 13 and GND.

As you see from your experiment with lower frequencies the voltage at pin 13 is about 2.3 times greater than the voltage across the LED. I suspect that your meter is just not sensitive enough to read the lower voltages.

Yes, based on my experiments and measurements. I think the same that it will be the limitation of my meter. And probable there is no reason why we shouldn't be able to measure the frequency on the LED itself if the right equipment is available.
Referring back the above mentioned possible reason, that the behavior of the LED is not linear. When I set the blinking to a very low frequency and I measured DC on the LED legs, the voltage clearly fluctuates. Is it possible that on higher frequencies, still this non linear behavior is the reason? But having 10/25 Hz are not specifically high frequencies.

Did someone made similar measurements on this LED circuit, with some more sophisticated measurement tools than what I have? Did you maged to measure the frequency on the LED legs?

The I-V curve of an LED can be non-linear but it has nothing to do with frequency
response.

Did you maged to measure the frequency on the LED legs?

Yes with an ocilloscope.

Is there a reason why you want to make this measurement?

1 Like

Led only conducts when forward voltage is reached. Then Ohm has some say.

The comment is in conflict with the instruction. As others have said this instruction should be removed. It has no relevance to your problem.

And you expect to see a frequency that high on a meter? You will not it is way too fast to see.

You need to replace both your dealy(50) with delay(500).

Delay (500) is half a second and with two of them you get a one second period blink.

Then go and measure the voltage on the LED and you should see it go on and off.

Here is the output from pin 13 on the yellow trace and the voltage across the LED on the blue trace.
Using your code with delayMicroseconds(1);
Measurements made satisfactorily.


e]

My Function/Arbitrary Waveform generator also has a frequency counter that will measure the frequency at the LED.

1 Like

Can even take measurements from 62.5ns pulses:

void setup(){
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop(){
  PORTB = 0B00100000;   // take pin 13 HIGH
  PORTB = 0B00000000;   // take pin 13 LOW
}

1 Like

Perfect, thanks a lot for all the help.

Thanks John for the measurement results, I think we can say that there is no other reason why I get 0 Hz, just because my meter cannot measure the real value.

Jim, you asked me why I wanted to measure it. I cannot tell any specific reason. Just learning and want to play around and getting first hand experience about what is going on in the world of electric power. The idea just came to me to measure the voltages at different points of the circuit, to know it more deeply, and as my meter also shows the frequency I noted the different frequencies as well. And I noted that measuring the voltage on the LED showed zero. And I couldn't find any reason, based on my current knowledge why this would happen.
This is how I got here :slight_smile:

So my question is answered.

Good enough reason.

1 Like

Here's some info and analysis of the "maximum pin toggle speed" on an Arduino: Maximum pin toggle speed