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)