一、六步换向
六步换向是针对直流无刷电机的一种较简单的控制算法,三相导通顺序循环按照(A,B),(C,B),(C,A),(B,A),(B,C),(A,C)依次导通。
二、关键代码
- void tiMER0_TRG_CMT_TIMER10_IRQHandler(void)
- {
- /* clear TIMER interrupt flag */
- timer_interrupt_flag_clear(TIMER0,TIMER_INT_CMT);
- switch(step){
- /* next step: step 2 configuration .A-C` breakover---------------------------- */
- case 1:
- /* channel0 configuration */
- timer_channel_output_mode_config(TIMER0,TIMER_CH_0,TIMER_OC_MODE_PWM0);
- timer_channel_output_state_config(TIMER0,TIMER_CH_0,TIMER_CCX_ENABLE);
- timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_0,TIMER_CCXN_DISABLE);
- /* channel1 configuration */
- timer_channel_output_state_config(TIMER0,TIMER_CH_1,TIMER_CCX_DISABLE);
- timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_1,TIMER_CCXN_DISABLE);
- /* channel2 configuration */
- timer_channel_output_mode_config(TIMER0,TIMER_CH_2,TIMER_OC_MODE_PWM0);
- timer_channel_output_state_config(TIMER0,TIMER_CH_2,TIMER_CCX_DISABLE);
- timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_2,TIMER_CCXN_ENABLE);
- step++;
- break;
- /* next step: step 3 configuration .B-C` breakover---------------------------- */
- case 2:
- /* channel0 configuration */
- timer_channel_output_state_config(TIMER0,TIMER_CH_0,TIMER_CCX_DISABLE);
- timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_0,TIMER_CCXN_DISABLE);
- /* channel1 configuration */
- timer_channel_output_mode_config(TIMER0,TIMER_CH_1,TIMER_OC_MODE_PWM0);
- timer_channel_output_state_config(TIMER0,TIMER_CH_1,TIMER_CCX_ENABLE);
- timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_1,TIMER_CCXN_DISABLE);
- /* channel2 configuration */
- timer_channel_output_mode_config(TIMER0,TIMER_CH_2,TIMER_OC_MODE_PWM0);
- timer_channel_output_state_config(TIMER0,TIMER_CH_2,TIMER_CCX_DISABLE);
- timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_2,TIMER_CCXN_ENABLE);
- step++;
- break;
- /* next step: step 4 configuration .B-A` breakover---------------------------- */
- case 3:
- /* channel0 configuration */
- timer_channel_output_mode_config(TIMER0,TIMER_CH_0,TIMER_OC_MODE_PWM0);
- timer_channel_output_state_config(TIMER0,TIMER_CH_0,TIMER_CCX_DISABLE);
- timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_0,TIMER_CCXN_ENABLE);
- /* channel1 configuration */
- timer_channel_output_mode_config(TIMER0,TIMER_CH_1,TIMER_OC_MODE_PWM0);
- timer_channel_output_state_config(TIMER0,TIMER_CH_1,TIMER_CCX_ENABLE);
- timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_1,TIMER_CCXN_DISABLE);
- /* channel2 configuration */
- timer_channel_output_state_config(TIMER0,TIMER_CH_2,TIMER_CCX_DISABLE);
- timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_2,TIMER_CCXN_DISABLE);
- step++;
- break;
- /* next step: step 5 configuration .C-A` breakover---------------------------- */
- case 4:
- /* channel0 configuration */
- timer_channel_output_mode_config(TIMER0,TIMER_CH_0,TIMER_OC_MODE_PWM0);
- timer_channel_output_state_config(TIMER0,TIMER_CH_0,TIMER_CCX_DISABLE);
- timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_0,TIMER_CCXN_ENABLE);
- /* channel1 configuration */
- timer_channel_output_state_config(TIMER0,TIMER_CH_1,TIMER_CCX_DISABLE);
- timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_1,TIMER_CCXN_DISABLE);
- /* channel2 configuration */
- timer_channel_output_mode_config(TIMER0,TIMER_CH_2,TIMER_OC_MODE_PWM0);
- timer_channel_output_state_config(TIMER0,TIMER_CH_2,TIMER_CCX_ENABLE);
- timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_2,TIMER_CCXN_DISABLE);
- step++;
- break;
- /* next step: step 6 configuration .C-B` breakover---------------------------- */
- case 5:
- /* channel0 configuration */
- timer_channel_output_state_config(TIMER0,TIMER_CH_0,TIMER_CCX_DISABLE);
- timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_0,TIMER_CCXN_DISABLE);
- /* channel1 configuration */
- timer_channel_output_mode_config(TIMER0,TIMER_CH_1,TIMER_OC_MODE_PWM0);
- timer_channel_output_state_config(TIMER0,TIMER_CH_1,TIMER_CCX_DISABLE);
- timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_1,TIMER_CCXN_ENABLE);
- /* channel2 configuration */
- timer_channel_output_mode_config(TIMER0,TIMER_CH_2,TIMER_OC_MODE_PWM0);
- timer_channel_output_state_config(TIMER0,TIMER_CH_2,TIMER_CCX_ENABLE);
- timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_2,TIMER_CCXN_DISABLE);
- step++;
- break;
-
- /* next step: step 1 configuration .A-B` breakover---------------------------- */
- case 6:
- /* channel0 configuration */
- timer_channel_output_mode_config(TIMER0,TIMER_CH_0,TIMER_OC_MODE_PWM0);
- timer_channel_output_state_config(TIMER0,TIMER_CH_0,TIMER_CCX_ENABLE);
- timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_0,TIMER_CCXN_DISABLE);
- /* channel1 configuration */
- timer_channel_output_mode_config(TIMER0,TIMER_CH_1,TIMER_OC_MODE_PWM0);
- timer_channel_output_state_config(TIMER0,TIMER_CH_1,TIMER_CCX_DISABLE);
- timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_1,TIMER_CCXN_ENABLE);
- /* channel2 configuration */
- timer_channel_output_state_config(TIMER0,TIMER_CH_2,TIMER_CCX_DISABLE);
- timer_channel_complementary_output_state_config(TIMER0,TIMER_CH_2,TIMER_CCXN_DISABLE);
- step = 1;
- break;
- }
- }
复制代码
三、结果
六步换向波形
|