New Member-New Project: 08M2 and the TLC5947

datasmith

Well-known member
Hi all. New forum member here, and working on a new Picaxe project.

I'm working on a piece of animated artwork that has eight multi-color glowing spheres driven by RGB LEDs.
I wanted to keep the electronics as simple as possible, and found this shift-register RGB-LED controller that I hoped would fit the bill.
It's the Texas Instruments TLC5947 on an Adafruit break-out board... cost me about $20 US on Amazon.com, but I just found a clone from Comimark also on Amazon for only $7.50 US which also comes with header pins. A much better deal, so I just picked up two more for future projects.

I took the minimalist approach and wired an 08M2 to the controller with a minimum of parts; two resistors (for the programming interface), two capacitors and a 5V voltage regulator. This allows me to run it with any DC power supply up to the break-out board's max voltage of I think is 24V. I'm using a 9V power supply.
I have attached pics of my schematic and associated breadboard, and I've actually got this thing working.

Here are some caveats.
1. The TLC5947 has12 bits of resolution per color (RGB) per LED. That's 12x3x8=288 bits that must be shifted out to the controller each and every time you want to change a color on any(or all 8) LED(s) connected to the controller.
2. The 08M2 apparently does not support hardware shiftout, so I had to use a modified version of the shiftout sub-procedure provided on page 238 of the picaxe programming manual to get data out to the controller. MSB first.
3. To get any smooth color animation out of the TLC5947 I had to crank the 08M2 clock speed up to 32MHz. This kills any multitasking capabilities and I had to write my program as a single thread.

Regardless, I was able to get it to work at about 15 updates per second. This gives me a relatively smooth animation, given the minimal parts and costs.
Here are pics of my schematic and breadboard in operation.

In my next post I will provide my program concept and base code for sending colors to the TLC5947.
 

Attachments

datasmith

Well-known member
First off, as I mentioned before, the TLC5947 has 12 bits of resolution per color. That's 4095 color steps per color. If I were to try and animate color changes using that fine of a step/resolution given the general speed the 08M2, the overall effect would be extremely slow, and handling 12 bit math in a byte/word environment would cost me more program memory overhead than I could afford. So, I decided to reduce my program resolution to just 8 bits per color. That's just 255 color steps per color. But, that's really all the color resolution I need for this art piece.

I made this resolution correction in my shiftout sub-procedure.
Since the TLC5947 controller requires data to be sent MSB first I was able to set up my shiftout sub-procedure to just repeat the LSB of each byte four additional times. So if my 8-bit color data is 1111 0000, the shiftout procedure sends 1111 0000+0000. If my 8-bit color data is 1111 0001 , the shiftout procedure sends 1111 0001+1111.

I set up an array of 24 bytes called Cur_LED_Array. Each three bytes in the array represents 8-bit R, G and B color values for each of the 8 LEDs. My main animation code manipulates the 8 bit color data values in this array with various algorithms and routines, and when ready to animate the next sequence calls gosub update_LED_Output to send changed values to the LED controller.

Here's the base code for this:
Code:
symbol sdata = C.1 ' a high or low on this pin sets bit data to a 1 or 0
symbol sclk = C.2   ' a pulse on this pin writes the bit data into the shift register MSB first
symbol XLAT = C.4  ' pulse on this pin writes the 288 bits of shited in data from the controller's SR to output latch 

symbol Cur_LED_Array = 28 ' pointer into memory where a 24 byte array represents 8 bit RGB values per each LED

'shiftout variables and counters
symbol sbytecounter = b0
symbol sbitcounter = b1
symbol var_out = b2 ' output byte variable
symbol mask = b3 ' bit masked variable

gosub update_LED_Output ' sends Cur_LED_Array values to the TLC5947 controller

'========================================================================
update_LED_Output:

    bptr = Cur_LED_Array             'points to LED color value array
    for sbytecounter = 1 to 24    ' iterates through all 24 bytes
        var_out = @bptrinc
        for sbitcounter = 1 to 8 ' number of bits
            mask = var_out & 128 ' mask MSB 128 = 1000 0000
            low sdata ' data low
            if mask = 0 then skipMSB
            high sdata ' data high
