欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
51單片機測雙電機轉速程序
[打印本頁]
作者:
x12138
時間:
2023-5-29 13:03
標題:
51單片機測雙電機轉速程序
大佬幫忙看下中斷服務程序和初始化部分有什么問題,在Proteus里仿真的時候LCD屏不顯示數字。
0.png
(35.99 KB, 下載次數: 23)
下載附件
2023-5-29 19:11 上傳
void init() //定時器0初始化
{
EA=1;
EX0=1;//開外部INTO中斷
IT0=1; //INT0負跳變觸發
EX1=1;//開外部INT1中斷
IT1=1; //INT1負跳變觸發
TMOD=0x01;//定時器0工作于方式1
TH0=0x3c; //50ms
TL0=0xb0;
ET0=1;//開定時中斷
TR0=1;//啟動定時
}
void display() //顯示函數
{
Velocity3=Velocity1+Velocity2;
Velocity=Velocity3/2;
Mileage=Mileage+Velocity*500/36;
write_1602com(0x80+2);
if(Velocity/100==0)
write_1602dat(' ');
else
write_1602dat(0x30+Velocity/100);
if((Velocity/100+Velocity%100/10)==0)
write_1602dat(' ');
else
write_1602dat(0x30+Velocity%100/10);
write_1602dat(0x30+Velocity%10);//數字+30得到該數字的LCD1602顯示碼
write_1602com(0x80+14);
if((VH/10)==0)
write_1602dat(' ');
else
write_1602dat(0x30+VH/10);
write_1602dat(0x30+VH%10);//數字+30得到該數字的LCD1602顯示碼
write_1602com(0x80+0x40+8);
write_1602dat(0x30+Mileage/1000000);//數字+30得到該數字的LCD1602顯示碼
write_1602dat(0x30+Mileage%1000000/100000);//數字+30得到該數字的LCD1602顯示碼
write_1602com(0x80+0x40+11);
write_1602dat(0x30+Mileage%100000/10000);//數字+30得到該數字的LCD1602顯示碼
write_1602dat(0x30+Mileage%10000/1000);//數字+30得到該數字的LCD1602顯示碼
write_1602dat(0x30+Mileage%1000/100);//數字+30得到該數字的LCD1602顯示碼
}
void main() //主函數
{
lcd_init();
init;
while(1)
{
anjian();
display();
alarm();
}
}
void EXINT0() interrupt 0 //外部中斷函數
{
count1++; //有信號加
}
void EXINT1() interrupt 2 //外部中斷函數
{
count2++; //有信號加
}
void time0() interrupt 1 //定時器中斷執行函數
{
uchar m;
TH0=0x3c;
TL0=0xb0; //50ms
m++;
if(m%5==0&&flag_alarm==1)
{
BUZZ=!BUZZ;
}
if(m>=10)
{
Velocity1=count1/5;//(速度是將500ms內的脈沖數除以5)(此處的速度值和轉數沒有計算公式,只是為了得到一個隨轉速大小變化的速度值)
Velocity2=count2/5;
m=0;
count1=0;
count2=0;
}
}
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1