Controlling led brightness on multiple channels

Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
Post Reply
FFMan
Posts: 502
Joined: 09 January 2010, 12:52 PM

Controlling led brightness on multiple channels

Post by FFMan »

I want to control 16 leds using a 328n which will receive a command via com1 indicating which led should be on. Each output will be connected to a darlington driver.

High brightness leds are required as the project is used outdoors, however brightness of leds in different colours does tend to vary both in mcd rating measurement terms and perception, and it would be useful if there was a master briughtness control

Across the 16 leds there will be 4 colours so potentially 4 different briughtness settings required.

Is there a creatiuve way using PWM or similar to achieve control of brightness across the led bank ?
rosariote
Posts: 39
Joined: 22 July 2007, 10:12 AM

Post by rosariote »

Hi,
Yes, You can by increasing/decreasing the frequency of the PWM it will increase/decrease the brightness of the LED. I am using the PWM to control the pump motor speed in one of my project.
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

Controlling led brightness on multiple channels

Post by GTBecker »

> ... increasing/decreasing the frequency of the PWM it will
increase/decrease the brightness of the LED.

You mean duty cycle. Frequency change will affect apparent LED
intensity very little. LEDs are a predominantly-resistive load.

While frequency change on an inductive load like a pump motor can change
torque and speed, duty cycle is more effective at speed - and intensity
- control.


Tom
Tom
FFMan
Posts: 502
Joined: 09 January 2010, 12:52 PM

Post by FFMan »

the main question was how I am going to control 16 leds with the limitations of pwm on a 328n ?

I assume I can't have pwm going on every pin can I ?
Don_Kirby
Posts: 341
Joined: 15 October 2006, 3:48 AM
Location: Long Island, New York

Post by Don_Kirby »

I would probably use current limiting resistors to tune the individual LEDs, and then use a single channel of PWM to feed the Darlington array for your global brightness control. Depending on the total current requirement of the LED display, you may need to use another Darlington array channel for the PWM itself, as the PWM output might not provide sufficient current.

-Don
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

FFMan wrote:I assume I can't have pwm going on every pin can I ?
The hardware-generated PWM is only available on certain pins. On the mega328 the 16-bit PWM outputs are B.1 and B.2. If you don't use the SW UART, 8-bit PWM is also available on pins B.3 and D.3 (both features use Timer2 and therefore are mutually exclusive).

You can also implement PWM in software on any number of pins. The general strategy is to configure a timer to generate an interrupt at a multiple of the desired base frequency. The Interrupt Service Routine code determines at each interrupt if it is time to change the state for each SW PWM output. There will be some jitter introduced by several sources including execution time differences for various paths through the ISR, frequency and duration of other ISRs, etc.
Last edited by dkinzer on 12 September 2015, 19:10 PM, edited 1 time in total.
- Don Kinzer
DocJC
Posts: 112
Joined: 16 March 2006, 6:23 AM
Location: Cleveland, OH
Contact:

Post by DocJC »

There will be some jitter
But fortunately this won't be an issue for PWM'd LEDs.

The other option, of course, is to use one of the many LED controller chips available these days.

I still have a bin full of Darlington transistors on my bench, but I haven't used one in quite a while. I've generally switched to NFets, with their improved efficiency over the older Darlingtons.

JC
Post Reply