Shop OBEX P1 Docs P2 Docs Learn Events
Using Propeller to display video on ws2812's — Parallax Forums

Using Propeller to display video on ws2812's

ratronicratronic Posts: 1,451
edited 2015-02-04 11:50 in Propeller 1
While working with colored object tracking using my Activitybot I was distracted by seeing if the Propeller could display video

from the Pi camera to an 8 x 8 matrix of 64 ws2812 led's from Adafruit. I first tried Spin (my preferred language for the Propeller)

but sadly it couldn't keep up with what the Pi was spitting out. So I ended up using David Betz ws2812 library in C to keep up with

the Pi. The C++ program on the Pi captures an 80 x 80 pixel color video frame then proceeds to isolate an 8 x 8 pix of the pixels

in the middle of the video then send a long of color data for each pixel (256 byte packet). So the display looks like a magnified

display of whatever is in the middle of the video. I had to scale back the output of the camera by 10 because the led's are so bright.

https://www.youtube.com/watch?v=NJw2vto3AtM&index=1&list=UUtHTG82Nn83T5JSdWdTgkAg

Edit: 2/3/15 Proper C++ source file for the Pi and cleaned up C code for the activity board in zip file "Activitybotdisplay.zip"
#include <simpletools.h>
#include <fdserial.h>
#include <servo.h>
#include "ws2812.h"

void getPix(void);

#define CENTER 1500
#define LED_PIN 0
#define LED_COUNT 64
#define PAN 8
#define TILT 9
#define PSRV 16
#define SCALE 10
uint32_t ledColors[LED_COUNT];
ws2812_t driver;
fdserial *ser;
int n;

int main() {
   set_directions(27, 26, 0b11);
   ser = fdserial_open(6, 7, 0, 115200);   
   
   if (ws2812b_init(&driver) < 0) {
     return 1;
   }       
   ws2812_refresh(&driver, LED_PIN, ledColors, LED_COUNT); 
   servo_set(PAN, CENTER);
   servo_set(TILT, CENTER);
   servo_set(PSRV, CENTER); 
     
   for (;;) {
     toggle(26);
     n = 0;
     while(n < 64) {
       ledColors[n++] = 0;
     }
     getPix();
     ws2812_refresh(&driver, LED_PIN, ledColors, LED_COUNT);
     pause(10);   
   }
   return 0;
}

void getPix(void) {
   n = 0;
   while(1) {
     if(fdserial_rxCheck(ser) == 33) {
       if(fdserial_rxTime(ser, 1) == 38) {
         toggle(27);
         while(n < 64) {
           ledColors[n] |= fdserial_rxChar(ser) / SCALE;
           ledColors[n] |= fdserial_rxChar(ser) / SCALE << 8 ;
           ledColors[n++] |= fdserial_rxChar(ser) / SCALE << 16;
         }
         break;   
       }          
     }       
  } 
}

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-02-02 12:11
    The linked video is private.

    This sounds really cool. I really want to see this.

    I've displayed monochrome video on a 12x10 LED array once but color sounds really interesting.
  • ratronicratronic Posts: 1,451
    edited 2015-02-02 12:12
    Let me see if I can fix that.

    Edit: Ok finally got it fixed https://www.youtube.com/watch?v=NJw2vto3AtM&list=UUtHTG82Nn83T5JSdWdTgkAg

    Can someone let me know if the video is viewable?
  • ratronicratronic Posts: 1,451
    edited 2015-02-02 13:06
    The Raspberry Pi only sends 3 bytes per pixel but the Propeller and David's program uses a long to assemble each pixel.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-02-02 13:14
    Fantastic!

    I love it. Very cool.
  • bte2bte2 Posts: 154
    edited 2015-02-02 20:45
    I too used Sparkfun boxes to set up my PiXY camera.
  • ratronicratronic Posts: 1,451
    edited 2015-02-03 07:40
    bte2 that is a Raspberry Pi camera box but I use SparkFun boxes too!

    Edit: And of course I use Parallax boxes for the heavy stuff.
  • Heater.Heater. Posts: 21,230
    edited 2015-02-03 08:42
    That's really nice.

    Reminds me of TV when I was a kid, but with colour !
  • David BetzDavid Betz Posts: 14,516
    edited 2015-02-03 08:48
    Nice! You'll only need 32,400 of those 8x8 modules to make an HD display!
  • ratronicratronic Posts: 1,451
    edited 2015-02-03 20:15
    I had put the wrong C++ source file for the Pi in the first zip file posted. The file "Activitybotdisplay.zip" contains the proper C++ file for the Pi called "vdo.cpp"

    and cleaned up the C code for the Activity board.
  • JDatJDat Posts: 103
    edited 2015-02-04 11:50
    Well! Some offtopic. I already done this with propeller!
    How it works?
    PC software: http://www.live-leds.de/
    Propeller:
    DMX-in library (by JonnyMac)
    WS2812 library (by JonnyMac)
    Some small SPIN code.
    LED panel: http://rgb-123.com/product/143/
    Leds Need ~ 6.5 Ampheres @ 5 VDC. I am using ATX PSU for LEDs.

    PC software reads, play and transform (with FFMPEG???)video file to DMX
    DMX is send to PropPulu (FT232RL)
    Propeller receive DMX data.
    Propeller convert DMX buffer content to WS2812 format.
    Propeller show data on 16x8 WS2812B LED panel.

    It all could be coded much better, but... It's just proof of concept. So, technically it is possible for raspberry PI, but you need some coding.

    dmx_ws2812b.zip

    BTW: One WS2812B LED need 50 mA current. Size ~ 5x5 mm.
    If you want to build FullHD LED screen, you need:
    1920x1080 pixels. It is 2*073*600 LEDs.
    2*073*600 leds will cost 1*036*800 USD + shipments, if 1 LED cost 0.5 USD.
    If pixel (LED) size is 5x5 mm. Minimal screen size is 9.6 meters x 5.4 meters.
    If one LED need 50 mA current then screen need 103*680 Amperes current @ 5 VDC. ~ 518*400 W ( 518 kW) power.
    What is weight for this constructin with frames?
    If one propeller can handle 1920 LEDs, you need at least 1080 propellers to control all leds.
    Any kickstarter project to build this? :D
Sign In or Register to comment.