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.

3 PWM with pic16f627a?

Status
Not open for further replies.

JeanTech

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

Latest threads

New Articles From Microcontroller Tips

Back
Top