Pages: [1] 2   Go Down
Author Topic: Leonardo with the TLC5940  (Read 5369 times)
0 Members and 1 Guest are viewing this topic.
Wisconsin
Offline Offline
Edison Member
*
Karma: 4
Posts: 1001
I LOVE THIS STUFF!!!!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I am working on a small project and I am finding it difficult to have a good spot for reprogramming headers.  As a result, I was looking at the leonardo as a middleman for me to learn how to use the Atmega32U4.

Does anybody know if the library for the TLC5940 works properly with the leonardo?
« Last Edit: January 12, 2013, 12:08:57 pm by funkyguy4000 » Logged

Accelerate to 88 miles per hour.

Austin, TX
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6132
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The Leonardo implements SPI different from the Uno.

You might have to change the TLC5940 library to use "bit-bang" mode instead of SPI until a pin mapping for the 32u4 is created.  Look at the tlc_config.h file to see how to change the mode and setup the 2 pins to use.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Wisconsin
Offline Offline
Edison Member
*
Karma: 4
Posts: 1001
I LOVE THIS STUFF!!!!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok.  Thank you!
Logged

Accelerate to 88 miles per hour.

Wisconsin
Offline Offline
Edison Member
*
Karma: 4
Posts: 1001
I LOVE THIS STUFF!!!!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

So I emailed the guy who made the previous libraries for the TLC5940 work with the arduino and here it is

Quote
Hi Shannon,
I haven't played around with a Leonardo yet, so the library won't be updated anytime soon.  Hopefully someone will contribute code to get it working :-).  The library uses two timers and the hardware SPI module.  If you want to try updating it, try comparing the timer section/SPI section in the Atmega168 datasheet with the 32U4 datasheet.
- Alex

I'm thinking it would be nifty to try to do it although I have absolutely no idea what I'd be doing.
Logged

Accelerate to 88 miles per hour.

Leeds, UK
Offline Offline
Edison Member
*
Karma: 78
Posts: 1719
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The Leonardo uses an ATMega32U4, the same chip used by the Teensy 2.0 which the TLC5940 Library already supports.

It should work without modification.
« Last Edit: June 23, 2012, 04:37:52 pm by TCWORLD » Logged

~Tom~

Wisconsin
Offline Offline
Edison Member
*
Karma: 4
Posts: 1001
I LOVE THIS STUFF!!!!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

REALLY!?
Aw man i'ma have to check that out
Logged

Accelerate to 88 miles per hour.

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've been trying to get the TLC5940 to work with a Leonardo for 2 days now. One problem is that the hardware SPI is now only available on the ICSP header rather than pins 10-13. The other is that the pin mappings in the Teensy pinout file don't seem to line up with the datasheet for the chip on the Leonardo.

If anyone has had success modifying this library, or if you might have ideas on how to get it going, myself as well as others would appreciate it.

Thanks.
Logged

Wisconsin
Offline Offline
Edison Member
*
Karma: 4
Posts: 1001
I LOVE THIS STUFF!!!!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If it is just pin mapping, it shouldn't be an issue. 

As soon as I get my leonardo working, i'll take a look into it and modify the library if i'm able.
Logged

Accelerate to 88 miles per hour.

Austin, TX
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6132
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

One problem is that the hardware SPI is now only available on the ICSP header rather than pins 10-13.
So?  Make your connections to the ICSP header instead of the digital pins.
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Wisconsin
Offline Offline
Edison Member
*
Karma: 4
Posts: 1001
I LOVE THIS STUFF!!!!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't have F/M headers smiley-sad
Logged

Accelerate to 88 miles per hour.

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I should have mentioned that I tried connecting directly to the ICSP but didn't have any luck. I think the problem lays in my attempt at rewriting the pin layouts. The Atmega_xx8 file uses pin designations like PB0 and PD5 whereas the Teensy_XXuh file uses numbered pins such as 16, 17, etc..

I've tried both methods of mapping but still have the same blank result. Mind you I'm a complete newbie when it comes to this so I'm sure I'm missing something simple.
Logged

