Controlling a Servo Motor with PWM - FRDM-KL43Z

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Controlling a Servo Motor with PWM - FRDM-KL43Z

ソリューションへジャンプ
1,454件の閲覧回数
zezao
Contributor I

So, basically, I'm trying to control a servo motor which pulse have 20ms, like the picture below:

Micro Servo 9g

I setup my PWM to 50 Hz, but when I'm updating the duty cycle (with the function TPM_UpdatePwmDutycycle), I can only work with percent changes, which give me like 10 differents angles (from varying the duty cycle from 1% to 10%, because 2 ms equals to 10% of the pulse), since the function expects an integer parameter.

void TPM_UpdatePwmDutycycle(TPM_Type *base, tpm_chnl_t chnlNumber, tpm_pwm_mode_t currentPwmMode, uint8_t dutyCyclePercent)

How can I work around it?

ラベル(2)
0 件の賞賛
返信
1 解決策
1,274件の閲覧回数
kerryzhou
NXP TechSupport
NXP TechSupport

Hi José Baretta

   The dutyCyclePercent in the API TPM_UpdatePwmDutycycle(TPM_Type *base, tpm_chnl_t chnlNumber, tpm_pwm_mode_t currentPwmMode, uint8_t dutyCyclePercent) just used to change the dutyCyclePercent.

    The value is from 0-100. If you want the duty cycle is 1-2ms, then you can use 5% to 10%.

    If you don't want to use the percent change, you also can calculate the according duty data, then input it in the TPM_CnV register.

   More details, you can refer to the KL43 reference manual.

    BTW, the KL43 is 3.3V chip, if you want to output 5V, you need external transform circuit.

Wish it helps you!

If you still have question about it, please kindly let me know.

Have a great day,
Kerry

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
1,275件の閲覧回数
kerryzhou
NXP TechSupport
NXP TechSupport

Hi José Baretta

   The dutyCyclePercent in the API TPM_UpdatePwmDutycycle(TPM_Type *base, tpm_chnl_t chnlNumber, tpm_pwm_mode_t currentPwmMode, uint8_t dutyCyclePercent) just used to change the dutyCyclePercent.

    The value is from 0-100. If you want the duty cycle is 1-2ms, then you can use 5% to 10%.

    If you don't want to use the percent change, you also can calculate the according duty data, then input it in the TPM_CnV register.

   More details, you can refer to the KL43 reference manual.

    BTW, the KL43 is 3.3V chip, if you want to output 5V, you need external transform circuit.

Wish it helps you!

If you still have question about it, please kindly let me know.

Have a great day,
Kerry

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 件の賞賛
返信
1,274件の閲覧回数
zezao
Contributor I

The problem is with that function I can only vary my pulse from 0.2 to 0.2 ms (I can't get 1.05 ms, for example). I think I'll have to use the TPM_CnV register anyway.

BTW, I'm powering the servo with 5V, only my PWM is 3.3V, and it seems to work fine.

Thank you for the reply!

0 件の賞賛
返信