snunn wrote:I have tried various demo's of controlling the LEDs but all I can ever seem to accomplish is some random flashing at best. Has anyone else had any luck?
When you say "random" where the pixels do what they should have been doing (i.e. correctly controlled) but just running test paterns, or not correctly controlled?
Which pixels and software have you tried?
I haven't had chance do anything this week - with snow, a project deadline of Friday, windows update killing my PC, a tax return and a 50th Birthday.
I can confirm that this works with a model B pi and WS2801s. A short video
I have the same thing set up, but I am powering the lights (blue/red) with an external power supply. What is the white wire(at the first light) connected to in your setup?
DO NOT assume wire colors are the same between strings you see... they aren't. You can order 10 of the same string from the same supplier, and they may not all be the same.
snunn wrote:I have the same thing set up, but I am powering the lights (blue/red) with an external power supply. What is the white wire(at the first light) connected to in your setup?
The red and white wires taped together are for injecting power - the string came with female socket (+5V, data, clock and 0V to connect to the controller), red and white wires for the pixel power. They are unused (taped up). As I am only testing with 3 pixels, +5V power is from the GPIO pin 2 (dont do this with a long string). Ground is pin 6, data is MOSI pin 19 and clock SCLK pin 23.
If you are using a seperate power supply have you connected the 0V from the power supply to the PI? If not you need to, connecting to pin 6 should do it (make sure you get it correct or you can kill the PI - if in doubt google it!).
Most of the problems I had came from spidev.
Type:
ls /sys/class
it should bring up some text in blue - spidev should be listed (mind is in the 4th column).
If its there, type:
ls dev/
it should bring up some text in blues and yellow - spidev0.0 and spidev0.1should be listed (mine is in the 3rd column).
If they are not there Type:
/etc/modprobe.d/raspi-blacklist.conf
In my case it listed:
blacklist spi-bcm2708
blacklist i2c-bcm2708
use the arrow keys to insert a # before blacklist spi-bcm2708
so it now looks like this:
#blacklist spi-bcm2708
blacklist i2c-bcm2708
Save using Ctrl R. Y. and exit using Ctrl X. Reboot your PI.
That was the main problem that was stopping my pixels working - then I had to mess around with the pixelpi cofigs. To get pixelpi to run for the first time I had to type:
sudo python /home/pi/PixelPi/pixelpi.py chase --chip WS2801 --spi_dev spidev0.0 --num_leds 3
note: no -- before the 'chase' the capital 'P' in the frist /PixelPI bit not in the second.
You should get a 1 sec pause and then a screen message 'Displaying...' and blinky flashy.
you can mess with the --refresh_rate (500 is default = 500ms). I haventt found a way to end the test - I power down the PI.
Hope that helps.
Woot! I got my lights working under java and can now control them correctly.
I am chalking up my problems to my power supply and the fact I picked the wrong mhz for the spi! lol.
I resoldered everything, and have a new power supply on order which I will use to power the 110 light strand
for testing.
I am using Java to control the lights using pi4j. So far the java code seems fast, I can control
110 lights and send out 255 different sets of color to the 110 lights in 1.8 seconds.
If I am thinking correctly, that means the code *could* set 127 universes(each containing a 110 lights) a second
or as currently tested a single string with a 110 lights a 127 times a second. Once I get a new power supply, I will
test out using the GPIO pins and 2 SN74145N's (or 744514's) to "route" the spi to individual strands of lights.
My goal is to be able to route spi and the clock to the appropriate universe. While I wait for the power supply I will
add a datagram socket to the code and start decoding the E1.31 protocol to use for control.
Here is the code so far:
package test.test2;
import java.util.Random;
import com.pi4j.wiringpi.Gpio;
import com.pi4j.wiringpi.Spi;
public class App {
public static void main(String[] args) {
System.out.println("Test 2!");
System.out.println("Out:" + Spi.wiringPiSPISetup(0, 500000));// 1mhz=1000000
System.out.println("Out:" + Gpio.wiringPiSetupSys());
int num_leds = 110;
try {
// Using a file vs wiringPi:
//
// FileOutputStream fos = new FileOutputStream(new
// File("/dev/spidev0.0"));
// fos.write(colors);
// fos.flush(); //limited success with this
Random randomGenerator = new Random();
for (;;) {
int colorToUse1 = randomGenerator.nextInt(255);
int colorToUse2 = randomGenerator.nextInt(255);
int colorToUse3 = randomGenerator.nextInt(255);
long startTimeMillis = System.currentTimeMillis();
// fade all lights out...
for (int j = 0; j < 255; j++) {
byte[] colors = new byte[num_leds * 3];
for (int i = 0; i < num_leds * 3; i = i + 3) {
colors = (byte) colorToUse1;
colors[i + 1] = (byte) colorToUse2;
colors[i + 2] = (byte) colorToUse3;
}
if (colorToUse1 != 0)
colorToUse1--;
if (colorToUse2 != 0)
colorToUse2--;
if (colorToUse3 != 0)
colorToUse3--;
Spi.wiringPiSPIDataRW(0, colors, colors.length);
Gpio.delayMicroseconds(800); // need to determine optimal value
}
System.out.println("Elapsed:"
+ (System.currentTimeMillis() - startTimeMillis));
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
