Multichannel Led Dimmer With Capsense Control

  • December 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Multichannel Led Dimmer With Capsense Control as PDF for free.

More details

  • Words: 2,244
  • Pages: 5
Application Note

AN13943

Multichannel LED Dimmer with CapSense Control – AN13943 Author: Victor Kremin, Michael Makovetskij Associated Project: Yes Associated Part Family: CY8C21xxx

GET FREE SAMPLES HERE Software Version: PSoC Designer™ 4.4 Associated Application Notes: AN2233a, AN2292, AN2318, AN2352, AN2355, AN2357

PSoC Application Notes Index

Abstract This Application Note describes a multichannel LED dimmer controlled by capacitive sensors. The dimmer is capable of setting the brightness of individual LEDs with nice fade effects.

Introduction This Application Note demonstrates the PSoC’s ability to manage multiple LEDs with individual brightness control together with CapSense functions. The fade-in/fade-out effects are implemented for each LED individually, activated by a proximity sensor or by touching a CapSense button. The associated design can be used as the foundation for a CapSense-driven key entry for media players, digital radios/TVs, car electronics, children’s toys, and various home appliances. This design has four capacitive button sensors with individual status LEDs and one proximity sensor. The device characteristics are summarized in Table 1. Table 1. Device Characteristics Characteristic Capacitance Sensing Technique

Value CSD

Proximity Sensor Count

1

Proximity Sensor Sensitivity

10-14 cm

Touch Sensor Count

4

Power Supply Voltage

5 ± 0.25V

The device functions as follows. At power on, the brightness of all LEDs is set to 0.5% of maximum brightness. This highlights the buttons in the dark. When the user places a hand near the device, the proximity sensor is activated and the brightness of all LEDs is smoothly increased to 10%. This state reflects the readiness of the device to accept commands. After touching a sensor, the corresponding LED light intensity smoothly increases to 100%. July 20, 2007

When the button is deactivated, the LED brightness drops smoothly back to 10% if the proximity sensor is still active (meaning a hand is close to the device) or 0.5% when the proximity sensor is not active, marking the device’s return to sleep mode. The fade-in and fade-out time is approximately one second, which provides a nice visual effect when a button is highlighted. All possible states of available capacitive sensors and corresponding LEDs are shown in Table 2. Table 2. Touch Sensor and LED States Touch Sensor State

Proximity Sensor State

LED State (Light Intensity In %)

Off

Off

0.5%

Off

On

Fade-in to 10% for all LEDs

On

On or Off

Fade-in to 100% for sensor LED

Off

On

Fade-out to 10% for sensor LED

Off

Off

Fade-out to 0.5% for sensor LED

Figure 1 shows how the LED light intensity changes depending on how long a hand is in range of the proximity sensor, and whether or not it touches the sensor. If the hand does not touch the sensor, the brightness of the LED steadily increases the longer the hand is in range of the sensor (up to 10% of maximum brightness). If the hand does touch the sensor, the LED brightness level increases to the maximum.

Document No. 001-13943 Rev. **

-1-

[+] Feedback

AN13943

Figure 1. LED Fading

If more CPU resources are needed, the 24 MHz CPU clock can be used, or the hardware counter interrupt rate can be reduced. Alternative implementations of the software PWM can include the variable period or pseudorandom source, sigma-delta modulators, etc. See AN2357, “Multi-Channel Fan Speed Control System” for one alternative based on the software sigma-delta modulator.

Light Intensity 100%

10%

0.5% 1

2

3

4

5

6

7

8

Time 1- Button Not Active, Proximity Not Active 2- Button Not Active, Proximity Active (Fade-In) 3- Button Not Active, Proximity Active 4- Button Active, Proximity Active ( Fade-In) 5- Button Active, Proximity Active 6- Button Not Active, Proximity Active (Fade-Out) 7- Button Not Active, Proximity Active 8- Button Not Active, Proximity Not Active (Fade-Out)

An additional interval timer sets the sample rate to smoothly change the light intensity for the fading control software module. Fading control changes the duty cycle for all software PWMs according to the capacitive sensor states and the LED fading control algorithm. Taking into account that the sensor scanning time with the CSD UM is constant, this time is used as a timebase for the LED fading timer. This timer triggers an LED brightness update every 6.8 ms. The LED dimming control functional diagram is shown in Figure 2. Figure 2. LED Dimming Functional Diagram

Vdd

LED1

