freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

畢業(yè)論文-基于mcs51單片機步進電機的控制系統(tǒng)設(shè)計與實現(xiàn)-資料下載頁

2025-01-16 18:44本頁面
  

【正文】 Init_Timer0()。//定時器中斷 0 Init_1()。 //外部中斷 1 Init_ST7920()。 //初始化 LCD_PutString(0,1,步進電機控制系統(tǒng) )。 //Y 從 14; X 從 07; LCD_PutString(0,2,當(dāng)前速度 : r/m)。 LCD_PutString(0,3,設(shè)定速度: r/m)。 LCD_PutString(0,4,顯示圈 : q )。 while(1) { sudu_sd()。 //矩陣鍵盤顯 示設(shè)定速度 dianji()。 //控制電機加減速和正反轉(zhuǎn) sudu_jc()。 //檢測實際速度 qs_jc()。 //檢測實際圈數(shù) } } 部分 include include sbit RS = P2^4。 //12864 sbit RW = P2^5。 sbit E = P2^6。 sbit RES = P2^3。 sbit PSB = P2^1。 sbit PAUSE = P3^0。 sbit KEY_ADD=P1^4。 // 按鍵 sbit KEY_DEC = P1^5。 unsigned char Speed=6。 //電機實際轉(zhuǎn)速 unsigned char numm。 //設(shè)定速度 unsigned char dis[2]。 define DataPort P0 //MCU P0 LCM 29 /* 檢測忙 位 */ void Check_Busy() { RS=0。 RW=1。 E=1。 DataPort=0xff。 while((DataPortamp。0x80)==0x80)。//忙則等待 E=0。 } /* 寫命令 */ void Write_Cmd(unsigned char Cmd) { Check_Busy()。 RS=0。 RW=0。 E=1。 DataPort=Cmd。 DelayUs2x(5)。 E=0。 DelayUs2x(5)。 } /* 寫數(shù)據(jù) */ void Write_Data(unsigned char Data) { Check_Busy()。 RS=1。 RW=0。 E=1。 DataPort=Data。 DelayUs2x(5)。 E=0。 DelayUs2x(5)。 } /* 液晶屏初始化 30 */ void Init_ST7920() { DelayMs(40)。 //大于 40MS 的延時程序 PSB=1。 //設(shè)置為 8BIT 并口工作模式 DelayMs(1)。 //延時 RES=0。 //復(fù)位 DelayMs(1)。 //延時 RES=1。 //復(fù)位置高 DelayMs(10)。 Write_Cmd(0x30)。 //選擇基本指令集 DelayUs2x(50)。 //延時大于 100us Write_Cmd(0x30)。 //選擇 8bit 數(shù)據(jù)流 DelayUs2x(20)。 //延時大于 37us Write_Cmd(0x0c)。 //開顯示 (無游標(biāo)、不反白 ) DelayUs2x(50)。 //延時大于 100us Write_Cmd(0x01)。 //清除顯示,并且設(shè)定地址指針為 00H DelayMs(15)。 //延時大于 10ms Write_Cmd(0x06)。 //指定在資料的讀取及寫入時,設(shè)定游標(biāo)的移動方向及指定顯示的移位,光標(biāo)從右向左加 1 位移動 DelayUs2x(50)。 //延時大于 100us } /* 顯示字符串 x:橫坐標(biāo)值,范圍 0~8 y:縱坐標(biāo)值,范圍 1~4 */ void LCD_PutString(unsigned char x,unsigned char y,unsigned char code *s) { switch(y) { case 1: Write_Cmd(0x80+x)。break。 case 2: Write_Cmd(0x90+x)。break。 case 3: Write_Cmd(0x88+x)。break。 case 4: Write_Cmd(0x98+x)。break。 default:break。 } while(*s0) { Write_Data(*s)。 s++。 DelayUs2x(50)。 } } 31 /* 設(shè)定速度顯示位置 //位置顯示與上述一 樣 */ void LCD_POS(unsigned char X,unsigned char Y) { unsigned char pos。 if(Y==1) {Y=0x80。} else if(Y==2) {Y=0x90。} else if(Y==3) {Y=0x88。} else if(Y==4) {Y=0x98。} pos=Y+X。 Write_Cmd(pos)。 //顯示地址 } /* 按鍵掃描子程序,設(shè)置初始 速度 值程序 */ void KEY_SCAN(void) //掃描按鍵設(shè)置初始時鐘信號 { unsigned char shiwei。 unsigned char gewei。 if(!KEY_ADD) //十位自我設(shè)置 { DelayMs(10)。 if(!KEY_ADD) { while(!KEY_ADD)。 if(Speed=2) { Speed=Speed1。 } } } if(!KEY_DEC) //減自我設(shè)置 { DelayMs(10)。 if(!KEY_DEC) { while(!KEY_DEC)。 Speed=Speed+1。 32 } } if(Speed==1) { numm=36。 } if(Speed==2) { numm=22。 } if(Speed==3) { numm=14。 } if(Speed==4) { numm=12。 } if(Speed==5) { numm=10。 } if(Speed==6) { numm=8。 } shiwei=numm/10。 gewei=numm%10。 dis[0] = shiwei+0x30。 dis[1] = gewei+0x30。 } void sudu_sd(void) //顯示設(shè)定速度 { unsigned char j。 KEY_SCAN()。 LCD_POS(5,3)。 for(j=0。j2。j++) { Write_Data(dis[j])。 } } unsigned char speed_num (void) //用于時間判斷 { 33 unsigned char nu。 nu= Speed。 return(nu)。 } include include include include sbit KEY_YUZHI=P1^6。 unsigned int calsp。 //設(shè)置讀時間時間 unsigned int calxx。 //設(shè)置讀時間時間 unsigned int counter=0。 //脈沖數(shù) unsigned int quanshu。 unsigned int qsyz。 //圈數(shù)預(yù)置 12*30 unsigned int qs,qs1。 unsigned int motorspeed。 unsigned char dis3[3]。 unsigned char dis5[3]。 unsigned char dis6[3]。 bit FLAG2=1。 /* 定時器中斷 0和外部中斷 1模塊程序 */ /* 定時器初始化子程序 */ void Init_Timer0(void) { TMOD |= 0x01。 //使用模式 1, 16 位定時器,使用 |符號可以在使用多個定時器時不受影響 //TH0=0x00。 //給定初值 //TL0=0x00。 EA=1。 //總中斷打開 ET0=1。 //定時器中斷打開 TR0=1。 //定時器開關(guān)打開 } /* 外部中斷 0初始化子程序 */ void Init_1(void) { EA=1。 //開啟總中斷 EX1=1。 //開啟外部中斷 1 34 IT1=1。 //設(shè)置成下降沿觸發(fā)方式 } /* 定時器中斷子程序 */ void Timer0_isr(void) interrupt 1 { //unsigned char j。 TH0=(655369217)/256。 TL0=(655369217)%256。 //10000/=9217 得到 10ms 執(zhí)行一次 calsp++。 calxx++。 } /* 外部中斷子程序 */ void INT1_isr() interrupt 2 { counter++。 if(FLAG2==1) { quanshu++。 } if(FLAG2==0) { // if(qsyz3) //{ qsyz。 //} } } /* 脈沖計算 */ void calspeed() { unsigned char GE,SHI,BAI。 //顯示速度 if(calsp=1000) //300*10ms=3s計算一次 { motorspeed=counter/2。 //由此轉(zhuǎn)一圈兩 個高低電平,所以與除以 。抵消/3*60=20 35 counter=0。 //清零脈沖數(shù) calsp=0。 //清零標(biāo)志 } BAI=motorspeed/100。 SHI=(motorspeed%100)/10。 GE=(motorspeed%100)%10。 dis3[0]=BAI+0x30。 dis3[1]=SHI+0x30。 dis3[2]=GE+0x30。 } void sudu_jc(void) //顯示檢測速度 { unsigned char j。 calspeed()。 LCD_POS(5,2)。 for(j=0。j3。j++) { Write_Data(dis3[j])。 }
點擊復(fù)制文檔內(nèi)容
環(huán)評公示相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1