新人求助,电机控制问题


#1


电机一直控制不了,想确认两件事:
1.这电机有三根线,分别是 红、黑、黄,是不是分别对应着12v+,12v-,和pwm信号线
2.我的控制代码如下,pwm波用示波器查看是正确的

int main()
{
    led_init();
    delay_init();
	/* pwm初始化,50Hz */
    pwm_init();

	/* 1.5ms */
    TIM_SetCompare1(TIM3, 1500);
    TIM_SetCompare2(TIM3, 1500);
    TIM_SetCompare3(TIM3, 1500);
    TIM_SetCompare4(TIM3, 1500);

    delay_ms(1000);
    delay_ms(1000);

	/* 2ms */
    TIM_SetCompare1(TIM3, 2000);
    TIM_SetCompare2(TIM3, 2000);
    TIM_SetCompare3(TIM3, 2000);
    TIM_SetCompare4(TIM3, 2000);

    delay_ms(1000);

	/* 1.5ms */
    TIM_SetCompare1(TIM3, 1500);
    TIM_SetCompare2(TIM3, 1500);
    TIM_SetCompare3(TIM3, 1500);
    TIM_SetCompare4(TIM3, 1500);

    while (1)
    {
        TIM_SetCompare1(TIM3, 1200);
        TIM_SetCompare2(TIM3, 1200);
        TIM_SetCompare3(TIM3, 1200);
        TIM_SetCompare4(TIM3, 1200);

        delay_ms(1000);
        delay_ms(1000);

        TIM_SetCompare1(TIM3, 1800);
        TIM_SetCompare2(TIM3, 1800);
        TIM_SetCompare3(TIM3, 1800);
        TIM_SetCompare4(TIM3, 1800);
		
		delay_ms(1000);
        delay_ms(1000);
    }
}

#2

红:供电正
黑:供电负
黄:信号

控制端的GND和供电的地是否共地了?
推进器上电后会响3声,电调过初始化是把信号给在1.5ms 延时一段时间后,推进器会再响两声,表示过初始化。过完初始化后,控制信号才能控制推进器的运行。