*u*

^{ ′ }

*v*

^{ ′ }< 5 × 10

^{ − 4}). Then, we propose a closed-loop feedback control (PID) to compensate for spectral shifts due to temperature changes or lumen decay of the LEDs. Both methods can be used independently, but only a combination of them (which uses the output of the first method as an initial guess for the second) offers fast computational times and high spectral accuracy and precision. Computation times are important because these algorithms are intended to be executed on dedicated microprocessors integrated in the LED modules, often sharing scarce memory and processing resources. The results presented here are aimed to be universal and hold for different implementations of the light engine and any number of LED channels.

## 1.

## Introduction

Spectrally tunable light engines are gaining increasing attention after several research efforts have shown how they can be used to create dynamic spaces and mimic daylight patterns with respect to human circadian rhythms and physiology.^{1}^{,}^{2} Solid-state lighting (SSL) is now a mature technology that is fully compatible with current digital systems and information technology. Light-emitting diodes (LEDs) are today present in a wide range of wavelengths across the visible and IR regions, showing fast time responses (in the microsecond range). In addition, LED presents narrow emission bands (typically about 20 nm), low power consumption, long lifetimes, and good dimming capabilities.^{3}

Currently, the role that light plays in the regulation of our approximately 24-h circadian rhythm is well accepted and understood.^{4}^{,}^{5} It also affects our body temperature,^{6} attention,^{7} hormonal secretion,^{8} and sleep.^{9} The discovery of a fourth type of retinal photoreceptor, the intrinsically photosensitive retinal ganglion cells (ipRGCs), in the 1990s was the missing link proving that light not only plays an image forming role but also has an equally important nonvisual influence on our sleep-wake cycle.^{10} ipRGCs are sensitive to light in a particular wavelength range, peaking at around 480 nm (melanopic region).^{10} This explains why not only illuminance levels or colorimetric properties such as the correlated color temperature (CCT) or color rendering index^{11} of light are important, but the whole spectral information of light, i.e., the spectral power distribution (SPD), needs to be considered. Because of these recent discoveries and due to the timely incursion of spectrally tunable solutions in an increasing number of color applications^{12}^{–}^{15} and humancentric lighting (HCL) applications,^{16}^{–}^{19} the benefits of multichannel LED light engines are now accepted for residential, business, public health, commercial, and industrial sectors.

In the literature, several LED multichannel systems can be found for different applications. Park et al.^{20} used an LED array system for a multispectral camera. Fryc and Brown^{21} proposed a light engine to match CIE standard illuminants, Kolberg et al.^{22} developed an LED solar simulator with the ability to modulate certain wavelengths, Tan et al.^{23} implemented a wireless control for lighting systems that demonstrated high energy savings, and Burgos et al.^{24} developed a spectral LED-based tunable light source. Although some of these works achieve at first good quality results after long computational times, none of the proposed methods take into account spectral shifts due to temperature changes or wear out of the LEDs (a widespread and inevitable problem that affects all LEDs^{25}), and none of them includes a feedback control system to monitor the emitted light, a key issue if a high quality and long lasting light source is pursued. In the line of the present work, Chew et al.^{26} developed a spectrally tunable lighting system with eight channels and a closed-loop control. The algorithm developed by these authors proved to be also slow (more than 80 s for stabilization) and with a poor spectral fidelity (color difference within a five-step MacAdam ellipses^{27}), which limits its applicability in practical scenarios.

The aim of this work is to provide new control methods that offer both high spectral fidelity and short computational processing times. The first obstacle to surmount is the fact that the output spectrum in the devised applications is not static (i.e., for HCL applications the spectrum changes over the course of the day). Since time-dependent signals applied to the LEDs bring about a distribution of different junction temperatures (therefore causing spectral shifts and optical power variations), the problem of predicting the spectral output through heat transfer equations (compact modeling) becomes unmanageable. The inaccuracy of some of the parameters (junction thermal resistance as a function of temperature, thermal capacitance, emissivity of different materials, convection coefficients, etc.) is high, and the problem is far from equilibrium because the spectrum is continuously changing over time. Thus, a new sensor feedback approach borrowed from control theory has been adopted.

