Teensy 4.1 with 12 TLC5940s over SPI with DMA (8x8x8 RGB LED Cube)

Status
Not open for further replies.

MWalstra

New member
Background: I'm looking at building a 8x8x8 RGB LED cube and have seen numerous tutorials. However, I prefer designing it myself, so that I understand how/why it works and gain valuable design experience, even though it takes more time, it's buggier, and it's significantly more difficult.



I want to use a teensy 4.1 to control 12 TLC5490s (I understand that the PJRC TLC5490 Library isn't compatible with the 4.1, so I will have to write my own driver similar to this one here: https://github.com/MaltWhiskey/LedCubeTeensy/blob/master/src/OctadecaTLC5940.h)



The TLC5490s daisy-chain together, but from what other people have said online, the LEDs start behaving erratically after the 6-10th one. I have seen two different options to solve this:

1. Use multiple SPI busses with DMA, so instead of 12 daisy-chained I have 4 or 6.

2. Use a non-inverting precision schmitt trigger (74HC7014D) every 3-6 TLC5490s to relay the signal



I'm currently leaning toward using multiple SPI ports because the 74HC7014D is limited to around 1MHZ, while the SPI bus can output at 5-30MHZ or so.



A few questions about using multiple SPI ports:

1. One example I saw was a Teensy 4.0 and 12 TLC5490s on 1 bus with the pins configured:

SPI0:

VPRG -> pin 6

GSCLK -> pin 7

BLANK -> pin 8

XLAT -> pin 9

SCLK -> SCK0 (pin 13)

SIN -> MOSI0 (pin 11)



a. Do I need to define MISO 0 or CS0 in the driver because the TLC5490 doesn't return data and doesn't have a Slave Select?

b. To scale this to three ports, should I reuse VPRG (6), GSCLK (7), BLANK (8) , and XLAT (9) for all three branches since I will write to all 12 TLC5490s at virtually the same time (EX1)? Or should I choose 4 different Digital/PWM ports for each SPI bus (EX2)?



EX1.

SPI 1

VPRG -> pin 6

GSCLK -> pin 7

BLANK -> pin 8

XLAT -> pin 9

SCLK -> SCK1 (pin 27)

SIN -> MOSI1 (pin 26)



SPI 2

VPRG -> pin 6

GSCLK -> pin 7

BLANK -> pin 8

XLAT -> pin 9

SCLK -> SCK1 (pin 45)

SIN -> MOSI1 (pin 43)



EX2

SPI 1

VPRG -> pin 2

GSCLK -> pin 3

BLANK -> pin 4

XLAT -> pin 5

SCLK -> SCK1 (pin 27)

SIN -> MOSI1 (pin 26)



SPI 2

VPRG -> pin 18

GSCLK -> pin 19

BLANK -> pin 22

XLAT -> pin 23

SCLK -> SCK1 (pin 45)

SIN -> MOSI1 (pin 43)



2. The Pinout diagrams of the Teensy 4.1 aren't exactly well labelled when it comes to pins 42 through 54 (SDIO pins and Back Memory Chips). The pinout diagram here (https://github.com/KurtE/TeensyDocuments/blob/master/Teensy4.1 Pins.pdf) shows the various functions of the pins, but doesn't link them to physical ports on the teensy.



I've attached a photo of the back of the teensy 4.1. If someone code annotate the image or accurately describe, which pins are 42-54 in that orientation, especially the main and alternate sck2 and mosi2; it would be quite helpful.

teensy41_2.jpg

Thank you!
 
a. Do I need to define MISO 0 or CS0 in the driver because the TLC5490 doesn't return data and doesn't have a Slave Select?

b. To scale this to three ports, should I reuse VPRG (6), GSCLK (7), BLANK (8) , and XLAT (9) for all three branches since I will write to all 12 TLC5490s at virtually the same time (EX1)? Or should I choose 4 different Digital/PWM ports for each SPI bus (EX2)?
[/code]
Sorry I don't know exactly what all you are asking nor have knowledge of these chips:
As for MISO pin when you start up an SPI port, for example SPI.begin();
It will configure the MOSI, MISO, and SCK pins associated with the underlying hardware SPI port to be in the appropriate mode for SPI communications. So for example pin 12 will be configured for SPI communications. However if you after that do something like: pinMode(12, OUTPUT);
It will reconfigure it again to be in GPIO mode. and my guess is SPI would still function. A transfer will return whatever is logically with that pin...

As for CS pin, in most cases we don't configure a hardware CS pin as part of the SPI library.
As for cn you reuse the same pins for your other signals, again I don't know these chips nor how these signals are used. Gut tells me, that you may need/want them on different pins, but again just a gut feeling.


2. The Pinout diagrams of the Teensy 4.1 aren't exactly well labelled when it comes to pins 42 through 54 (SDIO pins and Back Memory Chips). The pinout diagram here (https://github.com/KurtE/TeensyDocuments/blob/master/Teensy4.1 Pins.pdf) shows the various functions of the pins, but doesn't link them to physical ports on the teensy.

T4.1-Cardlike.jpg
I know maybe I should put in a picture showing it... But I am showing the pins here.

Pins 42-47 are the pins on the SDCard connector. Where I try to show with the vertical | characters which actual pin in the SDIO connector is which...

Pins 48-54 are the bottom memory chips location.

That is if you turn the chip over where the SD is still at the bottom and you look at the last two parts of the picture above (the section showing Back Memory chips)
Is showing the two 8 pin memory chips. You will see that most of the signals are repeated on both chips. But they then have different logical chip select pin. And you will notice
that I try to mark which pin is pin 1 on both of these chips.
Again pin 48 is on the chip that is closest to the bottom of the chip
 
74HC244 would be a faster buffering option, probably happily handle 20MHz, but you have to watch for
cumulative clock skew (ie duty cycle distortion) after several stages - limiting to 4 or 6 in a chain is
probably wise.
 
Just a quick FYI - I updated my Excel Page to show a picture with the pads on it... To hopefully make it more clear. I could not stretch exactly to show the pins, but I think pretty close.

I also added some Text labels over the internal (VBat... On/Off) pins to make easier to remember which one is which...

T4.1-Cardlike.jpg
 
Thank you for the feedback so far.

KurtE: That description clears it up. Thank you!
MarkT: The 74HC244 would probably work as well, but I'm still leaning toward multiple SPI buses just, so that each individual chain is shorter and I don't have the delay of a buffer relay.

If anyone else has any experience with the TLC5490 chips on multiple buses, please let me know

Either way, I'll order the parts, test both ways, and then post back here what I find. The Teensy has enough I/O ports that I can use 8 for the p-circuit mosfets, and 6 for each SPI bus plus additional buttons, potentiometers, and bluetooth/wifi without running out of space.
 
TLC5490 is very sensitive to static discharge, you may have damaged the ic if they are behaving badly. Take very good care of the ground. In the design stage my 9x9x9 led cube was blinking all over the place. After impoving my grounding i could get 17 TLC working great, nr 18 was still a bit tricky. So 12 should be easy. I used 9 separate pcb’s if you use 1 big board you should be golden. No need to parallel the outputs, you can if you want, but each ic will regenerate the signal anyway, schmit trigger is a waste of time, money and board space. Use 100nf caps on each ic as close to the power as possible.

How to use that chip:
Tie VPRG to (look up in data sheet, cant remember gnd or vcc) you wont need to change it.
You need to define how long a grayscale cycle will last, generate 4096 pulses for the gsclk in that time.
After this many pulse all your leds are off, now raise BLANK wait x ns (data sheet), raise XLAT, wait y ns, lower XLAT, wait x ns, lower BLANK
This will latch in all clocked data and start new grayscale cycle.
You can use an intterupt to manualy control the blank en xlat, it’s not that beneficial to let the hardware do this since you need to also control the layer mosfets at this time
Manual gives more control. I figured that out later when i made a cube with arduino nano.

Independend of above precisely timed grayscale cycles with blank and latch there is the matter of filling data in your TLC5940 array. Just set SIN with the value you want and
After that pulse the SCLK. Thats the basis. IDealy use DMA so it wont cost processing power, don’t go faster than datasheet. Was it 50MHz? Or 30? And the filling cycle needs to
Be faster than gscycle or you get missing data.

If i can get it to work anybody can? Lol.
I made that cube as my first electronics project, i designed pcb in kicad, read the datasheet over and over, tried to find a lot of stuff online, learned how to use the teensy and arduino programming environment, designed a case. And well it works :p
It was kind a hard since i had zero electronics knowledge and then i go and make this... crazy me lol
 
Status
Not open for further replies.
Back
Top