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

正文內(nèi)容

基于單片機(jī)的扭矩測(cè)量系統(tǒng)設(shè)計(jì)(精華)-資料下載頁

2025-06-20 12:37本頁面
  

【正文】 arr[8] = {0}。float xdata AD_VAL_SUM = 0。unsigned int xdata AD_Result_ago = 0。unsigned int xdata AD_Result_max = 0。unsigned int xdata AD_Result_maoci = 0。unsigned int xdata AD_ZhuanJu = 0。unsigned int xdata AD_ZhuanJu_max = 0。unsigned char xdata table[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}。//// MAIN Routine//sbit LCDRS=P2^6。sbit LCDEN=P2^7。 sbit ADC_CS=P2^6。 //CS 是必須的,但DI和DO可以接在一起,因?yàn)槭莻€(gè)半雙工sbit ADC_CLK=P2^5。 //di和do不同時(shí)傳輸數(shù)據(jù)sbit ADC_DO =P2^4。sbit ADC_DI =P2^3。/*******************************************************************/unsigned int Voltage(bit bi)。uchar code Num[]={0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39}。void Delay(uint z){uint x,y。for(x=0。xz。x++)for(y=0。y100。y++)。 //50在仿真上是可以顯示的,實(shí)物的話//可能得大些,}void Write_1602_Com(uchar )//液晶送指令{LCDRS=0。DATA_1602=。Delay(5)。LCDEN=1。Delay(5)。LCDEN=0。}void Write_1602_Date(uchar date)//液晶送數(shù)據(jù){LCDRS=1。DATA_1602=date。Delay(5)。LCDEN=1。Delay(5)。LCDEN=0。}void Init_Lcd(){// LCDEN=0。Write_1602_Com(0x38)。//定義為液晶狀態(tài)Write_1602_Com(0x0c)。//開顯示,關(guān)光標(biāo)和閃爍Write_1602_Com(0x01)。//清屏Write_1602_Com(0x80)。//數(shù)據(jù)指針歸零Write_1602_Com(0x06)。//光標(biāo)加一,自動(dòng)加一}/*次函數(shù)有用于將數(shù)據(jù)指針移到相應(yīng)的位置x,行, y第幾個(gè)*/ void Write_Pos(uchar x,uchar y){uchar posit。if(x==1)posit=0x80+y1。if(x==2)posit=0xc0+y1。Write_1602_Com(posit)。 } /*此函數(shù)用于顯示0999的數(shù)字,例如13顯示13不是 013,*/void Dis_Num_Zh(uint uhour) {if(uhour=100){Write_1602_Date(Num[uhour/100])。Write_1602_Date(Num[uhour%100/10])。Write_1602_Date(Num[uhour%10] )。}elseif(uhour=10){ Write_1602_Date(0x20)。Write_1602_Date(Num[uhour/10])。Write_1602_Date(Num[uhour%10] )。 }else{ Write_1602_Date(0x20)。 Write_1602_Date(0x20)。Write_1602_Date(Num[uhour%10] )。}Write_1602_Date(39。039。)。} /*此函數(shù)用于顯示,09的數(shù)***********************//*void Dis_num_deci(uchar uhour) {Write_1602_Date(Num[uhour/10])。 } *//*顯示字符串,x第幾行,y第幾個(gè)位置,然后字符竄內(nèi)容, l代表字符串的長(zhǎng)度*/ void Dis_Str(uchar x,uchar y,uchar *p){switch(x){ case 1:y=0x80+y1。break。case 2:y=0xc0+y1。break。}Write_1602_Com(y)。while(*p){Write_1602_Date(*p)。p++。}} /*此函數(shù)用來顯示數(shù)字,在什么位置需在里面修改 ,參數(shù),3個(gè)數(shù)如12,11,10 void Dis_Num(uchar uhour) {// write_date(num[uhour/100])。Write_1602_Date(Num[uhour%100/10])。 Write_1602_Date(Num[uhour%10] )。}void Dis_Jump(uchar x,uchar y,uchara){if(x==1)y=y+0x801。if(x==2)y=y+0xc01。 Write_1602_Com(y)。Write_1602_Date(0x20)。//送個(gè)空使這一位跳Write_1602_Date(0x20)。} */ //x代表第幾行,y第幾個(gè),ge代表空格的個(gè)數(shù)void KGE(uchar x,uchar y,uchar ge){ uchar i。y。if(x==1)y|=0x80。if(x==2)y|=(0x80+0x40)。Write_1602_Com(y)。for(i=0。ige。i++) Write_1602_Date(0x20)。}/*********************************************************************** 使用此函數(shù)時(shí),需要先配置CS,DI,DO,CLK端口,通過調(diào)用函數(shù)Voltage(bi)函數(shù) 來讀取相應(yīng)通道的數(shù)據(jù),其中bi為通道,其值為0,1 ,始化 **********************************************************************//*******************************************************************/ void Delays(unsigned char x){ unsigned char i。 for(i=0。ix。i++)。 //延時(shí),脈沖一位持續(xù)的時(shí)間}/*******************************************************************/unsigned char ReadADC(bit dat) //把模擬電壓值轉(zhuǎn)換成8位二進(jìn)制數(shù)并返回,dat 為通道選擇。 { unsigned char i,ch=0。 ADC_CS=0。 ADC_DO=0。//片選,DO為高阻態(tài) Delays(10)。 ADC_CLK=0。 Delays(2)。 ADC_DI=1。 ADC_CLK=1。 Delays(2)。//第一個(gè)脈沖,起始位 ADC_CLK=0。 Delays(2)。 ADC_DI=1。 ADC_CLK=1。 Delays(2)。//第二個(gè)脈沖, DI=1表示雙通道單極性輸入 ADC_CLK=0。 Delays(2)。 ADC_DI=dat。 /*******************************/ ADC_CLK=1。 Delays(2)。//第三個(gè)脈沖, DI=1表示選擇通道1(CH2 ) ADC_DI=0。 ADC_DO=1。//DI轉(zhuǎn)為高阻態(tài),DO脫離高阻態(tài)為輸出數(shù)據(jù)作準(zhǔn)備 ADC_CLK=1。 Delays(2)。 ADC_CLK=0。 Delays(2)。//經(jīng)實(shí)驗(yàn),這里加一個(gè)脈沖 AD便能正確讀出數(shù)據(jù), //不加的話讀出的數(shù)據(jù)少一位(最低位d0讀不出) for(i=0。i8。i++) { ADC_CLK=1。 Delays(2)。 ADC_CLK=0。 Delays(2)。 ch=(ch1)|ADC_DO。//在每個(gè)脈沖的下降沿 DO輸出一位數(shù)據(jù),最終ch 為8位二進(jìn)制數(shù)} ADC_CS=1。 return(ch)。//把轉(zhuǎn)換結(jié)果返回}/*******************************************************************/unsigned int Get_Voltage(bit bi){uchar vol=0。uint dat。 vol=ReadADC(bi)。 dat=(int)(100*vol)/51。 //51是由5/255的倒數(shù)得來的, 5是5V,255是8位AD。return(dat)。}void main(void){Init_Device()。LiangChengPanDuan()。 while (1) { WDTCN = 0xa5。for(i = 0。i8。i++){ADC()。}ADResult_Out()。if(Count_124us159){if(ZeroTest_Flag == 0x01) {Count_20ms++。if(Count_20ms = 1000) //30s game over,start again{AD_Result = 0。AD_Result_max = 0。AD_Result_ago = 0。Count_20ms = 0。ZeroTest_Flag = 0x00。}}Count_124us = 0。} }}//// Initialization Subroutines//void Init_Device(void){//WDTCN = 0xde。 // disable watchdog timer//WDTCN = 0xad。Reset_Sources_Init()。 SYSCLK_Init()。PORT_Init ()。Timer_Init()。ADC_Init()。UART0_Init()。Interrupts_Init()。}void Reset_Sources_Init(void){ WDTCN = 0x06。}//// PORT_Init//void PORT_Init (void){ PRT1CF = 0xF8。 // is input port //0xFF。 PRT2CF = 0xFF。 PRT3CF = 0x0F。 XBR0 = 0x04。 XBR1 = 0x00。 XBR2 = 0xC0。 }//// SYSCLK_Init//void SYSCLK_Init (void){ OSCXCN = 0x67。 // start external oscillator with for (i=0。 i 256。 i++) 。 // XTLVLD blanking interval (1ms) while (!(OSCXCN amp。 0x80)) 。 // Wait for crystal osc. to settle OSCICN = 0x88。 // select external oscillator as SYSCLK }//// UART0_Init//void UART0_Init (void){ SCON = 0x50。 // SCON: mode 1, 8bit UART, enable RX TMOD = 0x21。 // TMOD: timer 1, mode 2, 8bit reload TH1 = (SYSCLK/BAUDRATE/16)。 //
點(diǎn)擊復(fù)制文檔內(nèi)容
物理相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1