Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Spency's Rgb Led Program, For any 18F PIC

Status
Not open for further replies.

gramo

New Member
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 **broken link removed** 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 **broken link removed** (they are very bright and have very vivid colors)

**broken link removed**

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

**broken link removed**

More info about the program and circuit can be found **broken link removed**
 
Last edited:
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
 
The LED's are **broken link removed**

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;

**broken link removed**
 
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 **broken link removed**.

eg;

Remove the red code

Code:
Interrupt TMR2_Interrupt()
[COLOR="Red"]    High(Signal_Pin)[/COLOR]
    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
[COLOR="Red"]    Low(Signal_Pin)[/COLOR]
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!
 
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
hmm, seems I highlighted the wrong line on the bottom, and I can no longer edit - any chance of a moderator fixing that?
 
I reckon they'd be fairly close. They are the same current and almost the same Vf.
**broken link removed**

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)
 
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.


I reckon they'd be fairly close. They are the same current and almost the same Vf.
**broken link removed**

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)
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top