Jump to content

Search the Community

Showing results for tags 'RGB'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • News
    • Announcements
    • Suggestions
    • New users say Hi!
  • Spotlight!
    • Sponsor Spotlight
    • Sponsor Giveaways
  • Energia
    • Energia - MSP
    • Energia - TivaC/CC3XXX
    • Energia - C2000
    • Energia Libraries
  • MSP Technical Forums
    • General
    • Compilers and IDEs
    • Development Kits
    • Programmers and Debuggers
    • Code vault
    • Projects
    • Booster Packs
    • Energia
  • Tiva-C, Hercules, CCXXXX ARM Technical Forums
    • General
    • SensorTag
    • Tiva-C, Hercules, CC3XXX Launchpad Booster Packs
    • Code Vault
    • Projects
    • Compilers and IDEs
    • Development Kits and Custom Boards
  • Beagle ARM Cortex A8 Technical Forums
    • General
    • Code Snippets and Scripts
    • Cases, Capes and Plugin Boards
    • Projects
  • General Electronics Forum
    • General Electronics
    • Other Microcontrollers
  • Connect
    • Embedded Systems/Test Equipment Deals
    • Buy, Trade and Sell
    • The 43oh Store
    • Community Projects
    • Fireside Chat
  • C2000 Technical Forums
    • General
    • Development Kits
    • Code Vault
    • Projects
    • BoosterPacks

Calendars

There are no results to display.


Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Location


Interests


Sparkfun


Github

