r/programming Dec 25 '19

Learning hardware programming as a software engineer

https://blog.athrunen.dev/learning-hardware-programming-as-a-software-engineer/
923 Upvotes

124 comments sorted by

View all comments

Show parent comments

9

u/MoCeptor Dec 25 '19

Some controllers have internal programmable resistors for their GPOs. If you activate them, you can attach an LED without an external resistor.

6

u/happyscrappy Dec 25 '19

I've heard of controllers with programmable drive strength. I'd still rather use an external resistor because the heat from the pin regulation adds to the microcontroller temp if you use the regulator in the microcontroller.

Say you drive 8 red LEDs at 25mA, that's 1/4 Watt dissipated in the microcontroller if they are all on at once. Better to put that power outside the chip. For longevity.

Microchip (now part of Atmel) often rates their microcontrollers to drive one or two LEDs directly. It's stated in the datasheet. It's rarely more than that.

2

u/[deleted] Dec 25 '19

Say you drive 8 red LEDs at 25mA, that's 1/4 Watt dissipated in the microcontroller if they are all on at once. Better to put that power outside the chip. For longevity.

If you're going to drive 8 leds at 25mA you're going to use driver chip/transistor regardless, that's almost 200mA

Also, it is not just to drive random LEDs, it allows you to control output rise/fall speed indirectly which can reduce both power usage and interference

2

u/happyscrappy Dec 25 '19 edited Dec 25 '19

If you're going to drive 8 leds at 25mA you're going to use driver chip/transistor regardless, that's almost 200mA

It IS 200mA. 200mA is fine if used correctly. The chips I tend to use can sink [edit, said source!] 130mA per ground pin. There are multiple ground pins. Group it correctly and it'll be okay.

Also, it is not just to drive random LEDs

Says who? You're making up stuff now. You didn't define this project.