CapSense Configuration The PSoC® firmware serves two functions: capacitive sensor scanning and LED dimming. The scanning sensors process the touch and proximity sensors’ state and pass the information to the LED dimming control function. The CSD User Module (UM) is used for sensor scanning. The sensors are scanned with different resolutions, and the proximity sensor is scanned with a higher resolution to obtain the maximum operational range. Table 3 summarizes the settings. At the listed settings, the total sensor scanning time is 24 ms.

Hardware Counter

Interrupt Duty Cycle 1

Software PWM1 Vdd

LED2 Fading Control

Duty Cycle 2

Software PWM2 Vdd

Table 3. Sensor Scanning Parameters Sensor

Resolution (Bits)

Scanning Speed

Scanning Time (ms)

Proximity

14

Fast

5.8

Button

12

Normal

1

Multichannel LED Dimming The CSD UM occupies three digital blocks, leaving only one block for other purposes. There are insufficient resources to allocate a hardware (digital block) PWM for each LED state. Software PWMs are used to control LED brightness. A single hardware timer generates periodic interrupts for updating multiple software PWMs. Each software PWM controls a PSoC GPIO pin that drives an associated LED. A simple, fixed-period PWM source has been emulated in the firmware. The hardware PWM timer interrupt rate is 25 kHz and the software PWM resolution is 8 bits, pushing the LED drive output frequency to 98 Hz, which guarantees blink-free operation. The timer ISR execution time is 13 µs, consuming only 30% of CPU resources at a 12 MHz core frequency.

July 20, 2007

LEDn

Interval Timer Duty Cycle n

Software PWMn

The human eye’s sensitivity to a light source’s brightness looks like a logarithmic function (Figure 3). To provide a visible linear brightness change, the PWM duty cycle should be changed in an exponential way.

Document No. 001-13943 Rev. **

-2-

[+] Feedback

AN13943

Figure 3. Human Eye Brightness Perception vs. LED Luminous Flux

Visible Brightness

Another way is to us a computer graphic algorithm that obtains maximum flexibility in setting the LED fading parameters. This project uses Bresenham’s line algorithm [1] to create LED fade in/out effects. Generating fade effects can be thought of as the need to change the brightness level from value y1 at point of time t1 to value y2 at point of time t2, (Figure 5). The Bresenham algorithm allows you to arbitrarily set the fade effect duration and is characterized by low computation integer arithmetic (only adding/comparison operations are required). Figure 5. The Fade Effect as Line Drawing

y Light Source Brightness

(t2, y2)

The linear brightness levels are transferred to exponential duty cycle values using the lookup table. The following expression is used for the conversion:

N out = A ( exp ( N in ⋅ b ) − 1) ; A=

N max ; exp ( N max ⋅ b ) − 1

(t1, y1)

Figure 4 illustrates the table graphs at different values of parameter b. Note that Nmax has been set to 255. This expression converts an 8-bit unsigned BYTE value to the same range. In Figure 4, you can easily see that the transfer characteristic becomes more exponential as the b parameter increases. Figure 4. The LED Duty Cycle Conversion Table LED Lookup table 250 b =0.005 b =0.014 b =0.023

200

b =0.032

Nou t

b =0.041

150

t Parameters Customization The design parameters can be easily customized for different applications. This example has three different LED brightness levels that are set in the leddimerhl.h file: LowLevel, MiddleLevel, and HighLevel. The fade-in/fadeout time can be adjusted by tuning the constants TimeFadeOn and TimeFadeOff. Note that if you change the CSD UM parameters, you need to adjust hardware counter period in order to obtain the desired interrupt frequency because the counter is driven by the VC2 source and VC1/VC2 dividers are varied by changing the CSD UM resolution/scanning speed.

Device Schematic 100

A schematic of the CapSense-based LED dimmer is shown in Figure 6. The dimmer project was implemented using the standard CY3213A-CAPSENSE CapSense Sigma-Delta (CSD) Training Kit board with the sensor LEDs connected to the LCD connector pins.

50

0

0

50

100

150

200

250

Nin

LED Fading There are several ways to create LED fade effects. One possible way is to use a digital low pass filter and apply a step input signal. A filter response at different points in time can also be used for fading.

July 20, 2007

Document No. 001-13943 Rev. **

-3-

[+] Feedback

AN13943



Construction Recommendations for LED-Illuminated CapSense Buttons When a project places LEDs under button sensors, the following recommendations can help achieve the best results:



