|
|
View previous topic :: View next topic |
Author |
Message |
soulraven
Joined: 08 Feb 2009 Posts: 72 Location: campulung muscel
|
need help with a library for TLC5947 |
Posted: Sat Jun 15, 2013 1:14 pm |
|
|
hello,
i am trying to find a library for TLC5947,
i want to build a led cube 10x10x10 from this project but using PIC: http://libesz.digitaltrip.hu/ledcube/ |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19503
|
|
Posted: Sun Jun 16, 2013 2:34 am |
|
|
Doesn't anybody just write their own?.
It's not exactly complex.
The chip accepts standard SPI mode0. So 90% is already done for you by the CCS drivers.
Key things are that you need hardware to hold the BLANK line high before the PIC wakes up, and the XLAT line low (resistors on each).
Then code drives BLANK high, XLAT low.
All that is needed then is to send 36 bytes, then pulse XLAT high/low. Data is then latched into the registers. Now drop BLANK, and the data is displayed.
You don't have to worry about reading, since the returned data is garbage on the first write, and it then just the old data on subsequent writes.
The data keeps being output, so long as BLANK is held low. You can reset the counter at any time by pulsing blank high.
The only 'complex' thing, is that the data sent needs to be 36 bytes long, but the greyscale data is 12bits per output. So write an access function to talk to the right bytes into the array
Code: |
int8 clock_vals[36]; //36byte array.
void val_to_array(int16 val, int8 index)
{
//routine to put 12bits from 'val' into the data array at 'index' (0 to 23)
//three nibbles from val need to transfer into the array
int8 nib_index, array_index;
int8 nibble;
nib_index=index*3; //starting nibble number
array_index=nib_index/2;
if (index>23) return; //make sure cannot overshoot array....
//If the nibble_index is even, then byte is transferred from low byte of
//int16, and next nibble to the next low nibble.
//If odd, then low nibble is transferred to high nibble of target,
//and the next 8 bits go to the next byte
if ((nib_index & 1)==0)
{
//even
//easy just access the low byte
clock_vals[array_index++]=make8(val,0);
nibble=(make8(val,1) & 0xF);
clock_vals[array_index]=(clock_vals[array_index] & 0xF0) | nibble;
}
else
{
//odd
nibble=(make8(val,0) & 0xF);
swap(nibble);
clock_vals[array_index]=(clock_vals[array_index] & 0xF) | nibble;
nibble=val/16; //rotate four times
clock_vals[++array_index]=nibble;
}
}
void main()
{
int8 byte_to_send;
output_high(BLANK);
output_low(XLAT);
//ensure lines are driven
//make sure all non used values are clear
memset(clock_vals,0,sizeof(clock_vals));
//Now test writing to the array
val_to_array(0x122,0);
val_to_array(0x5AA,1);
val_to_array(0x211,4);
val_to_array(0xA55,23);
//So, write four twelve bit intensity values to the array at indexes
//0, 1, 4 & 23 - Indexes can be 0 to 23 only
//Then the device write is simply -
//(with SPI setup to suit your hardware, and
//XLAT and BLANK defined (SPI using stream 'SPI_DEVICE')
for(byte_to_send=0;byte_to_send<35;byte_to_send++)
{
spi_xfer(SPI_DEVICE,clock_vals[35-byte_to_send],8);
}
output_high(XLAT);
delay_cycles(1);
output_low(XLAT);
output_low(BLANK);
//data is now displayed
do
{
} while (TRUE);
}
|
Note you send MSB first from the array, This way the numbers agree with the manufacturer.
Best Wishes |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9224 Location: Greensville,Ontario
|
|
Posted: Sun Jun 16, 2013 6:03 am |
|
|
I do ! Well, I did for the TLC5947....seems 'similar',same pinout,protocol,might work...
It was one of those 'mind challenges' during winter 2 years ago.then of course another new chip came out( LED pixel) that cauget my eye, and made a driver for them....
hmm...lots of 1/2 finished 'projects' sitting on my bench.....
The great thing about doing your own driver is that you KNOW the details and can maximize performance.
cheers
Jay |
|
|
soulraven
Joined: 08 Feb 2009 Posts: 72 Location: campulung muscel
|
|
Posted: Sun Jun 23, 2013 6:58 am |
|
|
Hello, and thx for the idea, but i have one question. Why is it needed to send 36 bytes, because 24 outputs * 12bit/output = 288 bytes.
And also what is changed when i try to put 5 drivers in daisy chain, what i have to change? only the
Quote: | if (index>23) return; //make sure cannot overshoot array.... |
and
Quote: | int8 clock_vals[36]; //36byte array. |
and also, how i use the clock pin in this configuation |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Sun Jun 23, 2013 4:05 pm |
|
|
Quote: |
Why is it needed to send 36 bytes,
|
PLEASE READ the data sheet- it's there pretty plainly -
at least do something FOR YOUR OWN PROJECT-
if for no other reason -
than to show you actually have a clue about what you are attempting!!!!
in the real world - your boss or customer is not gonna accept cribbed work- and you should not seek it so eagerly either.
if the forum does your homework NOW-
what have you learned ,
except to beg others to do it again?
If you want this to be your career, then
for your own future - figure this part out yourself!!!
HINT READ PAGE 10 of the pdf and ask yourself:
"what is 288/8" ???? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19503
|
|
Posted: Mon Jun 24, 2013 1:12 am |
|
|
soulraven wrote: | Hello, and thx for the idea, but i have one question. Why is it needed to send 36 bytes, because 24 outputs * 12bit/output = 288 bytes.
And also what is changed when i try to put 5 drivers in daisy chain, what i have to change? only the
Quote: | if (index>23) return; //make sure cannot overshoot array.... |
and
Quote: | int8 clock_vals[36]; //36byte array. |
and also, how i use the clock pin in this configuation |
24*12 = 288 _bits_. 288/8 = 36 _bytes_.....
12bits=1.5 bytes.
Best Wishes |
|
|
soulraven
Joined: 08 Feb 2009 Posts: 72 Location: campulung muscel
|
|
Posted: Mon Jun 24, 2013 2:23 am |
|
|
thx, Ttelmah, i understand now and i made the modifications for 5 daisy chain |
|
|
soulraven
Joined: 08 Feb 2009 Posts: 72 Location: campulung muscel
|
|
Posted: Sat Jun 29, 2013 4:17 pm |
|
|
hello,
I am back with a problem,
I have connected all the 5 drivers in daisy chain, and is working ok, until i have reach index 85. From index 86 until index 100 or 120, is not working right. If i try to turn on a led 86 or ... 100 or 93 or a led in range from 86 to 100, is also power on a led from the first led driver.
Below is a example if my code, i have put 100 because i want to light only the first 100 leds, and 12 because each led has 12 bits.
Please help me, i really don't know what is wrong.
Code: |
for(byte_to_send=0; byte_to_send < 100; byte_to_send++) {
spi_xfer(LED_CUBE, clock_vals[100 - byte_to_send], 12);
}
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|