18th March 2010 05:15 AM
3 PWM with pic16f627a?
I would like to build a RGB led controller with a pic16f627. The problem is that it only has one PWM channel. It has 3 timers as well, Tmr0,Tmr1 and Tmr2.
Is there a way to use PWM on 2 other channels using software? The pic must also be able to accept serial data while PWM is on.
I'm currently programming in C.
Thanks in advance
18th March 2010 12:46 PM
Is there another task you'd like to perform with the microcontroller? If not you have plenty of room to implement PWM in software. What C compiler do you use?
18th March 2010 02:01 PM
The only other task besides PWM, is to accept incoming serial data. I use mikroC compiler. How would the code look in C to use PWM in software?
Thanks in advance
18th March 2010 02:45 PM
JeanTech, There are probably a few qualifiers for using software PWM.
(1) What is the desired frequency (PWM period)?
(2) How many duty cycle "steps" or "levels" do you require?
(3) What is the mcu clock speed (4, 8, 12, 16 MHz)?
(4) How many channels? Three for a single RGB LED?
18th March 2010 07:05 PM
1) Desired PWM frequency - 1000.
2) Levels I require - 0 to 255 ( 1 - 100%)
3) clock speed - 4 Mhz
4) channels - 3 channels
18th March 2010 11:38 PM
Generating 256 duty cycle steps with a 1000-Hz period translates to a step time of around 4-usecs. This can be difficult to achieve in software on a 4-MHz PIC.
I have developed a method recently using BAM (Bit Angle Modulation) which could provide a 2-usec "step" size and a 1953-Hz (512-usec) period on a 4-MHz PIC but I haven't found an easy way to reproduce the driver in C. Sorry!
May I ask if you are related to the JeanTech that produces computer cases?
Last edited by Mike, K8LH; 19th March 2010 at 12:04 AM.
19th March 2010 05:16 AM
thanks for all the help. I think I can upgrade my clock speed to 12mhz, so that should work.
No I'm not related to JeanTech who produces pc cases :-)
thanks for the help
Electronic Circuits |
Page Time: 0.07249 seconds Memory: 7,427 KB Queries: 16 Templates: 0