Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 22:13 11 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Cfunction for RGB LED IC...

Author Message
Zonker

Guru

Joined: 18/08/2012
Location: United States
Posts: 761
Posted: 07:30am 07 Feb 2015
Copy link to clipboard 
Print this post

Good afternoon Gent's..

I seem to remember someone had come up with a CFunction for This RGB LED but, I can't seem to locate it.. I wanted to use it as a controllable light source for a gauge backlighting project... Was wondering if the CFunction would allow chaining the lamps together in a string and how many deep you could go...

Thanks for any info on this...!


Edit: - I did find This Post But not any CFunction for it... Edited by Zonker 2015-02-09
 
Frank N. Furter
Guru

Joined: 28/05/2012
Location: Germany
Posts: 815
Posted: 07:22am 08 Feb 2015
Copy link to clipboard 
Print this post

Yeah, I am waiting too!

Plasma, what's going on? Did you reached anything new with the WS2812?

Frank

 
Zonker

Guru

Joined: 18/08/2012
Location: United States
Posts: 761
Posted: 10:16am 08 Feb 2015
Copy link to clipboard 
Print this post

Humm....

Maybe it's time for me to give this CFunction stuff a try...

We know basically what needs to happen...

You pass the intended pin to drive, and your first RGB 656 pattern shifted out to the drive pin... Then, (I guess) you would have a small basic subroutine pass the CFunction a group of bytes that match the number of IC RGB lamps you have strung together to form the group. The CFunction would push just one color control byte and let the user change the outer "basic" subroutine stuff...

I will try to find the "how do you do this" stuff that Matherp posted here somewhere... I'll be back after some head scratchin....
 
Oldbitcollector

Senior Member

Joined: 16/05/2014
Location: United States
Posts: 172
Posted: 10:54am 08 Feb 2015
Copy link to clipboard 
Print this post

+1

I think Plasma's got this working, but perhaps a little code-shy?


My Propeller/Micromite mini-computer project.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8600
Posted: 10:51pm 08 Feb 2015
Copy link to clipboard 
Print this post

I've ordered one of these , should make a fun present for my granddaughter

It should arrive tomorrow so I'll knock up a Cfunction then.

I have to say though this device has the most stupid data format I've ever seen - why isn't the frame length for a "1" the same as for a "0"? I can only think the little processor is running flat out and these timings are just a reflection of the code it can execute.

 
plasma
Guru

Joined: 08/04/2012
Location: Germany
Posts: 437
Posted: 12:22pm 09 Feb 2015
Copy link to clipboard 
Print this post

i send some code to matherp and i hope it helps.

unfortunately i cant help much beause the rescued hd is corupt and i cant remember
all the code.

it shows the timingstructure and some settings

i hope it helps.

thx
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8600
Posted: 01:09pm 09 Feb 2015
Copy link to clipboard 
Print this post

Typical of me being too headstrong - I'd just coded it from scratch . Looks good on the scope but waiting for some hardware to test. The code should support any number of LEDs but the RTC will lose 1msec for each refresh of each 29 LEDs in the string (3 refreshes/second with 72 LEDs in the string will lose 9msec / second). No loss of time if the number of LEDs is 28 or less .

If anyone wants to try the code while I wait for some hardware here it is, runs on 28 or 44 pin 170s. Get rid of the spaces in the 2 long strings (p28$ and p44$) that the BB software has put in:


