AnsweredAssumed Answered

AD7705 Data backwards?

Question asked by bitbang_116 on Jul 30, 2017
Latest reply on Aug 1, 2017 by bitbang_116

I've been having an issue with the AD7705 that the data I'm receiving seems to be reversed. That is, at A(in+)= 2.5V,  A(in-)=0V and G = 1, I get a value of -1. When A(in+)= 0V, A(in-)= 0V I read -32767 or so. Then it flips, A(in+)= 0V,  A(in-)=2.5V the data reads 1.

 

The setup is as follows:

  • G = 1
  • Vref - = GND
  • Vref+ = 2.5V
  • Full scale cal done at A(in-)= 0V, A(in+) = 2.5V
  • Zero scale cal done at A(in-)= 0V, A(in+) = 0V

 

All other writes and reads are OK. I can write a value to the clock or setup registers and read them back fine. Also the conversion data does scale correctly, just the numbers seem to be opposite of what I believe they should be.

 

void ad7705_init(void){
    //WRITE TO CLOCK REG p.19
    AD7705_CSn = 0;
    spi_tx(0b00100000); //DRDY = 0, RS2-RS0 = 010, R/Wn = 0, STBY = 0, CH1,CH0 = 00
    spi_tx(0b00010000); //ZERO = 000, CLKDIS = 1, CLKDIV = 0, CLK = 0, FS1,FS0 = 00
    AD7705_CSn = 1;
    
    INTCONbits.INTE = 1;        //Enable external INT pin
    INTCONbits.INTF = 0;        //Clear external INT flag
    INTCONbits.GIE = 1;         //Enable Global ints
    OPTION_REGbits.INTEDG = 0;  //Interrupt on falling edge
    
    //WRITE TO STATUS REG p.17
    AD7705_CSn = 0;
    spi_tx(0b00010000); //DRDY = 0, RS2-RS0 = 001, R/Wn = 0, STBY = 0, CH1,CH0 = 00
    spi_tx(0b01000000); //MD1,MD0 = 01, G2-G0 = 001, Bn/U = 0, BUF = 1, FSYNC = 0
    AD7705_CSn = 1;
}

 

void ad7705_read_data(void){
    AD7705_CSn = 0;
    spi_tx(0b00111000); //DRDY = 0, RS2-RS0 = 011, R/Wn = 1, STBY = 0, CH1,CH0 = 00
    ad7705_data.data_H = spi_tx(0xFF);
    ad7705_data.data_L = spi_tx(0xFF);
    AD7705_CSn = 1;
}

 

void ad7705_fs_cal(void){
    //WRITE TO STATUS REG p.17
    AD7705_CSn = 0;
    spi_tx(0b00010000); //DRDY = 0, RS2-RS0 = 001, R/Wn = 0, STBY = 0, CH1,CH0 = 00
    spi_tx(0b11000000); //MD1,MD0 = 11, G2-G0 = 001, Bn/U = 0, BUF = 1, FSYNC = 0
    AD7705_CSn = 1;
}

 

void ad7705_zs_cal(void){
    //WRITE TO STATUS REG p.17
    AD7705_CSn = 0;
    spi_tx(0b00010000); //DRDY = 0, RS2-RS0 = 001, R/Wn = 0, STBY = 0, CH1,CH0 = 00
    spi_tx(0b10000000); //MD1,MD0 = 10, G2-G0 = 001, Bn/U = 0, BUF = 1, FSYNC = 0
    AD7705_CSn = 1;
}

Outcomes