首页 开发技术 硬件开发     /    基于s51单片机的直流电机测速系统

基于s51单片机的直流电机测速系统

上传者: lance15 | 上传时间:2024/3/2 19:19:54 | 文件大小:400KB | 文件类型:rar
基于s51单片机的直流电机测速系统
#include#defineucharunsignedchar#defineuintunsignedint#defineulongunsignedlong#defineLED_DATP0sbitLED_SEG0=P2^7;sbitLED_SEG1=P2^6;sbitLED_SEG2=P2^5;sbitLED_SEG3=P2^4;#defineTIME_CYLC100//12M晶振,定时器10ms中断一次我们1秒计算一次转速//1000ms/10ms=100#definePLUS_PER10//码盘的齿数,这里假定码盘上有10个齿,即传感器检测到10个脉冲,认为1圈#defineK1.65//校准系数unsignedcharcodetable[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};uchardataDisbuf[4];//显示缓冲区uintTcounter=0;//时间计数器bitFlag_Fresh=0;//刷新标志bitFlag_clac=0;//计算转速标志bitFlag_Err=0;//超量程标志voidDisplayFresh();//在数码管上显示一个四位数voidClacSpeed();//计算转速,并把结果放入数码管缓冲区voidinit_timer();//初始化定时器T0\T1voidDelay(uintms);//延时函数voidit_timer0()interrupt1/*interruptaddressis0x000b*/{TF0=0;//定时器T0用于数码管的动态刷新TH0=0xC0;TL0=0x00;Flag_Fresh=1;Tcounter++;if(Tcounter>TIME_CYLC){Flag_clac=1;//周期到,该重新计算转速了}}voidit_timer1()interrupt3/*interruptaddressis0x001b*/{TF1=0;//定时器T1用于单位时间内收到的脉冲数//要速度不是很快,T1永远不会益处Flag_Err=1;//如果速度很高,我们应考虑另外一种测速方法:T测速法}voidmain(void){Disbuf[0]=0;//开机时,初始化为0000Disbuf[1]=0;Disbuf[2]=0;Disbuf[3]=0;init_timer();while(1){if(Flag_Fresh){Flag_Fresh=0;DisplayFresh();//定时刷新数码管显示}if(Flag_clac){Flag_clac=0;ClacSpeed();//计算转速,并把结果放入数码管缓冲区Tcounter=0;//周期定时清零TH1=TL1=0x00;//脉冲计数清零}if(Flag_Err)//超量程处理{Disbuf[0]=0x9e;//开机时,初始化为0000Disbuf[1]=0x9e;Disbuf[2]=0x9e;Disbuf[3]=0x9e;while(1){DisplayFresh();//不再测速等待复位i}}}}//在数码管上显示一个四位数voidDisplayFresh(){P2|=0xF0;LED_SEG0=0;LED_DAT=table[Disbuf[0]];Delay(1);P2|=0xF0;LED_SEG1=0;LED_DAT=table[Disbuf[1]];Delay(1);P2|=0xF0;LED_SEG2=0;LED_DAT=table[Disbuf[2]];Delay(1);P2|=0xF0;LED_SEG3=0;LED_DAT=table[Disbuf[3]];Delay(1);P2|=0xF0;}//计算转速,并

文件下载

资源详情

