Friday, November 23, 2012

Implementing Artcfox's TLC5940 code on an Arduino, Part 3

Well its been a while... Real Life(tm) has been rather busy!
The code for this post has been gathering bit-rot on my drive so I thought it time to just put it up with a a short post (basically just a code dump) which I will follow up at a later point.

In the previous article we got the Arduino setup with appropriate clock fuse settings so that Matt's code would work. Based on this I took the sample code from CH9 and modified it to implement a small RGB pattern using some of the CH9 features, specifically the gamma correction.

CH9 is based around mulitplexing the output. I haven't used this as I don't have the transistors availabe to test it, so basically the output is still a direct drive of the attached LEDs with one colour per output pin on the TLC5940. However there is no reason that multiplexing shouldn't work. If you want to try it out, refer to Matt's original document and wire appropriately. If you apply the techniques discribed previously to the original CH9 code you should be good to go. You can use the attached code as a reference.

Hardware setup should be the same as per the first article. To see the correct visual output, wire each leg of an RGB LED to output pins 0,1,2 (R,G,B) then 3,4,5 etc. for a total of 4 LEDs. Then compile and upload the sketch and you should be good to go. The code will colour fade between each rainbow colour.

The code is available here. Go get it!

Next time I get a chance to get to the local electronics supplier I'll buy some of the appropriate transistors and wire up for the multiplexing capabilities of Matt's library and post up some wiring info and more code.

For questions etc, follow me:
or mail me at: sweetlilmre (at) gmail (dot) com



  1. Mr. Edwards, thanks for pushing forwards on this. I have been busy as well but would like to take a bit more time over the holidays to follow up with you on all this. I have not read ch9 and wondering how the transistors are arranged. Is this to drive higher powered emitters?

    Went ahead and replaced the tlc chip described to you in the last email. Still cant figure out why the board is not providing a full 20mA of current to the leds.

    Still strange that the sense resistor is set at 2.2k and the 8 bit current and grey scale adjustments are set at full value..... still only getting a fraction of the total current out.... but otherwise everything seems to work correctly. It dims and the dot correction works.... Hmmmm

    I will go ahead and read more about the transistor applications and multiplexing (where does one find chapter 9?)

    happy holidays Photon144

    1. Hi,

      The transistors seem to be used as 'line' switches for each colour.
      If you look at the 'multiplexing.pdf' file in the schematics from Matt's site you will see that three transistors are used, one for each colour. Their switching is controlled by the AtMega.

      IIRC, CH9 is code only, Matt has not actually written it yet.

      I don't understand why you are getting such a low power output.
      Can you take a picture of your wiring / setup and send it to sweetlilme(at)gmail(dot)com? Maybe I can find your issue that way?

      Have a great holiday!

  2. Peter, you wili be sent a photo this week. thanks for the clarification on what chapter 9 is. I looked at the schematics and have a few comments about the selection of transistors and a few other details on the multiplexing.
    It looks like the transistore were selected based on a convenient package to breadboard but not so much on a good fit for the string voltages and currents supported by the tlc.

    I believe you will do much better selecting a different device for your application. What is the maximum forward string voltage you are runing?