OPTION DEFAULT NONE
OPTION EXPLICIT
CPU 48
const Green=0
const Red=1
Const Blue=2
const NUMLEDS=28 ' number of LEDs in chain
const WS2812pin=16 ' pin to use for output
DIM integer buffer(NUMLEDS*3-1)
dim INTEGER colours(2,NUMLEDS)
dim integer i,portnum,pinnum
'
for i=0 to NUMLEDS-1 'set up some example colours
colours(green,i)=&HFF
colours(red,i)=&HFF
colours(blue,i)=&HFF
next i
'
setpin WS2812pin,dout
i=getpin(WS2812pin,portnum,pinnum)
'
Do
i=pulses(NUMLEDS,portnum,pinnum,colours(),buffer())
LOOP
'
end
'
'number of LEDs, PIC port numer (0=A..2=C), Pin number within the port, array of colour codes, buffer array used by the CFunction
'
CFunction Pulses
00000000
8fa30010 24020001 8ccc0000 01826004 8c860000 00067840 01e67821 8ca60000
14c20003 8ca50004 10a00009 3c0ebf88 24020002 14c20003 3c0ebf88 50a00007
25cd6234 25cd6034 10000005 25ce6038 25cd6134 10000002 25ce6138 25ce6238
34058000 3c02bf80 ac450600 51e00012 8c820004 00605821 00005021 2409ffff
8ce80000 01602821 24020007 00483006 30c60001 a0a60000 2442ffff 1449fffb
24a50001 254a0001 24e70008 154ffff4 256b0008 8c820004 5c400007 3c02bf80
1440000c 3c05bf80 8c820000 2c42001d 14400008 3c02bf80 8c460c00 3c05ffff
24a57fff 00c52824 ac450c00 10000006 8c850000 8ca20c10 2c420065 1040fffd
00000000 8c850000 000510c0 00052940 00a21023 10400025 00003821 3c05bf80
00673021 90c60000 10c0000f 00000000 adcc0000 aca00610 8ca60610 2cc60019
14c0fffd 00000000 adac0000 aca00610 8ca60610 2cc6000d 14c0fffd 00000000
1000000e 24e70001 adcc0000 aca00610 8ca60610 2cc60005 14c0fffd 00000000
adac0000 aca00610 8ca60610 2cc60014 14c0fffd 00000000 24e70001 14e2ffe1
00673021 10000003 8c830004 00001021 8c830004 5c600008 3c03bf80 14600009
00000000 8c830000 2c63001d 14600005 00000000 3c03bf80 8c640c00 34848000
ac640c00 adac0000 03e00008 00001821
End CFunction
'
'long long Pulses(long long *numleds, long long *portname,long long *mypin,long long parray[], unsigned char sarray[]){
' #define tmr4 *(volatile unsigned int *)0xbf800C10 //timer 1 configuration register
' #define tmr4con *(volatile unsigned int *)0xbf800C00 //timer 1 configuration register
' #define tmr1con *(volatile unsigned int *)0xbf800600 //timer 1 configuration register
' #define tmr1 *(volatile unsigned int *)0xbf800610 //timer 1 counter
' unsigned int nextcol,index,k,bpos,pin=1<<*mypin,current_ticks=0;
' unsigned int numcols=*numleds*3;
' unsigned char ch;
' unsigned int volatile * mysetport;
' unsigned int volatile * myclearport;
' if(*portname==0) {
' mysetport=(volatile unsigned int *)0xbf886038;
' myclearport=(volatile unsigned int *)0xbf886034;
' }
' if(*portname==1) {
' mysetport=(volatile unsigned int *)0xbf886138;
' myclearport=(volatile unsigned int *)0xbf886134;
' }
' if(*portname==2) {
' mysetport=(volatile unsigned int *)0xbf886238;
' myclearport=(volatile unsigned int *)0xbf886234;
' }
' tmr1con=0x8000; //turn on timer at full speed
' index=0;
' for(k=0;k<numcols;k++){ //move the data into a single dimensional array that we can step though in even time
' nextcol=parray[k];
' for(bpos=0;bpos<8;bpos++){
' sarray[index]=(nextcol>>(7-bpos)) & 1;
' index++;
' }
' }
' if(*numleds > 28) { //Decide how to avoid RTC interrupts
' tmr4con &= 0xFFFF7FFF; //turn off the real time clock if it is going to interfere
' } else {
' while(tmr4>100); //synchronise with the RTC to avoid interrupts
' }
' k=*numleds * 24;; //get the number of bytes to output
' for (index=0;index<k;index++){ //step through the input data
' // Note the timer settings are not obvious as the execution of the loop elongates the low pulses
' if (sarray[index]){
' *mysetport=pin;
' tmr1=0;
' while(tmr1<25); //Tune for the 700ns pulse
' *myclearport=pin;
' tmr1=0;
' while(tmr1<13); //Tune for the 600ns pulse
' } else {
' *mysetport=pin;
' tmr1=0;
' while(tmr1<5); //Tune for the 350ns pulse
' *myclearport=pin;
' tmr1=0;
' while(tmr1<20); //Tune for the 800ns pulse
' }
' }
' if(*numleds > 28) tmr4con |= 0x0008000; //turn the clock back on
' *myclearport=pin; //Set the output low to create the reset pulse which loads the data
' return index;
'}
'
' uses the pin number to get the port number and the pin number on the port by reference to the Device ID
'
function getpin(MMpin as integer,portnum as integer,pinnum as integer) as integer
const P28$="N/AA00A01B00B01B02B03N/AA02A03B04A04N/AB05B06B07B08B09 N/AN/AB10B11B12B13B14B15N/AN/A"
const P40$="B09C06C07C08C09N/AN/AB10B11B12B13A10A07B14B15N/AN/AN/A A00A01B00B01B02B03C00C01C02N/AN/AA02A03A08B04A04A09C03C04C05 N/AN/AB05B06B07B08"
local integer i
local a$ length 3
i=(MMpin-1)*3 +1
if (peek(word &HBF80F220) and &HFFFFFFF) = &H6610053 then
if MMpin>=1 and MMpin<=28 then
a$=mid$(p28$,i,3)
else
a$="N/A"
endif
else
if MMpin>=1 and MMpin<=40 then
a$=mid$(p40$,i,3)
else
a$="N/A"
endif
endif
if a$="N/A" then
getpin=0
else
portnum=asc(left$(a$,1))-65
pinnum=val(right$(a$,2))
getpin=1
endif
end function
'
Edited by matherp 2015-02-10
 
Zonker

Guru

Joined: 18/08/2012
Location: United States
Posts: 761
Posted: 06:11pm 09 Feb 2015
Copy link to clipboard 
Print this post

Awesome Pete..!!

Wow, I am going to look at this tomorrow after work... I have a sparkfun RGB LED and will get it connected up and try it out... Now where IS that thing...?
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2870
Posted: 11:31pm 09 Feb 2015
Copy link to clipboard 
Print this post

Hey,

I wonder if we can string enough together to make a crude LED screen..

Mick
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2870
Posted: 11:40pm 09 Feb 2015
Copy link to clipboard 
Print this post

  bigmik said  
I wonder if we can string enough together to make a crude LED screen..


Looks like they are already available. (Don't ask me why I looked them up)

Panel

Mick


Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8600
Posted: 11:42pm 09 Feb 2015
Copy link to clipboard 
Print this post

They come ready "stringed" but quite pricey, also the power requirement starts to get quite high with larger numbers. Refreshing a unit like this would take about 3.5msec
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2870
Posted: 07:42pm 10 Feb 2015
Copy link to clipboard 
Print this post

Those LEDs are quite amazing.

They could even be incorporated onto a MicroMite board as a status LED to give some visual output to micromites or other modules.

Mick

Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2870
Posted: 07:47pm 10 Feb 2015
Copy link to clipboard 
Print this post

Lads,

Some interesting derivatives HERE

Mick
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024