欢迎来到三一办公! | 帮助中心 三一办公31ppt.com(应用文档模板下载平台)
三一办公
全部分类
  • 办公文档>
  • PPT模板>
  • 建筑/施工/环境>
  • 毕业设计>
  • 工程图纸>
  • 教育教学>
  • 素材源码>
  • 生活休闲>
  • 临时分类>
  • ImageVerifierCode 换一换
    首页 三一办公 > 资源分类 > DOC文档下载  

    测频率膜厚仪程序.doc

    • 资源ID:3275087       资源大小:37KB        全文页数:15页
    • 资源格式: DOC        下载积分:8金币
    快捷下载 游客一键下载
    会员登录下载
    三方登录下载: 微信开放平台登录 QQ登录  
    下载资源需要8金币
    邮箱/手机:
    温馨提示:
    用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP免费专享
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    测频率膜厚仪程序.doc

    #include<reg51.h> #include<math.h>#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 shu1=0x30,0x31,0x32,0x33,0x34,0X35,0x36,0x37,0x38,0x39; void delay(int count) /延时 int p; while(count-) for(p=0;p<110;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) interrupt 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=TL1=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_com(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);delay(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(houd/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() 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 while(1) show(); delay(5); #include <reg51.h>#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;x>0;x-) for(y=110;y>0;y-);void busy(uchar busyc)rs=0;rw=1;e=1;delay(1);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);void display()uchar i;write_command(0x80);/设置显示位置(第一行开头)for(i=0;i<16;i+)write_date(table1i);/显示字符write_command(0xc0);/ 设置显示位置(第二行开头)for(i=0;i<16;i+)write_date(table2i);/ 显示字符void main(void)init(); / 初始化LCDdelay(20);while(1)display();#include<reg51.h>#include<intrins.h>#define uchar unsigned char#define uint unsigned intsbit RS=P25;sbit RW=P26;sbit EN=P27;uchar str="f=6000.0khz,h=0000.0nm"/延时void DelayMS(uint ms)uchar i;while(ms-) for(i=0;i<120;i+);/忙检查uchar Busy_Check()uchar LCD_Status;RS=0;/寄存器选择RW=1;/读状态寄存器EN=1;/开始读DelayMS(1);LCD_Status=P1;EN=0;return LCD_Status;/写LCD命令void Write_LCD_Command(uchar cmd)while(Busy_Check()&0x80)=0x80);/忙等待RS=0;/选择命令寄存器RW=0;/写EN=0;P1=cmd;EN=1;DelayMS(1);EN=0;/发送数据void Write_LCD_Data(uchar dat)while(Busy_Check()&0x80)=0x80);/忙等待RS=1;RW=0;EN=0;P1=dat;EN=1;DelayMS(1);EN=0;/LCD初始化void Initialize_LCD()Write_LCD_Command(0x38);DelayMS(1);Write_LCD_Command(0x01);DelayMS(1);/清屏Write_LCD_Command(0x06);DelayMS(1);/字符进入模式:屏幕不动,字符后移Write_LCD_Command(0x0c);DelayMS(1);/显示开,光标关/显示字符串void ShowString(uchar x,uchar y,uchar *str)uchar i=0;if(y=0) Write_LCD_Command(0x80|x);/设置显示起始位置if(y=1) Write_LCD_Command(0xc0|x);for(i=0;i<16;i+)/输出字符串Write_LCD_Data(stri);void main()Initialize_LCD();while(1)ShowString(0,0,str);ShowString(0,1,str);#include<reg51.h> #include<intrins.h>#define uint unsigned int #define uchar unsigned char sbit Lcd_rs=P25; sbit Lcd_rw=P26; sbit Lcd_en=P27; uchar code disa = " 6000.0 KHzz "uchar code disb =" 0000.0nm " ;void delaynop( )_nop_( );_nop_( );_nop_( );_nop_( );_nop_( );void delay (uint ms)uchar t;while(ms-) for(t=0; t<120;t+);bit lcd_busy( )bit result;Lcd_rs=0;Lcd_rw=1;Lcd_en=1;delaynop( );result=(bit)(P0&0x80);Lcd_en=0;return(result);void lcd_write(bit start,uchar in_data)while(lcd_busy();if(start=0)Lcd_rs=0;elseLcd_rs=1;Lcd_rw=0;Lcd_en=0;delaynop( );P0=in_data;Lcd_en=1;delaynop( );Lcd_en=0;delaynop( );void lcd_init( )delay(15);lcd_write(0,0x28);delay(5);lcd_write(0,0x28);delay(5);lcd_write(0,0x28);delay(5);lcd_write(0,0x0c);delay(5);lcd_write(0,0x06);delay(5);lcd_write(0,0x01);delay(25);void lcd_pos(uchar pos)lcd_write(0,pos|0x80);void main( )uchar m;lcd_init( );lcd_pos(0x00);for(m=0;m<16;m+)lcd_write(1,disam);delay(150);lcd_pos(0x40);for(m=0;m<16;m+)lcd_write(1,disbm);delay(150);while(1);#include <reg51.h>#define uchar unsigned charsbit rs=P25;sbit rw=P26;sbit e=P27;uchar busyc,line;uchar code table116=" 6000 KHzz "uchar code table216=" 0000nm "void delay(uchar n) uchar x,y; for(x=n;x>0;x-) for(y=110;y>0;y-);void busy(uchar busyc)rs=0;rw=1;e=1;delay(1);busyc=P0;e=0;void write_command(uchar command)while(busyc);/判断LCD是否忙碌rs=0;rw=0;e=1;P0=command;delay(10);e=0;void write_date(uchar date)while(busyc);/判断LCD是否忙碌rs=1;rw=0;e=1;P0=date;delay(10);e=0;void init()e=0;write_command(0x38);delay(15);write_command(0x0c);write_command(0x06);write_command(0x01);void display()uchar i;write_command(0x80);/设置显示位置(第一行开头)for(i=0;i<16;i+)write_date(table1i);/显示字符write_command(0xc0);/ 设置显示位置(第二行开头)for(i=0;i<16;i+)write_date(table2i);/ 显示字符void main(void)init(); / 初始化LCDdelay(20);while(1)display();#include <reg51.h>#define uchar unsigned char#define uint unsigned intsbit RS=P25; /数据、命令选择,1:数据,0:命令sbit RW=P26; /读写控制,1:读,0:写sbit LCD_E=P27;/E端,使能端HLuint i,j;uchar tab1="6000.0KHz" /数组字符串uchar tab2="0000.0nm"uchar num;void delay(uint x)for (i=x;i>0;i-)for(j=120;j>0;j-);void write_cmd(uchar cmd) /命令子程序RS=0;RW=0;LCD_E=0;P0=cmd;LCD_E=1;delay(5);LCD_E=0; void write_data(uchar lcd_data) /写数据子程序RS=1;RW=0;LCD_E=0;P0=lcd_data;LCD_E=1;delay(5);LCD_E=0; void init() /初始化子程序write_cmd(0x38);/显示模式DL18位数据,N1两行显示 F0(5*7点阵)write_cmd(0x08);/关闭显示write_cmd(0x01);/清屏write_cmd(0x06);/读写操作后,AC自动增1write_cmd(0x0f);/开显示,开光标,开闪烁void main()init();for (num=0;num<16;num+)write_data(tab1num);delay(200);write_cmd(0x80+0x40); /换行命令for (num=0;num<13;num+)write_data(tab2num);delay(200);while(1);

    注意事项

    本文(测频率膜厚仪程序.doc)为本站会员(文库蛋蛋多)主动上传,三一办公仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知三一办公(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    备案号:宁ICP备20000045号-2

    经营许可证:宁B2-20210002

    宁公网安备 64010402000987号

    三一办公
    收起
    展开