Go Down

Topic: Library for TLC5940 16-channel PWM chip (Read 35 times) previous topic - next topic

Grumpy_Mike

My problem with the LEDs being different brightnesses disappeared. :)
When I put the blank pin high during data transfer into the TLC.

So I carried on working on my multiplexing matrix and had it all finished. I was just doing some tweeks and it re appeared :(, reversing the tweeks did not solve the problem. So I am now having to look at the timers in more detail. Which is a pity because they are always my least favourite bit of an architecture.

Basically I am using the TLC to power four RGB LEDs wired up alternatively that is LED1 Red output 0, Green Out 2, Blue Out 3, next LED2 Red output 4  ....
It is basically the Red on LED2 that is the correct brightness, all other red LEDs are too dim, but the other LED colours are OK.
It is not an issue of what is in the grey scale memory, nor it it hardware / wiring. However I do see on the scope that blank pulses just before I raise the blank in the data fill interrupt service routine.

So The task this weekend is to change the timers so that they are not generating the  blank and xlat signals and do it all from the ISR.

And this is supposed to be fun!  ;)

acleone

Major update coming soon!  I don't have access to my Arduino - can someone test the beta version?  You have to temporarily move the old library folder out of the libraries folder.

Some of the changes that I've been working on:
  • All the configuration is done in "tlc_config.h" now.  This includes setting the number of TLCs you have daisy-chained, enabling the dot-correction functionality, etc.
  • Hardware SPI is now an option (bit-banging is still the default for maximum flexibility).  See "DATA_TRANSFER_MODE" in tlc_config.h
  • Code quality improvements
  • Full documentation w/ doxygen (I'll put it online soon + update the playground page)
  • Unused pieces of the library don't take up sketch space (they're in separate files).  The downside to this is you have to include more files if you want to use some of the functions.  Like Fades and playing animations from memory.

yurki

Hi,
I'm trying to controller 12 lego motors with PWM.
I want to use the TLC5940 but I want max/msp
to control it. At the moment I use the simple message
system for max: http://www.arduino.cc/playground/Interfacing/MaxMSP

But the code of acleone:  http://www.arduino.cc/playground/Learning/TLC5940
is needed, as far as I understand, to use the
TLC chip. So I presume both codes have to be combined somehow.
I'm not into arduino coding at all, so I hope anyone can help me.

- Is it possible?
- How?

thanks!

- Yurki

acleone

Ok, online documentation is now up.

The latest source is now always available from Tlc5940_latest.zip

yurki:  I'll see if i can get something working.

Syvwlch

Wow, lovely work on the documentation!

Thank you  :)
----------
Mathieu

yurki

Fantastic documentation! :)
Timing was perfect, I just wanted to solder, funny.

Right now my TLC is working with led's!
I Also managed to make a new code to
control the TLC with max/msp. So, thanks
for checking Acleone, I already made it.

But I do have a new problem. ( I hope it's not
too much off subject)
As you mentioned on the arduino playground,
you think it is possible to drive motors. I want
to control 12 lego motors (the new ones
from lego power tools). I bought six L298
ic's to make it possible to rotate eacht motor both
left and right.

The problem is, I just found out
the TLC chip doesn't send 5volt through the outs
but just gates the GND. And the L298 ic's need
5volt to make the motor turn. Do you or anybody else
know a solution for that?

Also, the L298 needs some diodes around the motor as you can see on
figure 6 on the datasheet http://www.st.com/stonline/books/pdf/docs/1773.pdf
Is it still needed to put a diode on every out of the TLC?

Jonb mentioned different speeds on his motors. Did you directly connect the motors on the TLC or are you using a separate power
supply with H-bridges or single transistors? I presume in the
last case this wouldn't be a problem as long as your second power
supply is capable of enough current...

Thanks for the great work on the TLC library's!

acleone

#66
Nov 03, 2008, 12:17 am Last Edit: Nov 03, 2008, 12:20 am by acleone Reason: 1
You should send me the code for controlling the TLC with max and I'll put it in the library!

