All LEDs will operate at 1mA current (with the pedantic exception of rare tiny ones where even 1mA is too much). LED brightness is proportional to current, so you can use any current you like up to the maximum allowed by the various components in your circuit."rpdom" mentions high-brightness LEDs that only need 1mA forward current. What "key words" should1 I be using to search for LEDs that will operate at 1mA current?
LED datasheets will normally specify an absolute maximum (above which the LED is damaged), and a value for which the datasheet gives you the brightness. Sometimes those two currents are the same (ie. the datasheet tells you how bright it is at max current), sometimes they are different (the recommended current is less than the absolute maximum).
The Pico/RP2040 also specifies a maximum current - where the main "do not exceed" limit is 50mA total across all the pins added together, with an additional limit of 12mA per pin if the pin is to stay within voltage limits. So if using 25 pins for LEDs and no other significant uses then you could have 2mA per pin.
If you are using the 3V3 power supply, there's a limit there of about 300mA total for external devices.
If you are using a resistor, there will be a power limit - so current-squared * resistance must be less than the rated power of the resistor you have chosen; typical wire-ended ones are 0.24W, small SMT ones will be less.
All of those are the maximums that you must not exceed to avoid breaking things - an entirely separate calculation is how much current will actually flow in your circuit.
The Pico GPIOs are trying to be constant-voltage: they try to drive the pin to 3.3V for a logic '1' and 0V for a logic '0' regardless of the current taken, but as you approach the maximum current they are capable of the voltage will fall off a bit (see the graph in fig.171 of the datasheet).
LEDs are also notionally constant voltage devices - they have a specified forward voltage (about 2V, according to the colour of the LED, with blue ones having the highest voltage), and keep the voltage roughly constant as the current goes up, just getting brighter. In practice, real LEDs are not perfect and the voltage will go up a little bit as the current increases.
So if you connect just a LED to a Pico GPIO you have two devices both trying to achieve a constant voltage fighting against each other, and you will end up with at least one of them at or beyond their safe limits. The common solution for small LEDs is to 'soak up' the difference in voltage with a resistor, as resistors have a voltage that varies in proportion to the current.
So for an example calculation, let's say you look up your LED's datasheet and it says Vf is 2V. You have decided that 2mA is a suitable current for the brightness you want. One end of the resistor is connected to the 3.3V supply so there's 3.3-Vf = 1.3V at the other end of it. The Pico's output is trying to go to 0V and you have put a resistor in between, so there is 1.3V across the resistor. All this is more-or-less constant regardless of the current; the value you pick for the resistor is going to determine the current.
For any resistor, V = I * R. We know that V=1.3, we have chosen I as 0.002 (2mA) so we can calculate R = 1.3/0.002 = 650 ohms. 650 ohm resistors aren't easily available, so we pick one of the values available on the shelf, such as 680 or 560 which will give a current slightly below or above what we first thought of. Let's say I'd prefer it a little brighter and take 560. Put that back into V=I * R and that tells me I = 1.3/560 = 0.0023 = 2.3mA.
We know that 2.3mA is a safe value for the LED and the Pico, just double check that it's OK for the resistor too. P = I² R, so here that's 0.0023 * 0.0023 * 560 = 0.003W = 3mW so that's fine for even a 0.1W 0603 resistor.
Similar calculations apply if you decide you want your LEDs brighter and use more current than a Pico pin can provide: you now have a circuit with a transistor and two resistors. First you set the current in the LED by picking the resistor in series with it - again using the LED Vf, the power supply voltage and the VCEsat of the transistor (which like the Pico will be small, you can treat it as zero for an approximate answer), so this is exactly the calculation above just with different numbers - maybe you are now running at 20mA. Then you need to look up the minimum gain of your transistor, let's say it's 50, so we need to generate a base current of at least 20/50 = 0.4mA. Again you've got two constant-voltage devices with a resistor in the middle to soak up the difference - the Pico at 3.3V and the transistor's VBEsat which will be about 0.6V, giving 2.7V across the resistor. V=I * R so R = 2.7/0.0004 = 6750ohms. Again we pick the nearest convenient resistor, such as 5K6 or 4K7.
Statistics: Posted by arg001 — Fri Dec 20, 2024 3:00 pm