This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

frequency of PWM



Hello everyone,

I'm working onPWM, I have used it many times but now I want to know correctly about frequency of PWM.

Please let's me know how frequency of PWM influence on DC motor??

Many examples on the internet used

PWMPulseWidthSet(PWM0_BASE,PWM_OUT_1,pwm);

with pwm from 0 - 255. So what is the pwm??

And then, when I want to use above pwm, I have to configure like that:

PWMGenPeriodSet(PWM0_BASE,PWM_GEN_2,255);

or like that: 

PWMGenPeriodSet(PWM0_BASE,PWM_GEN_2,7323);

Here is all of the configure of my PWM:

u32FreqClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000);
	
=============
SysCtlPWMClockSet(SYSCTL_PWMDIV_64);
SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIOPinConfigure(GPIO_PF1_M0PWM1);
GPIOPinTypePWM(GPIO_PORTF_BASE,GPIO_PIN_1);
PWMGenConfigure(PWM0_BASE,PWM_GEN_0,PWM_GEN_MODE_DOWN|PWM_GEN_MODE_NO_SYNC);
PWMGenPeriodSet(PWM0_BASE,PWM_GEN_0,255);
PWMOutputState(PWM0_BASE,PWM_OUT_1_BIT, true);
PWMGenEnable(PWM0_BASE,PWM_GEN_0);

  • Hello Phu,

    Good read besides wikipedia.

    extremeelectronics.co.in/.../introduction-to-pwm-pulse-width-modulation

    The PWMGenPeriodSet sets the time after which the PWM pulse will repeat (in number of clock cycles of the system clock) and PWMPulseWidthSet sets the ON Time of the *** in this timer period (in number of clock cycles of the system clock)

    Regards
    Amit
  • Hi Amit,

    Thanks for your reply.

    I know how PWM works, however, the problem is that I don't know how to choose the right period (frequency) of PWM.

    In this case, What is the "Period_PWM" in "PWMGenPeriodSet(PWM0_BASE,PWM_GEN_0,Period_PWM);" I should choose?

    Also, What is the range of "pwm" in "PWMPulseWidthSet(PWM0_BASE,PWM_OUT_1,pwm);" I should set?

    Please help me understand clearly about 2 problems above.

    I'm using L298 to controll 2 DC motors  24V. 

    Thanks so much.

    -Phu

  • Hello Phu,

    That should depend on the what the DC motor specification. Since there are wide range of motor with different rpm requirements, I would recommend reading the specification and then deriving the PWM requirements for L298.

    Regards
    Amit