STM32F405 Data Sheet Confusion

MrChips

Joined Oct 2, 2009
30,810
You are overthinking this problem.

If you want a GPIO pin from a 3.3V processor to turn on an LED, aim for the lowest current that gives sufficient brightness.

Connect a resistor in series with the LED from the GPIO pin to GND. Adjust the value of the resistor to obtain the desired brightness.

IMPORTANT: Do not use this GPIO output as a logic source to another component or circuit. This output might not present acceptable logic level voltages.
 

Thread Starter

SDTricker

Joined Jul 2, 2016
18
Why are you brightness controlling your 8 red LEDs? What purpose do they serve?

Coming back to your SFH5454, these are InfraRed LED, so why do you want to control their brightness, since you can't see it!
I have the CAD work down pretty decent, but my circuit theory is killing me right now.

I mainly wanted to control the brightness of the RED LEDs for more of a cosmetic effect. Not so much for the system.
This is a picture of my PCB. If you have ever heard of a micro mouse.
I did this back in college, but this is the first time with an embedded MCU on a system like this and that has been a while ago. I am using this project to get my electronic understanding back in my head.
Mouse.PNG

My LEDs are used for debugging and an interface. I am going to have 4 LED in a row to make a binary list for different modes. the other 4 LEDS will be on each coroner of the mouse for debugging.



The IR Emitters are actually sensors. The robot uses the IR sensors paired with Receivers to get the distance from the maze walls. I was originally thinking that maybe I can adjust the brightness of the IR Emitters to tune the readings back on my receivers with code. That way I can get the best data. Now that I think of this more, I'm not even sure it would really even make a difference. I should always just have them on high.
Sorry, I also posted the wrong calculations for the SFH4545. That written out calculation on graph paper was actually for the Red LED, but now that calculation is wrong. It was for sinking current off my 5V supply.

The SFH4545 has Vf at 2.3V, and If at 100mA. This obviously needs a MOSFET.
I guess I was wrong with my gate resistor, so I recalculated all of it to this:

Emitter Calculaion.jpg

I hope this is correct?

Thank you again for such great help!
 

Thread Starter

SDTricker

Joined Jul 2, 2016
18
You are overthinking this problem.

If you want a GPIO pin from a 3.3V processor to turn on an LED, aim for the lowest current that gives sufficient brightness.

Connect a resistor in series with the LED from the GPIO pin to GND. Adjust the value of the resistor to obtain the desired brightness.

IMPORTANT: Do not use this GPIO output as a logic source to another component or circuit. This output might not present acceptable logic level voltages.
This is part of my confusion. Why do people throw on a 1K resistor if that calculates to around 600uA. Would you even be able to see this? Isn't this the typical forward voltage for a Red LED? 2V? Will you even be able to see it? If I look at the chart, 900uA is way at the bottom of the graph. Where is my confusion?

Thank you
 

Irving

Joined Jan 30, 2016
3,887
The spec is worst case, so it might be 3.3v @ 8mA but worst case it will be 2.9v @ 8mA. Now on one level you are right, the 0.4v has little bearing in the matter, but in other circumstances it could be critical (eg driving multiple inputs to other devices). I'm showing you how to read a data sheet and allow for the worst case scenario.

"At 20mA [...] the voltage on the GPIO pin won't go above 2v or below 1.3v which means most LEDs won't work anyway if GPIO is sourcing current."
I did make that qualification, so if you chose to drive the LED @ 20mA by sourcing current and do the calculations at 3.3v there's a good chance it won't actually light up .

The Vf on a high-efficiency 1mm SMD red LED is typically 1.2v - 1.5v so with 1k on 5v the current will be around 3.1 - 3.8mA, which is bright enough for most purposes.
 
Last edited:

MrChips

Joined Oct 2, 2009
30,810
I'm waiting for my ST32F4 discovery board to come in the mail. Otherwise I would have breadboarded it long time ago, so that is why I am asking for help on understanding the theory.
The theory is: an LED is a non-linear device with an I-V characteristic curve that is modeled as an exponential function, i.e. the current increases exponentially with voltage.

