How to set Timer PWM Module for controlling ESC?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to set Timer PWM Module for controlling ESC?

1,492 Views
jangajos
Contributor II

Hi, I try to set PWM for esc brushless motor which work on 50Hz by using sdk 2.0  and simply pwm example I couldn't achieve it. Could someone post how to configure it?

 

I use FRDM KL26Z.

Labels (1)
Tags (1)
5 Replies

874 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

You can use the following code:

TPM_GetDefaultConfig(&tpmInfo);

    /* Initialize TPM module */

tpmInfo.prescale = kTPM_Prescale_Divide_128;

    TPM_Init(BOARD_TPM_BASEADDR, &tpmInfo);

PM_SetupPwm(BOARD_TPM_BASEADDR, tpmParam, 2U, kTPM_EdgeAlignedPwm, 50U, TPM_SOURCE_CLOCK);

BR

Xiangjun Rong

874 Views
jangajos
Contributor II

Hi,
thanks for your help, now it works probably the problem was with prescaler because everything else i have the same :smileywink: thanks for the explanation :smileyhappy:

0 Kudos

874 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Jan,

If you would like to control a BLDC, I suggest you use a Kinetis processor with FTM module instead of TPM, as you know that the PWM generator module should have inverting/masking function when you control a BLDC motor, BTW, the PWM generator should have Fault function in order to disable pwm signals once over cruuent/voltage occur, but the TPM module is difficult to implement the above function.

BR

Xiangjun Rong

874 Views
jangajos
Contributor II

Thanks a lot for your answer. I will use different processor for my project but I want to check if it is possible to generate 50Hz (20ms period) pwm signal (because such signal use esc controllers ). I changed the period in TPM_SetupPwm() and I can generate only 400Hz as the smallest. It's normal for TPM and I need FTM to generate 50Hz?

0 Kudos

874 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Jan,

As you know that the PWM is a divider, the TPM_MOD register is 16 bits register, it's maximum value is 65535. If you use 48MHz clock to drive TPM module, set TPM in edge-alignment mode, and set the PS bits in 3b'111, the mimimum PWM signal frequency is 48MHz/(128*65535)=5.72Hz.

If you want to generate 50HZ PWM signal in edge-alignment mode, assume that you use 48MHz clock signal to drive TPM module and set the PS bits in TPMx_SC as 3b'111(128 divider).

48MHz/(128*50)=7500

In other words, in the condition:edge-alignment mode, TPM driving clock is 48MHz, set the PS bits in TPM_SC as 111 in binary, set the TPM_MOD as 7500, you will get 50HZ PWM signal.

Hope it can help you.

BR

XiangJun Rong