The datasheet states that the PGA gain is 1x, 2x, 4x, 8x V/V, and there is fixed gain block(INA) of 20. The only options available are 20, 40, 80, 160V/V
ECG_GAIN = PGA_GAIN x INA
The Full Scale Range of the ADC is FSR= Vref/ECG_GAIN.
The reference voltage is 1V as stated in the datasheet.
If if PGA gain is set to 1x, then ECG_GAIN = 20V/V, then the full scale range is FSR = 0.05V
Then,
1LSB = FSR/2^n = 0.05/2^(18-1) = 381.469nV
The 18-1 is due to the 2's complement output.
Then you can use the following formula to substitute the previous definitions and get the result in mV
V = ADC_Counts * LSB
V = ADC_Counts * FSR/2^(18-1)
V = (ADC_Counts)* VREF / (2^(18-1) * ECG_GAIN) //Vref in Volts
mV = (ADC_Counts* 1000mV)/(2^(18-1) * ECG_GAIN)
For example, if the data from the FIFO sample data is 16669383 (111111100101101011000111b, FE5AC7 hex), then you can format the data as follows:
1. Remove lower 6 bits, so you shoul get the following ADC_result 260459 ( 11 1111 1001 0110 1011b, 3f96b hex). Check the datasheet for more info on the lower 6 bit about for ETAG and PTAG.
2. Since the ADC_results has a leading 1 in binary, you need to perform the 2s complement conversion by substracting the result from the full set of bit codes, as follows:
ADC_Counts = ADC_result - 2^n, where n is the bit depth of the ADC.
Then the ADC_counts = 260459 - 262144 = -1685
If the ADC_result does not have a leading 1 then you just use the ADC_result = ADC_counts.
3. Then you can obtain the relative voltage with the above formula as follows:
mV = (1000*(-1685)/((2^17)*20) = -0.642mV