It is very difficult to predict the actual operating current and optical output. The easiest way to determine an acceptable value for the series resistor is by experimentation.

You don't need an STM32 discovery board to do this. Get an LED, 3.3V source and a bunch of resistors (or a variable resistor).

While an STM32F407 is not the same as a CMOS 4000 gate, you can experiment with something such as a CD4081 gate operating at 3V.
 

Irving

Joined Jan 30, 2016
3,887
If you have ever heard of a micro mouse.
Not only have I heard of it, I was a contestant at the 1979 London event. We sadly failed to complete the 2nd run of the course because our 12v SLA battery mysteriously stopped holding charge and we couldn't recharge fast enough between runs.

We did get an 'honourable mention' in the free activity class, where our mouse waltzed quite convincingly to a slightly off key rendition of the Danube Waltz and the BBC showcased our mouse on the Blue Peter children's TV programme.

Oh and we used IR sensors for wall detection originally but they were very susceptible to multiple extraneous reflections off the very white walls. The final mouse used whiskers as contact sensors which proved more reliable if also more easily damaged!
 

Thread Starter

SDTricker

Joined Jul 2, 2016
18
The spec is worst case, so it might be 3.3v @ 8mA but worst case it will be 2.9v @ 8mA. Now on one level you are right, the 0.4v has little bearing in the matter, but in other circumstances it could be critical (eg driving multiple inputs to other devices). I'm showing you how to read a data sheet and allow for the worst case scenario.

"At 20mA [...] the voltage on the GPIO pin won't go above 2v or below 1.3v which means most LEDs won't work anyway if GPIO is sourcing current."
I did make that qualification, so if you chose to drive the LED @ 20mA by sourcing current and do the calculations at 3.3v there's a good chance it won't actually light up .

The Vf on a high-efficiency 1mm SMD red LED is typically 1.2v - 1.5v so with 1k on 5v the current will be around 3.1 - 3.8mA, which is bright enough for most purposes.
Okay nowwww I understand! Worst case scenario. Got it.

I guess my confusion still lies when everywhere on the internet all the schematics I find they have a 1K SMD on the GPIO pins working fine.



I think I might understand this now. I am almost getting it!
So basically to sum this up:
If I wanted to use a 603 Red LED powered by a GPIO pin, then:
(3.3-2-.4)/.008 =112.5Ohm. Giving me 300mcd which is about 1 lumen. This is plenty bright.
This method will put more power consumption on the MCU.
I could bring up the resistance to save power consumption on the MCU, but I have no idea how bright that would be. I can't find any charts online where it shows the brightness in respect to Lumens. I have only found an example of 1 Lumen. This would be so much easier if I had the SMDs and the discovery board right now so I can see. Still waiting on Digi key for those SMDs. -_-

-Lets take the SMD and schematic on the Adafruit Feather STM32F405 Express.
https://cdn-shop.adafruit.com/product-files/4382/4382-schematic.pdf

They use a 2.2K on their board. Unfortunately, I can't find the BOM for this product, so I have no idea which SMD they are using.
I found a video of the board on YouTube and it is plenty brightness. I just don't' know what package size this is.

Is there a chart online i can find? like a reference chart or something? I don't feel comfortable throwing's on a random 1K resistor without knowing the full brightness of the LED.

I am almost there in understanding this. Sorry it is taking me so long to get this. -_-
 

Thread Starter

SDTricker

Joined Jul 2, 2016
18
Not only have I heard of it, I was a contestant at the 1979 London event. We sadly failed to complete the 2nd run of the course because our 12v SLA battery mysteriously stopped holding charge and we couldn't recharge fast enough between runs.

We did get an 'honourable mention' in the free activity class, where our mouse waltzed quite convincingly to a slightly off key rendition of the Danube Waltz and the BBC showcased our mouse on the Blue Peter children's TV programme.

Oh and we used IR sensors for wall detection originally but they were very susceptible to multiple extraneous reflections off the very white walls. The final mouse used whiskers as contact sensors which proved more reliable if also more easily damaged!
No way!!! That is so cool! Not many engineers around me have heard of this. :D I didn't know micromouse was around back then.
 

