sukisan
Posts: 10
Joined: Mon Jul 07, 2014 10:20 pm

TCL5947 via SPI from Python

Mon Jul 07, 2014 10:44 pm

Hey guys,

I'm trying to use the Adafruit 24-Channel 12-bit PWM LED Driver with an SPI interface from Python. I checked that SPI itself is working by using a small C program. The problem is, I can't convince the board to produce any meaningful output. All I get is a dirty ground signal on all channels. I probe the outputs directly with a oscilloscope, nothing else connected.

I already took a step back and bit banged the outputs roughly reproducing what's happening in the Adafruit library. No luck at all. Here's the script, containing both attempts.

For the SPI-Version I'm using the py-spidev lib.

First I'd like to make sure my hardware setup (connections, measurement, ..) is working properly and the chip is still alive. Does any of you have a working test script (whatever language) to simply produce valid output?

I found FPulse, but the readme is kinda sparse - dunno what "bcm2835 shared library" he's talking about.. oO

Any help highly appreciated! Thanks :-)

User avatar
joan
Posts: 14006
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: TCL5947 via SPI from Python

Tue Jul 08, 2014 3:50 am

What connections have you made between the SPI chip and the PI? A photo would be useful.

sukisan
Posts: 10
Joined: Mon Jul 07, 2014 10:20 pm

Re: TCL5947 via SPI from Python

Tue Jul 08, 2014 7:21 am

Please find attached four pictures...well, three pictures as it's the limit, the fourth is only highres available.

Other three links clickable:
IMG_7950
IMG_7951
IMG_7953
Attachments
IMG_7953.jpg
https://dl.dropboxusercontent.com/u/4701827/spi_connections/IMG_7953_highres.jpg
IMG_7953.jpg (53.13 KiB) Viewed 2561 times
IMG_7951.jpg
https://dl.dropboxusercontent.com/u/4701827/spi_connections/IMG_7951_highres.jpg
IMG_7951.jpg (57.71 KiB) Viewed 2561 times
IMG_7950.jpg
https://dl.dropboxusercontent.com/u/4701827/spi_connections/IMG_7950_highres.jpg
IMG_7950.jpg (60.22 KiB) Viewed 2561 times

User avatar
joan
Posts: 14006
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: TCL5947 via SPI from Python

Tue Jul 08, 2014 7:45 am

I can't quite make out the colours/connections. Could you fill in the gaps?

Code: Select all

white  p1-4  5V    --->?
       p1-6  GND   --->?

       p1-9  gpio4 --->?
       p1-11 GND   --->?

yellow p1-19 MOSI  --->?

orange p1-23 SCLK  --->?
brown  p1-25 GND   --->?
It's a pity it's a 4-wire device.

sukisan
Posts: 10
Joined: Mon Jul 07, 2014 10:20 pm

Re: TCL5947 via SPI from Python

Tue Jul 08, 2014 8:00 am

joan wrote:It's a pity it's a 4-wire device.
hehe

Code: Select all

white  p1-4  5V    ---> V+
brown  p1-6  GND   ---> used as reference for the oscilloscope

       I think you've been 1 off here, right?
brown  p1-9  GND    ---> /OE
blue   p1-11 GPIO17---> LAT

yellow p1-19 MOSI  ---> DIN

orange p1-23 SCLK  ---> CLK
brown  p1-25 GND   ---> GND

User avatar
joan
Posts: 14006
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: TCL5947 via SPI from Python

Tue Jul 08, 2014 9:47 am

Yes, my mistake about P1-9/11. I meant pity it's a 3-wire device (I don't know why I typed 4-wire). You get no confirmation of internal working.

I'm afraid I can't see anything wrong with the connections.

wrobell
Posts: 15
Joined: Fri Sep 06, 2013 9:47 am

Re: TCL5947 via SPI from Python

Tue Jul 08, 2014 1:14 pm

sukisan wrote: I found FPulse, but the readme is kinda sparse - dunno what "bcm2835 shared library" he's talking about.. oO
The library can be found at

http://www.airspayce.com/mikem/bcm2835/

I will update the README file soon. Thanks for pointing out.

sukisan
Posts: 10
Joined: Mon Jul 07, 2014 10:20 pm

Re: TCL5947 via SPI from Python

Wed Jul 09, 2014 3:13 pm

I installed the bcm2835 library and compiled Python3.4 from source to be able to run FPulse. I also copied fpluse/bin/fpulse to fpulse/fpulse.py to be able to run it without installing the module. Now I'm able to run

Code: Select all

sudo python3.4 fpulse.py tlc5947 conf/morse.conf
but I still don't see any PWM :-(

By reading the FPulse source, I guess the above line should set the outputs 0-2 alternating between high and low for 0.5s (roughly). But all outputs just stay low.

I changed the wiring that the tlc board is powered by 3.3V only (which at least gives me consistent output levels). I can confirm that LAT is being pulled low for ~10ms every...second or so. CLK goes high for ~10ms at roughly the same frequency. On DIN (I'm actually measuring DOUT) I see very short spikes. I wish I had a digital oscilloscope to be more precise :? Anyway, this seems a bit odd to me. Shouldn't CLK and DIN fluctuate at a much higher frequency than LAT? Can anyone confirm that this is the correct behavior?

User avatar
joan
Posts: 14006
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: TCL5947 via SPI from Python

Wed Jul 09, 2014 3:27 pm

sukisan wrote: ...
I wish I had a digital oscilloscope to be more precise
...
You could try piscope. I normally run it from a Linux laptop rather than my Pi which I use headless. As long as your pulses are in the several microseconds long region you should be able to see what us going on. piscope is a purely passive monitor.

sukisan
Posts: 10
Joined: Mon Jul 07, 2014 10:20 pm

Re: TCL5947 via SPI from Python

Wed Jul 09, 2014 3:42 pm

oh wow, this looks handy.

But for now, problem solved!

However, I can't completely explain the problem origin yet. Solution first: I had to pull up the outputs to V+. I used a 10k resistor. I guess it has something to do with the outputs being low active and wired as open drain?

wrobell
Posts: 15
Joined: Fri Sep 06, 2013 9:47 am

Re: TCL5947 via SPI from Python

Thu Jul 10, 2014 2:00 pm

Could you explain exactly how do you connect the LED driver and Raspberry Pi. Also, which code exactly you are using and how? (I know there is some information but looks quite random at this stage).

Return to “Interfacing (DSI, CSI, I2C, etc.)”