Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Newbie Help (RPi3, LDP8806)
#1
Hi All,

I have a project that I'm working on for my wedding this summer. I'm creating 12 independently controlled light fixtures that will light 12 silk lanterns that we purchased on a trip to Asia. I've been waiting on the shipment for the controllers I intend to use for the project but in the mean time i thought it would be a good introduction to get them setup with a RPi3.

I have the strip powered, I have gone through the SPI Setup, but I can't seem to get any response from the LED strip for any of the scripts that I have tried writing... wondering if anyone would have any insight into what the problem might be.

Here is a breakdown of my setup.

RPi3 running Jessie, the led strip is powered by a 5v 1A power supply, I have DI on the strip connected to pin 19 and CI to pin 23, 

$ pip freeze
Code:
BiblioPixel==2.0.9
chardet==2.3.0
colorama==0.3.2
gpiozero==1.1.0
html5lib==0.999
lxkeymap==0.1
mcpi==0.1.1
ndg-httpsclient==0.3.2
numpy==1.8.2
picamera==1.10
pifacecommon==4.2.1
pifacedigitalio==3.1.0
Pillow==2.6.1
pyasn1==0.1.7
pygame==1.9.2a0
pygobject==3.14.0
pyOpenSSL==0.13.1
pyserial==3.0.1
requests==2.4.3
RPi.GPIO==0.6.2
RTIMULib==7.2.1
sense-hat==2.1.0
six==1.8.0
spidev==3.1
urllib3==1.9.1

I do see see the SPI devices within /dev/
$ls /dev/soi*
Code:
/dev/spidev0.0  /dev/spidev0.1


Simple Python Script
Code:
#!/usr/bin/env python

from bibliopixel import *
from bibliopixel.drivers.LPD8806 import *
from bibliopixel.led import *
import bibliopixel.colors as colors


log.setLogLevel(log.DEBUG)

driver = DriverLPD8806(16, use_py_spi=True, c_order=ChannelOrder.RGB, dev="/dev/spidev0.0", SPISpeed=2 )
led = LEDStrip(driver)


print 'one'
led.all_off()
print 'two'
led.fillRGB(100,100,100)
print 'three'
led.update()
print 'four'


Now, when i run this script i don't get any errors, the script runs and returns however after some testing nothing runs after "led.update()" the output from the script looks like this: 

$ sudo ./test.py
Code:
INFO - spi_driver_base - py-spidev speed @ 2.0 MHz
one
two
three


It appears that the script stops execution after the call to update, and does not provide an error as to why the script exits... somewhat weird. Any idea what might be the issue here? Any help would be greatly appreciated. 

Thanks in advance! 
#2
Hmmm... interesting. Setup looks good.
Are you running your script with sudo? That is required for SPI access.
Also, have you enabled SPI in raspi-config?
#3
Thanks for sharing the great work.

+1 on the above.  Seeing the exact same behavior, though I am running on a pi2.  Wondering if it may be a problem with the SPI driver:

Code:
pi@raspberrypi:~ $ sudo pip install spidev --upgrade
Downloading/unpacking spidev from https://pypi.python.org/packages/source/s/spidev/spidev-3.2.tar.gz#md5=f601676f1bb48b9aa3b3897f95216365
Downloading spidev-3.2.tar.gz
Running setup.py (path:/tmp/pip-build-093Ujt/spidev/setup.py) egg_info for package spidev
 
Installing collected packages: spidev
Found existing installation: spidev 3.0
  Not uninstalling spidev at /usr/lib/python2.7/dist-packages, owned by OS
Running setup.py install for spidev
  building 'spidev' extension
  arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c spidev_module.c -o build/temp.linux-armv7l-2.7/spidev_module.o
  spidev_module.c:20:20: fatal error: Python.h: No such file or directory
   #include <Python.h>
                      ^
  compilation terminated.
  error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
  Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-093Ujt/spidev/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-BxAXN3-record/install-record.txt --single-version-externally-managed --compile:
  running install

running build

running build_ext

building 'spidev' extension

creating build

creating build/temp.linux-armv7l-2.7

arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c spidev_module.c -o build/temp.linux-armv7l-2.7/spidev_module.o

spidev_module.c:20:20: fatal error: Python.h: No such file or directory

#include <Python.h>

                  ^

compilation terminated.

error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1

----------------------------------------
Can't roll back spidev; was not uninstalled
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-093Ujt/spidev/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-BxAXN3-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip-build-093Ujt/spidev
Storing debug log for failure in /root/.pip/pip.log