The hole in the PCB should be located at the center of the button, on the opposite side of the PCB. In this case, the special surface mount device reverse mounting LED should be used.



The LED port pin drive mode should be set to STRONG (depending on port data) at all times to connect the LED pin to Vss or Vdd.



Light diffuser/pipe/micro lenses (special plastic, silicon rubber, etc.) can be used to provide uniform illumination of the button shape. Diffuser thickness needs to be determined in order to obtain uniform LED illumination and the appropriate CapSense system signal-to-noise ratio.

Many applications can use springs between the PCB and the case panel. In this example, the LED can be installed in the center of the spring, and located on the same side as the spring. The recommended spring diameter is 10 mm or more; for thick overlays, the larger diameter springs are recommended for better propagation of electric fields over the insulators.

References 1.

Bresenham's line algorithm is available online at: http://en.wikipedia.org/wiki/Bresenham's_line_algorith m.

Figure 6. Device Schematic +5V

R1 330

10nF

R2 330

C2

D2

LedBtn_3 R5

1k

PROXIMITY 1 R8

Vss P0[3] P0[5] P0[7] Vdd P0[6] P0[4] P0[2] P0[0] P2[6] P2[4] P2[2] P2[0] P3[2] P3[0] XRES

9 10 11 12 13 14 15 16

2.2k

P0[1] P2[7] P2[5] P2[3] P2[1] P3[3] P3[1] P1[7]

P1[5] P1[3] P1[1] Vss P1[0] P1[2] P1[4] P1[6]

1 2 3 4 5 6 7 8

LedBtn_0

0,1uF

ISSP 5 4 3 2 1

R4 330

U1 CY 8C21434

32 31 30 29 28 27 26 25

D1

C1

24 23 22 21 20 19 18 17

R3 330

D3

D4

LedBtn_1 LedBtn_2

1k

R6

BTN1

1k

R7

BTN2

1k

R9

BTN3

1k

R10

BTN4

+5V

J1

July 20, 2007

Document No. 001-13943 Rev. **

-4-

[+] Feedback

AN13943

PSoC Designer™, Programmable System-on-Chip™, and PSoC Express™ are trademarks and PSoC® is a registered trademark of Cypress Semiconductor Corp. All other trademarks or registered trademarks referenced herein are property of the respective corporations.

Cypress Semiconductor 198 Champion Court San Jose, CA 95134-1709 Phone: 408-943-2600 Fax: 408-943-4730 http://www.cypress.com/

© Cypress Semiconductor Corporation, 2007. The information contained herein is subject to change without notice. Cypress Semiconductor Corporation assumes no responsibility for the use of any circuitry other than circuitry embodied in a Cypress product. Nor does it convey or imply any license under patent or other rights. Cypress products are not warranted nor intended to be used for medical, life support, life saving, critical control or safety applications, unless pursuant to an express written agreement with Cypress. Furthermore, Cypress does not authorize its products for use as critical components in life-support systems where a malfunction or failure may reasonably be expected to result in significant injury to the user. The inclusion of Cypress products in life-support systems application implies that the manufacturer assumes all risk of such use and in doing so indemnifies Cypress against all charges. This Source Code (software and/or firmware) is owned by Cypress Semiconductor Corporation (Cypress) and is protected by and subject to worldwide patent protection (United States and foreign), United States copyright laws and international treaty provisions. Cypress hereby grants to licensee a personal, non-exclusive, non-transferable license to copy, use, modify, create derivative works of, and compile the Cypress Source Code and derivative works for the sole purpose of creating custom software and or firmware in support of licensee product to be used only in conjunction with a Cypress integrated circuit as specified in the applicable agreement. Any reproduction, modification, translation, compilation, or representation of this Source Code except as specified above is prohibited without the express written permission of Cypress. Disclaimer: CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress reserves the right to make changes without further notice to the materials described herein. Cypress does not assume any liability arising out of the application or use of any product or circuit described herein. Cypress does not authorize its products for use as critical components in life-support systems where a malfunction or failure may reasonably be expected to result in significant injury to the user. The inclusion of Cypress’ product in a life-support systems application implies that the manufacturer assumes all risk of such use and in doing so indemnifies Cypress against all charges. Use may be limited by and subject to the applicable Cypress software license agreement.

July 20, 2007

Document No. 001-13943 Rev. **

-5-

[+] Feedback

Related Documents

Pic Dimmer
November 2019 5
Led
November 2019 48
Led
June 2020 19
Led
December 2019 34