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.

ADS1256测量误差很大

Other Parts Discussed in Thread: ADS1256, REF3125, ADS1282, ADS1248

各位专家:

    我目前在使用ADS1256,实测结果显示误差很到,输入模拟电压值 = 2.5000V,AD实际采集值 = 2.5320V, 相差约32mV;在其它几点测量,误差也较大。

电路图在附件中。不知道是不是因为没有设置好自校准参数?请专家帮忙分析原因,谢谢。

 

 

程序代码如下:

 

延时子程序:

void delay_12clk(void)

{    unsigned char i;   

     for(i=0;i<24;i++)        ;                 

  }

 

写寄存器子程序:

static void write_register(unsigned char reg,unsigned char wdata)

 {     

         SPI1_send(WREG|reg);      //选择写入寄存器         

         SPI1_send(0x00);               //写入1个寄存器         

         SPI1_send(wdata);             //写入数据   

}

 

读寄存器子程序:

static unsigned char read_register(unsigned char reg)

{     

      static unsigned char  x;          

      while(ADRDYB);                     //DRDY信号低时才能读寄存器       

      SPI1_send(RREG|reg);          //选择写入寄存器     

      SPI1_send(0x00);                  //写入1个寄存器      

      delay_10us();                         //延时10us 20130413添加      

      delay_10us();                         //延时10us 20130413添加     

      x = SPI1_TranByte(0xFF);     //读出寄存器值                                  

      return (x);   

 

读ADS1256测量值程序:

unsigned long read_data()

 {    

       unsigned char rx_dat[4];     long x;      

       while(ADRDYB);          

        rx_dat[0] = SPI1_TranByte(0xFF);                      

        rx_dat[1] = SPI1_TranByte(0xFF);                      

        rx_dat[2] = SPI1_TranByte(0xFF);        

       x     = (long)rx_dat[0]*65536+(long)rx_dat[1]*256 +(long)rx_dat[2];    

       return (x);      

 }

 

初始化ADS1256子程序:

void INIT_ADS1256(void)  

 {    

        CS_SPI1 = 0;                              //选通SPI0    

        delay_100us();                            //延时100us        

        while( ADRDYB);                        //20130417添加    

        SPI1_send(RESET);                  //复位 20130313               

        write_register(STATUS,0x06);   //输出高位数据在前     

        write_register(MUX,   0x18);      //MUX寄存器为默认值         

        write_register(ADCON, 0x20);   //ADCON寄存器为默认值     

        write_register(DRATE,0xa1);     // 1000sps 采样率  

        write_register(IO,0x00);            

        write_register(OFC0,0x00);  

        write_register(OFC1,0x12);            

        write_register(OFC2,0x02);                              

       SPI1_send(SELFCAL);           

       delay_2us();    

       delay_2us();    

       delay_2us();    

       delay_2us();    

}     

 

ADS1256测试子程序:

void ADS1256_test(unsigned char *ADS1256_data_point)

{     

         unsigned long v = 0;    

         unsigned char i = 0;      

                      

         CS_SPI1 = 0;         

         SPI1_send(SELFCAL);          

         delay_2us();    

         delay_2us();    

         delay_2us();       

         delay_2us();                                

         while(ADRDYB);                   //DRDY信号低时才能读寄存器          

         write_register(MUX,0x38);    //选择#3 channel  

        SPI1_send(SELFCAL);  

        SPI1_send(SELFOCAL); 

        SPI1_send(SYNC);               //启动转换       

        delay_12clk();                       //延时12clk            

        SPI1_send(WAKEUP);                 

        delay_12clk();                      //延时12clk                                 

        SPI1_send(SELFOCAL);                                      

        SPI1_send(RDATA);                   

        delay_12clk();                     //延时12clk     

         v  = read_data();           

        *ADS1256_data_point = ((v & 0x00FF0000) >> 16);    

        ++ADS1256_data_point;    

       *ADS1256_data_point = ((v & 0x0000FF00) >>  8);      

       ++ADS1256_data_point;    

       *ADS1256_data_point = ((v & 0x000000FF)      );                

  }