直流电机控制Keil c51 源代码直流电机的开环控制Keil c51源代码//-----------------------函数声明,变量定义-------------------------------------------------------- #include #include #include //-----------------------定义管脚 -------------------------------------------------------- sbit PWM=P1^0; //PWM 波形输出sbit DR=P1^1; //方向控制#define timer_data (256-100) // 定时器预置值 ,12M 时钟是,定时0
1ms #define PWM_T 100 //定义 PWM 的周期 T 为 10ms unsigned char PWM_t; //PWM_t 为脉冲宽度 (0~100) 时间为 0~10ms unsigned char PWM_count; //输出 PWM 周期计数unsigned char time_count; //定时计数bit direction; //方向标志为//-------------------------------------------------------------------------------------------------- // 函数名称: timer_init // 函数功能:初始化设施定时器//-------------------------------------------------------------------------------------------------- void timer_init() { TMOD=0x22; /