Connection of LPD8806 to BeagleBone Black

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
cookegmp
 
Posts: 10
Joined: Mon Dec 17, 2012 6:22 pm

Connection of LPD8806 to BeagleBone Black

Post by cookegmp »

Sorry for the silly question. Which pin should I use to connect LPD8806 strips to a BeagleBone Black. In all of the examples included with Python LPD8806 libraries I can not find a pin for data and clock. Thanks for your help and sorry again for the silly question.

-James

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Connection of LPD8806 to BeagleBone Black

Post by adafruit_support_rick »

Which python code are you looking at? Adafruit_LEDPixels.py assigns CLK to pin 18 and DATA to pin 17

User avatar
cookegmp
 
Posts: 10
Joined: Mon Dec 17, 2012 6:22 pm

Re: Connection of LPD8806 to BeagleBone Black

Post by cookegmp »

A ha! I was using the Extended LPD8806 for Pi library.

I need to attach multiple strips and I don't really require SPI. Can I add additional clock and data pins for the extra strips?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Connection of LPD8806 to BeagleBone Black

Post by adafruit_support_rick »

Sure. Adafruit_LEDpixels.py is actually written to use hardware SPI, but it includes a function called slowspiwrite (which it doesn't use). You can use that function and assign however many pairs of clock and data pins you like.

User avatar
paxman81
 
Posts: 3
Joined: Sun Jan 08, 2012 12:25 am

Re: Connection of LPD8806 to BeagleBone Black

Post by paxman81 »

I've been working with Adafruit_LEDPixels.py to run the WS2801 LED Pixels using a Beaglebone Black. SPI isn't really necessary (I also can't get SPI working properly either)

I'd like to use the slowspiwrite() function, but I'm just not sure how to use it. Specifically I"m not sure how the byteout parameter should be used.

I modified writestrip from:

Code: Select all

def writestrip(pixels):
    spidev = file("/dev/spidev0.0", "w")
    for i in range(len(pixels)):
        spidev.write(chr((pixels[i]>>16) & 0xFF))
        spidev.write(chr((pixels[i]>>8) & 0xFF))
        spidev.write(chr(pixels[i] & 0xFF))
    spidev.close()
    time.sleep(0.002)
to

Code: Select all

def writestrip(pixels):
    for i in range(len(pixels)):
        slowspiwrite("P8_10","P8_12",(pixels[i]>>16) & 0xFF)
        slowspiwrite("P8_10","P8_12",(pixels[i]>>8) & 0xFF)
        slowspiwrite("P8_10","P8_12",pixels[i] & 0xFF)
    time.sleep(0.002)
Which causes some pretty erratic behavior with the LEDs. A few other attempts were with some other code got me a little close, but I've only been able to control the 1st LED in a string of 15.

Any help is greatly appreciated.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Connection of LPD8806 to BeagleBone Black

Post by adafruit_support_rick »

The byteout parameter should be identical to the argument in the spidev call:

Code: Select all

        slowspiwrite("P8_10","P8_12", chr((pixels[i]>>16) & 0xFF))
        slowspiwrite("P8_10","P8_12", chr((pixels[i]>>8) & 0xFF))
        slowspiwrite("P8_10","P8_12", chr(pixels[i] & 0xFF))

User avatar
paxman81
 
Posts: 3
Joined: Sun Jan 08, 2012 12:25 am

Re: Connection of LPD8806 to BeagleBone Black

Post by paxman81 »

Thanks. I tried that in my original attempt, but received an error in the slowspiwrite function line

Code: Select all

 if (byteout & 0x80): 
The error was something to the effect of "Cannot combine types str and int." Which is why I removed chr() from the slowspiwrite call. I guess I'm not understanding why chr() has to be used. My full code is below in case my mistake is obvious to anyone else.

Code: Select all

#!/usr/bin/env python

# Test code for Adafruit LED Pixels, uses hardware SPI
import ADAFRUIT_BBIO.GPIO as GPIO, time, os


def slowspiwrite(clockpin, datapin, byteout):
	GPIO.setup(clockpin, GPIO.OUT)
	GPIO.setup(datapin, GPIO.OUT)
	for i in range(8):
		if (byteout & 0x80):
			GPIO.output(datapin, True)
		else:
			GPIO.output(clockpin, False)
		byteout <<= 1
		GPIO.output(clockpin, True)
		GPIO.output(clockpin, False)



ledpixels = [0] * 10

def writestrip(pixels):
	spidev = file("/dev/spidev0.0", "w")
	for i in range(len(pixels)):
		slowspiwrite("P8_10","P8_12", chr((pixels[i]>>16) & 0xFF))
                slowspiwrite("P8_10","P8_12", chr((pixels[i]>>8) & 0xFF))
                slowspiwrite("P8_10","P8_12", chr(pixels[i] & 0xFF))
	spidev.close()
	time.sleep(0.002)

def Color(r, g, b):
	return ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | (b & 0xFF)

def setpixelcolor(pixels, n, r, g, b):
	if (n >= len(pixels)):
		return
	pixels[n] = Color(r,g,b)

def setpixelcolor(pixels, n, c):
	if (n >= len(pixels)):
		return
	pixels[n] = c

def colorwipe(pixels, c, delay):
	for i in range(len(pixels)):
		setpixelcolor(pixels, i, c)
		writestrip(pixels)
		time.sleep(delay)		



colorwipe(ledpixels, Color(255, 0, 0), 0.05)
colorwipe(ledpixels, Color(0, 255, 0), 0.05)
colorwipe(ledpixels, Color(0, 0, 255), 0.05)


User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Connection of LPD8806 to BeagleBone Black

Post by adafruit_support_rick »

I don't know much about python, but I imagine that the chr() was there to make sure that byteout was really just a byte. If you leave it an int, it will probably be 32 bits.

That said, the bit-shifting algorithm will still work, even with a 32-bit argument.

The BBB is faster than the Pi. I'm going to guess that the pulse width on the clockpin is too short. Try adding a 1 microsecond delay:

Code: Select all

      GPIO.output(clockpin, True)
      <add a 1us delay here. If I knew python better, maybe I could tell you how to do that.>
      GPIO.output(clockpin, False)

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”