与ATMega8535和LCD 2X16 DS2760

D

dimas_lilik

Guest
亲爱的大家..
能帮助我吗?
我想与液晶显示2 × 16
请帮助我

/***************************
DS2760接口
****************************/
#包括<stdio.h> / / printf()的,uchar,机组,....
#包括<reg51.h> / / CPU的interals
#包括“1wire.h”/ / 1 - Wire器件lib

/************************
港宣言
*************************/
/ / DS2760在1wire.c港口声明

/************************************************* ******************
T型(铜/康铜)(0℃参考热电偶数据)
作者:整理视差
更新时间:2004年1月19日
************************************************** ******************/
const机组Cnv_table [401] =

/ * T000 * / 0,39,78,117,156,195,234,273,312,352,
/ * T010 * / 391,431,470,510,549,589,629,669,709,749,
/ * T020 * / 790,830,870,911,951,992,1032,1074,1114,1155,
/ * T030 * / 1196,1238,1279,1320,1362,1403,1445,1486,1528,1570,
/ * T040 * / 1612,1654,1696,1738,1780,1822,1865,1908,1950,1993,
/ * T050 * / 2036,2079,2121,2165,2208,2250,2294,2338,2381,2425,
/ * T060 * / 2468,2512,2556,2600,2643,2687,2732,2776,2819,2863,
/ * T070 * / 2909,2952,2998,3043,3087,3132,3177,3222,3266,3312,
/ * T080 * / 3358,3403,3447,3494,3539,3584,3631,3677,3722,3768,
/ * T090 * / 3814,3859,3907,3953,3999,4046,4092,4137,4185,4232,
/ * T100 * / 4278,4325,4371,4419,4466,4512,4561,4608,4655,4701,
/ * T110 * / 4750,4798,4844,4892,4940,4988,5036,5084,5131,5179,
/ * T120磁带* / 5227,5277,5325,5373,5421,5469,5519,5567,5616,5665,
/ * T130 * / 5714,5762,5812,5860,5910,5959,6008,6057,6107,6155,
/ * T140 * / 6206,6254,6304,6355,6403,6453,6504,6554,6604,6653,
/ * T150 * / 6703,6754,6804,6855,6905,6956,7006,7057,7107,7158,
/ * T160 * / 7209,7259,7310,7360,7411,7463,7515,7565,7617,7668,
/ * T170 * / 7719,7770,7823,7874,7926,7977,8028,8080,8133,8185,
/ *版本T180 * / 8237,8288,8340,8393,8445,8496,8550,8602,8653,8707,
/ * T190 * / 8759,8811,8865,8916,8970,9022,9076,9128,9182,9234,
/ * T200 * / 9288,9341,9394,9448,9500,9554,9608,9662,9714,9769,
/ * T210 * / 9822,9875,9929,9984,10038,10092,10146,10200,10253,10307,
/ * T220 * / 10362,10416,10471,10525,10580,10634,10689,10743,10798,10852,
/ * T230 * / 10907,10961,11016,11072,11127,11182,11237,11291,11346,11403,
/ * T240 * / 11458,11512,11569,11624,11679,11734,11791,11846,11902,11958,
/ *模式相符* / 12012,12069,12125,12181,12237,12293,12349,12405,12461,12518,
/ * T260 * / 12573,12630,12686,12743,12798,12855,12912,12968,13025,13082,
/ * T270 * / 13139,13195,13253,13310,13365,13423,13480,13537,13595,13652,
/ * T280 * / 13708,13766,13823,13881,13938,13995,14053,14109,14168,14226,
/ * T290 * / 14282,14341,14399,14455,14514,14572,14630,14688,14746,14804,
/ * T300或* / 14862,14919,14977,15035,15095,15153,15211,15269,15328,15386,
/ * T310 * / 15445,15503,15562,15621,15679,15737,15797,15855,15913,15973,
/ * T320产品* / 16032,16091,16149,16208,16268,16327,16387,16446,16504,16564,
/ * T330 * / 16623,16682,16742,16801,16861,16920,1.698万,17039,17100,17158,
/ * T340 * / 17219,17278,17338,17399,17458,17518,17577,17638,17698,17759,
/ * T350 * / 17818,17879,17939,17998,18059,18120,18179,18240,18301,18362,
/ * T360 * / 18422,18483,18542,18603,18664,18725,18786,18847,18908,18969,
/ * T370 * / 19030,19091,19152,19213,19274,19335,19396,19457,19518,19579,
/ * T380 * / 19641,19702,19763,19824,19885,19946,20009,20070,20132,20193,
/ * T390 * / 20255,20317,20378,20440,20501,20563,20625,20687,20748,20810,
/ * T400 * / 20872
);

/*************************************************
常量和全局变量
************************************************** /
const uchar readnet = 0x33; / /读取单程网络地址
const uchar skipnet = 0xcc; / /跳过单程网络地址
const uchar rdreg = 0x69; / /读取寄存器

/ *近uchar IDX的; / /循环计数器(4位)
近uchar类型; / /设备类型(4位)
近uchar char_; / /显示字节/字
近机组葡萄酒; / /在毫伏* /
近机组tmpCJ; / /在C装置温度
近机组tCuV; / /热电偶毫伏
近机组标志; / /训练班符号位
近机组cjComp; / /温度补偿
近机组tempC; / /在摄氏温度
近机组tblLo,tblHi,eePntr; / /表指针
近机组testVal的; / /从表检验值
近uchar误差; / / 1 =超出范围(1位)
/ /近uchar store8; / / 8位的缓冲区

/**********************************************
子程序
***********************************************/

