This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMP275温度测量精度不够

Other Parts Discussed in Thread: TMP275

为什么我的TMP275不管是配置成几位精度,读到的温度都是整数在变,就是一度一度的变化,小数部分不变

  • 即使是在默认状态下(R1/R0: 0/0)其精度也为0.5度。因此,既然能够读的到温度,我感觉有可能是您的程序中计算温度的小数点后的算法可能有问题,请仔细检查一下程序

  • 可是我把温度两字节读回来,然后直接在12864液晶第一行上显示,然后计算温度在第二行显示,我用计算器算了也是那样,1s读一次,还是那样,我觉得真邪门了,我是两年前参加大赛的时候第一次用的TMP275,看了一下他的datasheet,一遍就把程序写对了,现在参照原来的ARM程序写出来的51居然有问题,呜呜...

  • 你检查一下程序啊,ARM和51不同的编译器支持的数据格式及运算有些地方不一样,看看你的编译器有没有出现warning什么的,有的话就要注意了哦

  • 楼主有没有解决好?我也遇到了同样的问题,如果你解决好了,希望你能给我指导,QQ:289883393

  • 给我看看,我的程序,我的也是这个问题

    #include<reg52.h>
    #define uchar unsigned char
    #define uint unsigned int
    #define NOP()
    uint b,d,a1;
    uchar n,r,a,d1,d2;
    sbit SDA=P0^0;
    sbit SCL=P0^1;
    sbit W=P2^3;
    sbit D=P2^4;
    sbit LED=P2^0;
    void display(uchar r);
    void write_add(uchar point,uint date);
    uchar code dtable[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x80,0x00};
    uchar code wtable[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
    uchar table[7];

    void delay(uchar z)
    {
    uint x,y;
    for(x=80;x>0;x--)
    for(y=z;y>0;y--);
    }

    void init()
    {
    SDA=1;
    NOP();
    SCL=1;
    NOP();
    n=0;
    a=0;
    b=0;
    }


    void start()//开始信号
    {
    SDA=1;
    NOP();
    SCL=1;
    NOP();
    SDA=0;
    NOP();
    }

    void stop()//停止信号
    {
    SDA=0;
    NOP();
    SCL=1;
    NOP();
    SDA=1;
    NOP();
    }

    void respons()//应答信号
    {
    uchar i;
    SCL=1;//时钟线为高电平等待应答信号SDA
    NOP();
    while((SDA==1)&&(i<250))i++;//等待应答信号SDA=0;
    SCL=0;//时钟线为低电平,控制总线暂停
    NOP();
    }

    void write_byte(uchar date)//写一个字节
    {
    uchar i,temp;
    temp=date;
    for(i=0;i<8;i++)
    {
    temp=temp<<1;//左移一位
    SCL=0;//SCL=0允许SDA数据可以变化,等待CY送到SDA上
    NOP();
    SDA=CY;
    NOP();
    SCL=1;//SCL=1,保持数据SDA稳定
    NOP();
    }
    SCL=0;
    NOP();
    SDA=1;//总线释放
    NOP();
    }

    uchar read_byte()//读一个字节
    {
    uchar i,k;
    SDA=1;//释放总线
    NOP();
    for(i=0;i<8;i++)
    {
    SCL=0;//SCL=0允许SDA数据变化,等待读取数据到SDA
    NOP();
    k=(k<<1)|SDA;
    SCL=1;//SCL=1,保持稳定,等待数据读取到SDA上
    NOP();
    }
    return k;
    }

    uint read_add(uchar address)
    {
    uint date;
    uchar date1,date2;
    start();
    write_byte(0x90);//写器件地址
    respons();
    write_byte(address);//写取寄存器
    respons();
    start();
    write_byte(0x91);//读器件单元地址
    respons();
    date1=read_byte();
    respons();
    date2=read_byte();
    respons();
    stop();
    date=256*date1;
    date=date+date2;
    return date;
    }


    void main()
    {

    init();
    while(1)
    {
    d=read_add(0x00);//读0x00寄存器
    d1=d/256;
    d2=d%256;
    d1=d1&0x7f;
    a=d1;
    d2=d2>>4;
    d2=d2&0x0f;
    b=625*d2;
    if(a/100==1)
    table[7]=1; //百位超过100度显示“1”
    else
    table[7]=11; //百位没超过100度,百威数码管熄灭
    table[6]=a%100/10; //十位
    table[5]=a%10; //个位
    table[4]=10;
    table[3]=b/1000; //小数点后第一位
    table[2]=b%1000/100; //小数点后第二位
    table[1]=b%100/10; //小数点后第三位
    table[0]=b%10; //小数点后第四位
    for(r=0;r<8;r++)
    {
    P1=0;
    D=1;
    D=0;
    P1=dtable[table[r]];
    D=1;
    D=0;
    P1=wtable[r];
    W=1;
    W=0;
    delay(1);
    }
    }
    }