Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 28th May 2008, 10:11 AM   (permalink)
Default Spency's Rgb Led Program, For any 18F PIC

I know there are 100's of RGB LED circuits and programs out there, but here's my take on things

I've made a program that allows the user to control the brightness of each LED from 0 to 100% by modifying a register from 0 to 255 for each color

What makes this program different? I back up the system registers before the interrupt, and restore them afterwards, so your main program could be doing absolutely anything (within reason), and the three PWM signals will function perfectly, and are all editable on-the-fly

It also includes a very handy mS register that can be used anywhere in the main program to create delays and the such, eg;

Code:
Red_Duty = 0                     // Clear the Red_Duty register
While Red_Duty < 255             // Create a loop condition
    Inc(Red_Duty)                // Increment the Red Duty Cycle
    mS = 0                       // Clear the mS register
    repeat
    until mS = 10                // Wait for 10mS to elapse
wend
This example will delay 10mS between each increment of the Red Duty Cycle. The main program is a little more elaborate, and generates a random number to decide which color to increase/decrease, for something so simple, the results are amazing in real life.

The Common Anode RGB LED's I used can be found here (they are very bright and have very vivid colors)


You can get very stunning effects with these LED's, and the video's I took didn't give them the justice! I used three LED's and a large white semi transparent bowl to diffuse the light and make a "mood rock" type feature.
RGB Practicle.wmv - File Shared from Box.net - Free Online File Storage


More info about the program and circuit can be found here
__________________
Spency.

PIC Micro's - Your mind is the limit

PIC's and interfacing with other devices - a PIC Basic Guide @ digital-diy.net

Last edited by gramo; 28th May 2008 at 10:11 AM.
gramo is offline   Reply With Quote
Old 28th May 2008, 12:19 PM   (permalink)
Default

Spency,

Nice demo and video. Those LEDs do look incredibly bright. May I ask which LEDs you're using on that Vendor page? Did you say you were using individual Red, Green, and Blue LEDs in your video?

Mike
Mike, K8LH is offline   Reply With Quote
Old 28th May 2008, 12:26 PM   (permalink)
Default

The LED's are these ones

I've got 3 in the circuit shown, but its just as bright and crisp with 2 (even with 1 it looks great). I was really surprised just how clean and balanced and vivid the color components were with these LED's, with past RGB LED's I have had to tone down either red or green to get a decent white balance.

