Choosing Period and Duty Cycle (PWM)

Thread Starter

KansaiRobot

Joined Jan 15, 2010
324
Hello everybody.
I would like to ask about the period and duty cycle quantities when generating a PWM signal.

1) First I am using a PIC18F2550 so I suppose that my Fosc = 1MHz. (I read this on the data sheet, is there a way to check this??)

2) Now I have to set the PWM period or frequency (the inverse).
How do I set this? What quantities are recommended for PWM period?
(i am planning to use this to control a motor, but in the meantime I am also trying to control a LED brightness too)

I heard there are some recommendations for choosing a period so that the motor does not generate a human audible sound?

I would really much appreciate your thoughts on this, I have read already PLENTY of pages on PWM and I know the concept but the points above are still unclear

Thanks in advance

kansai
 

jpanhalt

Joined Jan 18, 2008
11,087
Hello everybody.
I would like to ask about the period and duty cycle quantities when generating a PWM signal.

1) First I am using a PIC18F2550 so I suppose that my Fosc = 1MHz. (I read this on the data sheet, is there a way to check this??)
You set the oscillator frequency in the program (OSCCON register). See Section 2 of the datasheet. 1 MHz is an option and is the default for the internal oscillator. For motor control, it doesn't need to be that accurate.

What quantities are recommended for PWM period?
(i am planning to use this to control a motor, but in the meantime I am also trying to control a LED brightness too)
There can be a lot of debate about the best frequency to use for motor control. I prefer the higher frequencies (e.g., 20KHz) as that avoids most of the annoying whine. The higher frequencies require more switching per second. As the transitions are not instantaneous, heat is produced during each cycle. Thus, the higher frequencies may require better drivers for your mosfets than lower frequencies. You may also need bigger heat sinks.

John
 

retched

Joined Dec 5, 2009
5,207
This is what can happen if your motor PWM is in the audible range:
http://www.youtube.com/v/xS8s5p6BMa8

If you are already filtering a particular frequency later in the system, you can choose that as your PWM frequency. To kill two birds with one stone.

If you were building a hi-fi record player, and you already have a 24kHz filter before the amp circuits, you can use the 24kHz for the motor, and the existing filter will clean up the motor hum. (Which should be inaudible at that frequency)
 

Tahmid

Joined Jul 2, 2008
343
Hi,
Take a look over here:
http://www.edaboard.com/ftopic379285.html

The formula is like this:
Rich (BB code):
PR2 = [Fosc / (Fpwm * 4 * N)] - 1
Fpwm is desired frequency.
Fosc is system frequency(crystal/resonator/RC).
N is timer prescaler.
You won't be able to effectively produce 50Hz with the CCP module. You should be using software to generate this, or an IC.
Rich (BB code):
CCPR1L = (DC/100)*PR2
DC = duty cycle in percentage

I heard there are some recommendations for choosing a period so that the motor does not generate a human audible sound?
I would go for 25kHz to avoid the audible range.

Hope this helped.
Tahmid.
 
Top