We have divided this study into two sections. The first section is devoted to the calculation of the pulse-width modulation (PWM) weights that best match a target spectrum by means of heuristic algorithms, never used in this field before. Results obtained by a genetic algorithm, a simulated annealing algorithm, and a Monte Carlo simulation have been tested and analyzed for the case under study. Once the PWM weights for the target spectrum have been calculated, a second section shows how a proportional integral-derivative controller system (PID) can be used to finely tune the PWM weights and compensate for small spectral changes in the LEDs, primarily caused by thermal junction variations or by the nonlinear response of the LEDs. The proposed algorithm can also be used to compensate for aging of the LEDs or even failure of a small number of LEDs.

## 2.

## Methodology and Results

## 2.1.

### What Is the Most (Time) Efficient Algorithm to Match a Target Spectrum by Using Combinations of LED Spectra Having Different Peak Wavelengths?

The tunable light source developed in this work has 48 commercial monochromatic LEDs (from Lumileds Luxeon C:^{28} Deep Red, Red, Amber, PC Amber, Lime, Green, Cyan, Blue and Royal Blue; and from Lumileds Luxeon Z UV:^{29} 425–430) arranged in 10 individual channels (a channel should be regarded as an arrangement of LEDs having the same peak wavelength), essentially spread all over the visible part of the visible spectrum (400 to 700 nm, see Fig. 1). The different radiometric powers for each individual channels are (from blue to red): 0.59, 0.59, 0.41, 0.38, 0.52, 0.32, 1.97, 1.66, 0.31, and 0.34 W.

A block diagram of the hardware can be found in Fig. 2. The control system is executed in a microcontroller in the light engine. The same microcontroller also handles the PWM signals, the communications, and the sensor acquisition system, which include readings from the power sensors, the temperature sensors, and the spectrometer. The PWM constant current driver has a resolution depth of 12 bit. The overall system is controlled with a Python 3.4 program and a PC (Intel i5, 8 GB RAM) through a serial communications system RS-485.

The communication driver accepts two methods to produce a desired spectrum associated to two different messages: (a) receiving a full target spectrum (81 two-dimensional float data points with wavelengths and radiant flux values) or (b) directly the channel PWM values to be set (10 integer values from 0 to 4095). When the first method is selected, the control system calculates the PWMs values that give rise to the best possible fit to the target spectrum. When the second method is selected, the PWM weights are previously calculated in the PC and then sent to the control unit. The minimum time between consecutive spectral update is 6 ms. The criteria for selecting the first or the second method eventually depend on whether an external server is available to perform the calculations for the application under consideration.

Once a target spectrum ${S}^{t}(\lambda )$ is set, fast optimization algorithms are required to efficiently find an optimal solution. An arbitrary spectrum can be represented by $S(\lambda )=\sum _{n=1}^{10}{A}_{i}{L}_{i}(\lambda )$, where ${L}_{i}(\lambda )$ and ${A}_{i}$ are the spectral flux (W/nm) and weighting amplitude of the $i$’th channel, respectively.

The error function used to estimate the spectral fidelity is the mean absolute percentage deviation (MAPD), measured for each wavelength $j$, and defined by Eq. (1) for a system of $K$ wavelength points (in our system $K$ is a linear array of 81 points, representing the wavelength range between 380 and 780 nm, in 5 nm steps):

## Eq. (1)

$$\mathrm{MAPD}=\frac{100}{K}\sum _{j=0}^{K}\left|\frac{{S}_{j}-{S}_{j}^{t}}{{S}_{j}^{t}}\right|.$$We have investigated three different heuristic approaches: (i) a genetic algorithm, (ii) a simulated annealing, and (iii) a Monte Carlo simulation. In all cases, the input parameter is the target spectrum to be matched, the known variables are the full set of LED channels’ SPD, and the unknown variables are the PWM weights that best fit the target spectrum, as dictated by the MAPD. The PWM weights are free variables that can be varied only in the range from 0 to 4095 (PWM has a 12-bit resolution). The algorithms were designed to stop when the situation was such that further iterations were not contributing to improve the MAPD result from previous iterations (convergence criteria). Succinctly, the results presented in this first part deal with MAPD minimization while keeping short computation times.