Wisconsin
Offline Offline
Edison Member
*
Karma: 4
Posts: 1001
I LOVE THIS STUFF!!!!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Interesting.  You tried the PB# method?  Maybe instead of PB# it uses PORTB#
Logged

Accelerate to 88 miles per hour.

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello I'm a beginner with Arduino and I got same problem.

I've to clear the solution but it works and it's something.

You have to backup and then edit .../arduinoIDEfolder/libraries/TLC5940/pinouts/chip_includes.h
after the abbrevation port definitions (many sentences like '#define PB0     PORTB0') delete all and left it like this:
Quote
/* Copyright blablabla*/
#ifndef TLC_CHIP_INCLUDES_H
#define TLC_CHIP_INCLUDES_H

/** \file
    Includes the chip-specfic defaults and pin definitions. */

#include <avr/io.h>

#ifndef PB0
#define PB0     PORTB0
...
#define PH7     PORTH7
#endif

/* Chip Specific Pinouts */
#if defined (__AVR_ATmega32U4__)

/* Leonardo */
#include "Arduino_Leonardo.h"

#else
#error "Unknown Chip!"
#endif

#endif

Then copy 'Teensy_xxU4.h' (in the same folder), rename the copy to 'Arduino_Leonardo.h' and edit it like this:
Quote
#ifndef TLC_Teensy_xxU4_h
#define TLC_Teensy_xxU4_h

#if DATA_TRANSFER_MODE == TLC_BITBANG
#error "If you want bitbang mode, insert pin defs here"
#endif

// MOSI (Leo outter center ICSP pin) -> SIN (TLC pin 26)
#define TLC_MOSI_PIN   2
#define TLC_MOSI_PORT   PORTB
#define TLC_MOSI_DDR   DDRB

// SCK (Leo inner center ICSP pin) -> SCLK (TLC pin 25)
#define TLC_SCK_PIN   1
#define TLC_SCK_PORT   PORTB
#define TLC_SCK_DDR   DDRB

// SS (Leo RX LED)
#define TLC_SS_PIN   0
#define TLC_SS_DDR   DDRB

// OC1A (Leo pin 9) -> XLAT (TLC pin 24)
#define XLAT_PIN   5
#define XLAT_PORT   PORTB
#define XLAT_DDR   DDRB

// OC1B (Leo pin 10) -> BLANK (TLC pin 23)
#define BLANK_PIN   6
#define BLANK_PORT   PORTB
#define BLANK_DDR   DDRB

// OC3A (Leo pin 5) -> GSCLK (TLC pin 18)
#define GSCLK_PIN   6
#define GSCLK_PORT   PORTC
#define GSCLK_DDR   DDRC
#define TLC_TIMER3_GSCLK 1

#endif

You must advise that the pin numbers are different to the Teensy, even more, you must use the SCK and MOSI signals from the ICSP connector (not mapped to digital pins in Leonardo) and the SS signal from the RX LED board). See the next images for more help (the first is for the ICSP detail algthou is not Leonardo board, and the second is for the board conection to the SS signal)

ICSP:
http://www.gammon.com.au/images/ArduinoUno_R3_Pinouts.png
SS:
http://provideyourown.com/wordpress/wp-content/uploads/rx-pin-150x148.jpg

Be sure too that in .../arduinoIDEfolder/libraries/TLC5940/tlc_config.h you have correctly the numbers of TLC you're using '#define NUM_TLCS    2' (for 2 TLC5940's) at Line55

I hope this helps anyone new with Arduino Leonardo board and the TLC5940 chip.
Sorry for my english.
Logged

Wisconsin
Offline Offline
Edison Member
*
Karma: 4
Posts: 1001
I LOVE THIS STUFF!!!!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

This fix works?
Logged

Accelerate to 88 miles per hour.

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This fix works?

Yes, I've to integrate it correctly in 'chip_includes.h' in order to not delete the rest of include orders.

At the moment this fix is usefull only for Arduino Leornardo board as the rest of hardware (#includes) are being ignored.
Logged

Pages: [1] 2   Go Up
Jump to: