Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Control LED brightness using PWM?

Status
Not open for further replies.

maniac84

Full Member level 6
Joined
Mar 4, 2012
Messages
337
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Activity points
3,661
Hi guys, about adjusting LED brightness using PWM, I usually see design that input the PWM signal from the mcu to the OE of the LED driver like for example TPIC6C595 to control the LED brightness.
Now, if I'm not using the TPIC6C595 driver and I would like to connect directly the LED to the IO pins of the MCU and I have more than one LED. So how do I control using PWM? Can all the signal from the IO become PWM signal?
I've found a project website (**broken link removed**) which they connect directly many LEDs to the mcu but still using PWM to control. I'm wondering how do they do it? Is it all of the IO pins can produce PWM signal?
 

If your MCU can source enough current @ your desired voltage (see MCU spec sheet), you can drive an LED directly, which is what it appears that they are doing w/ the 16 series PIC. If your LEDs require more current, then use the MCU digital out pin to drive the gate of an N-channel MOSFET. Use the FET as a low-side switch to control the current going through the LEDs and the current-limiting resistor.

While it's in saturation, use RDS(on) to determine the FET's impact on the circuit during the "on" time. Be sure to find a FET with a a small gate capacitance (don't use a 10A FET if a 500 mA FET will work... more current-capacity = higher gate capacitance, typically). The lower the gate capacitance, the faster the switching speed will be (doesn't take as long to go from cutoff to saturation, "off" to "on").

Something like this:
https://2.bp.blogspot.com/-6SwMWGU5bNg/T1KLpEr6d_I/AAAAAAAAAUE/Jq26WyCZavw/s1600/pwm-mosfet.png

Don't forget the resistor across the FET from gate to source (ground). This ensures that the gate is pulled to ground (off) if the MCU goes crazy and the output pins are left floating (like during a reset event).
 
If your MCU can source enough current @ your desired voltage (see MCU spec sheet), you can drive an LED directly, which is what it appears that they are doing w/ the 16 series PIC. If your LEDs require more current, then use the MCU digital out pin to drive the gate of an N-channel MOSFET. Use the FET as a low-side switch to control the current going through the LEDs and the current-limiting resistor.

While it's in saturation, use RDS(on) to determine the FET's impact on the circuit during the "on" time. Be sure to find a FET with a a small gate capacitance (don't use a 10A FET if a 500 mA FET will work... more current-capacity = higher gate capacitance, typically). The lower the gate capacitance, the faster the switching speed will be (doesn't take as long to go from cutoff to saturation, "off" to "on").

Something like this:
https://2.bp.blogspot.com/-6SwMWGU5bNg/T1KLpEr6d_I/AAAAAAAAAUE/Jq26WyCZavw/s1600/pwm-mosfet.png

Don't forget the resistor across the FET from gate to source (ground). This ensures that the gate is pulled to ground (off) if the MCU goes crazy and the output pins are left floating (like during a reset event).

Thanks for the info on mosfet.
But what is the signal from the mcu to the mosfet? Is it PWM signal?
If I got 10 LED and I want to adjust the brightness of each LED individually, I need 10 mosfet connected to 10 IO pins of the mcu right? Can I produce 10 PWM signal from the IO pins?
 

Hi guys,
I know that pic mcu usually have up to 4 PWM pins only. If I want to control the brightness of 10 LEDs individually, what is the way to do it?
 

Thanks for the info on mosfet.
But what is the signal from the mcu to the mosfet? Is it PWM signal?
If I got 10 LED and I want to adjust the brightness of each LED individually, I need 10 mosfet connected to 10 IO pins of the mcu right? Can I produce 10 PWM signal from the IO pins?

Yes, that would be the PWM output from the MCU. You should look at the spec for your MCU's output (source) current for digital pins and see if it's sufficient to turn on your LED.

