您好,欢迎光临本网站![请登录][注册会员]  
文件名称: 开关磁阻电机的驱动程序
  所属分类: C
  开发工具:
  文件大小: 547byte
  下载次数: 0
  上传时间: 2013-04-06
  提 供 者: fanqi******
 详细说明: 对SRM电机的驱动程序 #include "DSP281x_Device.h" // DSP281x Headerfile Include File #include "DSP281x_Examples.h" // DSP281x Examples Include File #include "IQmathLib.h" #include "UserVariable.h" #include "math.h" int rpmreal=0,te=0,te1=0; long key=0,key2=0,key3=0,key4=0,key11=0; int speed_flag=0,loci_flag=0,speed_flag1=0; _iq a=0;//转速标志 unsigned int Sci_VarRx[100]; unsigned int i=0,j=0; unsigned long a1=40000; int tem1=0,temp,k2,k3,start=0; void calrpm1(){ if(Rpm<300) rpmreal=0; else rpmreal=Rpm; } void main2() { // LCD_GotoXY(2, 80); // Sendchar(" "); LCD_GotoXY(4, 80); Sendchar("1."); LCD_GotoXY(4, 96); Sendchar("2."); LCD_GotoXY(4, 112); Sendchar("3."); LCD_GotoXY(10, 16); SendStr("第十二届挑战杯作品"); LCD_GotoXY(7, 48);//16为一行,0为列,112为最大行代码 SendStr("高速磁悬浮开关磁阻电机系统"); WriteReg(0xF1, 0x0F); LCD_GotoXY(6, 80);//16为一行,0为列,112为最大行代码//共八行 SendStr("作品简介"); LCD_GotoXY(6, 96);//16为一行,0为列,112为最大行代码 SendStr("运行状态显示"); LCD_GotoXY(6, 112);//16为一行,0为列,112为最大行代码 SendStr("轴心轨迹显示"); LCD_GotoXY(6, 144);//16为一行,0为列,112为最大行代码 SendStr("南京航空航天大学高速实验室"); LCD_GotoXY(13, 160);//16为一行,0为列,112为最大行代码 Sendchar("2011/10/20"); } void main1() { LCD_GotoXY(10, 16); SendStr("第十二届挑战杯作品"); LCD_GotoXY(7, 48);//16为一行,0为列,112为最大行代码 SendStr("高速磁悬浮开关磁阻电机系统"); LCD_GotoXY(1, 80);//16为一行,0为列,112为最大行代码 SendStr("电压: 伏"); LCD_GotoXY(1, 96);//16为一行,0为列,112为最大行代码//共八行 SendStr("设定的转速: 转 分"); LCD_GotoXY(1, 112);//16为一行,0为列,112为最大行代码 SendStr("实际的转速: 转 分"); LCD_GotoXY(5, 144);//16为一行,0为列,112为最大行代码 SendStr("南京航空航天大学高速电机实验室"); LCD_GotoXY(26, 96); Sendchar("/"); LCD_GotoXY(26, 112); Sendchar("/"); disint(8,80,(unsigned long)200,0); // disint(15,96,(unsigned long)52700,0);//功能转换很重要! disint(15,112,(unsigned long)Rpm11,1);//功能转换很重要! } void main3() { WriteReg(0x10,0x68); while(loci_flag==1) { key=keyscan(); if(key=='*') { LcdClear(); LCD_ON(); main2(); loci_flag=0; } else if(key==16) { GUI_Point(x_trace[k1],y_trace[k1],1); a6=0;//zhouxin loci sample flag delay_ms(100); if(k1==200) { // LcdClear(); ClearBig(0,0);//clear 32/160 delay_ms(100); k1=0; } } } } void main4() { /* if((k1<100)&&(a5==0)) { // GUI_Point(x_trace[k1],y_trace[k1],1); a6=0;//zhouxin loci sample flag } else { */ // a5=1; k3=k1-1; if(k3<0) k3=k1+49; GUI_Point(x_trace[k3],y_trace[k3],1); if(k3<25) { k2=k3+25; } else if((k3>25)||(k3==25)) { k2=k3-25; } a5=0; delayms(100); GUI_Point(x_trace[k2],y_trace[k2],0); a6=0;//zhouxin loci sample flag // k1++; // } } void main5() { // WriteReg(0x00, 0xC5); GUI_Point(x_trace[k1],y_trace[k1],1); delay_ms(100); if(k1<100) { k2=k1+100; } else if((k1>100)||(k1==100)) { k2=k1-100; } // WriteReg(0x00, 0xC5); GUI_Point(x_trace[k2],y_trace[k2],1); a6=0;//zhouxin loci sample flag // delay_ms(100); k1++; if(k1==200) k1=0; } void menu1() { key=keyscan(); // delayms(1); // key11=keyscan(); if(key!=16) { if(key=='A') { LcdClear(); main2(); speed_flag=0; loci_flag=0; } else if(key=='D') {start=1;speed_flag=1;LCD_ON();main1();} else if(key!='B') key2=key2*10+key; else { key3=key2; key2=0; switch(key3) { case 1:LcdClear();LCD_ON();main1();speed_flag1=1;break; case 2:LcdClear();speed_flag=1;LCD_ON();main1();speed_flag1=1;break; case 3:LcdClear();loci_flag=1;main3();speed_flag1=1;break; case 4:LcdClear();speed_flag=1;LCD_ON();main1();speed_flag1=1;break; case 5:LcdClear();speed_flag=1;LCD_ON();main1();speed_flag1=1;break; case 6:LcdClear();speed_flag=1;LCD_ON();main1();speed_flag1=1;break; } //disint(9,128,key3,0);//赋值额定转速 } } } void menu2() { int i=0; while(speed_flag==1) { delayms(1000); disint(15,112,(unsigned long)Rpm11++,1); key=keyscan(); if(key!=16) { if(key=='A') { LcdClear(); main2(); speed_flag=0; } else if(key!='B') { // disint(15+(i++),96,(unsigned long)key,0); } } } } void main(void) { // voltage=270; InitSysCtrl(); // FILE: DSP281x_SysCtrl.c DINT;//屏蔽全局中断 InitPieCtrl(); // FILE: DSP281x_PieCtrl.c pie默认状态为pie所有的中断都禁止,且标志位清零 IER = 0x0000;//禁止cpu中断并清除所有的cpu中断标志位 IFR = 0x0000; InitPieVectTable(); //piecrtl.enpie已定义 EALLOW; // This is needed to write to EALLOW protected registers PieVectTable.TINT0 = &TINT0_ISR; EDIS; // Define PIE interrupt PieCtrlRegs.PIEIER1.all=0x0043; // PDPINTA(EV-A) interrupt //对应向量表中的各位,使能位p62 PieCtrlRegs.PIEIFR1.all=0x0000; //标志寄存器,中断时自动置位 PieCtrlRegs.PIEIER2.all=0x0008; // T1PINT(EV-A) interrupt PieCtrlRegs.PIEIFR2.all=0x0000; PieCtrlRegs.PIEIER3.all=0x0001; // T2PINT(EV-A) interrupt PieCtrlRegs.PIEIFR3.all=0x0000; PieCtrlRegs.PIEIER4.all=0x0008; // T3PINT(EV-B) interrupt PieCtrlRegs.PIEIFR4.all=0x0000; PieCtrlRegs.PIEIER5.all=0x0070; // CAPINT4,CAPINT5,CAPINT6 interrupt PieCtrlRegs.PIEIFR5.all=0x0000; PieCtrlRegs.PIEIER9.all=0x0003; //sci send and recieve interrupt PieCtrlRegs.PIEIFR9.all=0x0000; IER=0x011F; // level1,level2,level3,level4,level5; //int1,2,3,4,5,9 p57 InitCpuTimers(); ConfigCpuTimer(&CpuTimer0, 150, 100); StartCpuTimer0(); InitEv(); InitTimer(); InitAdc(); // InitSci(); InitGpio(); Init_LCD(); delay_ms(10000); LCD_ON(); delay_ms(100); main2(); //the reg 0x10 never set up before // LcdClear(); // WriteReg(0x00, 0xC5);//photo point!!!!!!!!! //temp = lcd_read(0x00); // ClearBig(0,0); //176,24//320240--30/240(row and line) (+64,+8)(line,row) while(1) { EINT; delayms(200); menu1(); menu2(); // delayms(100); // WriteReg(0x00, 0xC5);// // temp = lcd_read(0x00);//正式程序不能加 // tem1 = lcd_read(0xF0); /* delayms(100); main4(); */ /* if(start==1) { while(ii<200) { selfstart(); } } */ } } ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: srm_spwm
 输入关键字,在本站1000多万海量源码库中尽情搜索: