TI MSP430G2 Christmas Light Thingie
by vicvelcro in Circuits > Microcontrollers
6832 Views, 6 Favorites, 0 Comments
TI MSP430G2 Christmas Light Thingie
As is always the case, the holiday snuck up on me. I don't have enough time left to untangle the lights - much less put them up. But, with family dropping by to snag their swag, I had to figure out some means to make it appear that I am in the spirit of the season. The spirits in my cabinet don't count.
I remember that I had one RGB LED left over from some other thing I put together some time ago. Hey, red and green are holiday type colors! I rooted around in the spare parts containers and easily came up with enough stuff to make a fiber optical light changing whatchacallit to illuminate the glass blocks at my front door. Wow, no need to even go outside.
Because I have it running from a battery pack, I can snatch it up and take it with me shopping or restauranting or wherever! The Launchpad, breadboard, and battery pack combined all fit in the palm of my hand or in my shirt pocket.
I remember that I had one RGB LED left over from some other thing I put together some time ago. Hey, red and green are holiday type colors! I rooted around in the spare parts containers and easily came up with enough stuff to make a fiber optical light changing whatchacallit to illuminate the glass blocks at my front door. Wow, no need to even go outside.
Because I have it running from a battery pack, I can snatch it up and take it with me shopping or restauranting or wherever! The Launchpad, breadboard, and battery pack combined all fit in the palm of my hand or in my shirt pocket.
Tools, Materials, Parts
To get this project going, I used the following. Maybe you will, too.
Tools and Material
Soldering Iron
Solder
2 Pins from .100" Male Header
Tweezers
Magnifying Glass
Assorted Length Jumper Wires
270 Hole Breadboard (some people call it a half breadboard)
Parts
(1) Stranded FiberOptic Cable (Length based on your preference) (I forget where I got this, ages ago)
(1) Texas Instruments MSP430G2 LaunchPad
(1) LM7805 Voltage Regulator
(1) 10 microfarad 35VDC Tantalum Capacitor
(1) 100 microfarad 35VDC Aluminum Electrolytic Capacitor
(1) 2.1mm Power Connector
(1) RGB LED common cathode
(1) White LED - this is optional (I use it so I can tell the device is still running the loop)
(3) C945 (or equivalent such as 2N3904) NPN Transistors
(3) 2.2k to 2.7k Resistors (anywhere in there is fine) - for R1 to R3
(1) 68 Ohm Resistor - for the red part of the RGB
(2) 10 Ohm Resistors - for the green and the blue part of the RGB
(1) 270 Ohm Resistor - omit this if you don't use the white LED
For the resistors, you may consider just buying one single multipack. You'll end up with the values you need without having to buy 100 of each value.
Tools and Material
Soldering Iron
Solder
2 Pins from .100" Male Header
Tweezers
Magnifying Glass
Assorted Length Jumper Wires
270 Hole Breadboard (some people call it a half breadboard)
Parts
(1) Stranded FiberOptic Cable (Length based on your preference) (I forget where I got this, ages ago)
(1) Texas Instruments MSP430G2 LaunchPad
(1) LM7805 Voltage Regulator
(1) 10 microfarad 35VDC Tantalum Capacitor
(1) 100 microfarad 35VDC Aluminum Electrolytic Capacitor
(1) 2.1mm Power Connector
(1) RGB LED common cathode
(1) White LED - this is optional (I use it so I can tell the device is still running the loop)
(3) C945 (or equivalent such as 2N3904) NPN Transistors
(3) 2.2k to 2.7k Resistors (anywhere in there is fine) - for R1 to R3
(1) 68 Ohm Resistor - for the red part of the RGB
(2) 10 Ohm Resistors - for the green and the blue part of the RGB
(1) 270 Ohm Resistor - omit this if you don't use the white LED
For the resistors, you may consider just buying one single multipack. You'll end up with the values you need without having to buy 100 of each value.
The LaunchPad by Texas Instruments
This little baby can stand in for an Arduino much of the time. The price ($4.30 USD) really makes this choice a no-brainer for this project.
The MSP430 LaunchPad operates at 3.3v (not 5.0v like the Arduino) and can be supplied via USB 5.0v which goes through an onboard 3.3v regulator or with 3.3v directly to the Vcc and GND pins of the LauchPad at J6 or J4.
I added 2 pins near the USB input, so I can directly feed or tap 5.0v via external connection. The LaunchPad does not have pins at this location, it has holes that were never populated. I fixed it.
The two holes are not spaced for .100" headers, so I pulled two pins from a male header and then soldered them to the LaunchPad. The pin nearest the board edge is ground and the other pin is for 5.0v+DC.
I use DuPont style jumpers for breadboarding my LaunchPad because it was manufactured with male pin headers on the rest of the board, so I put pins near the USB just to be consistant. However, if you already have (or converted your LaunchPad to) female headers elsewhere on your board and use standard double-ended jumper wires for breadboarding, you may solder female pin headers to the LaunchPad near the USB, instead.
The jumpers TXD, RXD, RST, and TEST, at J3 can be removed to conserve power, if running on a battery pack. The sketch does not use those features. The VCC jumper at J3 must remain in place, unless you will be supplying a regulated 3.3v via J6 or J4. If you choose to use J6 or J4, you can remove all the jumpers at J3.
The 3.3v at the LaunchPad pins is insufficient to properly drive green or blue of my RGB LED (which has a forward voltage of 3.5 for green and blue). The LaunchPad also is not designed to feed the amount of current consumed by the RGB LED (LaunchPad is fine for 10 milliamps but the LED wants 30 milliamps or more for each color). But it is enough to bias a few transistors at about 2 milliamps each...
I needed to feed 5.0v to the breadboard circuit, so I incorporated a regulator LM7805 and put the output to the rails of my breadboard. The LaunchPad taps that voltage, since it would be silly to power it from USB when voltage is already available. The LaunchPad steps the 5.0v down further to 3.3v through the built in regulator of the LaunchPad. The breadboard rails also feed 5.0v to the transistors I used for driving the RGB LED. I am supplying the regulator with 9.0v from a six-pack of AA NiMH cells.
I put fiber optic cable from the RGB LED to glass blocks beside my front door so the blocks would be illuminated. I put the entire assembly inside an empty coffee can and fed the fiber optic through the lid and routed it directly to the glass blocks.
The MSP430 LaunchPad operates at 3.3v (not 5.0v like the Arduino) and can be supplied via USB 5.0v which goes through an onboard 3.3v regulator or with 3.3v directly to the Vcc and GND pins of the LauchPad at J6 or J4.
I added 2 pins near the USB input, so I can directly feed or tap 5.0v via external connection. The LaunchPad does not have pins at this location, it has holes that were never populated. I fixed it.
The two holes are not spaced for .100" headers, so I pulled two pins from a male header and then soldered them to the LaunchPad. The pin nearest the board edge is ground and the other pin is for 5.0v+DC.
I use DuPont style jumpers for breadboarding my LaunchPad because it was manufactured with male pin headers on the rest of the board, so I put pins near the USB just to be consistant. However, if you already have (or converted your LaunchPad to) female headers elsewhere on your board and use standard double-ended jumper wires for breadboarding, you may solder female pin headers to the LaunchPad near the USB, instead.
The jumpers TXD, RXD, RST, and TEST, at J3 can be removed to conserve power, if running on a battery pack. The sketch does not use those features. The VCC jumper at J3 must remain in place, unless you will be supplying a regulated 3.3v via J6 or J4. If you choose to use J6 or J4, you can remove all the jumpers at J3.
The 3.3v at the LaunchPad pins is insufficient to properly drive green or blue of my RGB LED (which has a forward voltage of 3.5 for green and blue). The LaunchPad also is not designed to feed the amount of current consumed by the RGB LED (LaunchPad is fine for 10 milliamps but the LED wants 30 milliamps or more for each color). But it is enough to bias a few transistors at about 2 milliamps each...
I needed to feed 5.0v to the breadboard circuit, so I incorporated a regulator LM7805 and put the output to the rails of my breadboard. The LaunchPad taps that voltage, since it would be silly to power it from USB when voltage is already available. The LaunchPad steps the 5.0v down further to 3.3v through the built in regulator of the LaunchPad. The breadboard rails also feed 5.0v to the transistors I used for driving the RGB LED. I am supplying the regulator with 9.0v from a six-pack of AA NiMH cells.
I put fiber optic cable from the RGB LED to glass blocks beside my front door so the blocks would be illuminated. I put the entire assembly inside an empty coffee can and fed the fiber optic through the lid and routed it directly to the glass blocks.
The Schematic
My specific choice of capacitor values for the regulator branch were chosen simply because I use that same configuration for so many other circuits. It is simply my standard. You don't have to replicate it exactly the way I have it.
Note that the capacitor microfarad values for the regulator branch can be substituted with other values, but the VOLTAGE rating needs to be twice as high as any wall wart you would plug in or any other voltage source you would supply. For instance, the 10microfarad tantalum *could* be a 1microfarad aluminum electrolytic but keep it at 35VDC rating if you will, or might ever, use a 12v wall wart (some of them do peak at 17v). The 100microfarad at the regulator output needs to be at least 10x the microfarad value of the input capacitor and the voltage rating should be at least 10VDC but 35VDC is safer (in case of a circuit fault).
I attempted to fritz this, but the application gets in its own way. I love Fritz but Fritz hates me. I wasn't able to place some of the parts. Also, some of the appropriate component values were not available. Avoiding confusion and conflicts between a fritz with improper substitutes and a schematic with proper values seemed pretty important to me.
Meanwhile, enjoy my beautiful "gall on papier" representation of the connections.
If anyone wants to give fritzing a go and send it to me, I'll post it here and give you proper recognition.
Note that the capacitor microfarad values for the regulator branch can be substituted with other values, but the VOLTAGE rating needs to be twice as high as any wall wart you would plug in or any other voltage source you would supply. For instance, the 10microfarad tantalum *could* be a 1microfarad aluminum electrolytic but keep it at 35VDC rating if you will, or might ever, use a 12v wall wart (some of them do peak at 17v). The 100microfarad at the regulator output needs to be at least 10x the microfarad value of the input capacitor and the voltage rating should be at least 10VDC but 35VDC is safer (in case of a circuit fault).
I attempted to fritz this, but the application gets in its own way. I love Fritz but Fritz hates me. I wasn't able to place some of the parts. Also, some of the appropriate component values were not available. Avoiding confusion and conflicts between a fritz with improper substitutes and a schematic with proper values seemed pretty important to me.
Meanwhile, enjoy my beautiful "gall on papier" representation of the connections.
If anyone wants to give fritzing a go and send it to me, I'll post it here and give you proper recognition.
The Sketch
//This sketch is written for the 2553 chip. Other chips support different pin configurations.
//The PWM and number of available timers is not the same from chip to chip.
//
//Note that if you have the XIN and XOUT populated with a crystal or oscillator, you can not use
//pin P2_6 for the RED of the RGB. Leave out the White LED and put the RED on pin P2_1 and
//change the appropriate line(s) in the sketch.
//
//These are the PWM pins I used. They are not on the same timer,
//so not all color combinations are available for PWM concurrently. All primary
//combinations are available for full OFF and full ON (digital HIGH and LOW, but not PWM).
//
//If this is being used for Arduino, the pins will definitely need reassignment.
#define GREEN P2_4
#define BLUE P1_6
#define RED P2_6
#define WHITE P2_1
#define delayTime 10
void setup() {
pinMode(GREEN, OUTPUT);
pinMode(BLUE, OUTPUT);
pinMode(RED, OUTPUT);
pinMode(WHITE, OUTPUT);
digitalWrite(GREEN, LOW);
digitalWrite(BLUE, LOW);
digitalWrite(RED, LOW);
digitalWrite(WHITE, LOW);
}
int redVal;
int blueVal;
int greenVal;
void loop()
{
delay(250);
redVal = 0;
blueVal = 0;
greenVal = 0;
for( int i = 255 ; i > 0 ; i -= 1 ){
redVal += 1;
analogWrite( RED, redVal );
analogWrite( BLUE, blueVal );
analogWrite(GREEN, greenVal );
delay( delayTime );
}
redVal=0;
greenVal=0;
for( int i = 0 ; i < 255 ; i += 1 ){
greenVal += 1;
analogWrite( GREEN, greenVal );
analogWrite( RED, redVal );
delay( delayTime );
}
greenVal=0;
blueVal=0;
for( int i = 0 ; i < 255 ; i += 1 ){
blueVal += 1;
analogWrite( BLUE, blueVal );
analogWrite( GREEN, greenVal );
delay( delayTime );
}
digitalWrite(RED, LOW);
digitalWrite(GREEN, LOW);
digitalWrite(BLUE, LOW);
delay(500);
for (int i = 0; i < 5; i +=1 ){
digitalWrite(RED, HIGH);
digitalWrite(GREEN, LOW);
digitalWrite(BLUE, LOW);
delay(250);
digitalWrite(RED, LOW);
delay(250);
}
for (int i = 0; i < 5; i +=1 ){
digitalWrite(RED, LOW);
digitalWrite(GREEN, HIGH);
digitalWrite(BLUE, LOW);
delay(250);
digitalWrite(GREEN, LOW);
delay(250);
}
for (int i = 0; i < 5; i +=1 ){
digitalWrite(RED, LOW);
digitalWrite(GREEN, LOW);
digitalWrite(BLUE, HIGH);
delay(250);
digitalWrite(BLUE, LOW);
delay(250);
}
for (int i = 0; i < 5; i +=1 ){
digitalWrite(RED, HIGH);
digitalWrite(GREEN, HIGH);
digitalWrite(BLUE, LOW);
delay(250);
digitalWrite(RED, LOW);
digitalWrite(GREEN, LOW);
delay(250);
}
for (int i = 0; i < 5; i +=1 ){
digitalWrite(RED, HIGH);
digitalWrite(GREEN, LOW);
digitalWrite(BLUE, HIGH);
delay(250);
digitalWrite(RED, LOW);
digitalWrite(BLUE, LOW);
delay(250);
}
for (int i = 0; i < 5; i +=1 ){
digitalWrite(RED, LOW);
digitalWrite(GREEN, HIGH);
digitalWrite(BLUE, HIGH);
delay(250);
digitalWrite(BLUE, LOW);
digitalWrite(GREEN, LOW);
delay(250);
}
for (int i = 0; i < 5; i +=1 ){
digitalWrite(RED, HIGH);
digitalWrite(GREEN, HIGH);
digitalWrite(BLUE, HIGH);
delay(250);
digitalWrite(BLUE, LOW);
digitalWrite(GREEN, LOW);
digitalWrite(RED, LOW);
delay(250);
}
for (int i = 0; i < 5; i +=1 ){
digitalWrite(RED, LOW);
digitalWrite(GREEN, LOW);
digitalWrite(BLUE, LOW);
digitalWrite(WHITE, HIGH);
delay(250);
digitalWrite(BLUE, LOW);
digitalWrite(GREEN, LOW);
digitalWrite(RED, LOW);
digitalWrite(WHITE, LOW);
delay(250);
}
}
//The PWM and number of available timers is not the same from chip to chip.
//
//Note that if you have the XIN and XOUT populated with a crystal or oscillator, you can not use
//pin P2_6 for the RED of the RGB. Leave out the White LED and put the RED on pin P2_1 and
//change the appropriate line(s) in the sketch.
//
//These are the PWM pins I used. They are not on the same timer,
//so not all color combinations are available for PWM concurrently. All primary
//combinations are available for full OFF and full ON (digital HIGH and LOW, but not PWM).
//
//If this is being used for Arduino, the pins will definitely need reassignment.
#define GREEN P2_4
#define BLUE P1_6
#define RED P2_6
#define WHITE P2_1
#define delayTime 10
void setup() {
pinMode(GREEN, OUTPUT);
pinMode(BLUE, OUTPUT);
pinMode(RED, OUTPUT);
pinMode(WHITE, OUTPUT);
digitalWrite(GREEN, LOW);
digitalWrite(BLUE, LOW);
digitalWrite(RED, LOW);
digitalWrite(WHITE, LOW);
}
int redVal;
int blueVal;
int greenVal;
void loop()
{
delay(250);
redVal = 0;
blueVal = 0;
greenVal = 0;
for( int i = 255 ; i > 0 ; i -= 1 ){
redVal += 1;
analogWrite( RED, redVal );
analogWrite( BLUE, blueVal );
analogWrite(GREEN, greenVal );
delay( delayTime );
}
redVal=0;
greenVal=0;
for( int i = 0 ; i < 255 ; i += 1 ){
greenVal += 1;
analogWrite( GREEN, greenVal );
analogWrite( RED, redVal );
delay( delayTime );
}
greenVal=0;
blueVal=0;
for( int i = 0 ; i < 255 ; i += 1 ){
blueVal += 1;
analogWrite( BLUE, blueVal );
analogWrite( GREEN, greenVal );
delay( delayTime );
}
digitalWrite(RED, LOW);
digitalWrite(GREEN, LOW);
digitalWrite(BLUE, LOW);
delay(500);
for (int i = 0; i < 5; i +=1 ){
digitalWrite(RED, HIGH);
digitalWrite(GREEN, LOW);
digitalWrite(BLUE, LOW);
delay(250);
digitalWrite(RED, LOW);
delay(250);
}
for (int i = 0; i < 5; i +=1 ){
digitalWrite(RED, LOW);
digitalWrite(GREEN, HIGH);
digitalWrite(BLUE, LOW);
delay(250);
digitalWrite(GREEN, LOW);
delay(250);
}
for (int i = 0; i < 5; i +=1 ){
digitalWrite(RED, LOW);
digitalWrite(GREEN, LOW);
digitalWrite(BLUE, HIGH);
delay(250);
digitalWrite(BLUE, LOW);
delay(250);
}
for (int i = 0; i < 5; i +=1 ){
digitalWrite(RED, HIGH);
digitalWrite(GREEN, HIGH);
digitalWrite(BLUE, LOW);
delay(250);
digitalWrite(RED, LOW);
digitalWrite(GREEN, LOW);
delay(250);
}
for (int i = 0; i < 5; i +=1 ){
digitalWrite(RED, HIGH);
digitalWrite(GREEN, LOW);
digitalWrite(BLUE, HIGH);
delay(250);
digitalWrite(RED, LOW);
digitalWrite(BLUE, LOW);
delay(250);
}
for (int i = 0; i < 5; i +=1 ){
digitalWrite(RED, LOW);
digitalWrite(GREEN, HIGH);
digitalWrite(BLUE, HIGH);
delay(250);
digitalWrite(BLUE, LOW);
digitalWrite(GREEN, LOW);
delay(250);
}
for (int i = 0; i < 5; i +=1 ){
digitalWrite(RED, HIGH);
digitalWrite(GREEN, HIGH);
digitalWrite(BLUE, HIGH);
delay(250);
digitalWrite(BLUE, LOW);
digitalWrite(GREEN, LOW);
digitalWrite(RED, LOW);
delay(250);
}
for (int i = 0; i < 5; i +=1 ){
digitalWrite(RED, LOW);
digitalWrite(GREEN, LOW);
digitalWrite(BLUE, LOW);
digitalWrite(WHITE, HIGH);
delay(250);
digitalWrite(BLUE, LOW);
digitalWrite(GREEN, LOW);
digitalWrite(RED, LOW);
digitalWrite(WHITE, LOW);
delay(250);
}
}
The Completed Project
These photos are for visual reference, if anyone wants to trace the wiring to see where I put everything on the breadboard.