skipMSB:
            pulsout sclk,1 ' pulse clock for each bit
            var_out = var_out * 2 ' shifts var_out left for the next bit from MSB
        next sbitcounter
        ' on the LSB of the byte repeat it 4 more times to reach 12 bits
        ' simply done by pulsing out four more times on the same sdata value
        pulsout sclk,1
        pulsout sclk,1
        pulsout sclk,1
        pulsout sclk,1
    next sbytecounter
    pulsout XLAT,1    ' when all bytes are shifted out 
                                'this tells the controller to latch the 288 bit SR data to the output
    return

'========================================================================
 

premelec

Senior Member
Good work! Looks like you've got it tamed...I went to APA102s some years ago - easy drive to multicolor...
 

datasmith

Well-known member
OK - I have been working on getting my RGB-LED control prototype into an actual piece of art. Using the 08M2's limited memory I was able to squeeze in five full color animated sequences that run about a minute each with 409 bytes of memory to spare. I also had a spare input pin on the 08M2, so I attached a capacitive touch sensor module to allow for some user interaction. Normally the program will cycle through the five animation sequences in a continuous loop, but touching the sensor once will cause it to keep repeating the current sequence if the viewer likes it. Touching it again will start it cycling through all sequences again. I picked up the HiLetgo TTP223B Capacitive Touch Switch Module in a 10-pack for $7.50 US from Amazon (of course). I have a love/hate relationship with Amazon.com. I'm an old-school guy and used to love browsing around in my local hobby/model shop and radio-shack electronics store. But they have gone the way of the Dodo bird. If I lived in New York, or Atlanta, or Miami maybe I could find one. But in middle America Amazon has eaten them all up. So that's where I go for just about everything now. Scary.
I digress.

So, the Idea is to take these eight RGB LED's and put them into a piece of Art. I've attached a concept image I created with Blender, and an image of my current work in progress getting it into reality...

The concept is to have this tower of spheres glow in a sequence of colors. The "tower" is constructed from 10AWG and 12AWG solid copper wire soldered together into a lattice, and the "spheres" are actually table tennis (ping-pong) balls. Celluloid ping-pong balls make perfect little projection screens and glow quite well with a bright LED inside.
 

Attachments

hippy

Senior Member
Here's the base code for this ..
If you add "Symbol sdatapin = pinC.1" you can speed up the code you have with -
Code:
update_LED_Output:
    Low sdata
    bptr = Cur_LED_Array             'points to LED color value array
    for sbytecounter = 1 to 24    ' iterates through all 24 bytes
        var_out = @bptrinc
        sdatapin = bit23 : pulsout sclk,1
        sdatapin = bit22 : pulsout sclk,1
        sdatapin = bit21 : pulsout sclk,1
        sdatapin = bit20 : pulsout sclk,1
        sdatapin = bit19 : pulsout sclk,1
        sdatapin = bit18 : pulsout sclk,1
        sdatapin = bit17 : pulsout sclk,1
        sdatapin = bit16 : pulsout sclk,1
        pulsout sclk,1
        pulsout sclk,1
        pulsout sclk,1
        pulsout sclk,1
    next sbytecounter
    pulsout XLAT,1    ' when all bytes are shifted out 
                                'this tells the controller to latch the 288 bit SR data to the output
    return
 

datasmith

Well-known member
Wow hippy! That change in my output subprogram easily doubled my animation sequence frame rate. I am looking at all my sequence code now. I can double the math precision in my routines and get a lot smoother transitions. Thanks for the tip!
 

datasmith

Well-known member
Wanted to post an update on the progress of this art project. I am nearing completion and wanted to document the progression of the electronics components. The first two images are my Photoshop mock-ups of my PCB layout. I try do do everything virtually first. The second two images are the finished product.
 

Attachments

AllyCat

Senior Member
Hi,

(y) +1 . :)
The first two images are my Photoshop mock-ups of my PCB layout.
Have you seen "Pebble" which can do much the same thing (Veroboard / Stripboard included), but maybe quicker? Its download link seems a little "buried" now, but it can be found here:


Cheers, Alan
 

erco