[{"title":"(52个子文件400KB)基于s51单片机的直流电机测速系统","children":[{"title":"测速","children":[{"title":"LastLoaded电动机测速.DBK <span style='color:#111;'>115.15KB</span>","children":null,"spread":false},{"title":"123.Uv2 <span style='color:#111;'>1.61KB</span>","children":null,"spread":false},{"title":"123_Uv2.Bak <span style='color:#111;'>0B</span>","children":null,"spread":false},{"title":"123.lnp <span style='color:#111;'>38B</span>","children":null,"spread":false},{"title":"1.ddb <span style='color:#111;'>194.00KB</span>","children":null,"spread":false},{"title":"BackupofPCBPrint1.PPC <span style='color:#111;'>1.01KB</span>","children":null,"spread":false},{"title":"测速.plg <span style='color:#111;'>916B</span>","children":null,"spread":false},{"title":"123.LST <span style='color:#111;'>11.00KB</span>","children":null,"spread":false},{"title":"CLIENT~1.Bkp <span style='color:#111;'>674.00KB</span>","children":null,"spread":false},{"title":"123 <span style='color:#111;'>1.46KB</span>","children":null,"spread":false},{"title":"Backupof直流电机测速原理图.Sch <span style='color:#111;'>9.62KB</span>","children":null,"spread":false},{"title":"123.ASM <span style='color:#111;'>4.05KB</span>","children":null,"spread":false},{"title":"PreviousBackupof显示部分.PCB <span style='color:#111;'>77.40KB</span>","children":null,"spread":false},{"title":"123.OBJ <span style='color:#111;'>1.42KB</span>","children":null,"spread":false},{"title":"MyDesign.Bkp <span style='color:#111;'>192.00KB</span>","children":null,"spread":false},{"title":"1.Bkp <span style='color:#111;'>192.00KB</span>","children":null,"spread":false},{"title":"BackupofPCB1.PCB <span style='color:#111;'>82.79KB</span>","children":null,"spread":false},{"title":"电动机测速.DSN <span style='color:#111;'>115.15KB</span>","children":null,"spread":false},{"title":"BackupOf电动机测速.DBK <span style='color:#111;'>111.69KB</span>","children":null,"spread":false},{"title":"PreviousBackupof总图.PCB <span style='color:#111;'>101.36KB</span>","children":null,"spread":false},{"title":"测速_Opt.Bak <span style='color:#111;'>859B</span>","children":null,"spread":false},{"title":"CLIENT~1.DDB <span style='color:#111;'>438.00KB</span>","children":null,"spread":false},{"title":"测速.hex <span style='color:#111;'>2.82KB</span>","children":null,"spread":false},{"title":"123.hex <span style='color:#111;'>807B</span>","children":null,"spread":false},{"title":"测速.Uv2 <span style='color:#111;'>1.61KB</span>","children":null,"spread":false},{"title":"Backupof显示部分.PCB <span style='color:#111;'>77.40KB</span>","children":null,"spread":false},{"title":"Backupof总图.PCB <span style='color:#111;'>101.36KB</span>","children":null,"spread":false},{"title":"PreviousBackupof测量部分.Sch <span style='color:#111;'>6.86KB</span>","children":null,"spread":false},{"title":"PreviousBackupofPCB1.PCB <span style='color:#111;'>82.79KB</span>","children":null,"spread":false},{"title":"123.Opt <span style='color:#111;'>958B</span>","children":null,"spread":false},{"title":"Backupof测量部分.Sch <span style='color:#111;'>6.86KB</span>","children":null,"spread":false},{"title":"123_Opt.Bak <span style='color:#111;'>959B</span>","children":null,"spread":false},{"title":"PreviousBackupof测量部分.PCB <span style='color:#111;'>53.04KB</span>","children":null,"spread":false},{"title":"PreviousBackupof直流电机测速原理图.Sch <span style='color:#111;'>9.62KB</span>","children":null,"spread":false},{"title":"测速.Opt <span style='color:#111;'>859B</span>","children":null,"spread":false},{"title":"Text1.OBJ <span style='color:#111;'>3.65KB</span>","children":null,"spread":false},{"title":"123.C <span style='color:#111;'>4.18KB</span>","children":null,"spread":false},{"title":"BackupofCLIENT~1.RCS <span style='color:#111;'>242.68KB</span>","children":null,"spread":false},{"title":"PreviousBackupofSheet1.Sch <span style='color:#111;'>6.79KB</span>","children":null,"spread":false},{"title":"BackupofSheet1.Sch <span style='color:#111;'>936B</span>","children":null,"spread":false},{"title":"Text1.c <span style='color:#111;'>3.17KB</span>","children":null,"spread":false},{"title":"MyDesign.ddb <span style='color:#111;'>192.00KB</span>","children":null,"spread":false},{"title":"电动机测速.PWI <span style='color:#111;'>792B</span>","children":null,"spread":false},{"title":"Text1.LST <span style='color:#111;'>6.04KB</span>","children":null,"spread":false},{"title":"Backupof测量部分.PCB <span style='color:#111;'>53.04KB</span>","children":null,"spread":false},{"title":"测速.M51 <span style='color:#111;'>11.93KB</span>","children":null,"spread":false},{"title":"测速 <span style='color:#111;'>3.42KB</span>","children":null,"spread":false},{"title":"电机测速.Bkp <span style='color:#111;'>1.14MB</span>","children":null,"spread":false},{"title":"测速.lnp <span style='color:#111;'>41B</span>","children":null,"spread":false},{"title":"电机测速.ddb <span style='color:#111;'>454.00KB</span>","children":null,"spread":false},{"title":"123.plg <span style='color:#111;'>2.10KB</span>","children":null,"spread":false},{"title":"123.M51 <span style='color:#111;'>7.31KB</span>","children":null,"spread":false}],"spread":false}],"spread":true}]

评论信息

  • jackkiddd:
    有代码适合初学者参考2015-08-16
  • Owen_Gun:
    很好,很实用,要是附普通原理图就更好了,不是每个人都会用protel99的2015-08-08
  • 巍巍秦岭:
    东西非常不错,对我毕设有很大帮助,谢谢2015-07-14
  • liukunox:
    可以运行,代码注释也比较完整2014-04-26
  • yeswin888:
    如果带上注释会比较好~2013-08-28

免责申明

【好快吧下载】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【好快吧下载】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【好快吧下载】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,8686821#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明