What is the reason for this?
Earlier this year I had a plain idea, and then I decided to make it more fun. What if I had an RGB led stripe to make some nice ambiance in my car...no... not strikink enough... Wait, why not make it change color every time I press the clutch. That would be something quite unique, random colors changes makes for an imaginative environement! So I let this idea aside for some months and as winter came so did the interest to make it come to life.
|What it looks installed in the car|
Here is a poor video showing the device in action
Theory of operation (RGB LEDS and pulsewidth modulation)For those not familliar with RGB led stripes, it is quite simple there is 3 leds X some distance(ex 2m), Red, Green, Blue. by adusting the voltage fed to each of those 3 channels we can produce a chosen color. To do this my device emits a constant frequency, what makes the color is that the pulse widht vary according to each channels. This in turn power each channel to a certain level and can produce a color predicted in the software.
|My christmass tree for 2013|
|Comparison of 2 colors being produced by the same device|
How it is done Hardware side
|LPC1115 ,the led Drivers on the prototyping area of the LPC board, and the 5v power supply|
I currently use NXP LPCXPRESSO boards for my MCU projects so it had to use one.
The LPC1115 was chosen because:
1) it comes with it's own programmer/debuger attached,
2) it's price as a dev board is not too high IMO.
3) it's processing power and built-in features is also interesting in other projects, reusability was in mind.
4) C programming Language, personal preferences I guess....
5) The eclipse Based IDE is easy to get along if you already know eclipse for other programming tasks.
6) Building and installation of software on this board can be done by people with little electronics or programming knowledge.(might make a tutorial on this at sometime)
LED stripe would be a 3 channels 12v 2meters unit.
3 x TIP122 as switching transistors would be used to control how long each Color would be powered.
Appropriate resitors would be used between the LPC1115 and the TIP122, this is necessary to make the transistor work as a switching transistor. 10k ohms was the value that worked for my LEDs stripe. with varying lenght of LED stripe and power consumption the resistor values should vary...
An instantaneous switch would be used to trigger the color change. this switch would have to be debounced with a pull-down resistor so that it does not trigger unexpectedly(*it might not even suffice if the switch used is really crappy)
A 2.2k ohms resistor was used to do the pull-down work on the switch.
A USB adapter for the car that connect in the cigarette lighter was dismantled and used as a "clean" 5v dc power source coming from a 12v dc environement (this device is made to work in a car, remember;) )
A plastic case and a 9 pin connector was used to protect and make installation/removal easier
*the JTAG debugger is the left half of the LPC1115 PCB, it can be cut out, by doing this one person cannot power it's LPC1115 from the JTAG debugger usb connector, it cannot reprogram the device unless it is connected again.
this JTAG debugger does takes room in this particular project, but with possible reusability in mind and further features addition I decided to keep the JTAG debugger in place and live with the extra room necessary for it.
Power does not come from A USB cable connected to JTAG and to a 12V->USB adapter, for this project I choosed to power the LPC1115 directly on the board (yellow and green wire coming from the lower PCB in the picture) when programming the device turn off power from this source
LEDs driver shematics
4 pins on the LPC1115 are used,
Red channel is controled by Port 0 pin 7
Green channel is controled by Port 1 pin 8
Blue channel is controled by Port 0 pin 6
Button input comes from Port 0 pin 10
How it is done Software side
the software that controls the Transistors was written with the LPCXpresso v5.1.2 IDE.
it is a C program that choose at random a color when it starts. then enter an infinite loop where it checks if the button was pressed and generate another random color that will be used.
two 32b timers are used together to produce a frequency not visible to the eye and the pulse width control.
Things to learn from this C program
-Analog Input readings
-Random numbers generation on a Microcontroller with no feature built-in ( Uses floating ADC pins for initialization)
-Working with 32b timers
-Working with GPIO input and output
this program CAN be improved.A better design using more built-in features of the LPC1115 could be made to control the frequency and pulsewidth.
Download the project files
Any feedback is welcome.