I played around with hooking up servos to the TLC before:
Connect a pull-up resistor (~2K) between +5V and the TLC output pin that you want to control with.  Then connect the TLC output pin to the input line (C or D in fig.6) on the H-bridge.

To test this, try:
1.  Hooking input C to a TLC output pin w/ pullup resistor.
2.  Hooking input D to a TLC output pin w/ pullup resistor.
3.  Connect enable (B I think?) for C and D to +5V. (always enabled)

To drive the motor in one direction, set the output for channel C to 0 (so the pull-up forces it to always be +5V)
and set the output for channel D to 4095 (so it's always grounded)

To drive the motor in the other direction, reverse 4095 and 0.

To drive the motor w/ a PWM signal, set one of the channels to 4095 and the other to (4095 - x), where x is the PWM value (eg 4095 will be 100% on, 3072 will be 75% on, ...)

yurki

I see, a pull up resistor.
I looked it up on wiki and now I understand.
Thanks, I'll try it out tomorrow
after I bought the resistors.
Do you think I need to put a extra diode in it?
Because I already have  4 diodes around each
motor because of the L298.

I dropped the code on a server:
http://student-kmt.hku.nl/~JERKE/arduino/

It was far more simple than I thought it was. As I said, I used
your library combined with the library of simplemessagesystem.

as their website says, it should also be possible to use with:    
   * Linux TTY
   * Windows HyperTerminal
   * Pure Data
   * Processing
   * Max/Msp
   * SuperCollider
   * Wiring
   * Python (library available here)

yurki

just a message to say: it works perfectly!

I can control one motor right now, now I have to finish
the other 11 but I know how to do it now sow it won't
be difficult.

Thanks for the help!

acleone

Finally got to play around with my library:





I'm only using the first TLC.  The pin setup is the default with SPI mode enabled (and I added a button so the timing was easier).

The sketch I used is the BasicAnimations example.  I also made a simple program to convert images to animation files (see the BasicAnimations example folder for java source).

Get the latest version for all the goodies.

Syvwlch

Nice! I like the pixelation effect from the PWM...
----------
Mathieu

acleone

First attempt at color:

Red and cyan are recognizable, and apparently pink, orange, and yellow = rainbow.  Here's the source image:



Pacman vs Beam Cannon?


The circuit: 16 RGB LEDs, 3 TLCs, one for each color.

This is running GSCLK at 8MHz, and the pwm values are just 0-255 (straight from the source image - my LEDs are too bright otherwise).  Here's the java code for generating the animation.


dwan

#72
Nov 14, 2008, 11:39 am Last Edit: Nov 14, 2008, 12:45 pm by dwan Reason: 1
Hello everybody !

At last, some shiny LED action on this topic, and at last, i'm able to test the shiny-flickering power of this wonderful library, because i received my samples from TI !
Here is my secret evil project : I plan to generate VGA sync and to send colors to 16 VGA screens with only one Arduino, thus using all the timers (bah, who needs delay()  8-) ?). My VGA generator is ready, i just have to move it from Timer2 to Timer0, i guess it'll be ok. I control the brightness of the leds (no colors yet, because i only have common cathode RGB leds  :-[ ) via serial link with PureData, that's very simple. The last step will be moving from leds to 0.7vpp signal, in order to make nice colors with my screens. I still hesitate between vactrols, more common optoisolators, etc (if you have a clever plan, i'm all ears). I'll keep you informed.

That was just to say thank you to everyone in this helpful topic, and especially to acleone, whose library is really fantastic !

FuzzyOne

I'm loving the pacman effects, once I figure out how to post vids i'll show what i've done with the tlc5940.

FuzzyOne

Hello everyone!

Been playing with the Arduino and TLC5940 for about a month now.

I'm very interested in getting the Arduino to decode dmx data, if anyone has any clues feel free to give me a shout, I've seen the stuff on the playground but none of the examples show the arduino as just a dmx receiver.

Anyway, here's a couple of vids showing the arduino processing external data.

[media]http://uk.youtube.com/watch?v=UhZLJFZ13N0[/media]

[media]http://uk.youtube.com/watch?v=bmgdAyaMM_w[/media]

Go Up