In this case, yes, you'd need 10 PWM output signals to control the LEDs, unless you wanted to somehow multiplex the four PWM outputs and do a round-robin lighting sequence. However, this would limit you to 33% and 50% of maximum intensity (10 LEDs / 4 PWM signals = 2.5 LEDs per PWM line... so some get 2 LEDs (50% duty due to round-robin) and some get 3 LEDs (33% duty, due to round-robin). That's probably not your preferred approach.

There are some alternate methods, but I'm not up to speed on them. Here's a link to another forum that talks about an off-board chip that may do the trick... worth investigating. Read the other posts in the thread to see if any other methods seem more reasonable for what you want to do. In general, to get more LEDs than you have LED channels, you'll either need to run off-MCU PWM controllers and feed it analog voltages from your MCU, or you'll have to implement some kind of resource sharing and timing tradeoffs.
 

Thanks for the help.
I've found this website **broken link removed**
I'm wondering how they adjust the brightness of the LED using PWM since they connect many LED directly into the IO pins of the mcu. Do you know how they do it?
 

Thanks for the help.
I've found this website **broken link removed**
I'm wondering how they adjust the brightness of the LED using PWM since they connect many LED directly into the IO pins of the mcu. Do you know how they do it?

The answer is in the schematic near the top of the page:
**broken link removed**

They use one PIC16 MCU to control 4 LEDs on each "driver" board: **broken link removed**

By powering certain digital pins they control the color. By adjusting the on/off timing of those digital pins, they control the intensity. They are only controlling four LEDs with one MCU. The larger image if of four "driver" boards.... so 4x4 = 16 LEDs, but uses 4 MCUs.
 

U r right.
1 led need to connect 3 pins (rgb) to the mcu. If 4 led then that means 3x4=12pins mcu io needed. I don't think pwm signal can be produce on all 12 pins of the mcu. Do u know how they do it? How do they control the brightness of each colour?
 

I would guess they used four timers to generate four interrupts (one for each LED). Each interrupt would be used to toggle one set of RGB pins on/off. By looking at a stored variable, the PIC would "remember" which of the 3 RGB pins are supposed to be turned on, and which ones should say off during the 5V pulse.
 

I would guess they used four timers to generate four interrupts (one for each LED). Each interrupt would be used to toggle one set of RGB pins on/off. By looking at a stored variable, the PIC would "remember" which of the 3 RGB pins are supposed to be turned on, and which ones should say off during the 5V pulse.

So what u r saying is that, actually they r not using the PWM pins (CCP1 or CCP2) which is available on the mcu, but they use timer interrupt to on and off the 12 io pins to produce the signal which is similar to a PWM signal?
 

Noted.
But I seen before a design which is using TLC5916 as the LED driver IC. So, this ic uses serial communication to transfer the data. So, it just need serial in, clock and latch pins which is just 3 pins from the mcu. And I do not see any PWM pin to this TLC5916. Then how do they control the brightness of the led using TLC5916? I know they maybe using the serial data to control the brightness. But how? Do you know how they do it?
 

Without digging too deep into the datasheet, it looks like you set up a reference current using an external resistor, then you can scale the output currents against that reference using the serial input of the chip. However, it appears that the brightness is global. You can control the brightness of all 8 channels together, but not separately.

I think you're going to have a hard time finding a simple solution to generate 10 PWM signals from one simple chip.
 

How do we scale the output current using the serial input of the driver chip?
 

How do we scale the output current using the serial input of the driver chip?

"Without digging too deep into the datasheet"...
I skimmed the spec sheet and misinterpreted one of the statements about "individual control" in the serial interface section. Upon closer inspection, it appears you set the current with an external resistor and can only control the individual channel on/off state through the serial interface.
 

Can we control the brightness using the serial data interface? The design I saw jz connect 3 pins from the mcu to the tlc5916 which is serial data, clk and latch. N the led can change from dim to bright. There is no pwm pin connected.
 

I have never dealt with that device before, so I can't tell you yes or no. Look at the dimming example and examine that circuit implementation. Also read through the TLC5916 datasheet and identify what command(s) you need to send to the serial input that will control the current output setting. The answers are probably available if you dig into it far enough.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top