TLC5940 and Ethernet Shield using SPI

its connected exactly as described in the tlc5940 libary demo "BasicUse". ie:

/*
    Basic Pin setup:
    ------------                                  ---u----
    ARDUINO   13|-> SCLK (pin 25)           OUT1 |1     28| OUT channel 0
              12|                           OUT2 |2     27|-> GND (VPRG)
              11|-> SIN (pin 26)            OUT3 |3     26|-> SIN (pin 11)
              10|-> BLANK (pin 23)          OUT4 |4     25|-> SCLK (pin 13)
               9|-> XLAT (pin 24)             .  |5     24|-> XLAT (pin 9)
               8|                             .  |6     23|-> BLANK (pin 10)
               7|                             .  |7     22|-> GND
               6|                             .  |8     21|-> VCC (+5V)
               5|                             .  |9     20|-> 2K Resistor -> GND
               4|                             .  |10    19|-> +5V (DCPRG)
               3|-> GSCLK (pin 18)            .  |11    18|-> GSCLK (pin 3)
               2|                             .  |12    17|-> SOUT
               1|                             .  |13    16|-> XERR
               0|                           OUT14|14    15| OUT channel 15
    ------------                                  --------

    -  Put the longer leg (anode) of the LEDs in the +5V and the shorter leg
         (cathode) in OUT(0-15).
    -  +5V from Arduino -> TLC pin 21 and 19     (VCC and DCPRG)
    -  GND from Arduino -> TLC pin 22 and 27     (GND and VPRG)
    -  digital 3        -> TLC pin 18            (GSCLK)
    -  digital 9        -> TLC pin 24            (XLAT)
    -  digital 10       -> TLC pin 23            (BLANK)
    -  digital 11       -> TLC pin 26            (SIN)
    -  digital 13       -> TLC pin 25            (SCLK)
    -  The 2K resistor between TLC pin 20 and GND will let ~20mA through each
       LED.  To be precise, it's I = 39.06 / R (in ohms).  This doesn't depend
       on the LED driving voltage.
    - (Optional): put a pull-up resistor (~10k) between +5V and BLANK so that
                  all the LEDs will turn off when the Arduino is reset.

    If you are daisy-chaining more than one TLC, connect the SOUT of the first
    TLC to the SIN of the next.  All the other pins should just be connected
    together:
        BLANK on Arduino -> BLANK of TLC1 -> BLANK of TLC2 -> ...
        XLAT on Arduino  -> XLAT of TLC1  -> XLAT of TLC2  -> ...
    The one exception is that each TLC needs it's own resistor between pin 20
    and GND.

    This library uses the PWM output ability of digital pins 3, 9, 10, and 11.
    Do not use analogWrite(...) on these pins.

    This sketch does the Knight Rider strobe across a line of LEDs.

    Alex Leone <acleone ~AT~ gmail.com>, 2009-02-03 */

Is D10 used by the TLC5940? If so you need to move it to another pin. D10 is the slave select for the w5100.

yeah it is used by the tlc5940. it is connected to the blank pin on the tlc although im not sure what that does exactly.
if i move it over to another pin for the tlc5940, wont i have to edit the library or something like that to accommodate for a change like that?

if i move it over to another pin for the tlc5940, wont i have to edit the library or something like that to accommodate for a change like that?

Yes.

so i just looked through all of the library files and i cant seem to find where to change the BLANK pin number, unless i'm missing somewhere simple...

The library may not change that pin. I am not familiar with the TLC5940, but I am familiar with the ethernet shield, and what will interfere with it. D10 should not be used by any other device. Don't use D4 either, unless you never plan on using a SD card in the shield slot. That is the slave select for the SD card.

so is it out of the question to choose a different pin than D10 for the ethernet slave select?

Not out of the question. I don't do it, but I have seen posts on the forum where it has been done.

If there is no mention of the BLANK pin, you might try disconnecting that connection from the Arduino. Don't connect the TLC5940 to D10.

Do you know which pin is the SPI slave select for the TLC5940? You will need to know that to initialize the SPI devices.

never mind on changing the ethernet slave select as this seems to be somewhat hardwired through the shield and anything different would have to be connected through wires aka not connecting the shield directly to the top of the arduino.

so i guess i will have to figure out how to change the BLANK pin for use by the TLC5940. According to the playground reference on arduino.cc:

BLANK: this marks the end of a PWM cycle in addition to blanking the output. We will reprogram TIMER1 to generate this signal. That will cost us the native PWMs on digital 9 and digital 10. (Tie a real, physical pull-up resistor on this line to keep things blanked while your Arduino boots. Depending on your hardware, it is possible that the TLC5940 would come up in a configuration that would dissipate too much power.)

So theoretically it should be as simple as finding another timer to use on the arduino

So theoretically it should be as simple as finding another timer to use on the arduino

