Post Go back to editing

Read Tolerance

Category: Software
Product Number: AD5252

Hi,

Can anyone give me an example on how to read tolerance of AD5252 using Arduino ?

I tried several strategies and none worked. I2C communication is working fine.

Thanks!

  • Hi  ,

      will be taking a look at this query, thanks for your patience.

    Br,

    Den

  • Hi  ,

    Can you provide a scopeshot of your read command?

    Best Regards,

    Yokki

  • Hi, here is an example of the code I tried to use to obtain the tolerance value.

    The output was quite random. I could not obtain nothing reasonable from this code.

    Can you tell me what is the problem with the algorithm? Or maybe give me another algorithm that works properly for AD5252?

    Thanks!

    #include <Wire.h>

    const int AD5252_ADDRESS = 0x2C; // I2C address of the AD5252 (0101100 in binary)

    void setup() {
    Wire.begin();
    Serial.begin(9600);
    while (!Serial); // Wait for serial connection
    }

    void loop() {
    byte data = readTolerance(AD5252_ADDRESS);
    Serial.print("RDAC3 Tolerance: ");
    Serial.print(data & 0x7F); // Extract the 7-bit integer value (mask with 0x7F)
    Serial.print(" (");
    Serial.print(data & 0x80 ? "Negative" : "Positive"); // Check the sign bit (mask with 0x80)
    Serial.println(")");
    delay(1000);
    }

    byte readTolerance(byte address) {
    Wire.beginTransmission(address);
    // Set register address (0xEE for tolerance)
    Wire.write(0xEE);
    Wire.endTransmission();

    Wire.requestFrom(address, 1);
    if (Wire.available() == 1) {
    return Wire.read();
    } else {
    Serial.println("Error: Could not read tolerance data");
    return 0;
    }
    }

  • Hi,

    I think the read tolerance address you used is wrong. From p19 of the datasheet, you need to read two registers per RDAC. first is for the sign and 7-bit integer, second is for the 8-bit decimal. 
    For RDAC1, 0x3A and 0x3B
    For RDAC3, 0x3E and 0x3F

    your syntax for parsing the first byte with the sign and 7-bit integers looks correct. 

    Best regards,

    Ian

  • Thank you very much ! This solved the problem!

    By the way... how did you understand from page 19 that those are the addresses?

    On top of the table says "(CMD/REG = 0, EE/RDAC = 1, A4 = 1)".

    Is that wrong? should be "A5 = 1" ?

    Anyway... thank you.

  • Hi  

    You will notice in Table 11 in the datasheet that A4=0 is reserved for other purposes and A4=1 is used for tolerance readback.

    Regards

    Vikash