《pwm控制电机C程序.doc》由会员分享,可在线阅读,更多相关《pwm控制电机C程序.doc(5页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、pwm控制电机C程序基于89C51的pwm#include reg52。hinclude ”intrins。h#define uc unsigned char uc deasil;/顺时针uc widdershins;/逆时针uc start,up; /停止uc key_value,a,Tcount,temp;uc ge,shi,bai,qian,i,samp,now;uc code seg=0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f;int pwm;uc buf10;sbit PWM=P37;sbit text=P36;sbit tex
2、t1=P35;/延时子程序/void delay(unsigned int delay_time) uc i; while(delay_time-) for(i=0;i125;i+) ; /延时8+6delay_time us void display() uc i,temp; temp=0xfe; buf0=now%1000%10010;buf1=now%1000%100/10;buf2=now1000/100;buf3=now/1000;for(i=0;inow) text=0;pwm=pwm+500;if(pwm57500) pwm=57500; if((now3)samp) text1=0;pwm=pwm500;if(pwm0) pwm=0; void init() TMOD=0x11; TR0=1; ET0=1; TH1=0x4c; TL1=0x00; TR1=1; ET1=1; IT0=1; EX0=1; EA=1; PWM=1;void main() init(); while(1) display(); key_scan(); change();