Jump to content

Search the Community

Showing results for tags 'ws2811'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • 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


There are no results to display.

Found 15 results

  1. Nick Gammon published an interesting post on using SPI on 16 MHz Arduinos to run WS2812 LEDs (aka neopixels) at: http://gammon.com.au/forum/?id=13357. He also provides a link with a lot of information about the NRZ protocol used by the WS2812 and tolerances: https://wp.josh.com/2014/05/13/ws2812-neopixels-are-not-so-finicky-once-you-get-to-know-them/. The tolerances are actually quite a bit looser than what I previously believed. So, I set out to do something similar with Energia and LaunchPads running at different speeds. Spoiler alert: It works. The previously linked articles provide all the background so minimal information is repeated here. NRZ is a one wire protocol that transfers information to the LEDs by varying the length of the signal when high. A longer pulse is used for a 1, and a shorter one for a 0. The timing, with tolerances, is shown in the figure below. The length between pulses cannot exceed about 5 us and most everything else is pretty loose. The protocol is implemented using SPI which I find pretty clever. A byte is sent out with the SPI module with the proper length to represent the desired bit for the protocol. The following must be determined and set to do this: Set proper SPI clock speed using SPI.setClockDivider() in Energia Determine the proper byte to send by SPI.transfer() in Energia to represent a 0 or 1 bit For example, using the MSP430F5529: Clock speed is 25.6 MHz Setting the SPI clock divider to 4 gives a SPI clock of 6.4 MHz and since the SPI block executes in one cycle (Arduino executes in 2), each bit in the byte is equivalent to 156.25 ns. Therefore, to send a pulse indicating a "1", a byte equal to 0b1111000 could be used which gives 4x156.25 = 625 ns. This is in the acceptable range of 550 to 850 ns. Similarly, for a 0 an acceptable byte would be 0b11000000 or 312.5 ns. A similar process can be used to determine acceptable values for the MSP430G2553. The sketch below is a simplification of the library presented by Nick which and includes the modifications described above to run on both the G2553 and F5529. The preprocessor is used to set appropriate values for the clock divider and long and short bytes. The functions are very nearly the same as posted by Nick. Note that interrupts must be disabled before sending data and then reenabled manually after. /* * WS2812 display using SPI on various TI LaunchPads with Energia * * Connections: * LaunchPad LED Strip * --------- --------- * 3V3 5VDC * Pin 15 (MOSI) DIN * GND GND * * How to use: * ledsetup (); - Get ready to send. * Call once at the beginning of the program. * sendPixel (r, g, ; - Send a single pixel to the string. * Call this once for each pixel in a frame. * Each colour is in the range 0 to 255. Turn off * interrupts before use and turn on after all pixels * have been programmed. * show (); - Latch the recently sent pixels onto the LEDs . * Call once per frame. * showColor (count, r, g, ; - Set the entire string of count Neopixels * to this one colour. Turn off interrupts before use * and remember to turn on afterwards. * * Derived from NeoPixel display library by Nick Gammon * https://github.com/nickgammon/NeoPixels_SPI * With ideas from: * http://wp.josh.com/2014/05/13/ws2812-neopixels-are-not-so-finicky-once-you-get-to-know-them/ * Released for public use under the Creative Commons Attribution 3.0 Australia License * http://creativecommons.org/licenses/by/3.0/au/ * * F Milburn November 2016 * Tested with Energia V17 and WS2812 8 pixel strip on launchpads shown below. */ #include <SPI.h> #if defined(__MSP430G2553) #define SPIDIV SPI_CLOCK_DIV2 // 16 MHz/2 gives 125 ns for each on bit in byte #define SPILONG 0b11111100 // 750 ns (acceptable "on" range 550 to 850 ns) #define SPISHORT 0b11100000 // 375 ns (acceptable "on" range 200 to 500 ns) #elif defined(__MSP430F5529) #define SPIDIV SPI_CLOCK_DIV4 // 25.6 MHz/4 gives 156.25 ns for each on bit in byte #define SPILONG 0b11110000 // 625 ns (acceptable "on" range 550 to 850 ns) #define SPISHORT 0b11000000 // 312.5 ns (acceptable "on" range 200 to 500 ns) #else #error This microcontroller is not supported #endif const unsigned int PIXELS = 8; // Pixels in the strip void setup (){ ledsetup(); } void loop (){ // Show a solid color across the strip noInterrupts(); // no interrupts while sending data showColor (PIXELS, 0xBB, 0x22, 0x22); // single color on entire strip interrupts(); // interrupts are OK now delay(1000); // hold it for a second // Show a different color on every pixel noInterrupts(); // no interrupts while sending data sendPixel(0xBB, 0x00, 0x00); // red sendPixel(0x00, 0xBB, 0x00); // green sendPixel(0x00, 0x00, 0xBB); // blue sendPixel(0xBB, 0xBB, 0xBB); // white sendPixel(0xBB, 0x22, 0x22); // pinkish sendPixel(0x22, 0xBB, 0x22); // light green sendPixel(0x22, 0x22, 0xBB); // purplish blue sendPixel(0x00, 0x00, 0x00); // pixel off interrupts(); // interrupts are OK now delay(1000); // hold it for a second } // Sends one byte to the LED strip by SPI. void sendByte (unsigned char { for (unsigned char bit = 0; bit < 8; bit++){ if (b & 0x80) // is high-order bit set? SPI.transfer (SPILONG); // long on bit (~700 ns) defined for each clock speed else SPI.transfer (SPISHORT); // short on bit (~350 ns) defined for each clock speed b <<= 1; // shift next bit into high-order position } // end of for each bit } // end of sendByte // Set up SPI void ledsetup(){ SPI.begin (); SPI.setClockDivider (SPIDIV); // defined for each clock speed SPI.setBitOrder (MSBFIRST); SPI.setDataMode (SPI_MODE1); // MOSI normally low. show (); // in case MOSI went high, latch in whatever-we-sent sendPixel (0, 0, 0); // now change back to black show (); // and latch that } // end of ledsetup // Send a single pixel worth of information. Turn interrupts off while using. void sendPixel (unsigned char r, unsigned char g, unsigned char { sendByte (g); // NeoPixel wants colors in green-then-red-then-blue order sendByte (r); sendByte (; } // end of sendPixel // Wait long enough without sending any bits to allow the pixels to latch and // display the last sent frame void show(){ delayMicroseconds (9); } // end of show // Display a single color on the whole string. Turn interrupts off while using. void showColor (unsigned int count, unsigned char r , unsigned char g , unsigned char { noInterrupts (); for (unsigned int pixel = 0; pixel < count; pixel++) sendPixel (r, g, ; interrupts (); show (); // latch the colours } // end of showColor The timing, when checked on a logic analyzer, checks out with the calculations above (hooray for math). The "gaps" between pulses are within tolerance and largely set by code overhead as well as the byte being sent. And here it is showing the strip lit up in one color. I tried this on several other LaunchPads I had handy and here is a summary: FR6989 - I had never noticed, but Energia defaults to 8 MHz. Doing the math, there isn't a good match to the WS2812 requirements without changing processor speed (which I did not try). MSP432 - there was behavior I couldn't explain, probably due to RTOS and I didn't pursue this for long. In summary, the method works although I did limited experimentation. It would be even easier to implement outside of Energia with full access to clocks. It was an interesting exercise but alternative methods have been posted here on 43oh with tuned assembler and having used those successfully in the past, I will probably continue to preferentially use them in the future.
  2. MSP432 WS2811 Library port

    Has any one been able to port the WS2811 lib to msp432?
  3. Here is some code to drive ws281x strips using DMA driven SPI for the msp430f5529. I hadn't seen any example code showing how to use DMA and SPI. The example also provides some code that shows how to use inline asm that will work with both msp430-gcc and msp430-elf-gcc. The code below was tested with a ws2811 strip and msp430-elf-gcc. https://gist.github.com/RickKimball/9761b8f5a89d46a53939 -rick
  4. Some time ago, I wrote about WS2812D, an 8mm RGB LED with built-in controller (WS2811.) However, that LED was killed off after very short run. Since then, APA Electronics came out with it's own version, APA-106, which is compatible with WS2811. I have 2 versions available in my store right now, 5mm and 8mm. They are perfect for any breadboarding or through hole project. I will be using them in updated versions of my clocks (Geek & Gear.)
  5. GrownUp LA Gears

    As I teased a little bit in another post, here's my latest project: GrownUp LA Gears! For those of us who were growing up in the mid 90s, LA Gears were the best thing you could strap to your feet. They had LEDs in the heal that would flash when you walked. I wasn't lucky enough to have a pair when I was a kid, so maybe this whole thing is just me living out a lost childhood fantasy..... Much like the WS2811 driver library this project is being used to demo, I also snagged the idea from AdaFruit: https://learn.adafruit.com/firewalker-led-sneakers/overview I recommend reading through the post, since they do a better job of explaining things than I will here. While their design is good, there are some improvements to be made. Mainly, there isn't an MSP430 in it. Hardware I didn't want to strap a launchpad to my shoe, so I deadbuged a 430 with the minimal requirements to run it. A small 3.3V LDO, pins broken out for input and programming, and a pullup on RST. I don't have pictures of the final build, but you get the idea. Once all the joints were made, they were encased in hot glue, the best strain-reliever and sealer known to man. For the shoe itself, the LEDs where mounted around the perimeter and glued in with RTV silicon adhesive (https://learn.adafruit.com/firewalker-led-sneakers/attach-neopixel-led-strip). I ended up drilling some holes in the battery case and sewing it to the side of the shoes. The Chucks worked well because they have handy vent holes on the sides to run wires through (they are also classy for every occasion). AdaFruit used a custom sensor made of velostat, a material which changes resistance when force is applied. If you connect the sensor between ground and an analog input, then turn on an internal pullup for that IO, you can essentially make a simple voltage divider. The problem here was that the velostat sensor I made went from 1kohm with no pressure, to 300 with pressure. This in series with the internal 40k of the MSP was just too small a range to detect well. I ended up using a force sensor from SparkFun that goes from 1Mohm down to 1kohm. It saturate at 10kg, but it works well. I may revisit the velostat for cost reasons, but I'm happy with this guy: https://www.sparkfun.com/products/9376 I ended up just gaff taping it down inside the heal. With LEDs on, and sensor in place, it just has to be wired up. Here's a quick block diagram and image of what it all looks like mounted. You can see that I left TEST and RST on there for programming. Software The main push behind these was that I had the modifications to Rickta59's WS2811 driver done, and needed a demo platform ( http://forum.43oh.com/topic/2882-energia-library-ws2811driver-led-controller-class/ ). Since that lib does the hard part, the rest of the Energia project is pretty easy, and hopefully well documented in line. #include <WS2811Driver.h> #define N_LEDS 44 // TOTAL number of LEDs in strip #define SHOE_LEN_LEDS 23 // Number of LEDs down ONE SIDE of shoe #define SHOE_LED_BACK 8 // Index of REAR-MOST LED on shoe #define STEP_PIN 2 // Analog input for footstep #define LED_PIN 3 // NeoPixel strip is connected here #define MAXSTEPS 3 // Process (up to) this many concurrent steps #define STEP_TRIGGER 30 #define STEP_HYSTERESIS 200 WS2811Driver strip = WS2811Driver(N_LEDS, LED_PIN, NEO_GRB); //Globals, becouse lazy boolean stepping = true; // If set, step was triggered, waiting to release uint8_t dup[SHOE_LEN_LEDS]; // Inside/outside copy indexes uint16_t Filtered; uint8_t step_order = 1; void setup() { //Enable internal pullup for analog sensor pinMode(STEP_PIN, INPUT_PULLUP); //Setup the array to index the two sides of the shoe memset(dup, 255, sizeof(dup)); int8_t a, b; for(a=1 , b=SHOE_LED_BACK-1 ; b>=0 dup[a++] = b--; for(a=SHOE_LEN_LEDS-2, b=SHOE_LED_BACK+SHOE_LEN_LEDS; b<N_LEDS;) dup[a--] = b++; //Start the LEDStrip strip.begin(); //Max desired drightness strip.setBrightness(255); } void loop() { //Wait until a step is detected while (stepping == false) { pinMode(STEP_PIN, INPUT_PULLUP); Filtered = analogRead(STEP_PIN); if(Filtered < STEP_TRIGGER) stepping = true; } //A step has been detected, so play the desired pattern //Pulse a different color each step and then fade out switch(step_order){ case 1: colorWipe(strip.Color(0, 0, 255), 5); // Blue step_order = 2; break; case 2: colorWipe(strip.Color(255, 0, 0), 5); // Red step_order = 3; break; case 3: colorWipe(strip.Color(0, 255, 0), 5); // Green step_order = 1; break; } for(uint16_t i=0; i<128; i++) { strip.setBrightness(255-(2*i)); strip.show(); } colorWipe(strip.Color(0, 0, 0), 1); // blank strip.setBrightness(255); //Restore brightness for next pass //Simple back to front color wipe /* colorWipe(strip.Color(128, 0, 10), 5); // Redish colorWipe(strip.Color(255, 255, 255), 5); // White colorWipe(strip.Color(0, 0, 0), 5); // blank */ //Holdoff until the foot has been lifted while (stepping == true) { pinMode(STEP_PIN, INPUT_PULLUP); Filtered = analogRead(STEP_PIN); if(Filtered > STEP_HYSTERESIS) stepping = false; } } // Fill the dots one after the other with a color void colorWipe(uint32_t c, uint8_t wait) { uint8_t j; for(uint16_t i=0; i<strip.numPixels(); i++) { strip.setPixelColor(i+SHOE_LED_BACK, c); // Pixels along inside are funny... j = dup[i]; if(j < 255) strip.setPixelColor(j, c); strip.show(); delay(wait); } } Final Product And here it is! I wore then to a friend of mines baby gender reveal party, and the three AAAs lasted all night. No idea what the actual battery life is yet, but I'll probably do a V2 with a LiPo system. The rainbow pattern is actually in the sample code I put with the library, I was just testing it here. The videos really show it off. Just ignore my messy living room. These are both out of the code I posted above, just comment out the different sections.
  6. WIZpix is an internet enabled RGB pixel controller with built in PoE. WIZpix uses W5500 internet appliance to connect to internet and MSP430F5172 MCU to control RGB pixels. Built-in DC/DC converter allows use of PoE, which eliminates need for directly connected power supply, ability to place controller far away from the outlet, and use of only one inexpensive CAT-5 cable. It
  7. Those APA-102 leds that are packaged like ws281x pixels but you drive like a ws2801 (clk/data) have hit ebay.com. I ordered a 1 meter length and it arrived today. They look and feel like a ws2811 strip. It has 4 connections. 5V, GND, CLK, DATA. I whipped up a quick test and they seem to be happy: /** * APA-102 - test of 5 leds * * Author: rick@kimballsoftware.com * Date: 09-11-2014 * */ #include <fabooh.h> #include <main.h> #include <spi.h> namespace { typedef spi_attr_t<> SPI_MODE3_A; typedef spi_eusci_b0_t<CS, SCLK, MOSI, NO_PIN, SPI_MODE3_A > spi_t; spi_t spi; } void setup(void) { spi.begin(); spi.set_divisor(8); // 1MHz spi } static const unsigned char buff0[] = { 0x00, 0x00, 0x00, 0x00, // start frame (0b111 << 5 | 31), 0x00, 0x00, 0xFF, // red (0b111 << 5 | 31), 0x00, 0xFF, 0x00, // green (0b111 << 5 | 31), 0xFF, 0x00, 0x00, // blue (0b111 << 5 | 31), 0xFF, 0xFF, 0xFE, // white (0b111 << 5 | 31), 0x00, 0x00, 0x00, // off 0xFF, 0xFF, 0xFF, 0xFF // end frame }; static const unsigned char buff1[] = { 0x00, 0x00, 0x00, 0x00, // start frame (0b111 << 5 | 31), 0x00, 0x00, 0x00, (0b111 << 5 | 31), 0x00, 0x00, 0x00, (0b111 << 5 | 31), 0x00, 0x00, 0x00, (0b111 << 5 | 31), 0x00, 0x00, 0x00, (0b111 << 5 | 31), 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF // end frame }; void loop(void) { while(1) { spi.select(); spi.shiftout(buff0, sizeof(buff0)); spi.deselect(); delay(1000); spi.select(); spi.shiftout(buff1, sizeof(buff1)); spi.deselect(); delay(1000); } } These chips are perfect when you don't want to run your msp430 at high clock speed but still want to be able to use a bunch of rgb leds without resorting to external led drivers or shift registers. However, if you do want to run fast, even faster than the ws281x 800kHz, you can. I tested with both a low speed (500Hz) and a high speed (up to 16MHz) configuration successfully. Using an msp430fr5969 chip at 8MHz I settled on 1MHz in the code above. For a nice review of the chip's internals, you can read more about them on this cpldcpu's blog: http://cpldcpu.wordpress.com/2014/08/27/apa102/ -rick
  8. WS2812 driver for Tiva is available here
  9. WS2812 driver for Tiva (and Stellaris.) It uses hardware SPI and is non-blocking (you can run your code while updating WS2812.) 7/31 - updated demo code and fixed comments about timing main.cstartup_ccs.c
  10. Has anyone hooked up some ws2811 or ws2812 pixels to a connected launchpad (with a 120MHz TMC1294x processor) The closest example I could find for this platform was bit-banging in assembly code for the MSP430 processor. The most common technique on other platforms (Arduino, Pi) is "Fast SPI" where they change the clock rate on the SPI bus to match that of the pixels and send the data out that way. That's kinda pushing the limits of my skills/knowledge though, without an example to look at.
  11. MSP430 Xmas

    This year, LaunchPad has a very special assignment during the holidays - to control our Xmas tree lights. So far, more than 20 different sequences are programmed into G2553. Piano pedal connected to LP allows easy selection. Finally, my wife can have Xmas lights she likes, one day white, another day warm colors, then maybe little strobe light here and there, and so on. There are 100 WS2811 pixels on the tree (those lights look much, much better in real life) (You can see LP right above the train, tiny green light.) MSP430 is also used to power my 10W RGB flood lights.
  12. 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)
  13. This is a continuation of this project. While playing around with my WS2811 strips, I figured that it would be nice to have a board like this one. Could be used with one or two EQ chips and as a stand-alone board. The question is: with booster pack support or without?
  14. 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#?
  15. I ported over oPossum's ws2811 asm routines to msp430-gcc and wrapped it in simple Energia library. This class provides Energia users with a simple class with methods that allow you to configure the datapin, and set the leds colors in a ws2811 led strip. To install, stop running Energia and create a directory in your sketch folder called 'libraries'. Unzip the attached zip file into libraries directory. You should end up with a directory called libraries/WS2811Driver. Restart Energia and you should have some new items in your "File/Sketchbook/libraries/WS2811Driver/Examples" menu item. blink_strip example You need to create an instance of the WS2811Driver class. It provides methods that let you set the number of leds in your strip, it is called setLedCount(). The begin() methjod configures P1.7 as an output pin. The write() call is the main method for setting the leds. The write() method takes an array of uint8_t, it expects 3 bytes of color data per led in Green, Red, Blue order. See the blink_strip.ino example for more details. This could use a lot of work, however some might find it useful. I only ported the high speed 800KHz version of the asm code. One problem with using the asm routines with Energia is that they use cycle counting to achieve accurate timing. This will cause problems with the millis() accuracy. When I'm sending data I disable the watchdog before calling the asm routine and then reenable it after. I've only tested with the msp430g2553, however it might work with the other chips. I was testing with my development environment which is in flux at the moment. You can edit the ws2811.h file and change the port and pins if P1.7 doesn't work for you. -rick WS2811Driver_0_1.zip