测频率膜厚仪程序.doc
《测频率膜厚仪程序.doc》由会员分享,可在线阅读,更多相关《测频率膜厚仪程序.doc(15页珍藏版)》请在三一办公上搜索。
1、 #include #include#define uint unsigned int #define uchar unsigned char signed long count=0; signed long houd,fq;signed long k1,k2,k3;int i=0, x=0;sbit P2_4=P24; sbit RS=P25; sbit RW=P26; sbit E=P27; /数字ASCII码放在数组中 /unsigned int shu=0x30,0x31,0x32,0x33,0x34,0X35,0x36,0x37,0x38,0x39; unsigned int shu
2、1=0x30,0x31,0x32,0x33,0x34,0X35,0x36,0x37,0x38,0x39; void delay(int count) /延时 int p; while(count-) for(p=0;p110;p+); void write_com(unsigned int n) /写指令 RS=0; P1=n; delay(5); E=1; delay(5); E=0; void write_data(unsigned char t) /写数据 RS=1; P1=t; delay(5); E=1; delay(5); E=0; void time1_int(void) int
3、errupt 3 TH1=TL1=0; TR1=1; x+; void time0_int(void) interrupt 1 TH0=(65535-50000)/256; /装初值,定时50ms TL0=(65535-50000)%256; i+; if(i=20) /1s时间已到 i=0; TR1=0; /关闭计数器1 count=(65536*x+256*TH1+TL1)*1000; x=0; if(k1=1)fq=2.65; else if(k2=1)fq=2.7; else if(k3=1) fq=3.97; houd=0.123*(6000000-count)/fq; TH1=TL
4、1=0; /重新装初值 TR1=1; /重新启动计数器器 void show() write_com(0x85);write_data(shucount/100000); delay(5); /显示十万位 write_com(0x86);write_data(shu(count/10000)%10);delay(5); /显示万位 write_com(0x87);write_data(shu(count/1000)%10);delay(5); /显示千位 write_com(0x88); write_data(shu(count/100)%10);delay(5); /显示百位 write_c
5、om(0x89);write_data(shu(count/10)%10);delay(5); /显示十位 write_com(0x8a);write_data(shucount%10);delay(5); /显示个位 write_com(0x83);write_data(0x66);delay(5); /显示频率表示的字符f write_com(0x84);write_data(0x3d);delay(5); /显示字符= write_com(0x8b);write_data(0x48);delay(5); /显示字母H write_com(0x8c);write_data(0x7a);de
6、lay(5); /显示字母z write_com(0xc5);write_data(shu1houd/100000); delay(5); /显示十万位 write_com(0xc6);write_data(shu1(houd/10000)%10);delay(5); /显示万位 write_com(0xc7);write_data(shu1(houd/1000)%10);delay(5); /显示千位 write_com(0xc8); write_data(shu1(houd/100)%10);delay(5); /显示百位 write_com(0xc9);write_data(shu1(h
7、oud/10)%10);delay(5); /显示十位 write_com(0xca);write_data(shu1houd%10);delay(5); /显示个位 write_com(0xc3);write_data(0x68);delay(5); /显示频率表示的字符hwrite_com(0xc4);write_data(0x3d);delay(5); /显示字符= write_com(0xcb);write_data(0x6e);delay(5); /显示字母n write_com(0xcc);write_data(0x6d);delay(5); /显示字母m void main()
8、TMOD=0x51; /T1计数、T2定时,且都工作在方式1 TH1=0x00;TL1=0x00; TH0=(65535-50000)/256; /装初值,定时50ms TL0=(65535-50000)%256; EA=1; /开总中断 ET0=1;ET1=1; /中断允许 TR0=1;TR1=1; /启动定时器 RW=0; E=0; write_com(0x01); /显示清零,数据指针清零 write_com(0x38); /设置16X2显示5X7点阵,8位数据口 write_com(0x0c); /设置开显示,显示光标且闪烁 write_com(0x06); /写一个字符后地址指针加1
9、 while(1) show(); delay(5); #include #define uchar unsigned charsbit rs=P25;sbit rw=P26;sbit e=P27;uchar busyc,line;uchar code table116= freq= 6000.0 KHz;uchar code table216= houd= 0000.0 nm ;void delay(uchar n) uchar x,y; for(x=n;x0;x-) for(y=110;y0;y-);void busy(uchar busyc)rs=0;rw=1;e=1;delay(1);
10、busyc=P1;e=0;void write_command(uchar command)while(busyc);/判断LCD是否忙碌rs=0;rw=0;e=1;P1=command;delay(10);e=0;void write_date(uchar date)while(busyc);/判断LCD是否忙碌rs=1;rw=0;e=1;P1=date;delay(10);e=0;void init()e=0;write_command(0x38);delay(15);write_command(0x0c);write_command(0x06);write_command(0x01);v
11、oid display()uchar i;write_command(0x80);/设置显示位置(第一行开头)for(i=0;i16;i+)write_date(table1i);/显示字符write_command(0xc0);/ 设置显示位置(第二行开头)for(i=0;i16;i+)write_date(table2i);/ 显示字符void main(void)init(); / 初始化LCDdelay(20);while(1)display();#include#include#define uchar unsigned char#define uint unsigned intsb
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 频率 膜厚仪 程序
链接地址:https://www.31ppt.com/p-3275087.html