AN-1052 GreenPAK Macro Circuit Design LED Brightness Control

This application note demonstrates how to design a simple LED brightness control using a GreenPAK™ chip. To control the brightness of an LED you can vary the average power which is sent to the LED. PWM from the GreenPAK can provide the varying levels of power by varying the duty cycle. For example, if we turn the LED on for 50% and off for 50% of the time, the LED will appear half as bright. The pulse width is the important factor here. By varying the pulse width we can effectively control the average light power from the LED. The minimum LED oscillating frequency should be at least 50Hz so the switching is not obvious to the human eye. In this application, we will use 50Hz. When using PWM, duty-cycle refers to the percentage of time a pulse is ‘on’ over the duration of the cycle. At the 50Hz frequency the resulting period is 20ms. During that time we have to turn the LED either on or off depending on the required duty-cycle. For example, a 75% duty-cycle requires the pulse to be HIGH for 15ms (LED will be off) and then LOW for 5ms (LED will be on due to open drain pulldown circuit used for this application).

LED Brightness Control Circuit Design

The screen capture of FSM that controls the PWM can be seen in Figure 5. The 3-bit LUT0 is connected to PIN3, PIN4, which are configured as Digital in with Schmitt trigger with pull up resistor 1MegΩ. Output of 3-bit LUT0 is connected to KEEP FSM1. When KEEP is HIGH, Q will stay at its current value. The 2-bit LUT0 is configured as NAND. Output LED is configured to be 1x Open Drain NMOS. PWM period is defined by the period of FSM0.

FSM0 period is 20ms. IN+ for the PWM is an 8-bit data string that is sourced from FSM1. IN- for the PWM is an 8-bit data string that sourced from FSM0. PWM output duty cycle ranges from 0% to 99.61% and is determined by: Output Duty Cycle = IN+/256 (IN+ = 0: output duty cycle = 0/256 = 0%; IN+ = 255: output duty cycle = 255/256 = 99.61%).

Note: PWM block has a possibility to configure duty cycle range with two options: 0% to 99.61% and 0.39% to 100%. This application note utilizes the first option.

Finite State Machine, which has features for UP/DOWN control. When UP/DOWN is HIGH, FSM is in up-counting mode, the Q value will count from 0 to 255 (256 steps total). When Q is equal to 255, OUT generates a single clock cycle pulse. When UP/DOWN is LOW, FSM is in down-counting mode. When Q is equal to 0, OUT generates a single clock cycle pulse.

As can be seen in Figures 7 and 8, output of FSM1 is connected to the PWM SHARED PD and IN0 of 2-bit LUT1. The 2-bit LUT1, P DLY and DFF4 are used to obtain 0% duty cycle. The 2-bit LUT3 is connected to DFF4 and PWM. The 2-bit LUT3 is configured as NOR. The 2-bit LUT2 is connected to DFF4 and PIN3. Output of 2-bit LUT2 is connected to UP/DOWN of FSM1. FSM1 is in down-counting mode when the output of DFF4 is LOW and button “+” is not pressed. P DLY is configured as “both edge delay”.

Figures 2, 3 and 4 show the timing diagrams of the circuits’ functionality shown in Figures 5, 6 and 7.

Figure 1 shows the application circuit with buttons connected to the GND and LED connected to PIN 10.

LED Brightness Control Typical Application Circuit

Figure 1. LED Brightness Control Typical Application Circuit

LED Brightness Control_1 Timing Diagram

Figure 2. LED Brightness Control_1 Timing Diagram

LED Brightness Control_2 Timing Diagram

Figure 3. LED Brightness Control_2 Timing Diagram

LED Brightness Control_3 Timing Diagram

Figure 4. LED Brightness Control_3 Timing Diagram

LED Brightness Control_1 Block Diagram

Figure 5. LED Brightness Control_1 Block Diagram

LED Brightness Control_2 Block Diagram

Figure 6. LED Brightness Control_2 Block Diagram

LED Brightness Control_3 Block Diagram

Figure 7. LED Brightness Control_3 Block Diagram

LED Brightness Control Circuit Analysis

Figure 8 shows the operation of the design LED Brightness Control_1. If button “+” is pressed, "LED" output will generate PWM signal with changing duty cycle from 256/256 to 1/256 (the LED brightness will go up). When button “-” is pressed, "LED" output will generate PWM with changing duty cycle from 1/256 to 256/256 (the LED brightness will go down).

LED Brightness Control _1 waveforms LED Brightness Control _1 waveforms

Figure 8. LED Brightness Control _1 waveforms.
Top line is button “+” input, 2nd line is button “-” input, 3rd line – LED output

Figure 9 shows the operation of the design LED Brightness Control _2. If button “+” is pressed, "LED" output will generate PWM with changing duty cycle from 256/256 to 0/256. When button “-” is pressed, "LED" output will generate PWM with changing duty cycle from 0/256 to 256/256.

LED Control_2 design advantages are decreased quiescent current and PWM duty cycle range to 0/256.

LED Brightness Control _2 waveforms LED Brightness Control _2 waveforms

Figure 9. LED Brightness Control _2 waveforms.
Top line is button “+” input, 2nd line is button “-” input, 3rd line – LED output

Figure 10 shows the operation of the design LED Brightness Control _3. If button “+” is pressed, output PWM duty cycle will decrease by 1/256. When button “-” is pressed, output PWM duty cycle will increase by 1/256.

LED Brightness Control _2 waveforms LED Brightness Control _2 waveforms

Figure 10. LED Brightness Control _3 waveforms.
Top line is button “+” input, 2nd line is button “-” input, 3rd line – LED output

Conclusion

The PWM block is a standard block used in many devices and systems. The ease of use and configurability of this block in GreenPAK4 devices makes it a perfect candidate to replace bigger and more expensive microcontrollers.

About the Author

Name: Bogdan Holod

Background: Bogdan Holod graduated from Lviv Polytechnic National University in 2011 and received a Master’s Degree in Radio engineering devices, systems and complexes. Since 2012 he has been working as a design engineer on low power analog systems, and developing design guidelines of digital and analog electronic circuits.

Contact: appnotes@silego.com

 

Files



See full list of Application Notes