L.A.S.S.I.E — LED Controller

LED Automation System Supporting Infrared or Ethernet

 

0. Overview

This project was inspired by Adafruit’s RGB LED strips and Sparkfun’s IR sensor. I had purchased the LED strips a while ago from Adafruit with the intention of putting them under my desk at work to give my cube a unique look. Everybody at work loved them, and it really gave me motivation to figure out how to make the effect even better and easier to use. Suddenly it hit me; if I could figure out how to use IR to control the color, then any TV remote control could be used! This way if friends/family wanted their own LASSIE, they wouldn’t have to keep track of yet ANOTHER remote control (who hasn’t lost the TV remote in the couch before!).

The journey began with purchasing the Sparkfun IR sensor board and hooking it up to an Arduino which was driving 3 MOSFETS (per recommendation of Adafruit). Everything was going smoothly until I noticed that on certain colors I was getting a pulsing effect. After further investigation I discovered that the Arduino PWM timers only handle 2 pins at a time, and with 3 colors needing PWM, I was unknowingly using 2 different internal timers.

I looked into the PWM issue and found that digital pins 5,6,9, and 10 all seem to be in phase with the same PWM frequency. Pins 3 and 11 are in phase and have the same frequency (but what appeared to be almost double the PWM frequency of 5,6,9, and 10). I was using pins 3,5, and 6 to control the LEDs at first. I found more detail by Arduino here: “The ATmega328P has three timers known as Timer 0, Timer 1, and Timer 2. Each timer has two output compare registers that control the PWM width for the timer’s two outputs: when the timer reaches the compare register value, the corresponding output is toggled.” I decided to check this out on my oscilloscope by uploading a sketch to my UNO that set all 6 PWM pins to a value of 125:

 

DS1ET152009421_1

Pin 3 is the top waveform and Pin 5 is the bottom

 

DS1ET152009421_2

You can see the PWM frequencies are almost the same (~481 Hz vs ~490 Hz)

DS1ET152009421_3

Here is Pin 3 and Pin 11

DS1ET152009421_4

And finally Pin 5 against Pin 9 (looked the same for Pin 10 against Pin 11 and was in phase with Pin 5 and Pin 9)

Just about the time I had figured it all out I saw Adafruit carrying their PCA9685 breakout! Bingo! That chip is a little bit overkill (only needed 3 out of the 16 channels) but it would take care of the phasing issues! Now knowing that 5,6,9, and 10 are in phase I could have used those instead, but ultimately the PCA9685 has better resolution and with the increased number of outputs allows for easy expansion in the future. I had to modify the code a bit to work with the breakout (Adafruit’s library saved the day) and everything came together as I had imagined.

I wanted to take it a step further and, using an Ethernet Shield or Ethernet Arduino, control the color over a network. This way multiple “nodes” could be connected to a network and a central controller (Rasp Pi) could be used to change the color of any node based on some kind of input (maybe a user keypad or even change the color based on the temperature outside). The code to do this was written and it tested out well. The only problem is I wanted the Arduino to have the capability to be controlled through IR or over the network. I started running into problems with the code getting stuck in loops when there was no network connection present. I’m still working on ironing out the bugs for this phase of the project, but if you want the Ethernet code I’ll be happy to release it to my github!

1. Install the Arduino IDE

Head on over to the Arduino Website to download the Arduino IDE.

2. Install the libraries

Once the Arduino IDE is installed it should have created an Arduino folder in your “Documents” directory (aka My Documents). Within the Arduino folder there should be a “libraries” directory.  You will need to copy the 2 needed libraries into the “libraries” directory; the modified Adafruit PWM driver library and the IR remote library.  NOTE: the Arduino software is very picky about the naming convention of the folders in the libraries directory, and ironically most of the time I’ve downloaded additional libraries the folder name contains characters that the Arduino software won’t recognize. A good rule to follow is don’t use folder names that contain dashes or underscores.

You can find Ken Shirriff’s IR remote library here:
https://github.com/shirriff/Arduino-IRremote/
(click on “Download Zip” on the lower right side of the window then extract its contents to the IR remote folder under your “libraries” directory).

Here is the modified Adafruit library:
https://github.com/Echoskope/Adafruit-PWM-Servo-Driver-Library
(
same as above; click on the “Download Zip” button.)

 

3. Upload the code to the board

Download the Arduino sketch here:
 https://github.com/Echoskope/LASSIE_IR_ONLY 

Adafruit has some really good tutorials for Arduino beginners:
http://learn.adafruit.com/lesson-0-getting-started/overview

 

 

4 . How to use LASSIE

Key Commands:
0 = Enter
1 = Scene 1
2 = Scene 2
3 = Scene 3
4 = Scene 4
5 = Scene 5
6 = Scene 6 / Party Mode (depending on the code you upload)
7 = RED Select
8 = GREEN Select
9 = BLUE Select
Volume Up = Increase color intensity (after pressing 7, 8, or 9)
Volume Down = Decrease color intensity (after pressing 7, 8, or 9)
Channel Up = Increase scene intensity
Channel Down = Decrease scene intensity
Power button = fade in from complete off to last scene or fade out from current scene to complete off

Operation:
Press 1 – 6 to activate the scene
Current scene will stay in place while new scene fades in
To edit scene, press 7 – 9
Use the Volume up/down to adjust the colors
To save scene, press 0
Lights will blink once to signify a good save
Press any key other than 7 – 9 or 0 to exit this mode
To turn the lights on to the last used scene
Press the power button
To turn the lights off
Press the power button

 

 

5. Schematic and Layout

Schematic_top

Layout_top

3D_model_2

3D_model

Included in the 3D images are the custom acrylic mounts I designed for an Arduino. The idea behind them is you can attach velcro to the underside and make it super easy to attach an Arduino to different surfaces.

IMAG1544

IMAG1541

IMAG1545

5 . The Custom Acrylic Arduino Mounts

LASSIE Acrylic Mounts, LH_REV A

LASSIE Acrylic Mounts, RH_REV A

 

 

Here is a link to a PDF that is a higher resolution:

LASSIE Acrylic Mounts_REV A

Here is the hardware I used to make the mounts:

2522A663 General Purpose Tap, Starting (taper), 2-56 Thread Size
2901A225 Gen Purp Black-oxide Hss Jobbers’ Drill Bit, Wire Ga 50, 2″ Oal, 0.9″ Drill Depth,135 Deg Point
93505A855 Aluminum Male-female Threaded Hex Standoff, 3/16″ Hex, 1/4″ Length, 2-56 Screw Size
91735A007 Type 316 Ss Pan Head Phillips Machine Screw, 2-56 Thread, 3/16″ Length

 

 

6 . The future of LASSIE

As of right now I don’t have any plans on taking the LASSIE shield any further. I did this project mostly as a learning experience, and until I find a need for such a device I have moved on to other projects that have caught my interest.

If you have any questions or want to make your own LASSIE shield and need the schematic/layout files (which were made in Altium) feel free to email me: andrew [at} andrewbaker {dot] me

© 2014 - Brain Overload. All Rights Reserved. Powered by Wordpress and Design by We Create Web Designs