If anything, it was way to bright, and thats why I had to turn the container around (to get rid of the extremely bright spot on the side the LED's were on). You can just see the glare of the bright side in the images at the back of the container;

__________________
Spency.

PIC Micro's - Your mind is the limit

PIC's and interfacing with other devices - a PIC Basic Guide @ digital-diy.net
gramo is offline   Reply With Quote
Old 28th May 2008, 12:29 PM   (permalink)
Default

Quote:
Originally Posted by Mike, K8LH View Post
Spency,
Did you say you were using individual Red, Green, and Blue LEDs in your video?

Mike
I was probably referring to each color chip within the LED's - the LED's used were 5mm RGB Common Anode LED's
__________________
Spency.

PIC Micro's - Your mind is the limit

PIC's and interfacing with other devices - a PIC Basic Guide @ digital-diy.net
gramo is offline   Reply With Quote
Old 28th May 2008, 12:34 PM   (permalink)
Default

Nice demo Gramo, I'll have to give it a try.
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is offline   Reply With Quote
Old 30th May 2008, 05:06 AM   (permalink)
Default

Thanks Bill


__________________
Spency.

PIC Micro's - Your mind is the limit

PIC's and interfacing with other devices - a PIC Basic Guide @ digital-diy.net
gramo is offline   Reply With Quote
Old 31st May 2008, 11:36 AM   (permalink)
Default

As pointed out in a different thread, you could remove the context saving in the interrupt routine should you want less code overhead in the main program.

eg;

Remove the red code

Code:
Interrupt TMR2_Interrupt()
    High(Signal_Pin)
    Save(0)                   // Back up system variables    
    If TMR2IF = 1 Then        // Check if the interrupt was from TMR2    
        TMR2IF = 0            // Clear the TMR2 interrupt flag
        uS = uS + 50
        If uS >= 1000 Then
            uS = uS - 1000
            Inc(mS)
        EndIf        
        Inc(Red_DutyVal)
        Inc(Green_DutyVal)
        Inc(Blue_DutyVal)
        If Red_DutyVal > Red_Duty or red_Duty = 0 Then
            Red_Pin = 0
        Else
            Red_Pin = 1
        EndIf
        If Green_DutyVal > Green_Duty or Green_Duty = 0 Then
            Green_Pin = 0
        Else
            Green_Pin = 1
        EndIf
        If Blue_DutyVal > Blue_Duty or Blue_Duty = 0 Then
            Blue_Pin = 0
        Else
            Blue_Pin = 1
        EndIf                
    EndIf                     //
    Restore                   // Restore system variables
    Low(Signal_Pin)
End Interrupt
It was put in as a safety blanket for public use, but as Mike noticed in the .asm, context saving was not required for the program as it stands!
__________________
Spency.

PIC Micro's - Your mind is the limit

PIC's and interfacing with other devices - a PIC Basic Guide @ digital-diy.net
gramo is offline   Reply With Quote
Old 31st May 2008, 11:57 AM   (permalink)
Default

hmm, seems I highlighted the wrong line on the bottom, and I can no longer edit - any chance of a moderator fixing that?

The lower red line should be

Code:
Restore                   // Restore system variables
__________________
Spency.

PIC Micro's - Your mind is the limit

PIC's and interfacing with other devices - a PIC Basic Guide @ digital-diy.net
gramo is offline   Reply With Quote
Old 2nd June 2008, 05:21 PM   (permalink)
Default

Damed that 15 minute edit time. I have deleted a post because of this, and really screwed up the thread, as people quoted the deleted post and anyone reading it would be lost...lol Learned that the hard way. 15 minutes is a bit short for this type of forum, since allot go back and fix or update their posts. It saves posting 10 times by adjusting your original post, alway put and EDIT: indicator so people can see it was modified. Any chance of raising this time limit Mods?

Cheers,
-BaC
Quote:
Originally Posted by gramo View Post
hmm, seems I highlighted the wrong line on the bottom, and I can no longer edit - any chance of a moderator fixing that?
__________________
Error: {Panic!} when trying to load: [reality shell]. kernel: "universe has been halted"...
Information Underground
BaCaRdi is offline   Reply With Quote
Old 2nd June 2008, 06:21 PM   (permalink)
Default

You thinks those are bright check these out: Common Anode 8000MCD Super Flux RGB LED-The Electronic Goldmine

totally blinding!!!!!
__________________
Error: {Panic!} when trying to load: [reality shell]. kernel: "universe has been halted"...
Information Underground
BaCaRdi is offline   Reply With Quote
Old 2nd June 2008, 08:42 PM   (permalink)
Default

I reckon they'd be fairly close. They are the same current and almost the same Vf.
Core Electronics - Red Green Blue CA 5mm LED

I've already emailed CE to get a MCD/mlm rating for the LED's because im interested to know what they are

I modified the project afterwards (and the examples on the site) for a single RGB LED, and it was just as good (actually better, as there were no "bright" spots)
__________________
Spency.

PIC Micro's - Your mind is the limit

PIC's and interfacing with other devices - a PIC Basic Guide @ digital-diy.net
gramo is offline   Reply With Quote
Old 2nd June 2008, 08:44 PM   (permalink)
Default

Its a fun project though, you can make some nice effects with this sort of thing
__________________
Spency.

PIC Micro's - Your mind is the limit

PIC's and interfacing with other devices - a PIC Basic Guide @ digital-diy.net
gramo is offline   Reply With Quote
Old 2nd June 2008, 08:59 PM   (permalink)
Default

Quote:
Originally Posted by BaCaRdi View Post
Damed that 15 minute edit time... Any chance of raising this time limit Mods?
I think 48-72 hours would be good. 24 hours minimum. 15 minutes is ridiculous for this type of forum!
__________________
=========================
Futz's Microcontrollers & Robotics
=========================
futz is online now   Reply With Quote
Old 6th June 2008, 03:36 AM   (permalink)
Default

Have to admit they did look very blinding, since that bright spot was pretty intense. Usually their even brighter in person I would love to see the specification on them. Sometimes manufactures stray from doing such, because of the differences from product to product. In this day-and-age we want bright! So if they fail short in specs of some samples they would have reflect that in their specs, via averaging So why put it out anyways..lol

-BaC
Not saying that is what is going on, they may just be in the process, as they tighten the design.


Quote:
Originally Posted by gramo View Post
I reckon they'd be fairly close. They are the same current and almost the same Vf.
Core Electronics - Red Green Blue CA 5mm LED

I've already emailed CE to get a MCD/mlm rating for the LED's because im interested to know what they are

I modified the project afterwards (and the examples on the site) for a single RGB LED, and it was just as good (actually better, as there were no "bright" spots)
__________________
Error: {Panic!} when trying to load: [reality shell]. kernel: "universe has been halted"...
Information Underground
BaCaRdi is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Latest
"Program verify failed at program address 0x000, progra Jimmy Vivas Micro Controllers 17 25th July 2008 01:35 AM
what exactly does Program Verify Error at Program Address 0x000 mean Gaston Micro Controllers 5 24th December 2006 06:17 PM
schematic & program to program pic 16f84a plz mafiaaa Micro Controllers 2 27th November 2004 04:00 PM
Program Help Timmymna Micro Controllers 3 15th March 2004 05:45 AM
Pic (A) program Pic (B) NewCurrent Micro Controllers 0 3rd October 2003 04:13 PM



All times are GMT. The time now is 05:04 AM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.