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?
Hi there
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
JeanTech
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?
Hi there
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
JeanTech
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?
Regards, Mike
Hi there
1) Desired PWM frequency - 1000.
2) Levels I require - 0 to 255 ( 1 - 100%)
3) clock speed - 4 Mhz
4) channels - 3 channels
Thanks
JeanTech
Hi JeanTech,
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?
Regards, Mike
Last edited by Mike, K8LH; 19th March 2010 at 12:04 AM.
Hi Mike
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
| Tags |
| Similar Threads | ||||
| Thread | Starter | Forum | Replies | Last Post |
| pic16f627a USB connection | JeanTech | Microcontrollers | 4 | 5th March 2010, 04:12 PM |
| PIC16F627A will not program? | i_build_stuff | Microcontrollers | 8 | 8th June 2009, 01:22 PM |
| PIC16F627A Upgrade...? | tlambertsen | Microcontrollers | 6 | 28th October 2008, 03:06 PM |
| Differences between PIC16F627 and PIC16F627A | Cypher | Microcontrollers | 3 | 14th March 2007, 01:17 PM |
| Help with the PIC16F627A, cant get ports to act right | FusionITR | Microcontrollers | 6 | 16th March 2006, 11:59 AM |