Theshadowwalker91 0 Posted August 30, 2011 Share Posted August 30, 2011 a friend of mine recently got a new car and he wants me to do somthing to it to make it different. he has a led light bar as a brake light in the middle of his trunk and i wanted to mod it. but i am haveing trubles. what i want to do is have it so when he presses the brakes the lights go from the center and out to each side and back to the middle. and when he signals it will go from one side to the other. i have a few options in msp chips. i have the MSP430G2211 MSP430G2131 MSP430G2231 MSP430G2252 and MSP430F2012. Any advice on witch chip to use. the led bar will be broke into 8 segments. i also have multiple ULN2803's SN74HC595N's and TLC5916IN's. i will need to have 3 inputs and i will have to drop the voltage from 12v to a voltage that the chip will handle. And i Am useing Code Composer Studio v4 to program via a launchpad. any help will be appreciated. Quote Link to post Share on other sites
Theshadowwalker91 0 Posted September 1, 2011 Author Share Posted September 1, 2011 ok so i figured something out. i dont think it is the best way but it works. i am useing the MSP430G2252 along with a ULN2803. i am probally going to use resisters to drop the signal voltage from 12 to 3 volts. when you signal left the leds go from right to left. and the opposite for right. when you brake the leds go from center out to the edges and back again. and if you signal and brake it will do both sequences one after the other. if anyone has any tips on making the code better feel free to let me know. will post vid when done installing on car. #include "msp430g2252.h" #define LED0 BIT0 #define LED1 BIT1 #define LED2 BIT2 #define LED3 BIT3 #define LED4 BIT4 #define LED5 BIT5 #define LED6 BIT6 #define LED7 BIT7 void delay_ms(unsigned int ms ){ // Not really a milliseconds delay! unsigned int i; for (i = 0; i <= ms; i++){ // The operator is <=, I've yet to fix this site bug. __delay_cycles(500); } } void do_led( int led, int delay ) { P1OUT = led; delay_ms( delay ); } void main (void) { WDTCTL = WDTPW | WDTHOLD; P1DIR = LED0 | LED1 | LED2| LED3| LED4| LED5 | LED6 | LED7; //Sets all the LEDs to output P1OUT &= ~(LED0 + LED1 + LED2 + LED3 + LED4 + LED5 + LED6 + LED7); for(; //Infinite loop { volatile unsigned int i; P1OUT &= ~(LED0 + LED1 + LED2 + LED3 + LED4 + LED5 + LED6 + LED7); if((P2IN & BIT0) != 0) { do_led( LED3+LED4 , 500); do_led( LED2+LED5 , 500); do_led( LED1+LED6 , 500); do_led( LED0+LED7 , 500); do_led( LED1+LED6 , 500); do_led( LED2+LED5 , 500); }else{} if((P2IN & BIT2) != 0) { do_led( LED0 , 500); do_led( LED1 , 500); do_led( LED2 , 500); do_led( LED3 , 500); do_led( LED4 , 500); do_led( LED5 , 500); do_led( LED6 , 500); do_led( LED7 , 500); }else{} if((P2IN & BIT1) != 0) { do_led( LED7 , 500); do_led( LED6 , 500); do_led( LED5 , 500); do_led( LED4 , 500); do_led( LED3 , 500); do_led( LED2 , 500); do_led( LED1 , 500); do_led( LED0 , 500); }else{} } } Quote Link to post Share on other sites
bluehash 1,581 Posted September 1, 2011 Share Posted September 1, 2011 i am probally going to use resisters to drop the signal voltage from 12 to 3 volts. Use a voltage divider like a 7803. Quote Link to post Share on other sites
Fe2o3Fish 33 Posted September 1, 2011 Share Posted September 1, 2011 Blue' I think the op was talking about using resistors to drop the brake and turn signal "signals" down from 12v to 3v, not for a source of power. But for power, the 7803 wouldn't be a terribly bad choice. :-) -Rusty- Quote Link to post Share on other sites
zeke 693 Posted September 2, 2011 Share Posted September 2, 2011 Uhm, from a power dissipation point of view, using a linear regulator to drop 12V to 3V would be a rather hot proposal. Literally. Depending on the current draw of the circuit, you would have (12-3)Volts * Amps = Power dropped across the regulator. It comes out as heat. Might I suggest a switching regulator to do the same thing? Here's a part to prime your imagination. Just a thought to consider. AaronInSpace 1 Quote Link to post Share on other sites
Theshadowwalker91 0 Posted September 2, 2011 Author Share Posted September 2, 2011 i plan on using a UA78M33 (3/4 Pin 500mA Fixed 3.3V Positive Voltage Regulator) for power to the msp. there shouldnt be much current because i am using the uln2803. the leds will have resisters to operate at 12 v. but i am haveing problems. the code works when in my launchpad but when i put it on a circuit board that i made it wont work. it is getting 3.3volts and i did ground the reset but it wont seem to do anything. any thoughts? Quote Link to post Share on other sites
Theshadowwalker91 0 Posted September 2, 2011 Author Share Posted September 2, 2011 i also ran into anouther problem. when i hold a positive voltage to bit 0 of port 2 it does the sequence but it also plays the bit 1 sequence *it was my finger joining contacts. now i feel like an idiot lol Quote Link to post Share on other sites
DanAndDusty 62 Posted September 2, 2011 Share Posted September 2, 2011 ... and i did ground the reset I think that may be your problem. Reset needs a pullup resistor not to be taken to gnd Sent from my GT-I5700 using Tapatalk Quote Link to post Share on other sites
Theshadowwalker91 0 Posted September 2, 2011 Author Share Posted September 2, 2011 lol i just relised that lol thanks. works now. Quote Link to post Share on other sites
Theshadowwalker91 0 Posted October 8, 2011 Author Share Posted October 8, 2011 well i got it all wired up and in the car and the realized the the brake and signals share bulbs. so i need to work on my code. i need to figure out how to read two inputs and based on them do something. so if P2.3 is high and P2.4 is low then do one pattern. and if P2.3 is low and P2.4 is high do a different pattern. and if P2.3 is high and P2.4 is high do another. Quote Link to post Share on other sites
SirZusa 34 Posted October 8, 2011 Share Posted October 8, 2011 try something like: // when P1.1 LOW AND P1.2 HIGH then ... if(!(P2IN & BIT1) && (P2IN & BIT2)) { ... } // OR if((P2IN & ~BIT1) && (P2IN & BIT2)) { ... } should both do the same Theshadowwalker91 1 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.