TLC2543是TI公司的12位串行模数转换器,使用开关电容逐次逼近技术完成A/D转换过程。由于是串行输入结构,能够节省51系列单片机I/O资源;且价格适中,分辨率较高,因此在仪器仪表中有较为广泛的应用。 TLC2543的特点 (1)12位分辩率A/D转换器; (2)在工作温度范围内10μs转换时间; (3)11个模拟输入通道; (4)3路内置自测试方式; (5)采样率为66kbps; (6)线性误差±1LSBmax; (7)有转换结束输出EOC; (8)具有单、双极性输出; (9)可编程的MSB或LSB前导; (10)可编程输出数据长度。 TLC2543的引脚排列及说明 TLC2543有两种封装形式:DB、DW或N封装以及FN封装,这两种封装的引脚排列如图1,引脚说明见表1 TLC2543电路图和程序欣赏 #include<reg52.h> #include<intrins.h> #define uchar unsigned char #define uint unsigned int sbit clock=P1^0; sbit d_in=P1^1; sbit d_out=P1^2; sbit _cs=P1^3; uchar a1,b1,c1,d1; float sum,sum1; double sum_final1; double sum_final; uchar duan[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; uchar wei[]={0xf7,0xfb,0xfd,0xfe}; void delay(unsigned char b) //50us { unsigned char a; for(;b>0;b--) for(a=22;a>0;a--); } void display(uchar a,uchar b,uchar c,uchar d) { P0=duan[a]|0x80; P2=wei[0]; delay(5); P2=0xff; P0=duan[b]; P2=wei[1]; delay(5); P2=0xff; P0=duan[c]; P2=wei[2]; delay(5); P2=0xff; P0=duan[d]; P2=wei[3]; delay(5); P2=0xff; } uint read(uchar port) { uchar i,al=0,ah=0; unsigned long ad; clock=0; _cs=0; port<<=4; for(i=0;i<4;i++) { d_in=port&0x80; clock=1; clock=0; port<<=1; } d_in=0; for(i=0;i<8;i++) { clock=1; clock=0; } _cs=1; delay(5); _cs=0; for(i=0;i<4;i++) { clock=1; ah<<=1; if(d_out)ah|=0x01; clock=0; } for(i=0;i<8;i++) { clock=1; al<<=1; if(d_out) al|=0x01; clock=0; } _cs=1; ad=(uint)ah; ad<<=8; ad|=al; return(ad); } void main() { uchar j; sum=0;sum1=0; sum_final=0; sum_final1=0; while(1) { for(j=0;j<128;j++) { sum1+=read(1); display(a1,b1,c1,d1); } sum=sum1/128; sum1=0; sum_final1=(sum/4095)*5; sum_final=sum_final1*1000; a1=(int)sum_final/1000; b1=(int)sum_final%1000/100; c1=(int)sum_final%1000%100/10; d1=(int)sum_final%10; display(a1,b1,c1,d1); } }
上传时间: 2013-11-19
上传用户:shen1230
#include<iom16v.h> #include<macros.h> #define uint unsigned int #define uchar unsigned char uint a,b,c,d=0; void delay(c) { for for(a=0;a<c;a++) for(b=0;b<12;b++); }; uchar tab[]={ 0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,
上传时间: 2013-10-21
上传用户:13788529953
数字运算,判断一个数是否接近素数 A Niven number is a number such that the sum of its digits divides itself. For example, 111 is a Niven number because the sum of its digits is 3, which divides 111. We can also specify a number in another base b, and a number in base b is a Niven number if the sum of its digits divides its value. Given b (2 <= b <= 10) and a number in base b, determine whether it is a Niven number or not. Input Each line of input contains the base b, followed by a string of digits representing a positive integer in that base. There are no leading zeroes. The input is terminated by a line consisting of 0 alone. Output For each case, print "yes" on a line if the given number is a Niven number, and "no" otherwise. Sample Input 10 111 2 110 10 123 6 1000 8 2314 0 Sample Output yes yes no yes no
上传时间: 2015-05-21
上传用户:daguda
The government of a small but important country has decided that the alphabet needs to be streamlined and reordered. Uppercase letters will be eliminated. They will issue a royal decree in the form of a String of B and A characters. The first character in the decree specifies whether a must come ( B )Before b in the new alphabet or ( A )After b . The second character determines the relative placement of b and c , etc. So, for example, "BAA" means that a must come Before b , b must come After c , and c must come After d . Any letters beyond these requirements are to be excluded, so if the decree specifies k comparisons then the new alphabet will contain the first k+1 lowercase letters of the current alphabet. Create a class Alphabet that contains the method choices that takes the decree as input and returns the number of possible new alphabets that conform to the decree. If more than 1,000,000,000 are possible, return -1. Definition
标签: government streamline important alphabet
上传时间: 2015-06-09
上传用户:weixiao99
驴友格子(access)版v1.50 (中国驴友网开发http://www.hikers.cn) 后台管理:admin 管理员用户名:admin 管理员密码:admin (md5加密后:21232f297a57a5a743894a0e4a801fc3) 5.29日 1.修复了日期小于10号时的排名出错 2.修正了点出功能 3.增加了排名功能 4.增加了防刷新功能,按ip计算点入点出
上传时间: 2015-06-12
上传用户:stewart·
电力系统在台稳定计算式电力系统不正常运行方式的一种计算。它的任务是已知电力系统某一正常运行状态和受到某种扰动,计算电力系统所有发电机能否同步运行 1运行说明: 请输入初始功率S0,形如a+bi 请输入无限大系统母线电压V0 请输入系统等值电抗矩阵B 矩阵B有以下元素组成的行矩阵 1正常运行时的系统直轴等值电抗Xd 2故障运行时的系统直轴等值电抗X d 3故障切除后的系统直轴等值电抗 请输入惯性时间常数Tj 请输入时段数N 请输入哪个时段发生故障Ni 请输入每时段间隔的时间dt
上传时间: 2015-06-13
上传用户:it男一枚
此系统是应老师所布置的作业编制而成,该系统具有存贮学生数据,按学号、姓名查询,列出学生成绩和统计功能。\n \n 使用方法:系统输入数据后,将在当前目录中建立一个名为stu.dat文件,用于保存输入的数据。学号输入只能用数字输入,并且学号只能是10位。姓名输入符合中国人的姓名,只能用中文,且最长为5个汉字。\n
标签: 编制
上传时间: 2015-06-14
上传用户:huannan88
数字电压表 AD芯片: 采用8位串行A/D转换器ADC0832。 ● 8位分辨率,逐次逼近型,基准电压为 5V ● 5V单电源供电 ● 输入模拟信号电压范围为 0~5V ● 有两个可供选择的模拟输入通道 显示: 使用三个数码管。 显示范围: 0.00 - 5.10 (单位:V) 连接方式: AD_CLK → P1.0 AD_DAT → P1.1 AD_CS → P3.4 模拟输入 → CH0 (AD_DAT = DO + DI) ADC0832输出最大转换值=FFH (255) 设定最大测量值=5.1V 255X=5.1 X=0.02 即先乘2再除以100 (小数点放在第三位数码管)
上传时间: 2015-06-18
上传用户:fandeshun
// 语法制导翻译器设计示范程序 // ----- 算数表达式四元式翻译(递归子程序法) // 要求:1. 读懂该程序,并上机调试成功; // 2. 运行该程序,输入源表达式(字母:表示变量,数字:表示常数。) // 3. 反复运行,考查输出的各种四元式的正确性。 // 4. 实验报告内容:表达式的属性翻译文法;递归子程序框图; // 运行结果的记录(输出的三元式不得少于10条!)
上传时间: 2015-06-19
上传用户:wangzhen1990
使用mega16单片机进行片上自带的AD转换编程,实现10位AD数据转换,使用时需要仔细阅读Mega16的数据手册,对线路进行连接
上传时间: 2014-06-13
上传用户:Yukiseop