## 2.1.1.

#### Genetic algorithm

A genetic algorithm is a method inspired by natural selection principles that can be effectively used in optimization problems. This method includes concepts emerged from the well-known theory of evolution such as inheritance, mutation, selection, and crossover. Starting from a population of individual solutions (initial guess), the algorithm continuously modifies them and creates new solutions by crossing two of them together and applying random mutations. After several new generations, the system tends to evolve toward an optimal global solution, as supposedly biological species have done.

The basic workflow of our genetic algorithm is as follows:

1. Starting from a population of randomly generated solutions (called chromosomes), the error to the target is measured, and the best solutions are chosen and set apart.

2. New solutions are generated by combining (crossing) the previously selected solutions in pairs of two.

3. Randomly, a selected number of them are mutated to avoid falling into local minima.

4. Start over from step 2 until convergence to the desired solution is obtained.

## 2.1.2.

#### Simulated annealing algorithm

The simulated annealing was invented to generate sample states of thermodynamic systems. Given a random solution, it is slightly perturbed by adding or subtracting small amounts, and the error to the target solution is calculated. In case, the new solution improves the error of the previous iteration, the new weights are updated and the process continues over a loop. As the number of iterations increases, the strength of the perturbation is decreased to warrant a fast convergence to a solution. This algorithm handles local minima by giving a likelihood of accepting a solution even when it increases the error as compared to the preceding iteration.

The main steps of a simulated annealing algorithm are:

1. An array of random coefficients is generated and the error is calculated.

2. Perturbation of the currently accepted solution: a small random amount is added or subtracted to the initial array (in subsequent iterations the perturbation gets reduced).

3. The new error is calculated.

4. Start over from step 2.

## 2.1.3.

#### Monte Carlo algorithm

Monte Carlo methods are widely used in many branches of science. In our case study, an initial guess to the solution is multiplied by an array of random numbers, for which the magnitude is decreased in successive iterations until reaching convergence. For each iteration, the algorithm passes the best solution (lowest error) over to the next iteration to keep on refining the optimization process.

For a Monte Carlo simulation, the main steps are:

1. The initial guess is set to an array of 10 components with value 4095 (all LED channels set to full power).

2. An array with random numbers is generated (the magnitude of these numbers is decreased with increasing iterations). Afterward, the array is multiplied by the currently accepted solution array (weighting amplitudes).

3. The error is calculated for each array resulting from this multiplication, and the one with the lowest error is passed to the next iteration.

4. Start over from step 2.

## 2.1.4.

#### Computational time results

Table 1 shows the results obtained with the three different heuristic algorithms under study. In all cases, we used as target SPD: a D65 illuminant (CIE Daylight of $\mathrm{CCT}\simeq 6500\mathrm{K}$)^{30} because it is the standard accepted representation of natural daylight; an incandescent SPD as the most traditional lighting technologies ($\mathrm{CCT}=2636\mathrm{K}$); a white LED SPD as one of the latest lighting technologies ($\mathrm{CCT}=6464\mathrm{K}$); and the melanopic SPD, because ipRGCs are sensitive to this light spectrum and this is the mechanism that regulates our 24 h circadian clock. The outcomes relevant for our study are the MAPD to assess the spectral fidelity [Eq. (1)] and the computational time, defined as the time elapsed during the calculation of the PWM weights.

## Table 1

Heuristic methods comparison: a genetic algorithm, a Monte Carlo simulation, and a simulated annealing.

Target spectrum | Parameters | Genetic | Monte Carlo | Simulated annealing |
---|---|---|---|---|

Daylight D65 | Computational time (s) | 0.667 | 0.340 | 0.085 |

MAPD | 10.1 | 10.3 | 10.4 | |

Incandescent | Computational time (s) | 0.667 | 0.335 | 0.093 |

MAPD | 14.3 | 14.3 | 14.1 | |

Melanopic | Computational time (s) | 0.650 | 0.320 | 0.093 |

MAPD | 8.2 | 8.1 | 8.3 | |

White LED | Computational time (s) | 0.667 | 0.340 | 0.086 |

MAPD | 5.9 | 5.5 | 6.1 |

