linear1 forums
[part of the
linear1 network
]
+ [
linear1 case mods
]
+ [
LED Center
]
+ [
privacy policy
]
Welcome,
Guest
. Please
login
or
register
.
March 14, 2010, 01:52:40 AM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
linear1 forums
|
LED discussion
|
Microcontroller madness
| Topic:
RGB LED control using PIC micro
« previous
next »
Pages:
[
1
]
Author
Topic: RGB LED control using PIC micro (Read 770 times)
MichEngin03
Strong like bull
Offline
Posts: 5
RGB LED control using PIC micro
«
on:
June 25, 2008, 09:48:19 PM »
So I'm wanting to control a 3 color LED using PWM from a micro. I have noticed that most PIC controllers only have 2 hardware PWM outputs. Is there a smart way to produce a third PWM signal? Software or some kind of logic system?
Thanks.
Logged
justDIY
Microcontroller Madman
Administrator
Smart like tractor
Offline
Posts: 1652
UFOric
Re: RGB LED control using PIC micro
«
Reply #1 on:
June 26, 2008, 08:53:30 AM »
you can use the pic737,767 which has three hardware pwm outputs, or you can write an interrupt routine in assembler which will generate a low freq pwm on as many pins as you need, commonly 8 pins since it's easiest to juggle that 1 byte around in the ram.
Logged
Want to contact me directly? gmail gordonthree
My Project Blog -
http://projects.dimension-x.net
Favorite numbers:
09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
MichEngin03
Strong like bull
Offline
Posts: 5
Re: RGB LED control using PIC micro
«
Reply #2 on:
June 26, 2008, 12:20:59 PM »
OK, thanks for the hardware advice. I was planning on writing this in C. Would using C be too slow to generate a PWM signal in software?
Logged
justDIY
Microcontroller Madman
Administrator
Smart like tractor
Offline
Posts: 1652
UFOric
Re: RGB LED control using PIC micro
«
Reply #3 on:
June 26, 2008, 10:02:06 PM »
it is not that C is slow, it is that the structure of the high level compiler (C, Basic, etc) doesn't lend it self very well to true hardware interrupts. The high level compilers usually deal with polled interrupts or soft interrupts, instead of hard interrupts so they have time to get their memory addresses and what not protected (slow), before branching to the interrupt. when writing in pure assembler, your memory is always in order, so it's ok to let the pic branch to the interrupt for you (fastest)
im not saying it can't be done, and for most purposes, the delay from soft interrupts is not noticeable.
google has tons of assembler based PWM interrupts, which you can copy and paste into your C application, you'll just need to tweak how the interrupt is called
Logged
Want to contact me directly? gmail gordonthree
My Project Blog -
http://projects.dimension-x.net
Favorite numbers:
09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
cadstarsucks
Smart like tractor
Offline
Posts: 449
Re: RGB LED control using PIC micro
«
Reply #4 on:
June 27, 2008, 05:50:59 AM »
Along those lines it should be no trouble servicing a 1600Hz interrupt to give you 16 different levels for each 100Hz pulse.
You neglected to mention if you were doing anything else with the processor. If you were say reading a serial port for data and all the PIC was doing was display you might manage PWMing a 16x16 array with an endless loop since there would be no interrupt overhead.
Logged
Pages:
[
1
]
linear1 forums
|
LED discussion
|
Microcontroller madness
| Topic:
RGB LED control using PIC micro
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Important
-----------------------------
=> Please read our rules
-----------------------------
Case mod questions
-----------------------------
=> Case modding
-----------------------------
LED discussion
-----------------------------
=> Special Offers
=> Article discussion
=> LED questions and discussion
=> Electronics discussion
=> Microcontroller madness
=> LED project showcase
-----------------------------
Other Stuff
-----------------------------
=> La Bodega
=> Garden
=> Woodwork