Senior Member
Impressive work, datasmith! You're already setting the bar high for a "new member". I'm guessing this ain't your first rodeo. :)
 

datasmith

Well-known member
Well erco, I've been around this stuff for a long, long time... a retired engineer disciplined in electronics (digital and analog) and computer sciences. Now that I am out to pasture I just can't see myself fly fishing, playing golf or a hand of Bridge, or anything else of that nature. So here I am trying to make art using the things I know.
 

datasmith

Well-known member
OK. Here are some final construction shots, and a sneak peek at one in operation(test pattern-all LEDs blue). I am working on a video to put on Youtube, so you can see all the final color patterns in operation. That will be in a few more days. I suppose that link should go into the Finished Projects section.
 

Attachments

erco

Senior Member
Awesome work, datasmith! Are you in the US? Way to keep busy, you're way too good to be put out to pasture, you should be doing either freelance or inventing, like me. Plenty of opportunitie$ around.
 

datasmith

Well-known member
Hi erco.I live on the North Carolina coast in the US. Actually want to try my hand in some 3D printing. Saw the need during this project. Thought there might some $ in it. But, do it for myself first. Right now I am enjoying not having to answer to anyone else.
 

erco

Senior Member
Love it. I'm in LA, originally from SC. My brother in Raleigh is retiring to Oriental, NC to sail his boat.

Have fun learning 3D printing. My buddy here came OUT of retirement and has gone from zero to 3D printing whiz. He uses an iPad pro and https://www.shapr3d.com/ . Check that out before you blow $10K on Solidworks and a workstation.
 

lbenson

Senior Member
Beautiful work, and masterful presentation (though I'm perhaps most impressed by how tidy everything in the background is).

Maybe I missed it earlier in the thread, but what did you use to do your 3D modelling?

And do you play (or program) a synth to produce the background music?
 

datasmith

Well-known member
Hi lbenson,
You should see the pile of junk that got put behind the camera. I have a Yamaha USB piano keyboard interface and use Reason synth software and Sonar music composer software. I have no music skills or coordination. The computer has to play for me. I used Blender for my 3D modelling. It's like the 747 of 3D modeling and animation tools, and it's FREE! But like a 747 it's really complex-constant learning curve. I recently discovered Tinkecad.com, a free online tool from Autocad that I hear a lot of people use for 3D printing.
 

datasmith

Well-known member
BTW erco, I REALLY liked that Shapr3D app. Too bad I'm an Android guy. Guess I'll have to wait till it gets ported over... if ever. I bought bigtime into Samsung. Phone, tablet, TV.
 

eclectic

Moderator
An exemplary piece of work.

Just out of interest, what's the reason for the transliteration of "smile"

Sigma mu iota lambda eta?

smile.JPG

E
 

premelec

Senior Member
@datasmith - That's a super well done video & project! I have a small request.... could you include word PICAXE in the video title so it shows up on a PICAXE search :)?
 

datasmith

Well-known member
Hi ecletic,
σμίλη is actually Greek for "chisel"... since I am calling this thing a "sculpture".
Started with me trying to come up some kind of logo around my last name... Smith
You see, I come from a long line of Smiths . (bada-boom)
I could have used the modern Greek translation for Smith (Σιδηρουργός) but that certainly is a mouthful.
Then I thought I would go more esoteric. What does Smith actually mean? What's its origin?
Blacksmith? Ironsmith? Swordsmith? Silversmith?
All of those are also Greek mouthfuls. So I ended up with a sculptor's tool instead, the chisel.
More recently I stumbled across the Maker Community. I think I could be a maker, and smiths made things (sword maker, Iron maker, silver maker...)
A Greek translation for poet/maker is ποιητής, which is not too much a mouthful, but I think I still like the look of "chisel" more.
When you are retired you have way too much time to think about junk like this.
 

Hemi345

Senior Member
Excellent work! The video is really well done.

I use Tinkercad for 3D modeling as well and print my designs on a Creality Ender3 Pro. If you haven't purchased one yet, the Ender3 is a fantastic machine for little money.
 

datasmith

Well-known member
Yeah Hemi345, I was actually looking at the Ender 3 as a good first 3D printer to learn on. (I am also a big fan of Naomi Wu)
 
Top