List of related posts
- [Dynamic Living-room Lights] Description
- [Dynamic Living-room Lights] Simple System Design
- [Dynamic Living-Room Lights] The YUN review - When the Penguin Met The Arduino.
Prelude
LED stands for Light Emitting Diode and it is a Semiconductor Device which when forward biased, produces light. The LED is predicted to replace all light bulbs etc since it consumes less power and offers a more compact product. The heat produced is also less at the same brightness compared to other sources. But unlike traditional bulbs, the LED cannot be simply plugged into a wall socket. It runs on a lower voltage and in order to elongate its life AND do some brightness control etc, we need a circuit which is called an LED drivers. This document is a review of the Infineon LED driver Shield which can be controlled by an arduino and is useful for a lot of projects.
LED Driver?
Just like a normal diode, we can plot the current and voltage characteristics of LED. I googled it and came up with the following.
http://www.electronics.dit.ie/staff/tscarff/DT089_Physical_Computing_1/LEDS/LED_Characteristics.gif
It is easily seen that after a certain voltage, as the voltage is increased, the current increases drastically. Larger current equal to a larger brightness change..This can also cause heat dissipation by
P = R x (I^2) = V x I
which means I can blow up my LED quite easily. I need a way to control the current through the LED and keep the current at a constant value. So how can I do that? The simplest way I have been making constant current sources has been the LM317 and the circuit looks like...
The 1.25 is due to the internal reference but I wont go into the details because the problem here is that this circuit is based on a linear regulator and is not very efficient nor does it offer digital control.
So how else can I control the current? The simple answer is PWM.
PWM Stands for Pulse Width Modulation and simply put, we switch the LED ON and OFF really quickly for a variable duration of time. The longer we switch it on, the longer the current flows and larger the average current and brighter the LED. Take a look at the image below.
(http://www.electronics-tutorials.ws/diode/diode44.gif)
So my arduino can do that by default. There are PWM modules in built right? So whats wrong with that? Well you can switch the LED ON and OFF using the Arduino and you could probably do it using say a 555 in an astable mode too. I have used this circuit for some time now where I need variable brightness of the LEDs
For a circuit explanation see the video below
The problem with using the 555 is the switching speed. The slower the switching, the more prone to flicker in the LED. The second problem which is common with the arduino switcher is that we have no way of knowing what current is being drawn. Remember we need a constant current and if say one of the LEDs is shorted out, then we have no way of knowing about it and it might even damage the MOSFET. Yikes!
The solution is adding a small resistor say 1 Ohm in series with the LED and then use an Op-AMP to monitor the voltage across it. By Ohms law, if there is a drop of 1 volt across the resistor then there must be 1 amp flowing through it! We can read it using an analog pin and then do that for every LED strip and then... aawwwhh. Thats a lot of work!
The LED driver shield simplifies this process.
What is the XMC1202?
The XMC1202 is an ARM Cortex-M0 based micro-controller which has a dimming control peripheral for LED lighting applications, known as the Brightness and Colour Control Unit (BCCU). It contains 3 independent dimming engines and 9 independent Pulse Density Modulated (PDM) channels. 1 dimming engine and 6 channels are used in this shield.
What!?
Its an ARM Cortex-M0 core with some dedicate for control of LEDS and ADCs to measure the currents like I said before. The block diagram of the Chips is given below.
Whats the BCCU?
Take a look at this...
This is a slide from http://www.infineonic.org/download/index.php?act=down&id=4166 and is a presentation on the BCCU itself. The point here is that the ADC needs to sample current at the right time and needs to be fast enough. The XMC1202 can do a lot more as well but for people who just want to control the LEDs using an arduino, Infineon put the chip on a circuit, write a firmware on the processor and made it an I2C slave.
If you want to program the XMC1202 there is great tutorial by shabaz sir at
RGB LED Shield from Infineon - Getting Started Guide
The RGB LED Shield
The RGB shield has the XMC1202 IC as well as the required circuitry to drive LED successfully. The circuit looks like...
Not much to talk about here. Its the same circuit I have discussed and the DMX section is something not mounted nor reviewed. What we can discuss is that the shield uses only 4 pins from the arduino which are voltage, GND, I2C_SCL and I2C_SDA and I can even drive this using my BusPirate. There is some ready code for the shield and I have attached the example code below.
Understanding the commands
The user guide has a long table of commands that can be used to control the shield and the LEDs attached. We will take a look at a subset of the commands and how to use them. In order to send these commands to the shield we can write our own functions but the demo code has ready functions. These are essentially running the I2C peripheral on the Arduino so I will use them directly. There are a number of reasons why I want to do this.
Firstly, these are tested functions so it will reduce my prototying time. Secondly, I will probably wrap these functions in other functions which will have a more simplistic interface. In the days of C based network programming, I was taught to write these wrapper functions to reduce complexity but it has a second advantage. If I decide to change my platform to say a Launchpad, then I will write my own I2C driving code in Code Composer and wrap it with the same function as my arduino code. That way I dont need to modify my calling code and the transition becomes simpler. This is standard practice when writing protocols and I picked it up when I wrote my first MODBus Client on an 8051. Now I do this most of the time since I will change the platform at will depending upon the cost of the final product I am building and this means my code is reusable across products.
OK Back to the Commands. The first command is intensity which is intensity...
Simply put, the intensity is a 12 bit value which can be changed by calling ..
This is simple enough... so what else?
Peak Current Control.
This is important when you know your LEDs cannot handle more than a specific current. The system is as follows and is explained as well.
This is means I can set the max current by...
Another parameter is the Walk Time which is used to smoothly change the colour intensities. The intensities change linearly over time. Take a look.
The last thing I want to highlight is the dimming level. We discussed intensity but...
"The dimming engine in the XMC1202 microcontroller on-board the RGB LED Shield performs dimming along a pseudo-exponential curve so that the change appears natural to the human eye. This compensates for the eye’s logarithmic sensitivity to light." ... "The brightness value of a channel and therefore the brightness of the connected LED string, is the product of the intensity of the respective channel and the dimming level divided by 4096.
The dimming engine which controls the dimming level is separate from the BCCU channels. This enables the RGB LED shield to control the colour of the LED strings separately from the lamp brightness. The brightness level of the lamp can stay the same while its colour changes. Changes in brightness do not affect the colour of the lamp either."
FROM THE USER MANUAL...
Simply put, intensity and dimming are associated with changing the color without changing the brightness of the RGB LED and vice versa. Pretty neat! I encourage you to explore this concept to actually see the effect in practice.
There are some commands to read the values as well but I won't need them unless I am facing some color problems.
Tests
I did some basic tests with the shield but I need to do a lot more to report something. I am using this in my project which will be submitted soon and you can judge if the shield does a good job or not.
I will link up more associated posts here as I get them done. For now enjoy the holidays.
Cheers,
IP
Top Comments