TLC5940 + USB Host Shield : Trying to make them working together

Hi there :slight_smile:

My current project is to control leds using a Wiimote.

I have managed to control Leds using TLC5940 with success (very good library).

After some research over the internet I saw that in order to be able to control the Arduino using a Wiimote, I need an Usb Host Shield + bluetooth dongle. ==> http://www.circuitsathome.com/mcu/ps3-and-wiimote-game-controllers-on-the-arduino-host-shield-part-1

My question is : can I connect the TLC5940 and the Usb Host Shlied (the one from circuit@home) on the arduino at the same time ?

The USB host shield seems to use these pins :

Digital Pin 7 used for MAX_RESET
Digital Pin 8 used for GPX
Digital Pin 9/PWM used for INT
Digital Pin 10/PWM used for SS
Digital Pin 11/PWM used for MOSI
Digital Pin 12 used for MISO
Digital Pin 13/LED used for SCLK

And the TLC5940 use these pins :

Digital Pin 13 used for SCLK
Digital Pin 11 used for SIN
Digital Pin 10 used for BLANK
Digital Pin 9 used for XLAT
Digital Pin 3 used for GSCLK

Thanks for reading :slight_smile: and sorry for my bad english :frowning:


EDIT : I also found a moded TLC5940 library using these pins :

Digital Pin 4 used for SCLK
Digital Pin 7 used for SIN
Digital Pin 10 used for BLANK
Digital Pin 9 used for XLAT
Digital Pin 3 used for GSCLK

I don't know if it can help :confused:

Well, after some more reasearch this is what I have in mind :

According to this : http://www.circuitsathome.com/usb-host-shield-hardware-manual
I can change INT and SS pins of the Usb Host Shield which are respectively pin 9 and 10.
These pins are PWM so I can mod the usb host library to use pin 5 and 6.

With this mod the pin map for the Usb Host Shield should be like this :

Digital Pin 7 used for MAX_RESET
Digital Pin 8 used for GPX
Digital Pin 5/PWM used for INT
Digital Pin 6/PWM used for SS
Digital Pin 11/PWM used for MOSI
Digital Pin 12 used for MISO
Digital Pin 13/LED used for SCLK

The moded TLC5940 library use these pins :

Digital Pin 4 used for SCLK
Digital Pin 7 used for SIN
Digital Pin 10 used for BLANK
Digital Pin 9 used for XLAT
Digital Pin 3 used for GSCLK

Pin 7 is already used by the USB Host ^^
But it seems that I can modify the SCLK and SIN pin for TLC5940 library.
The only arduino pin free is the pin 2...

So, the final pin map should be :

usb host :

Digital Pin 7 used for MAX_RESET
Digital Pin 8 used for GPX
Digital Pin 5/PWM used for INT
Digital Pin 6/PWM used for SS
Digital Pin 11/PWM used for MOSI
Digital Pin 12 used for MISO
Digital Pin 13/LED used for SCLK

tlc5940 :

Digital Pin 4 used for SCLK
Digital Pin 2 used for SIN
Digital Pin 10 used for BLANK
Digital Pin 9 used for XLAT
Digital Pin 3 used for GSCLK

How to modify the TLC5940 library (r014_2) :
Open Tlc5940/pinouts/ATmega_xx8.h and search for :

#define DEFAULT_BB_SIN_PIN      PD7

Replace with :

#define DEFAULT_BB_SIN_PIN      PD2

Open Tlc5940/tlc_config.h and search for :

#define DATA_TRANSFER_MODE    TLC_SPI

Replace with :

#define DATA_TRANSFER_MODE    TLC_BITBANG

How to modify the Usb Host Library :
Open USB_Host_Shield/Max3421e_constants.h and set :

#define SS_PIN from 10 to 6
#define MAX_SS from 10 to 6
#define MAX_INT from 9 to 5

This is untested, I'm waiting to receive my USB Host Shield to try.