Found 14 results

  1. As an electrical engineering student at John Brown University, we were tasked with creating a useful product or service using the combined skills gained through our embedded systems class. As someone who likes interior decorating and hates mismatched paint, I came up with the idea to make an RGB color sensor attachment for a camera. Of course converting RGB data to paint colors is not conventional, it is something that could potentially be viable. To make things interesting and for the experience of working with a Raspberry Pi, I used a raspberry Pi camera to act as the base for the project. A KMASHI 10,000mAh power bank was used as the power source to make it portable and act as a psuedo case to strap all of the components together. It is definitely not elegant in any way, shape, or form, but it is more experience for me and hopefully you can find an interesting tid bit here or there in my documentation! Enjoy! RGBColorSensorAttatchmentRPI.docx
  2. Hi Everyone, I have made available binaries and source code for an RGB lighting project called LightServer that I thought some of you would be interested in. The best way to see what you can do with LightServer is to view the videos on Vimeo here - https://vimeo.com/album/3015956 No coding experience required to set this up and use. Technical Details LightServer uses the Tiva C LaunchPad and the CC3100 Wi-Fi BoosterPack and a custom BoosterPack (Eagle files included
  3. 3 channel, high power LED driver, built to fit 10W RGB LEDs (those things are blindingly bright!) Now on Tindie.
  4. If you have one of those 5050/WS2811 aka WS2812 strips and you want to "wear" it, I have a board for you. Here are the specs: 20pin MSP430G2xx3 5V power supply 0.05" programming header UART input (allows pixel or sequence control) 11mm wide (0.45") 25mm long (1") 32mm long (1.25") - version with memory optional SOIC SRAM or EEPROM 1mm thick There are 4 boards on the panel, 2 with memory option. Assembled boards Board in the sleeve Board attached to 30 LED strip (0.5m)
  5. About a year ago, in an effort to reduce cost of my DMX decoders, I have started to look for an alternative to MSP430. One chip that really fit the bill was STM8S003K3. It has 1K RAM, it's fairly cheap, comes in package that is easier to solder than TSSOP, has 5V operating voltage (less parts and cheaper parts,) HF crystal oscillator, UART, and 4 channel timer. In addition, STM has few nice low cost DISCOVERY eval boards, some of them cost only $7. My initial work was halted for various reasons, but last week I have decided to resume and the software is almost done. However, not everything went as smooth as I have expected and after this whole experience with STM8, if I had to choose between TI and STM, I would definitely go with TI. Don't get me wrong, I will still use STM8S/L, but MSP430 will remain my #1 choice. And since I am feeling adventurous, I am thinking of finally diving into the world of Atmel, maybe rediscover Microchip. Next week, I will be working with Freescale's Kinetis.
  6. superbrew

    RGB Matrix slot machine game

    I have started to develop a slot machine based an 8x8 RGB matrix. I intend this to be a learning experience, and I am going to focus on the logic and control of the game. Hardware: Tiva C Launchpad TLC5947 breakout from Adafruit 8 PNP transistors 8 1k resistors As of right now, I have 2x2 sprites in 6 colors representing the symbols on the reels. Each 'spin', I populate an array representing the matrix with randomly chosen colors of sprites and place them in the matrix. Then I set a random number of rotations where the symbols spin and then slow down and come a stop. As of right now, all three reels spin and stop at the same rate, but I plan to update that to be more slot machine like. I also have not implemented any sort of win detection mechanism. Here is a short video, but it looks much better in person. The scrolling effect is much smoother and realistic.
  7. amstan

    [POTM] RGB Binary Clock

    This project is an update to the binary clock that I used on my desk. The new version has a lot of new features including RGB leds(WS2812), a bigger microcontroller(The Olimexino-5510 board), capacitive touch and light sensor. My first idea was to have something based on the MSP430G2553, a couple of WS2812 leds and capacitive touch. But after comparing the work i would have to do, and very few rewards to the Olimexino-5510 functionality I quickly reconsidered. The Olimexino-5510 provides quite a few things I wanted: MSP430F5510 Battery Charger USB capabilities Arduino Form Factor So all I had to do was make a nice board that went on top with the stuff I wanted for the clock functionality. WS2812 RGB LEDs The main feature of the Clock is the 6x3 WS2812 RGB led matrix. These leds contain a little controller that accept a serial protocol for the color data and they handle the PWM. They're also chainable meaning that only one pin(D11, LED-DATA) is required to quite all of them. In my using @@oPossum's library Power Supply The Olimexino-5510 has a connector for a battery. But it just connects the battery to the 5V rail, the battery could go as low as 3V. The WS2812 aren't meant to run that low, specifically the Blue led get a lot dimmer. In order to fix this I incorporated a SMPSU that can get 5V from the battery voltage. It could in theory handle as much as 2A. The design was done with TI Webench, all parts are the same as the suggested ones. I had to modify the Olimexino a little to actually give me the raw battery voltage on the shield connector, on battery there's no voltage on the 5V pin, i assumed there was. It all works quite well now except it's kinda whiny. The WS2812 leds are very bright, so in the darkness this might be a problem. One could dim them by sending them a darker color but this reduces resolution. Q2's purpose is to PWM is the 5V that the LEDs in order to dim them externally. This essentially gives another scaling factor for the brightness. It's a similar principle to how dynamic contrast works in TVs. Unfortunatelly this did not work as I wanted, the mosfet was too slow to PWM the leds fast enough without aliasing. My next design will probably contain a mosfet driver. Capacitive Touch Pads I have 4 pads acting as buttons. I originally connected them directly to some pins assuming I had PinOsc hardware like on the value line. Unfortunately I discovered this was not the case too late. I fixed it by adding 2 resistors between each of the pairs. This allows me to do a pretty crappy RC measure. It still works quite good though, i can get about 200 discrete values of the reading. As suggested by TI I had a non solid ground plane of the backside to reduce the intrinsic capacitance. Light Sensor The shield also has a light sensor, meant to measure ambient brightness. One can use this to make the display's brightness match the room. The sensor is connected via I2C, since neither the Arduino nor the Olimexino-5510 have I2C exposed on the pins I will have to do a software solution for this. The TCS34725FN sensor is also capable of measuring RGB color; I'm sure something fun can be accomplished using that. Of course I managed to do the footprint wrong for this, so it required some cutting traces to swap some pins; after that it worked just fine. Eagle Files I also have the schematics in PDF format. Code The current code is mostly made to prove the hardware. It could use a lot more work for the UI. Features Clock Functionality with fading SMPSU Off demo Capacitive Touch Demo Light Sensor Demo USB CDC ported from Energia that i used for debugging so far Everything was compiled with msp430-gcc. I uploaded the firmware using the new f5529 launchpad board due to the fact that mspdebug does not support the olimexino usb bootloader. Parts Most parts I got from digikey, except the Olimexino-5510, the beefy 6600mAh battery and the WS2812 leds. I got a pretty good price for the LEDs from Alibaba at only 13 cents each. I ordered the board through Elecrow, I really needed it to be black. Meta My old clock was this boring thing with an attiny44, using a matrix of green leds. I originally started this version(v2.0) as a school project, but I wanted to share it. Due to the many issues I had I'll probably make a version 2.1(if i fix the shield) or a v3 if I make a standalone board. I'm open to ideas. I still have quite a few board leftover(about 7), i'm open to sending them to people if postage is cheap/free/easy. Imgur album for non-users.
  8. Created as part of GB#11, this booster pack uses 5050 RGB LEDs with integrated WS2811. Will post code examples later on. BTW, I cannot get a preview of this YouTube video to show up, can you check it out B#?
  9. Hi Gents, I've modified the SpaceLen driver to receive commands from '433mhz remotes' to drive ledStrips. These controllers + remote cost a whoping 5$, and drive upto 2A a led (so 6A in total, so rather cheap for the capabilities. Using this library, you mimic the remote. Unfortunately sending custom commands, other than replayed remote commands seems impossible, without flashing the original uC in the receiver. edit: both sending and receiving works. The code can be found on: https://github.com/vinietje/LedProtocol the controllers look like: https://github.com/vinietje/LedProtocol/blob/master/docs/Controller.jpg the timing of the signals: https://github.com/vinietje/LedProtocol/blob/master/docs/Timing%20signal.png I which I could be more specific regarding type-numbers and, such, but the Chinese are very limited regarding these unfortunately, eq, the chips inside the remotes don't bear any markings :-( and prints like '433mhz' and 'paired 1-on-1' aren't gonna cut it... please keep in mind that due to the lack of a 'change event' i have used a workaround, although in the latest commits on Energia this issue is resolved. So when using them, you will need to alter the interupt routine.
  10. Hello everyone! I'm continuing my project of creating an RGB LED matrix capable of displaying live images being transmitted from a laptop via a serial cable to the MSP430G2553. At the moment, I'm coding four 8x8 Common Anode RGB LED matrices joined together to create a 16x16 display. Hardware I'm using: - 3 * TLC5940s (one for each colour) - 2 * 74HC595 shift registers (drives the columns/anodes) I'm using code provided by RobG from this link <http://forum.43oh.com/topic/2315-tlc5940-examples/> and this one <http://forum.43oh.com/topic/3328-rgb-to-hsv-conversion-with-msp430g2231-help/#entry29106> in order to drive the LEDs with PWM enabled. BUT, the problem I'm having is that I'm trying to allow every pixel to have different colours, but when running, the microcontroller isn't refreshing the pixels fast enough so there is MASSIVE flickering - which isn't ideal.... Here is the code from which I am working : feel free to insult :-P #include <msp430g2553.h> #include <msp430.h> // Need to sort hsv2rgb because yellow is pish... // u_long is 32 bits so 2^32 - 1 is max value. Need more for 32x32 matrix // TLC inputs #define VPRG_PIN BIT0 // TIE TO GND? #define GSCLK_PIN BIT4 #define SCLK_PIN BIT5 #define DATA BIT6 // DS -> 1.6 | 595 DATA PIN #define MOSI_PIN BIT7 #define MOSI595 BIT2 // 595 data pin ? THIS ISNT DOING ANYTHING #define DCPRG_PIN BIT0 // TIE IT TO GND? #define XLAT_PIN BIT1 #define BLANK_PIN BIT2 #define CLOCK BIT3 // SH 11 -> 2.3 // 595 OUTPUTS #define LATCH BIT4 // ST 12 -> 2.4t typedef unsigned char u_char; typedef unsigned int u_int; typedef unsigned short u_short; typedef unsigned long u_long; // ================================// // Prototypes // // ================================// void init( void ); void SPI_setup( void ); void updateTLC( void ); void shiftOut( u_long ); void HSV2RGB( u_short*, u_short*, u_short*, short, u_char); void set_row_char_hue (u_char, u_long, short, u_char); void row_refresh(u_char,short,short,short,short,short,short,short,short,short,short,short,short,short,short,short,short); #define NUMBER_OF_OUTS 48 // TLC OUTPUTS #define NUMBER_OF_ROWS 8 #define NUMBER_OF_COLUMNS 16 #define max_COLUMN NUMBER_OF_COLUMNS-1 #define max_ROW NUMBER_OF_ROWS-1 #define OFF 0 u_short leds[NUMBER_OF_OUTS]; // 0 - 15 Red Rows, 16 - 31 Blue Rows, 32 - 47 Green Rows {0, } u_char timerCounter = 0; void init(void) { WDTCTL = WDTPW + WDTHOLD; // disable WDT BCSCTL1 = CALBC1_16MHZ; // 16MHz clock DCOCTL = CALDCO_16MHZ; BCSCTL2 |= DIVS_0; // divide clock by 1 P1OUT &= ~(VPRG_PIN); P1DIR |= (VPRG_PIN + GSCLK_PIN + DATA); // port 1.4 configured as SMCLK out P1SEL |= GSCLK_PIN; P2DIR |= (BLANK_PIN + XLAT_PIN + CLOCK + LATCH + DCPRG_PIN); P2OUT &= ~(BLANK_PIN + XLAT_PIN); P2OUT &= ~DCPRG_PIN; // setup timer CCR0 = 0xFFF; TACTL = TASSEL_2 + MC_1 + ID_0; // SMCLK, up mode, 1:1 CCTL0 = CCIE; // CCR0 interrupt enabled } void SPI_setup(void) { // setup UCA0 ----UCA0 ISNT DOING ANYTHING YET! SHOULD I CONFIGURE THE 595's TO BE CONTROLLED BY SPI? P1SEL |= MOSI595; // p1.2 P1SEL2 |= MOSI595; // UCA0SIMO UCA0CTL0 = UCCKPH + UCMSB + UCMST + UCSYNC; // data captured on 1st UCLK edge/changed on follwing edge, MSB first, master, 3-pin SPI,synchronous UCA0CTL1 |= UCSSEL_2; // SMCLK UCA0BR0 |= 0x01; // 1:1 UCA0BR1 = 0; UCA0CTL1 &= ~UCSWRST; // clear SW // setup UCB0 P1SEL |= SCLK_PIN + MOSI_PIN; // pins 5 + 7 P1SEL2 |= SCLK_PIN + MOSI_PIN; // UCB0CLK + UCB0SIMO UCB0CTL0 = UCCKPH + UCMSB + UCMST + UCSYNC; // data captured on 1st UCLK edge/changed on follwing edge, MSB first, master, 3-pin SPI,synchronous UCB0CTL1 |= UCSSEL_2; // SMCLK UCB0BR0 |= 0x01; // 1:1 UCB0BR1 = 0; UCB0CTL1 &= ~UCSWRST; // clear SW } void main(void) { init(); SPI_setup(); updateTLC(); P2OUT |= (XLAT_PIN); P2OUT &= ~(XLAT_PIN); short o = 240; short y = 60; // yellow short b = 240; // blue short hue = 0; _bis_SR_register(GIE); for(; { // creates box image row_refresh(0, b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,; row_refresh(1, b,y,y,y,y,y,y,y,y,y,y,y,y,y,y,; row_refresh(2, b,y,b,b,b,b,b,b,b,b,b,b,b,b,y,; row_refresh(3, b,y,b,y,y,y,y,y,y,y,y,y,y,b,y,; row_refresh(4, b,y,b,y,b,b,b,b,b,b,b,b,y,b,y,; row_refresh(5, b,y,b,y,b,y,y,y,y,y,y,b,y,b,y,; row_refresh(6, b,y,b,y,b,y,b,b,b,b,y,b,y,b,y,; row_refresh(7, b,y,b,y,b,y,b,y,y,b,y,b,y,b,y,; row_refresh(8, b,y,b,y,b,y,b,y,y,b,y,b,y,b,y,; row_refresh(9, b,y,b,y,b,y,b,b,b,b,y,b,y,b,y,; row_refresh(10, b,y,b,y,b,y,y,y,y,y,y,b,y,b,y,; row_refresh(11, b,y,b,y,b,b,b,b,b,b,b,b,y,b,y,; row_refresh(12, b,y,b,y,y,y,y,y,y,y,y,y,y,b,y,; row_refresh(13, b,y,b,b,b,b,b,b,b,b,b,b,b,b,y,; row_refresh(14, b,y,y,y,y,y,y,y,y,y,y,y,y,y,y,; row_refresh(15, b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,; _bis_SR_register(LPM0_bits); // go to sleep } // end of for(; loop } void updateTLC(void) // RobG's code { u_char ledCounter = NUMBER_OF_OUTS >> 1; while (ledCounter-- > 0) { u_char i = ledCounter << 1; UCB0TXBUF = leds[i + 1] >> 4; while (!(IFG2 & UCB0TXIFG)); // TX buffer ready? u_char unib = leds[i + 1] << 4; u_char lnib = (leds[i] >> 8) & 0x0F; UCB0TXBUF = unib | lnib; while (!(IFG2 & UCB0TXIFG)) ; // TX buffer ready? UCB0TXBUF = leds[i]; while (!(IFG2 & UCB0TXIFG)); // TX buffer ready? } } void row_refresh(u_char row,short a,short b,short c,short d,short e,short f,short g,short h,short i,short j,short k,short l,short m,short n,short o,short p) { // this function checks if led is supposed to be ON // for example, if row = 0, and a = 360 then the top left led is OFF // if a = 120, then the led will be ON, and will be assigned the appropriate hue (green) u_long col_data = 0x0000; if(a < 360){col_data = 0x8000; set_row_char_hue(row,col_data,a,1);} // 0 if(b < 360){col_data = 0x4000; set_row_char_hue(row,col_data,b,1);} // 1 if(c < 360){col_data = 0x2000; set_row_char_hue(row,col_data,c,1);} // 2 if(d < 360){col_data = 0x1000; set_row_char_hue(row,col_data,d,1);} // 3 if(e < 360){col_data = 0x0800; set_row_char_hue(row,col_data,e,1);} // 4 if(f < 360){col_data = 0x0400; set_row_char_hue(row,col_data,f,1);} // 5 if(g < 360){col_data = 0x0200; set_row_char_hue(row,col_data,g,1);} // 6 if(h < 360){col_data = 0x0100; set_row_char_hue(row,col_data,h,1);} // 7 if(i < 360){col_data = 0x0080; set_row_char_hue(row,col_data,i,1);} // 8 if(j < 360){col_data = 0x0040; set_row_char_hue(row,col_data,j,1);} // 9 if(k < 360){col_data = 0x0020; set_row_char_hue(row,col_data,k,1);} // 10 if(l < 360){col_data = 0x0010; set_row_char_hue(row,col_data,l,1);} // 11 if(m < 360){col_data = 0x0008; set_row_char_hue(row,col_data,m,1);} // 12 if(n < 360){col_data = 0x0004; set_row_char_hue(row,col_data,n,1);} // 13 if(o < 360){col_data = 0x0002; set_row_char_hue(row,col_data,o,1);} // 14 if(p < 360){col_data = 0x0001; set_row_char_hue(row,col_data,p,1);} // 15 } void set_row_char_hue (u_char row, u_long col_data, short hue, u_char bool) { u_char led = 0; u_long byte; for(led = 0 ; led < 16 ; led++ ) { byte = (col_data>>led)&(0x01); if( byte ) { HSV2RGB( &leds[row], &leds[row + 32], &leds[row + 16], hue, bool); //on; shiftOut( col_data ); } } // turn off leds leds[row] = OFF; leds[row+32] = OFF; leds[row+16] = OFF; } void HSV2RGB(u_short* r, u_short* g, u_short* b, short h, u_char bool) { const u_char s = 255; u_char v = 255; u_char i, p, q, t; u_short fs; if (h < 60 ) i = 0; else if (h < 120) i = 1; else if (h < 180) i = 2; else if (h < 240) i = 3; else if (h < 300) i = 4; else if (h < 360) i = 5; else return; fs = ((h - i * 60) * s)/ 60; p = 255 - s; q = 255 - fs; t = 255 - s + fs; switch(i) { case 0: *r = 255;*g = t;*b = p;break; case 1: *r = q;*g = 255;*b = p;break; case 2: *r = p;*g = 255;*b = t;break; case 3: *r = p;*g = q;*b = 255;break; case 4: *r = t;*g = p;*b = 255;break; case 5: *r = 255;*g = p;*b = q;break; } if ( bool == 1 ) { *r *= v/16; *g *= v/16; *b *= v/16; } else { *r *= 0; *g *= 0; *b *= 0; } } #pragma vector = TIMER0_A0_VECTOR __interrupt void Timer_A0(void) { // 4096 GS clock cycles have been generated, time to restart PWM P2OUT |= (BLANK_PIN); P2OUT |= (XLAT_PIN); P2OUT &= ~(XLAT_PIN); P2OUT &= ~(BLANK_PIN); // increase timer counter timerCounter++; if (timerCounter == 1) // this is also from RobG, except updateTLC is every interrupt because otherwise it is far too slow { // is it time to for next frame? updateTLC(); // data was already prepared by main loop when it was awake last time timerCounter = 0; _bic_SR_register_on_exit(LPM0_bits); // wake up main loop so that it can prepare data for the next frame } } void shiftOut(u_long val) { P2OUT &= ~LATCH; int i; for (i = 0; i < 16; i++) // iterate over each bit 16 { if(val & (1 << i)) { P1OUT |= DATA; } else { P1OUT &= ~DATA; } P2OUT |= CLOCK; // PULSE CLOCK P2OUT ^= CLOCK; } // } P2OUT |= LATCH; // PULSE LATCH P2OUT &= ~LATCH; } If anyone has any suggestions on how to improve this code, it will be greatly appreciated, because I've really hit a wall with it. I did think that using SPI P1.2 for UCA0SIMO instead of the shiftOut() function might be a solution but I don't know how to go about doing that. Keep in mind that soon I'll be using P1.1 for RXD. Cheers!
  11. chipi92

    RGB Led IR Library PWM problem

    MSP430g2553 ALL DOCUMENTATION BELOW Playing with IR receiver (IR Library from Energia) and RGB led. I cant write analog values to my RGB led without breaking the program. I connected the three outputs to analogWrite capable pins. All works great when writing 0 or 255 but the library stop working well when i try to write other value to make the color less bright. Then i read about timers and PWM. I notice my library use Timer1_A so i need to connect leds to pins capable of analog writing but using Timer0_A. These pins were three, but one is RXD of Serial and messed things up. So I changed the library to use Timer0_A and connect leds to pins capable of analog writing but using Timer1_A. The program at the moment works nice, but again only with 0 or 255 values. BUT i noticed i can write other values to ONE of these pins, it dont breaks things. I wonder what could be the difference, with datasheet. The pins were: #define RED P2_1 #define GREEN P2_2 #define BLUE P2_4 ---> this works with values between 0 and 255 With datasheet i noticed pin P2_4 has "Out2 output", thats all difference i have found. BUT i put RED to P2_5 wich is "Out2 output" too and again it breaks things, while BLUE doesnt. All of these without knowing what can be out2 output. I miss something. Can you help me? I can give you more details if needed. EDITED: Individually, it works. Pins that are analogWrite capable and use T0_A are {2_1 - 2_2 - 2_4 - 2_5} DOCUMENTATION ABOUT: Problems with timers and IR library http://forum.43oh.com/topic/3550-ir-library-and-pwm/ Datasheet(page 6) http://www.ti.com/lit/ds/symlink/msp430g2553.pdf PinOUT https://www.dropbox.com/s/mcvbnkdpzsn1wna/LaunchPad%20MSP430G2553-V1.4.jpg
  12. I bought some addressable RGB Leds from Dealextreme and instead of the expected WS2801 chip, they came with TLS3008 drivers (8bit control for each colour, single wire, different protocol from WS2811 too). It took some time with the osciloscope to get the timing right but this now works perfect. This is in C rahter than assembly but I can get a decent update rate. I do not work with the full 50 Leds as there is not enough RAM in the chip I use (2231) but I tried looping the code to work with the full length, that worked ok except on one set of Leds which was sometimes lagging, I think that this is due to the extra time used by the loop when returning. If all the RGB data is in a table there should be no issue. I will check this when I have a better chip. I am making a kind of light organ - vu meter mix with a short string of 6 Leds and the update on the audio is faster than I need. This is compiled with IAR. Any comments and improvements welcome! H3rv3 // TLS3008 based 6 RGB LEDs string test application for MSP430 // Based on DonJuanito99 for arduino //THIS IS THE WORKING CODE // includes #include "msp430g2231.h" #include "intrinsics.h" // defines #define PULSEUS1 33 // Manchester half period in clock cycles (2.5us) to 1 #define PULSEUS0 22 // Manchester half period in clock cycles (2.5us) to 0 #define PULSEUS2 9 // used for end of command last 0 delay #define EOSYNCDELAYMS 50750 // Pause duration at end of SYNC frame (3.5ms) #define EORESETMS 29000 // Pause duration at end of RESET frame (2ms) #define EOFDELAYMS 5000 // Pause duration at end of each frame (of 50 LEDs RGB data) (0.35ms) #define UP 0x00 #define DOWN 0x01 #define HOLD 0x02 // variables //all reds //unsigned char RGBTable [18]={0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00,0xFF,0x00,0x00}; //one color each //unsigned char RGBTable [18]={0xFF,0x00,0x00,0x0F,0x00,0x0F,0x00,0x00,0xFF,0x00,0x0F,0x0F,0x00,0xff,0x00,0x0f,0x0F,0x00}; //all off unsigned char RGBTable [18]; int i; int bc; char led_red = 1; char led_green = 255; char led_blue = 1; char red = UP; char blue = HOLD; char green = DOWN; // routines void reset(void); // sends reset frame void sync(void); // sends sync frame void frame_start(void); // sends emty data frame (last bit, out of procedure delay) void updateRGB (void); // sends the data to the leds void bitc(char); // bit sending procedure to send commands void bitd(char); // bit sending procedure to send data void main(void) { //pin setup output and 0 P1DIR |= BIT0; P1OUT &= ~BIT0; //Stop watchdog timer WDTCTL = WDTPW + WDTHOLD; //Set clock at 16MHz DCOCTL = DCO0 + DCO1; BCSCTL1 = RSEL0 + RSEL1 + RSEL2 + RSEL3; //Disable interupts __disable_interrupt(); // initialising strings reset(); sync(); reset(); sync(); reset(); sync(); while(1) { // reset(); // not required in this loop, consider regular reset // sync(); // not required in this loop, consider regular re-sync // send the data to the string updateRGB(); // the code below is just for the show while (P1IN & BIT3) {} //fade logic switch (red){ case UP: ++led_red; if (led_red == 255) {red = DOWN; green = HOLD; blue = UP; led_green=0;} break; case DOWN: --led_red; if (led_red == 0) {red = HOLD;} break; case HOLD: break; }//end switch switch (blue){ case UP: ++led_blue; if (led_blue == 255) {blue = DOWN; green = UP; red = HOLD;led_red=0;} break; case DOWN: --led_blue; if (led_blue == 0) {blue = HOLD;} break; case HOLD: break; }//end switch switch (green){ case UP: ++led_green; if (led_green == 255) {green = DOWN; red = UP; blue = HOLD;led_blue=0;} break; case DOWN: --led_green; if (led_green == 0) {green = HOLD;} break; case HOLD: break; }//end switch RGBTable [0]=led_red; RGBTable [1]=led_green; RGBTable [2]=led_blue; RGBTable [3]=led_blue; RGBTable [4]=led_green; RGBTable [5]=led_red; RGBTable [6]=led_red; RGBTable [7]=led_blue; RGBTable [8]=led_green; RGBTable [9]=led_blue; RGBTable [10]=led_red; RGBTable [11]=led_green; RGBTable [12]=led_green; RGBTable [13]=led_blue; RGBTable [14]=led_red; RGBTable [15]=led_green; RGBTable [16]=led_red; RGBTable [17]=led_blue; } //end while } // end main() void updateRGB(void) // send the RGBTable data to the string { frame_start(); // prepare to send data __delay_cycles (PULSEUS0-4); for(i=0;i<18;i++) // Repeat for 6 leds * 3 data blocks { // Start tag (= 0 bit) P1OUT &= ~BIT0; // set to 0 __delay_cycles(PULSEUS1); P1OUT |= BIT0; //set to 1 __delay_cycles(4); for (bc=0x80;bc!=0;bc>>=1) bitd( RGBTable[i] & bc ); // send the 8 data bits __delay_cycles (6); } P1OUT &= ~BIT0; __delay_cycles (EOFDELAYMS); //pass value from chip to LED (=send a complete frame start) frame_start(); __delay_cycles (PULSEUS1-3); P1OUT &= ~BIT0; // write a low __delay_cycles (EOFDELAYMS); } void bitd(char { if (b==0){ P1OUT &= ~BIT0; // set to 0 __delay_cycles(PULSEUS1); P1OUT |= BIT0; //set to 1 __delay_cycles (4); } else{ P1OUT |= BIT0; // set to 1 __delay_cycles(PULSEUS1); P1OUT &= ~BIT0; //set to 0 __delay_cycles (4); } } void bitc(char { if (b==0){ P1OUT &= ~BIT0; // set to 0 __delay_cycles(PULSEUS1); P1OUT |= BIT0; //set to 1 __delay_cycles (PULSEUS0); } else{ P1OUT |= BIT0; // set to 1 __delay_cycles(PULSEUS1); P1OUT &= ~BIT0; //set to 0 __delay_cycles (PULSEUS0); } } void sync() { bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(0); bitc(0); bitc(0); bitc(1); bitc(0); bitc(0); bitc(0); bitc(0); bitc(0); bitc(0); bitc(0); bitc(0); bitc(0); bitc(0); bitc(0); __delay_cycles (PULSEUS2); // additional delay on last 0 P1OUT &= ~BIT0; // now set to 0 __delay_cycles (EOSYNCDELAYMS); // end of sync frame delay } void reset() { bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(0); bitc(1); bitc(0); bitc(0); __delay_cycles (PULSEUS2); // additional delay on last 0 P1OUT &= ~BIT0; // now set to 0 __delay_cycles (EORESETMS); // end of reset frame delay } void frame_start() { bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(1); bitc(0); bitc(0); bitc(1); P1OUT &= ~BIT0; __delay_cycles(PULSEUS1+9); P1OUT |= BIT0; //set to 1 // last 0 bit has no delay (delay will be set outside due to procedure return delays) }
  13. Hi all! I was wondering if anyone has used this algorithm with the G2231 before? I'm trying to use it but I keep getting an error message saying: "program will not fit into available memory. placement with alignment fails for section ".text" size 0x142e ." The reason I am trying to implement this is so I can represent exact colours for RGB LEDS in a large-ish matrix. Does anyone know a method to decrease the amount of memory being consumed by this algorithm, or increase the amount of memory allocated to ".text"? Any advice would be greatly appreciated. Here is the code I am using: #include <msp430g2231.h> #include <math.h> // TLC inputs #define SCLK_PIN BIT5 #define MOSI_PIN BIT7 #define GSCLK_PIN BIT4 #define BLANK_PIN BIT2 #define XLAT_PIN BIT1 #define VPRG_PIN BIT0 // 595 Inputs #define DATA BIT6 // DS -> P2.6 #define LATCH BIT6 // ST_CP -> 1.6 #define CLOCK BIT7 // 11 -> 2.7 // -------------- MACROS ------------------------------------------// #define setHigh(n) ( P1OUT |= n ) // Only for TLC! #define setLow(n) ( P1OUT &= ~n ) // TLC!! #define pulse(n) do { setHigh(n); setLow(n); } while(0) // ---------------------------------------------------------------------// typedef unsigned char u_char; typedef unsigned int u_int; typedef unsigned short int us_int; // Prototypes void init(void); void updateTLC(); void sendMOSI(u_int data); void pulseClock ( void ); void pinWrite ( unsigned int, int ); void shiftOut(unsigned char); void shift(unsigned int); void allrowsON(void); void allrowsOFF(void); void allcolsON(void); void delay (unsigned int); void bounce (int); void knight(int); void HSV2RGB(u_char *r, u_char *g, u_char *b, signed int h, u_char s, u_char v); #define NUMBER_OF_LEDS 24 #define NUMBER_OF_COLUMNS 8 #define NUMBER_OF_ROWS 8 u_int leds[NUMBER_OF_LEDS] = { 0, }; // 0 - 7 Red Rows, 8 - 15 Green Rows, 16 - 23 Blue Rows u_int rows[NUMBER_OF_ROWS] = { 0, }; u_char timerCounter = 0; short int icount = 0; void init(void) { WDTCTL = WDTPW + WDTHOLD; // disable WDT DCOCTL |= DCO0 + DCO1; // DCO = 15.25MHz BCSCTL1 |= RSEL0 + RSEL1 + RSEL2 + RSEL3; // as above BCSCTL2 |= DIVS_2; // divide clock by 8 P1OUT &= ~(VPRG_PIN + BLANK_PIN + XLAT_PIN + SCLK_PIN + MOSI_PIN ); P1DIR |= VPRG_PIN + BLANK_PIN + XLAT_PIN + SCLK_PIN + MOSI_PIN; // 595 P2SEL &= ~(CLOCK + LATCH); P1DIR |= DATA; // Setup pins as outputs P2DIR |= (CLOCK + LATCH); P1DIR |= GSCLK_PIN; // port 1.4 configured as SMCLK out P1SEL |= GSCLK_PIN; // setup timer CCR0 = 0xFFF; TACTL = TASSEL_2 + MC_1 + ID_0; // SMCLK, up mode, 1:1 CCTL0 = CCIE; // CCR0 interrupt enabled } void main(void) { init(); updateTLC(); pulse(XLAT_PIN); _bis_SR_register(GIE); bounce(300); knight(300); int loopCounter = 0; int p,hue; for(; { // this loop will be executed every 16.384ms, ~61Hz //leds[0-7] = Red //leds[8-15] = Green //leds[16-23] = Blue for( hue = 0 ; hue < 360 ; hue ++) // this is where the problem lies! { HSV2RGB(0,0,0,hue,1,1); } allcolsON(); if (loopCounter < 512) {//512 for( p = 0 ; p < 8 ; p++) // R (0-7) { leds[p]++; } } else if (loopCounter < 1024) { // G (8-15) for( p = 8 ; p < 16 ; p++) { leds[p]++; } } else if (loopCounter < 1536) { //dim R (0-7) for( p = 0 ; p < 8 ; p++) { leds[p]--; } } else if (loopCounter < 2048) { // B (16 - 23) for( p = 16 ; p < 24 ; p++) { leds[p]++; } } else if (loopCounter < 2560) { //dim G (8-15) for( p = 8 ; p < 16 ; p++) { leds[p]--; } } else if (loopCounter < 3072) { // R (0-7) for( p = 0 ; p < 8 ; p++) { leds[p]++; } } else if (loopCounter < 3584) { //dim B (16-23) for( p = 16 ; p < 24 ; p++) { leds[p]--; } } else if (loopCounter < 4096) { //dim R (0-7) for( p = 0 ; p < 8 ; p++) { leds[p]--; } } else { loopCounter = 0; } // do not edit below loopCounter++; // sleep _bis_SR_register(LPM0_bits); } } void updateTLC() { u_char ledCounter = NUMBER_OF_LEDS >> 1; while (ledCounter-- > 0) { u_char i = ledCounter << 1; sendMOSI(leds[i + 1]); sendMOSI(leds[i]); } } // the HSV algorithm void HSV2RGB(u_char *r, u_char *g, u_char *b, signed int h, u_char s, u_char v) { int i,z; float f, p, q, t, hf, sf, vf; hf=(float)h; sf=(float)s; vf=(float)v; sf /=255; if( sf == 0 ) { // achromatic (grey) *r = *g = *b = vf; return; } hf /= 60; // sector 0 to 5 i = floor( hf ); f = hf - i; // factorial part of h p = (u_char)(v * ( 1 - sf )); q = (u_char)(v * ( 1 - sf * f )); t = (u_char)(v * ( 1 - sf * ( 1 - f ) )); switch( i ) { case 0: *r = v; *g = t; *b = p; break; case 1: *r = q; *g = v; *b = p; break; case 2: *r = p; *g = v; *b = t; break; case 3: *r = p; *g = q; *b = v; break; case 4: *r = t; *g = p; *b = v; break; default: // case 5: *r = v; *g = p; *b = q; break; } for( z = 0 ; z < 8 ; z++) { leds[z] = *r; // red pins leds[z+8] = *g; // green pins leds[z+16] = *b; // blue pins } } void allcolsON(void) { for( icount = 0; icount < NUMBER_OF_COLUMNS ; icount++ ) { shiftOut(1 << icount); //1 << } for( icount = NUMBER_OF_COLUMNS-1; icount >= 0 ; icount-- ) { shiftOut(1 << icount); //1 << } } void allrowsON(void) { int x; for( x = 0; x < 8 ; x++ ) { leds[x] = 4095; } for( x = 7; x >= 0 ; x-- ) { leds[x] = 4095; } } void allrowsOFF(void) { int x; for( x = 0; x < 8 ; x++ ) { leds[x] = 0; } for( x = 7; x >= 0 ; x-- ) { leds[x] = 0; } } void delay(unsigned int ms) { while (ms--) { __delay_cycles(2000); // set for 16Mhz change it to 1000 for 1 Mhz } } void bounce (int time) { int a; allcolsON(); for( a = 0; a < 8 ; a++) // red { leds[a] = 4095; delay(time); leds[a] = 0; } for( a = 7 ; a >= 0 ; a--) { leds[a] = 4095; delay(time); leds[a] = 0; } for( a = 0; a < 8 ; a++) // yellow { leds[a] = 4095; leds[a+8] = 3500; delay(time); leds[a] = 0; leds[a+8] = 0; } for( a = 7 ; a >= 0 ; a--) { leds[a] = 4095; leds[a+8] = 3500; delay(time); leds[a] = 0; leds[a + 8] = 0; } for( a = 0; a < 8 ; a++) // green { leds[a+8] = 4095; delay(time); leds[a+8] = 0; } for( a = 7 ; a >= 0 ; a--) { leds[a+8] = 4095; delay(time); leds[a+8] = 0; } for( a = 0; a < 8 ; a++) // cyan { leds[a+8] = 4095; leds[a+16] = 4095; delay(time); leds[a+8] = 0; leds[a+16] = 0; } for( a = 7 ; a >= 0 ; a--) { leds[a+8] = 4095; leds[a+16] = 4095; delay(time); leds[a+8] = 0; leds[a+16] = 0; } for( a = 0; a < 8 ; a++) // blue { leds[a+16] = 4095; delay(time); leds[a+16] = 0; } for( a = 7 ; a >= 0 ; a--) { leds[a+16] = 4095; delay(time); leds[a+16] = 0; } for( a = 0; a < 8 ; a++) // magenta { leds[a] = 4095; leds[a+16] = 4095; delay(time); leds[a] = 0; leds[a+16] = 0; } for( a = 7 ; a >= 0 ; a--) { leds[a] = 4095; leds[a+16] = 4095; delay(time); leds[a] = 0; leds[a+16] = 0; } for( a = 0; a < 8 ; a++) // white { leds[a] = 4095; leds[a+8] = 4095; leds[a+16] = 4095; delay(time); leds[a] = 0; leds[a+8] = 0; leds[a+16] = 0; } for( a = 7 ; a >= 0 ; a--) { leds[a] = 4095; leds[a+8] =4095; leds[a+16] = 4095; delay(time); leds[a] = 0; leds[a+8] = 0; leds[a+16] = 0; } } void knight(int time) { int x; allrowsON(); for( x = 0 ; x < 8 ; x++) { shift(1 << x); delay(time); } for( x = 7 ; x >= 0 ; x--) { shift(1 << x); delay(time); } allrowsOFF(); } #pragma vector = TIMER0_A0_VECTOR __interrupt void Timer_A0(void) { setHigh(BLANK_PIN); pulse(XLAT_PIN); setLow(BLANK_PIN); timerCounter++; if (timerCounter == 8) { // 0x08 - 2ms * 8 = 16.384ms, ~61Hz updateTLC(); timerCounter = 0; _bic_SR_register_on_exit(LPM0_bits); } } void sendMOSI(u_int mosi) { u_char c = 0; while (c < 12) { (mosi & 0x0800) ? (P1OUT |= MOSI_PIN) : (P1OUT &= ~MOSI_PIN); pulse(SCLK_PIN); mosi <<= 1; c++; } } void shiftOut(unsigned char val) { P2OUT &= ~LATCH; pinWrite(DATA, val); pulseClock(); P2OUT |= LATCH; P2OUT &= ~LATCH; } void shift(unsigned int val) { P2OUT &= ~LATCH; int i; for (i = 0; i < 8; i++) { pinWrite(DATA, (val & (1 << i))); pulseClock(); } P2OUT |= LATCH; P2OUT &= ~LATCH; } void pinWrite( unsigned int bit, int val ) { if (val){ P1OUT |= bit; } else { P1OUT &= ~bit; } } // Pulse the clock pin void pulseClock( void ) { P2OUT |= CLOCK; P2OUT ^= CLOCK; }
  14. mtlevine0

    RGB LED PC Case Fan

    I have several of these case fans installed on my PC. Each fan uses four standard 5mm LEDs like the one pictured here. I'd like to replace each LED with an RGB LED controlled by a ws2801 ic. I plan to design a small PCB which would include the ws2801 controller along with a 5mm RGB LED. I would probably just control the whole thing with a Launchpad and use the USB to UART connect for communication with a visual basic or python app on the PC side. The board I'm planning would almost identical the Sparkfun ws2801 breakout, the only differences being the dimensions and LED type. This will be the first PCB I've ever designed so I'm hoping the 43oh community will be able to help me with some advice and hopefully double checking my work. The PC side app would allow for the user to select any color or animation. Another mode I'd like to implement would be a visual temperature monitor that would fade the LEDs from blue to red based on ambient or CPU temp. Phase One: Design PCB: Would you guys recommend I use Eagle PCB for this? Any tutorials you would recommend? I'll be doing this over the next few weeks or so depending on my class work load. Order PCB: I'm going to need 8 to 12 identical boards (depending on price breaks) for two to three fans. Whats the recommended budget PCB house around here, Itead/Dorkbot? Phase Two: Write embedded application: I'm thinking a MSP430g2553 should be fine, It's overkill really. Write PC side application: A GUI that runs in the background and hangs out on the task bar would be awesome for this. This will be another learning curve for me. That's all for now, let me know what you guys think. -Matt
×