智能电表主控程序源代码.

上传人:我** 文档编号:115372017 上传时间:2019-11-13 格式:DOC 页数:44 大小:367KB
返回 下载 相关 举报
智能电表主控程序源代码._第1页
第1页 / 共44页
智能电表主控程序源代码._第2页
第2页 / 共44页
智能电表主控程序源代码._第3页
第3页 / 共44页
智能电表主控程序源代码._第4页
第4页 / 共44页
智能电表主控程序源代码._第5页
第5页 / 共44页
点击查看更多>>
资源描述

《智能电表主控程序源代码.》由会员分享,可在线阅读,更多相关《智能电表主控程序源代码.(44页珍藏版)》请在金锄头文库上搜索。

1、/*2 程序名称:智能电表主控程序3 程序设计:freevanx、LDZ4 时间:20069295 功能: 1、计算电量、电费6 2、接受键盘输入,将所要求的信息显示在LCD上7 3、通过键盘设置内部计费参照,适应不同种类的器材,不同的8 地区,不同的电价,不同的计费时段。910 备注:版权所有,此程序仅可参考,未经授权,不得复制,分发。1112 编译方法:将main.c13 characterlib.h14 C51FPS.LIB15 STARTUP.A51(不是必需文件)16 添加到同一Group,然后1718 1、在工程文件列表中的main.c文件上右击鼠标19 2、选择Options f

2、or file “main.c”,打开一个对话框,20 3、在Properties选项卡的右边激活 Generate Assembler SRC file 复选框21 4、在同一位置激活 Assemble SRC file. 复选框2223 */2425 /*26 REG51.h 包含各种寄存器的定义27 math.h 使用了其中的ceil()和pow()函数28 string.h 使用了其中的memset()函数29 characterlib.h 自定义头文件,包含所有的字库30 定义了uchar,因为头文件中要用到31 */32 #include 33 #include 34 #inclu

3、de 35 /#include characterlib.h3637 /*38 8255的各种命令字,通过控制8255的PC口控制LCD芯片的各种显示39 方式40 */41 #define TYPE_COMMAND 0x0e42 #define TYPE_DATA 0x0f43 #define RESET 0x094445 /*46 LCD芯片的命令字47 */48 #define CS1_LOW 0x0c49 #define CS1_HIGH 0x0d50 #define CS2_LOW 0x0651 #define CS2_HIGH 0x075253 #define SOFT_RESET

4、 0xe25455 #define DISPLAY_ON 0xaf56 #define PAGE_BASIC 0xb857 #define COLUMN0 0x00585960 typedef unsigned char uchar;6162 /*63 各种初值定义,作为计算的基本单位64 */65 struct initset66 67 float high_fee;68 float low_fee;69 unsigned char highrange_start;70 unsigned char highrange_end;71 unsigned char lowrange_start;7

5、2 unsigned char lowrange_end;73 int rotate_speed;74 ;75 /*76 电量计定义,记录电量使用情况77 */78 struct coulometer79 80 int high;81 int low;82 int total;83 ;84 /*85 电费计定义,记录用电电费86 */87 struct fee88 89 float high;90 float low;91 float total;92 ;9394 /*95 各个外部存储器或者端口地址的绝对定位定义96 */97 volatile unsigned char xdata RAM

6、6264 _at_ 0x1FF0;9899 volatile unsigned char xdata CommandPortOf8279 _at_ 0x5FFF;100 volatile unsigned char xdata DataOf8279 _at_ 0x5EFF;101102 volatile unsigned char xdata CommandPortOf8255 _at_ 0xBFFF;103 volatile unsigned char xdata APortOf8255 _at_ 0xBFFC;104 volatile unsigned char xdata CPortOf

7、8255 _at_ 0xBFFE;105106 /*107 设置LCD芯片各页的命令字108 */109 uchar idata page4=0xb8,0xb9,0xba,0xbb;110111 /*112 键盘程序中使用到全局变量113 */114 uchar idata WhichFunctionKey=0x00;115116 /*117 整个程序中共享的全局变量,智能电表的基本数据118 */119 struct initset idata Set=0.8 ,0.6, 6, 21, 22, 5 ,1000;120 struct coulometer idata Coulo=0,0,0;1

8、21 struct fee idata Fee=0.0,0.0,0.0;122123 /*124 各个提示信息的下半行,显示实际的数据,由于要改动,所以125 不能放在code段126 */127 uchar xdata HighCoulometerTextBottom832=0;128 uchar xdata LowCoulometerTextBottom832=0;129 uchar xdata AllCoulometerTextBottom832=0;130 uchar xdata HighFeeTextBottom832=0;131 uchar xdata LowFeeTextBott

9、om832=0;132 uchar xdata AllFeeTextBottom832=0;133 uchar xdata HighFeeSetTextBottom832=0;134 uchar xdata LowFeeSetTextBottom832=0;135 uchar xdata RotateSpeedSetTextBottom832=0;136 uchar xdata HighStartSetTextBottom832=0;137 uchar xdata HighEndSetTextBottom832=0;138139 /*140 字库,如果放在头文件中,低版本的Keil编译时会报错

10、,所以拿过来了141 */142 uchar code HighCoulometerTextTop832=/*高峰用电量 */143 144 /高145 0x04,0x04,0x04,0x0F4,0x94,0x94,0x95,0x96,146 0x94,0x94,0x94,0x0F4,0x04,0x06,0x04,0x00,147 0x00,0x0FE,0x02,0x02,0x7A,0x4A,0x4A,0x4A,148 0x4A,0x4A,0x7A,0x02,0x82,0x0FF,0x02,0x00149 ,150 /峰151 0x00,0x0F0,0x00,0x0FF,0x00,0x0F0,0x90,0x88,152 0x4F,0x54,0x0A4,0x54,0x4C,0x0C4,0x40,0x00,153 0x00,0x1F,0x10,0x0F,0x08,0x1F,0x00,0x14,154 0x15,0x15,0x0FF,0x15,0x15,0x14,0x00,0x00155 ,156

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 高等教育 > 大学课件

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号