The three algorithms give comparable results in terms of spectral fidelity (MAPD), as can be seen in Table 1. However, the genetic algorithm was the most computationally intense while the simulated annealing was the fastest, by a factor of 7. This implies that the simulated annealing algorithm corrects the SPD at refresh rates of around $>10\text{\hspace{0.17em}\hspace{0.17em}}\mathrm{Hz}$, which assures a perfectly smooth real-time correction that is not perceptible to the naked eye. In contrast, the genetic and Monte Carlo algorithms operate at 1 to 2 Hz, which causes a nondesired visible glitch that can be perceived by the final user, making them unsuitable for real-life situations.

Figure 3 shows the SPD of the light engine for each target spectrum generated with the coefficients given by the simulated annealing algorithm (similar results are obtained with the other algorithms). The color difference was measured using the CIE 1976 ${L}^{*}$, ${u}^{*}$, ${v}^{*}$ (CIELUV) color space $({u}^{\prime},{v}^{\prime})$^{31} since it is a well-accepted metric for assessing the chromaticity of SSL products,^{32} and results are reported in Table 2. In all cases, it can be seen that the new generated color coordinates are very close to the target ones, being the difference in color $\mathrm{\Delta}{u}^{\prime}{v}^{\prime}<5\times {10}^{-4}$, which is way below the chromaticity deviation threshold recommended for SSL products.^{32}

## Table 2

Color coordinates difference (Δu′v′) between target/tuned SPD.

Daylight D65 | Incandescent | Melanopic | White LED | |
---|---|---|---|---|

$\mathrm{\Delta}{u}^{\prime}{v}^{\prime}$ | 0.0004 | 0.0005 | 0.0003 | 0.0002 |

## 2.2.

### (Computationally) Low-Demanding PID Controller for Accurate Spectral Fidelity Against Thermal Junction Variations and LED Luminous Flux Depreciation

As a consequence of either changes in the PN junction temperature or aging of the LEDs, the emitted SPD is always submitted to nondesired fluctuations (that can be at short or long time scales depending on whether the originating mechanism is temperature or aging). These changes may imply both depreciation in the luminous flux and/or wavelength shifts. Also, they are generally noticeable to the naked eye and worsen with aging of the LEDs. Furthermore, the PWM modulation may not follow a perfect linear relationship with power, which may induce further errors in the output spectrum, especially at low powers.

The printed circuit board (PCB) temperature increase during 1 h when the light engine is at 80% of its maximum power is exponential: it increases from room temperature (25°C) to 60°C. This is the typical time-scale of the temperature transient until the steady state is reached for this particular light engine, which means that a precise monitoring of the PWM weights must be done at a suitable refresh rate. These relatively fast changes in the temperature affect the overall performance of the system in the same time-scale.

Recently, several ultracompact spectrometers are appearing in the marketplace, making them suitable as feedback sensors for multichannel LED light engines that require accurate spectral compensation. In our prototype, a low-cost miniature spectrometer is included within the tunable LED light source and collects a small fraction of the emitted light after being mixed by the diffuser. This compact spectrometer consists of an entrance slit, a nanoimprinted grating to disperse the light, and a CMOS image sensor. The light is collected from the diffuser element where all the wavelength channels are mixed and are guided with a polycarbonate waveguide (with a flat transmission response in the visible range) to the entrance slit of the spectrometer. Since the light is gathered from the diffuser, we obtain a perfect color mixing that represents the mixing at the far field.

The on-board spectrometer is used as the sensing element for the PID control system. It takes real-time measurements of the color-mixed SPD emitted by the LED channels and detects if the spectral shape, color, and luminous flux have changed from the previous iteration. All the information is passed to the PID controller and new PWM weights for each channel are found until the calculated error is below an acceptable threshold. A schematic of the modeled system is shown in Fig. 4.

Each LED channel is governed by an independent PID control. However, given an SPD obtained with the spectrometer, it is not possible to separate out the contributions of each individual channel since a given spectral region is covered by multiple LED channels as seen in Fig. 1(b), so the system becomes overdetermined. To overcome this limitation, our method compares flux and wavelength shifts only at channel peak wavelengths, which are unique for each channel. This assumes that channels are independent and there is not cross-talk between them at the positions where the channels peak, which has been largely verified.