if I try it with use_py_spi=False:

Code:
pi@raspberrypi:~ $ sudo python animateLEDs.py
here
Traceback (most recent call last):
File "animateLEDs.py", line 19, in <module>
  anim.run()
File "/usr/local/lib/python2.7/dist-packages/bibliopixel/animation.py", line 185, in run
  self._run(amt, fps, sleep, max_steps, untilComplete, max_cycles, seconds)
File "/usr/local/lib/python2.7/dist-packages/bibliopixel/animation.py", line 124, in _run
  self._led.update()
File "/usr/local/lib/python2.7/dist-packages/bibliopixel/led.py", line 136, in update
  d._update(self.buffer[pos:d.bufByteCount + pos])
File "/usr/local/lib/python2.7/dist-packages/bibliopixel/drivers/driver_base.py", line 51, in _update
  self.update(data)
File "/usr/local/lib/python2.7/dist-packages/bibliopixel/drivers/spi_driver_base.py", line 80, in update
  self._sendData()
File "/usr/local/lib/python2.7/dist-packages/bibliopixel/drivers/spi_driver_base.py", line 75, in _sendData
  self.spi.write(self._buf)
TypeError: must be string or buffer, not list

Here is the code:
Code:
from bibliopixel.drivers.LPD8806 import *
from bibliopixel.drivers.visualizer import *
from bibliopixel import LEDStrip
#import the module you'd like to use
from BiblioPixelAnimations.strip import Rainbows

#init driver with the type and count of LEDs you're using
driver = DriverLPD8806(num=26, use_py_spi=False)
#driver = DriverVisualizer(num=26)

#init controller
led = LEDStrip(driver)

#init animation; replace with whichever animation you'd like to use
anim = Rainbows.RainbowCycle(led)
print("here")
try:
   #run the animation
   anim.run()

The code works fine with the visualizer driver instead.

Here is a pip freeze:

Code:
pi@raspberrypi:~ $ pip freeze
BiblioPixel==2.0.9
BiblioPixelAnimations==4b58357c675ac4c3f752294047980ba2f084c6e6
Pillow==2.6.1
RPi.GPIO==0.6.2
RTIMULib==7.2.1
argparse==1.2.1
chardet==2.3.0
colorama==0.3.2
gpiozero==1.1.0
html5lib==0.999
lxkeymap==0.1
mcpi==0.1.1
ndg-httpsclient==0.3.2
numpy==1.8.2
picamera==1.10
pifacecommon==4.2.1
pifacedigitalio==3.1.0
pyOpenSSL==0.13.1
pyasn1==0.1.7
pygame==1.9.2a0
pygobject==3.14.0
pyserial==3.0.1
requests==2.4.3
sense-hat==2.1.0
six==1.8.0
spidev==3.0
urllib3==1.9.1
wheel==0.24.0
wsgiref==0.1.2
#4
Hmmm...looks like something changed on the pi recently in regards to SPI. What version of Rasbian are you using?
I will try to take a stab at it tonight.
#5
(03-23-2016, 08:26 AM)Adam Wrote: Hmmm...looks like something changed on the pi recently in regards to SPI. What version of Rasbian are you using?
I will try to take a stab at it tonight.

uname - a gives me:
Linux raspberrypi 4.1.19-v7+ #858 SMP Tue Mar 15 15:56:00 GMT 2016 armv7l GNU/Linux
#6
Grab BiblioPixel v2.0.10 (latest) and this should be fixed.
Sadly the 2.x version of spidev has been completely removed and I could not test with it. But I've confirmed this is working on spidev 3.0-3.2
Also, I'm not sure how it ever worked with use_py_spi=False (file access mode). That was completely broken.
My guess is that it broke with a change in python itself.
Anyways, now it's in a state of "works with the latest"
#7
(03-24-2016, 11:04 PM)Adam Wrote: Grab BiblioPixel v2.0.10 (latest) and this should be fixed.
Sadly the 2.x version of spidev has been completely removed and I could not test with it. But I've confirmed this is working on spidev 3.0-3.2
Also, I'm not sure how it ever worked with use_py_spi=False (file access mode). That was completely broken.
My guess is that it broke with a change in python itself.
Anyways, now it's in a state of "works with the latest"
It worked first time!  You are the best, thanks!


Forum Jump:


Users browsing this thread: 1 Guest(s)