/ * Inisialisasi的UART @ 9600个基点,8的N - 1 * /
无效init232(无效)

TMOD =(TMOD&0x0F)| 0x20; / /定时器1模式2(自动刷新)
SCON的= 0x52; / /串行模式1(8位UART),任= 1(接收器使)
/ /德州仪器= 1(发送缓冲区空)
PCON寄存器= PCON的&0x7F; / / SMOD = 0(双波特率禁用)
TH1 = 0xFD; / / 9600基点(11059兆赫)
ET1 = 0; / /禁用定时器1中断
TR1的= 1; / /定时器1运行


/ *读取当前的注册
, 以获取训练班电压
-每个原始位= 15.625紫外
- tCuV在微伏* /
(无效)无效Read_TC_Volts(
uchar缓冲带;
机组buf16;
ow_reset(); / /读取电流寄存器
ow_writebyte(skipnet);
ow_writebyte(rdreg);
ow_writebyte(0x0e);
tCuV = ow_readbyte();
丁咯= ow_readbyte();
ow_reset();
tCuV“”= 8;
tCuV =缓冲带;
标志= tCuV“”15; / /保存符号位
tCuV“”= 3; / /正确对齐
如果(签名== 1)(
tCuV | = 0xf000; / /垫2's -恭维位
tCuV =〜tCuV; / / tCuV = - tCuV
tCuV = 1;

/ * tCuV *= 156; / / x 15.625紫外
tCuV / = 10; * /
/ * tCuV x 15.625紫外==(tCuV × 15) (tCuV x 0.625)* /
buf16 = tCuV * 15; / / tCuV × 15
tCuV *= 5; / / tCuV x 0.625 ==(tCuV × 5)/ 8
tCuV“”= 3;
tCuV = buf16;


/ *读取冷端(设备)的温度
-每个原始位= 0.125摄氏度
-返回tmpCJ全部摄氏度* /
无效Read_CJ_Temp(无效)(
uchar缓冲带;
ow_reset();
ow_writebyte(skipnet);
ow_writebyte(rdreg);
ow_writebyte(0x18);
tmpCJ = ow_readbyte();
丁咯= ow_readbyte();
ow_reset();
tmpCJ“”= 8;
tmpCJ =缓冲带;
如果(tmpCJ“= 0x8000)(/ /检查标志
tmpCJ = 0; / /禁止负
否则()
tmpCJ“”= 8; / /“”5 × 0.125(“”3)



/ *搜索当前选定的训练班表最近的入口
-使用修改二进制算法来查找cjComp
-高端的搜索
, 然后再调用(tblHi集)
-成功的搜索设置tempC * /
无效TC_Lookup(无效)(
tblLo = 0; / /低入口表
tempC = 22; / /默认为室温
testVal的= Cnv_table [tblHi] / /检查最高温度
如果(cjComp“testVal的)(
错误= 1; / /超出范围
否则()
而(1)(
eePntr =(tblLo tblHi)/ 2; / /中点搜索跨度
testVal的= Cnv_table [eePntr] / /读取的中点值
如果(cjComp == testVal的)(
转到exitTC; / /找到了!
否则()
如果(cjComp“testVal的)(tblHi = eePntr;)/ /搜索的下半
否则(tblLo = eePntr;)/ /搜索的上半

如果((tblHi - tblLo)“2)(/ /跨度最低
eePntr = tblLo;
转到exitTC;


exitTC:
tempC = eePntr;

)/*******************************************
主:这里开始!
********************************************/
无效的主要(无效)(
uchar一;
uchar编号[8];

/ * Inisialisasi的UART * /
init232();
/ * Check_Device * /
如果(!ow_reset())(/ /获取序列号
printf(“不存在!\ N”的);
转到exitMain;

ow_writebyte(readnet);
为(1 = 0;“8,我 )(
编号[我] = ow_readbyte();

ow_reset();
printf(“编号=”);
为(1 = 0;“8,我 )(
printf(“%X”的,编号[一]);

printf(“\ N”的);
如果(编号[0] = 0x30)(/ /如果不是0x30,错误的设备
printf(“错误的1 - Wire器件!\ N”的);
转到exitMain;


/ *测量温度* /
而(1)(
错误= 0;
Read_TC_Volts(); / /读取塞贝克电压
Read_CJ_Temp(); / /读取冷端温度
cjComp = Cnv_table [tmpCJ] / /得到赔偿电压
/ *结合cjComp和tCuV * /
如果(签名== 1)(
/ *训练班下面冷端* /
如果(tCuV“cjComp)(
cjComp - = tCuV;
否则()
cjComp = 0; / /限制为0荤

否则()
/ *训练班上述冷端* /
cjComp = tCuV;

tblHi = 400; / /设置搜索高端
TC_Lookup(); / /反向查找表
如果(错误== 0)(
/ *显示tempC * /
printf(“温度=%苞\ N”的,tempC);
否则()
/ *超出范围* /
printf(“超出范围!\ N”的);
转到exitMain;

ow_waitms(1000);

exitMain:
而(1)();


/ *完* /

 
许多感谢的所有人。
现在,我可以Atmega8535和LCD 2X16项目DS2760

这可能是有益的每一个机构

比的
很抱歉,您还没有登录查看此附件

 

Welcome to EDABoard.com

Sponsor

Back
Top