Go Down

Topic: help with how to connect tlc5940 to atmega1284p (microduino core+) (Read 6217 times) previous topic - next topic

account001

Hello
I need to control 6 tlc5940nt chips to Microduino core+, which uses Atmega 1284p
The 1284p has timer 0,1,2,3 I believe and I am not sure which timer to use with blank, XLAT and GSCLK pin on the tlc5940. And I don't know which pins to connect VPRG and DCPRG to. I am not planning to use XERR to read error.  After doing some research I have come to the possible pin layout and I need someone to tell me which pin layout is the best.
The tlc5940 uses SPI interface, so I would use:
•   (PCINT13/ICP3/MOSI) PB5  to      SIN (TLC pin 26)  /pin8 on Microduino core +
•   (PCINT15/OC3B/SCK) PB7    to   SCLK (TLC pin 25)/pin9 on Microduino core+

For the rest of the pins: I read blank and XALT needs to be on using the same frequency timer, so I am thinking for black and XLAT:
Option 1:
•    ((PCINT28/XCK1/OC1B) to BLANK 16bit timer
•   (PCINT29/OC1A) PD5 to XLAT   16bit timer

Option 2:
•   (PCINT11/OC0A/AIN1) PB3 to XLAT 8bit timer
•   (PCINT12/OC0B/SS) PB4 to blank 8bit timer
Option 3:
•   PD7 (OC2A/PCINT31)  8 bit timer
•   (PCINT30/OC2B/ICP) PD6 8 bit timer

I would not be able to use timer 3 as MOSI takes up on of the timer 3 pin, and I do not know if BLANK, XLAT  and GSCLK needs to be on the same bit timer e.g.(16 bit timer)

For the GSCLK pin I am thinking of using:
•   (PCINT9/CLKO/T1) PB1 , I got this idea form 'demystifying tlc5940' 
•   (PCINT14/OC3A/MISO) PB6 16 bit timer
•   (PCINT28/XCK1/OC1B) PD4
•   (PCINT29/OC1A) PD5

If I use the last oc1b or oc1a pin for GSCLK, I would not be able to use it for blank and XLAT, I am not sure whether to use CLKO pin, can someone tell me what frequency it can run at, I read it can run at 16 MHz.

For VRPG and DCPRG I have no idea as what pin to use, so I need suggestions, but I am planning to use both dot correction and grayscale so I cannot simply connect them to VCC or GND


Please correct me if any of my concept understanding is wrong.
Once I figure out what pin to use I might post the schematics here.
One other thing is I can only find the Microduino core+ 644p schematics and not the 1284p versions schematic, if anyone knows anything please tell me.

raschemmel

#1
Mar 24, 2014, 06:34 am Last Edit: Mar 27, 2014, 12:41 am by raschemmel Reason: 1
If you were using  an arduino UNO I,'d say your concept ia totally wrong becsuse you don't seem to be aware that the TLC55940 uses  SPI protocol and there is a library that defines all the pins.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

account001

Thanks for the reply, but i am not using a arduino uno and hence i am not using the atmega 328p chip on the arduino uno. i am using a Microduino core+ 1284p performance edition. when you talked about the library, do you mean i should take a look at the given tlc5940 library for the arduino uno, and see which pin connects to which?

raschemmel

I'm saying I don't know anything about the 1284 so I don't know if it will work by redefining the pins to match the 1284 pinout.
The library was written for the TLC5940 . It doesn't care which uC is using it if that uC uses compatible code. Of course it wouldn't work with a PIC because the code is different but  a PIC programmer who knows arduino code could re-write it to run on a PIC .
I think you should start with the assumption that if you can run arduino code , then you can redefine the pins. You may need to consult the datasheet but it might be doable. Looking at the "Basic Use "Sketch will tell you which arduino pins go where on the TLC5940.  I have been advised that it looks like your shouting if you use all caps but after you read this I don't think you will mind.
DO NOT UNDER ANY CIRCUMSTANCES CONNECT THE POWER PINS TO THE TLC5940 WRONG !
YOU WILL FRY THE CHIP  IN A HEARTBEAT !
DO NOT UNDER ANY CIRCUMSTANCES FORGET THE IREF RESISTOR ON  PIN 20 OF THE CHIP AND CONNECT A JUMPER WIRE BY
MISTAKE ! YOU WILL FRY THE CHIP IN A HEARTBEAT !
IF YOU MISWIRE THE R(IREF) RESISOR ON PIN 20 TO +5V INSTEAD OF GROUND THE CHIP WILL NOT WORK BUT IT WILL NOT DAMAGE THE CHIP.
IF YOU USE TOO SMALL A RESISTOR ON PIN 20 YOU COULD DAMAGE THE CHIP AND THE LEDS !
IF YOU MAKE A MISTAKE AND FRY A CHIP IT WILL PROBABLY TAKE A WEEK TO GET ANOTHER. AT $5/EACH IT IS BETTER TO ORDER A COUPLE OF SPARES.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

account001

thanks for the reply, i looked at the tlc5940 ibrary and it seems to have atmegaxx4.h which i think   includes 1284p, so i will look into that, thanks for the help. the thing is i have not got the parts yet(microduino), but i am designing the circuit board to host the tlc5940 and leds and i need to know what pins to connect the tlc5940 with. thanks you

raschemmel

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

account001

i believe so, all the pins (other than SIN) are connected to the previous chip's same pin. only one resistor connecting blank and VCC, For IREF each tlc5940 chips need to have its own resistor,like the picture i attached. i will use 2.2k ohm resistor for 18mAv each channel and 10k connecting blank and VCC. Please tell me if i am wrong.  The only thing i am worried about is how to power the microduino, leds and tlc5940. Do i connect the 6 tlc5940 chips to the microduino's 5v power supply pin? and do i power the leds with  separate power supply or connect them to the microduino's 3.3v pin. i have 6x16 LEDs, with 3.3 v rating and max 20mA. i appreciate your help. just to let you know, i am making a cylinder POV display as a school project.

account001

i realize that the picture i attached(grabbed it off Google image) had the 5v connect 3.3v and could possible be a mistake. i might post my schematics up soon, hopefully.

raschemmel

Quote
Do i connect the 6 tlc5940 chips to the microduino's 5v power supply pin?

Not unless you only plan to run programs that sequence the leds one by one , rather than all on at the same time.
If you run any programs that turn all the leds on at the same time you need:
6x16x0.018A=1.92A. (IF ALL LEDS CAME ON AT ONCE)  (about 2A)

The chip itself draws about 30- 50mA just for the chip (not including any leds)
Quote
and do i power the leds with  separate power supply or connect them to the microduino's 3.3v pin.

NO . You need to supply +5Vdc on the ANODE of all the leds. The CATHODE of each led will connect to an output of the chip, as per your schematic. Again, as long as you only sequence the leds one at a time, you can power everything from the arduino +5V pin.
Make sure that pin goes to the +5V bus of your breadboard and that the ground from the arduino goes to the ground bus of your breadboard.  If you set everything up for sequential operation and later you load a program that turns on all the leds at once , as soon as you see ALL the leds come ON, IMMEDIATELY TURN OFF THE POWER SUPPLY ! At this point you would disconnect the +5v from your arduino to the breadboard bus so you can upload the correct sketch.. This practice will prevent damage to your arduino regulator. Keep in mind that there may be some sketches that give the appearance of all the leds being on at once but in fact that is POV (Persistence Of Vision ) wherein your eyes and brain process the image and your brain holds that image long enough for the next led to come on making it look like they are both on etc... About the power supply, if you plan or want to turn all the leds on at once you will not be able to use the arduino power for the chips or the leds and plugging a large power supply into the dc jack of the arduino will not help. The +5V for the chips and leds will have to come from an external +5V power supply.
It is possible to build a 5V 5A power supply if you need one. I have a schematic.The chips and leds must retain a common ground with the arduino and no jumper wire can be plugged into the arduino +5V pin in that scenario.  You will not be using the 3.3V pin of the arduino for anything.  Do you understand why the chips are wired the way they are with all the pins connected together except the SIN ?
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

account001

#9
Mar 26, 2014, 01:40 am Last Edit: Mar 27, 2014, 12:35 am by account001 Reason: 1
I will be turning on all the leds for my program and hence i will need to use an external power supply for the leds and the chips and one other power supply for the arduino right?i can use the 5v5A power supply you have for the leds and the chips ?it should use about 2A  in total? right, would the difference in amps matter?if  it works, can you please post the schematics, please.
about the way the chips are conneted, sin sends the data bite and fills up the chip register with the last chip first, all the other pin connection, like thr xlat and blank are pulse of high and low, so work for all the chips. i have rather bad explanation but i do think i understand.

raschemmel

Attached are two schematics for 5V power supplies. I recommend the 5A one because it uses the LM7805 regulator ic.
Make sure to mount the 2n2955 on a heatsink with mica insulator (radioshack) and thermal paste.
Quote
about the way the chips are conneted, sin sends the data bite and fills up the chip register with the last chip first, all the other pin connection, like thr xlat and blank are pulse of high and low, so work for all the chips. i have rather bad explanation but i do think i understand. 

You are right about that but the answer I was looking for is that all those pins are connected to the SPI (Serial Peripheral Interface)
bus. (a group of connections (physical size depends on application. This is a logic application so a logic bus does not need large conductors like a power bus. The connections are similar to the edge connectors on plug in PCBs in a PC, like a video card. In this case the protocol is SPI which requires MISO (Master In-Slave Out), MOSI ( Master Out Slave In) SCK (Serial Clock) and SS (chip select) . The TLC5940 requires all  of these EXCEPT MISO because it sends no data to the uC , only receives. That's why pin-12 of the arduino is not used. Also , the SS pin is redefinable, the others are not . EVERY SPI application you do with an arduino will require
the pins I just described but SS can be redefined to any pin so if you have 6 SPI devices that are NOT cascadable the TLC5940 ,you would pick pin 10 (DEFAULT SS) for the first device , and then any other pins you want for the rest  , like 9,8,7,6,5 etc...
There are a zillian different kinds of ic's that use SPI bus protocol . I have used SPI digital 10k ohm pots that only receive commands to set the resistance.  (SEE ATTACHED PROGRAM for FIVE digital pots. I started with six but fried one)
On the forum, you can usually find a library for the SPI chip you want to use that make it easy to use like the TLC5940. The reason I am telling you this is because if you ever want to use a SPI chip or device with your arduino again, the first thing you need to ask yourself is "Does it TALK, LISTEN , or BOTH ? How many chip selects will  I need ? If it only LISTENS, you need pin-11. If it only TALKS , you need pin-12.If it does both, you need both. SCK is not redefinable (Pin-13) so you will always need that.When you have time, look up I2C /arduino examples. (I SQUARED C) (I - I C) (Inter-Integrated Circuit)
http://en.wikipedia.org/wiki/I%C2%B2C 
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

account001

#11
Mar 26, 2014, 10:47 pm Last Edit: Mar 27, 2014, 12:39 am by account001 Reason: 1
Thanks, for the information. i would not be using any other device using the SPI interface other that the 6 tlc5940 and i was wondering would i still need the SS pin, and i don't know which pin on the tlc5940 i would connect the SS pin to. i read some where you just define the SS pin as output, without the need to connect it to tlc5940 and is that what is should do?please tell me what to do with the SS pin, thanks.

raschemmel

I don't think you understood my explanation about the TLC5940 or you didn't read the datasheet or both. The TLC5940 uses SPI
protocol. NO MATTER WHAT, ALL SPI DEVICE MUST HAVE A CHIP SELECT ! The "SS" pin , as you keep referring to it as , is the generic name for the chip select for a SPI device. This is the ONLY SPI pin on an arduino UNO that is redefinable , meaning you can change the pin number in the code to any pin you want because it is not hardcoded as a SPI pin like the other three SPI pins I already mentioned.  You are not asking the right questions.  The pinouts are shown in the "Basic Use" sketch in the TLC5940.  I have already told you which pins a SPI device requires but you have not asked me which pins on a 1284 correspond to the pins you need to use the TLC5940. You have not posted the datasheet for the 1284 so how do you know how to connect it to a 1284? Did you find a schematic somewhere showing how to connect the TLC5940 to a 1284 ?
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

account001

just to see if I  have misunderstanding on how the SS pin works, this is what I have understood so far: the master device is the arduino, and it has a SS pin that is not hardware specific, I need to connect the pin I defined as the SS pin on the arduino to the tlc5940's corresponding chip, and the arduino will send low and high pulse to tell the tlc5940 chip if it should read the data it is receiving in the MOSi line etc. this is probably  a wrong concept I have and can you please tell me how it really works in detail.

Quote
The pinouts are shown in the "Basic Use" sketch in the TLC5940.

i took a look at the 'basic use' and i didn't find anything on the SS pin, would you be kind enough to point it out?


I don't think you understood my explanation about the TLC5940 or you didn't read the datasheet or both.

I have read the tlc5940 full version datasheet, not the summary and I have also read the atmega 1284p data sheet. perhaps i didn't understand you, please bear with me.

 

I have already told you which pins a SPI device requires but you have not asked me which pins on a 1284 correspond to the pins you need to use the TLC5940.

i think that was what I was trying to ask in my very first post, but I think it was too confusing and perhaps you didn't get me. basically I want to ask which timer on the atmega1284p to connect to the  tlc5940's BLANK,XLAT and GSCLK.


You have not posted the datasheet for the 1284 so how do you know how to connect it to a 1284? Did you find a schematic somewhere showing how to connect the TLC5940 to a 1284 ?

I have no found a schematic and  was hoping after reading my first post someone can tell me what to do.  i think the datasheet for the atmega 1284p is too big to be attached. i was hoping people can search that up themselves, sorry for the inconvenience.
The MOSI, SCLK and default SS pin on the atmega1284p seems pretty clear on the atmega1284p's datasheet, i am more unsure on what timer pins to use.

i read this online pdf:  https://sites.google.com/site/artcfox/demystifying-the-tlc5940 and i didn't think i read on use of the SS pin, other than that it was set to output mode and used for the BLANK pin on the tlc5940.

Thank You very much for your help, much appreciated

raschemmel

Quote
I have read the tlc5940 full version datasheet, not the summary and I have also read the atmega 1284p data sheet. perhaps i didn't understand you, please bear with me.

LOOK AT PHYSICAL PINS 6,7,8 of the 1284 and tell me the signal names assigned to those pins.
pin-6=[NAME]
pin-7=[NAME]
pin-8=[NAME]

DO YOU SEE ANYTHING REMOTELY RELATED TO SPI PINS ?
Do you remember when I said this ?
Quote
In this case the protocol is SPI which requires MISO (Master In-Slave Out), MOSI ( Master Out Slave In) SCK (Serial Clock) and SS (chip select)

and this?
Quote
The TLC5940 requires all  of these EXCEPT MISO because it sends no data to the uC , only receives.   


So, in a nutshell, you read the complete datasheet but never looked at the pin names ?
Is that what I am to understand ?
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Go Up