And this is not possible as the TLC5940 library needs Timer1 and Timer2 to drive the different pins as well as the millis() function which depends on Timer0 being used for it's functionality. But you can use the TLC5940 and the Ethernet shield together if you use another SS pin for the Ethernet shield (you have to modify the shield for that). The only requirement of the shield is that pin 10 is configured as an output and this is the case with the TLC5940 library.
If you want to have it easier, go with an Arduino Mega2560, you have more timer available and more PWM pins, so pin 10 is free for the Ethernet shield.

Im actually going to be using the mega1280 which as i understand, has timers on 5,6,9,11,46.(and timer0 but im not using that)
But i am already using 46 to drive an infrared led as a universal remote (IRremote Library)
TLC and ethernet share pins, 13,11 and 10. 13 and 11 are ok but 10 needs to be changed for the ethernet, and this should be relatively easily done in the library? And tlc absolutely needs 9 and 3 as timer outputs.

This summarizes what we have been discussing right? Is everything correct I hope. I really should stop working on this and study for my microwave active circuits class, haha oh well

and i was looking more at the library pinout code for the tlc and for the mega it still wants to use pin 10 so wouldn't there still be a problem and conflict with the ethernet shield?

On the Mega pin 10 is not used by the TLC5940 library. Look at Arduino_Mega.h. BLANK is on pin 12 not 10.

okay i see that but now however i see that the tlc uses pin 10 for XERR but i guess that usually disconnected so this won't be a problem i assume?
So this is the summary of how things should be connected for Ethernet and TLC:
50: tlc (VPRG)
10: tlc(XERR),ethernet(SS)
51: tlc(SIN)
52: tlc(SCLK)
51: tlc(MOSI)
52: tlc(SCK)
53: tlc(SS)
11: tlc(XLAT)
12: tlc(BLANK)
9: tlc(GSCLK)
46: IRled

So everything should be working with this setup then?

XERR doesn't need to be connected. If you want to connect it, use another pin than 10 and define the corresponding port and bit number in tlc_config.h. XERR must not be connected to pin 10 because pin 10 is an output and XERR on the TLC is an output too, so you produce a short circuit if you connect it that way.

You know that you have two pins twice in your list, don't you?

You may have to save the SPI registers between calls to the Ethernet library and the TLC library.

yeah i guess i do, i just double checked, its like that in the Arduino_Mega parameters in the tlc library

You may have to save the SPI registers between calls to the Ethernet library and the TLC library.

what do you mean by this?

A bit (unusable without modification) code to illustrate what I mean:

byte saved_spcr = 0;
byte saved_spsr = 0;
byte tlc_spcr = 0;
byte tlc_spsr = 0;

void setup() {
  Ethernet.begin(...);
  saved_spcr = SPCR;
  saved_spsr = SPSR;
  Tlc.init(...);
  tlc_spcr = SPCR;
  tlc_spsr = SPSR;
}

void loop() {
  SPCR = saved_spcr;
  SPSR = saved_spsr;
  Ethernet.anyCall(...);
  SPCR = tlc_spcr;
  SPSR = tlc_spsr;
  Tlc.anyCall(...);
}

im not really sure what any of that is doing.
but i recently hooked up the tlc to the ethernet shield + mega like this:
50: tlc (VPRG) (actually went to gnd)
10: tlc(XERR) (not this)
51: tlc(SIN)
52: tlc(SCLK)
51: tlc(MOSI)
52: tlc(SCK)
53: tlc(SS)
11: tlc(XLAT)
12: tlc(BLANK)
9: tlc(GSCLK)
46: IRled
and nothing attached to the tlc was working. so maybe it is necessary to add some form of register call stuff or whatever that is

I explicitly told you that you must not connect pin 10 to XERR, I hope your "not this" means you haven't made that connection. Why is it still in the list?

In your list you still have two pins listed twice so my belief in that being the actual wiring is a bit lowered.

On which pin is SS located on your TLC?

Have you tried this configuration without the Ethernet shield? Does it work? What code are you using for your tests?

first off, I' d like to say thanks for helping me through this as this is my first time really dealing with SPI. so THANKS!

I explicitly told you that you must not connect pin 10 to XERR, I hope your "not this" means you haven't made that connection. Why is it still in the list?

i did not connect pin 10 to XERR for the reasons you mentioned before.

i have the tlc connected as such:
52: SCLK (25TLC)
51: SIN(26TLC)
12: BLANK(23TLC)
11: XLAT(24TLC)
9: GSCLK(18TLC)
per the BasicUse.pde with pinouts for Mega from library file

On which pin is SS located on your TLC?

yeah im not sure which actually. i guess according to my list in my other post, i guess it should be 53 but im not sure if i actually have it connected, ill have to check when i get home.

Have you tried this configuration without the Ethernet shield? Does it work? What code are you using for your tests?

I have not tried it without the ethernet shield, as the mega gets commands over udp. i can however send similar commands via serial so i will have to try that as well when i get home.
The code used is the code listed in like the third posting or so. It's kind of long so I won't post it again.

Again, thank you very much!