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.

ADS1292R: I have a problem about data transform and gain.

Part Number: ADS1292R

plz understand that I'm not used to using eng.

I'm making a lib. in sketch that is based on C or C++.

I saved data set in data_array[](Byte type, 0~8(9)) and I want to changed data to double type.

0~2 of data_array is header(Cx xx xx), 3~5 is CH1 value (V) and 6~8 is CH2 value (V).

I transform data to value with following code, is this code correct?

/--------------------------------------------------------------------/ 

if ((data_array[3] >> 4) <= 7) { // Positive value transform

temp = (data_array[3] * pow(256, 2)) + (data_array[4] * pow(256, 1)) + (data_array[5] * pow(256, 0));

ch1_val = double(temp) / (pow(2, 23) - 1) / GAIN1 * VREF * 1000; // GAIN = (6)default, VREF = 2.42V, '*1000' means (V >mV)

Serial.println(ch1_val, 10);

} else {  // Negative value transform

temp = 0xFFFFFF - ((data_array[3] * pow(256, 2)) + (data_array[4] * pow(256, 1)) + (data_array[5] * pow(256, 0))) + 1;

ch1_val = double(temp) / (pow(2, 23) - 1) / GAIN1 * VREF * 1000;

Serial.println(-ch1_val, 10);

}

/--------------------------------------------------------------------/ 

When I read AC test signal, the range was -0.9xmV to 1.1xmV that is right value if the zero offset was considered (+0.1mV).

But, when I changed gain is 12, the range was half value of gain 6. (-0.5xmV to 0.5xmV).

I guessed that the amplified value will be increase and the divided value will be same with gain 6, as gain increase.

Do you know why this error was occurred? (The register value changed correctly)

  • Hi Seonjo,

    Nice to hear from you again, I hope you are well!

    When you changed the gain, did you issue the OFFSETCAL command to re-calibrate?

    From the DS: OFFSETCAL: Channel Offset Calibration
    This command is used to cancel the channel offset. The CALIB_ON bit in the RESP2 register must be set to '1' before issuing this command. OFFSETCAL must be executed every time there is a change in the PGA gain settings.
  • Thanks for your advise.

    then, is the transform function right?

    i added the calibration function after I changed the PGA.

    //--------------------------//

    void CALIBRATION() {

    byte RESP2_STAT = read_reg(RESP2) | (CALIB_ON);

    write_reg(RESP2, RESP2_STAT) // Sst CALIB_ON bit 1

    send_command(OFFSETCAL); // and then send command

    RESP2_STAT = RESP2_STAT & (~CALIB_ON); // and then reset CALI_On bit 0

    write_reg(RESP2, RESP2_STAT);

    }

    //--------------------------//

    But I can't read the data set correctly except default gain.(The register value is still right)

    and additionally, when I Reset the chip, 0 bit of the RESP2 that must be one, is zero. I guess there is critical error... 

  • Hi Seonjo,

    Writing the code is ultimately up to the customer. I will do my best to understand what is being done, but am not sure if the double is being transformed correctly or not. Since you are able to get the correct value for the default gain, it makes me think that the error is somewhere during the PGA gain change or code doing the calculation.

    What values are returned for different gains? We only have two data points (gain 6,12) and more may be helpful.

    Is the GAIN1 variable being updated in your code when the device register is changing? That would explain the difference for this particular case.