Hello.
I am using an Arduino Uno to read ADC Values from 24 bit ADS1231.
I have used this code below to convert the 24 bit adc value to 32 bits which seems to work fine now if I press my sensor for positive push: (zero+offset) to 0x7FFFFF and (0+offset) to 0xFF8000000 for negative push. 24 bits for positive and 32 bit for negative which seems to be working as expected?.
Now I just need to know how to convert this number to something more meaningful like instead of going from negative full scale 0xFF8000000 to 0 midpoint to 0x7FFFFF positive full scale. I would like to have it like 0 to X where 0 is equivalent to 0xFF8000000, X/2 is equivalent to midpoint and X is the postive full scale. How do I achieve this code?
code:
X = bit24 & adcvalue; // zero-ing the rest of the adcvalue bits except the sign bit. if(X==bit24) // if sign bit is = 1 { adcvalue_32bit = adcvalue+0xFF000000; // sign extend adc value to 32 bit } else // sign bit is = 0 { adcvalue_32bit = adcvalue+0x00000000; // sign extend adc value to 32 bit }