Each PID controller follows Eq. (2), where $u(t)$ is the signal, $e(t)$ is the current error (defined as the difference between the target and the output signal), ${k}_{p}$ is the controller path gain, ${T}_{i}$ is the integral time constant, and ${T}_{d}$ is the derivative time constant:

## Eq. (2)

$$u(t)={k}_{p}e(t)+\frac{{k}_{p}}{{T}_{i}}{\int}_{0}^{t}e(t)\mathrm{d}t+{k}_{p}{T}_{d}\frac{\mathrm{d}e(t)}{\mathrm{d}t}.$$Since we are working with a digital signal, Eq. (3) can be used instead of Eq. (2). The PID has three different proportional, integral, and derivative parameters. The integral part acts on accumulated past errors and the derivative part is a prediction of future errors that depends on the rate of change. The PID parameters are generally found following a trial/error process until a fast convergence with a low overshoot is obtained (in our system this tuning process resulted in values ${k}_{p}=0.5$, ${k}_{i}=0.5$, ${k}_{d}=0.1$):

where ${k}_{i}={k}_{p}/{T}_{i}$ and ${k}_{d}={k}_{p}{T}_{d}$.## 2.2.1.

#### Spectral PID control results

For the sake of comparison, Fig. 5 shows the time evolution (1 h) of the system with (a) the feedback off and (b) with the feedback on. The efficiency of the LEDs decreases as time goes by and there is also a decrease in flux in all parts of the SPD, which is stronger in the red region. Thus, color coordinates show a trend toward more bluish colors with a $\mathrm{\Delta}{u}^{\prime}{v}^{\prime}=0.010$, for the same period of time. The overall lumen depreciation may be higher than 10% when the feedback is off. Even if we are in a best case scenario where the spectrum is static and the time window is only 1 h, the observed color shifts and lumen depreciation would never be acceptable by the lighting industry.

When active, the implemented feedback monitors the system evolution and compensates for a possible lumen depreciation. Even more importantly, spectral shifts are detected and compensated to ensure a constant SPD over time despite changes in the overall LEDs temperature and efficiency. Hence, the difference between the emitted and target spectra is significantly reduced.

This behavior shows to be consistent over time: when a decrease in flux is detected, higher power is provided to those channels that maintain the flux constant. In this process, color coordinates may experience minor shifts but still are not visually perceivable ($\mathrm{\Delta}{u}^{\prime}{v}^{\prime}<2\times {10}^{-3}$). Since the controller is built on-board, there is minimal lag between signals, processing times are negligible, and the steady state is achieved after a few milliseconds and keeps stable after that. The overall lumen depreciation is less than 1% when the feedback is on.

To validate spectral errors, we have used an external spectrometer (CAS 120 by Instrument Systems). The local and immediate effect of the junction temperature can be corrected by monitoring the emitted light. Figure 6(a) shows the difference between the emitted spectrum and the target spectrum at different output powers. As can be seen, the relative error increases as the power decreases, which suggests that the input PWM signal (from 0 to 4095) is not linear with the output optical power. However, this nonlinearity can be corrected when the feedback control is active as shown (in terms of the MAPD and color differences) in Figs. 6(b) and 7, where the MAPD and $\mathrm{\Delta}{u}^{\prime}{v}^{\prime}$ are significantly reduced. The feedback control effectively corrects all these deviations [see Fig. 6(b)], preserving the target spectral shape for all output powers despite variations on temperature, aging, and presence of nonlinearities. It is worth noting that even with all these effects taking place, not only the spectral shape is kept constant within a small error but also the feedback mechanism preserves also the color point throughout the product lifetime within an absolute error below $\mathrm{\Delta}{u}^{\prime}{v}^{\prime}<0.0025$, which is way below the limit established by the lighting industry standards.^{32}

The method presented here is not dependent on the selected target spectrum and its use and effectiveness hold for any light spectra as well as for different implementations of the device, for example, by using more LED channels or different optimization algorithms to calculate the channel weights.