MrChips

Joined Oct 2, 2009
30,810
Why 1kΩ resistor?

I am going to bet that most people don't know why they choose a certain component value or part number. They simply choose what they have seen someone else has done before.
 

Thread Starter

SDTricker

Joined Jul 2, 2016
18
The theory is: an LED is a non-linear device with an I-V characteristic curve that is modeled as an exponential function, i.e. the current increases exponentially with voltage.

It is very difficult to predict the actual operating current and optical output. The easiest way to determine an acceptable value for the series resistor is by experimentation.

You don't need an STM32 discovery board to do this. Get an LED, 3.3V source and a bunch of resistors (or a variable resistor).

While an STM32F407 is not the same as a CMOS 4000 gate, you can experiment with something such as a CD4081 gate operating at 3V.
Great advice.

I just checked my digi key order. UGHHH fail. It is back ordered. Going to get them off mouser right now. They have many
Why 1kΩ resistor?

I am going to bet that most people don't know why they choose a certain component value or part number. They simply choose what they have seen someone else has done before.
Exactly! That is my point. haha
I don't want to just throw on a random resistor just because someone else did it. That is just coping and pasting.

Do you think my MOSFET circuit for the SFH4545 makes sense. I don't have the time to learn a spice program right now, as I only have an Altium license till the 16th. -_- I'm behind schedule. just need a sanity check.

I did a rush order on my parts from mouser and got the BSS138. I hope this works.

Thank you both for such great help.
 

MrChips

Joined Oct 2, 2009
30,810
Your MOSFET circuit doesn't make sense because I don't see the necessity.
You can drive the LED directly from the GPIO pin via an appropriate series resistor (try 220 to 1kΩ).
 

Thread Starter

SDTricker

Joined Jul 2, 2016
18
Your MOSFET circuit doesn't make sense because I don't see the necessity.
You can drive the LED directly from the GPIO pin via an appropriate series resistor (try 220 to 1kΩ).
The reason I am using the MOSFET to turn on the SFH4545 is because it is an IR emitter with a forward current at 100mA.
 

Irving

Joined Jan 30, 2016
3,887
No way!!! That is so cool! Not many engineers around me have heard of this. :D I didn't know micromouse was around back then.
It was 1980, not 1979...
From https://ukmars.org/contests/micromouse/micromouse-history/
"
1980
Professor John Billinsley, of Portsmouth Polytechnic, modified the rules and introduced the first European competition – held in London at Euromicro. the rule changes required the mice to find a goal in the centre of the maze and wall followers could be prevented from finding the goal. There were 200 enquiries and 100 entries, but only 9 mice at the finals. Nick Smith’s Sterling Mouse became the first ever (and that year the only) micromouse to find the centre and know it had done so. Although performance was less than stunning at about 0.18m/s, it was and still is a remarkable feat. "
 

Irving

Joined Jan 30, 2016
3,887
Why 1kΩ resistor?

I am going to bet that most people don't know why they choose a certain component value or part number. They simply choose what they have seen someone else has done before.
Sadly I have to agree with you...

Which is why I keep telling my students to learn to read datasheets and apply them properly. I'm also an exponent of using simulation software to check out ideas before building them (but also to be aware that simulations aren't 100% reality!)
 

Irving

Joined Jan 30, 2016
3,887
Do you think my MOSFET circuit for the SFH4545 makes sense.
Coming back to your MOSFET switch using BSS138, in general there are 2 aspects you need to consider - static losses, due to \( I^2R \) and switching losses due to gate charge and transition times. We touched on this before back in post #14. For your BSS138 the static situation is that the GPIO output will be very close to 3.3v since there is no gate current so you can take Vgs as 3.3v. Looking at the datasheet, fig 1 suggests that at 3v Vgs, \(I_D\) can be as high as 0.8A so 100mA is easily achieved, while Fig 2 suggests at 100mA the drain-source resistance will be around 1.9ohm. Therefore your typical static losses will be \(I^2R = 0.1^2 . 1.9 = 0.019W.\) To be continued...

1625739699582.png1625740144084.png
 
Last edited:
Top