It is also worth noting that even though our algorithms ensure high precision and accuracy (refer to Tables 1 and 2), this is not a strict requirement for the overall method to work as desired since the spectral matching algorithms provide only an initial guess for the PID, which from this initial estimate uses real spectral measurements to iteratively correct the output. However, because changes in color and/or flux may be perceived during transition times between iterations (especially if the first guess is far from the optimal result), it is better to begin with a good enough initial estimate to build upon.

## 3.

## Conclusions and Future Work

LED engines with added intelligence and spectral awareness offer great possibilities to create healthier living spaces by having a complete control over the full visible spectrum. The methods developed in this work provide tools and offer robustness to SSL tunable light sources that can be used to boost different applications in lighting, automobiles, transportation, communication, imaging, agriculture, or medicine. The methodology presented may be applied to lamps with any number of channels, from a simple red-green-blue, red-greed-blue-amber-white, or more complex 10-channel engines as the ones studied in this work.

We have shown two different methods that may be used to generate arbitrary SPDs using multichannel LED engines. In the first part, we performed an in-depth study of different heuristic algorithms that can be used to find the channel weights that best match a target SPD. Results showed that the simulated annealing algorithm gives excellent results with regards to spectral fidelity while at the same time involving extremely low computation times. In the second part, we implemented a closed-loop control system to monitor and correct spectral deviations in the emitted light and to compensate for spectral shifts due to temperature changes or depreciation of the LEDs. We demonstrated a reliable and robust method that is able to keep an emitted spectrum constant and stable over time.

Many applications (i.e., medicine, agriculture, imaging, and museum lighting, among others) are in need of highly accurate light spectra that do not produce undesired shifts or optical power variations over time. Our methods set a general framework for multichannel SSL systems and the results and conclusions achieved are universal, which means that they can be applied to different systems and lighting technologies.

The methods presented here minimize the MAPD difference to a target spectrum. This approach assumes that as the MAPD decreases so does the color difference $\mathrm{\Delta}{u}^{\prime}{v}^{\prime}$. Even though this holds true for most of the cases, it is out of the scope of this work to provide methods that improve the color difference of the emitted light independently of the spectral shape. Potentially, the color difference could also be controlled with other heuristic algorithms specially designed to minimize the $\mathrm{\Delta}{u}^{\prime}{v}^{\prime}$. As a future work,^{33} due to the cost associated with current miniature spectrometers, it will be helpful for the research community to develop an implementation of a joint spectral/color correction algorithm with a new type of CIE 1931 XYZ color sensor (which is much cheaper) embedded in the light engine in substitution of the more costly spectrometer. This would allow our methods to scale up and be directly applicable to the general lighting market, which is so far more cost-driven than technology-driven.

## Acknowledgments

This research has received funding from the European Union’s Horizon 2020 Research and Innovation Programme, under Grant No. 766792; from the European Union Seventh Framework Programme, under Grant No. 619912; from the Government of Catalonia, under Grant No. 2015 DI 081 (Pla de Doctorats Industrials); and from the Government of Spain, under Grant No. DI-14-06883 (Plan Estatal de Investigación Científica y Técnica y de Innovación). The authors have no conflict of interests in the manuscript and no other potential conflicts of interest to disclose.

## References

## Biography

**Aleix Llenas** received his BS degree in physics from the University of Barcelona and his MS degree in photonics from the Universitat Politècnica de Catalunya. He has worked in several international research projects in optics, photonics, and nanotechnology. He also worked in the NTT—Nippon Telegraph and Telephone Corporation in Japan before joining the Catalonia Institute for Energy Research (IREC), where he is conducting research with multichannel LED light engines in collaboration with the R&D team at Ledmotive Technologies.

**Josep Carreras** received his BS, MS, and PhD (cum laude, honors) degrees in physics from the University of Barcelona, Barcelona, Spain. He has authored over 40 articles in several SCI journals, holds two patents, and has participated in more than 15 different projects at the national and international levels. He is also the president, founder, and chief technology officer of the spin-off Ledmotive Technologies. Since 2009, he has been with the IREC, Barcelona, as the leader of the Lighting Group, where he leads research on concepts for energy efficient lighting, color science and technology, simulations, photometry, and intelligent lighting with advanced communication and computation functionalities. He supervises several national and European projects in close collaboration with industrial partners.