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.

ADS131E08S: ADS131E08S with PIC18F26K22 Data reading issue

Part Number: ADS131E08S

I am using ADS131E08S with PIC18f26k22 for reading Force sensor values. The sensor which i am using is FSG020WNPB. 

These are my register settings,

CONFIG1         0xF2

CONFIG2         0xE0

CONFIG3         0xE8

CH1SET          0x20

After initialization of registers using below code i am reading values from ADC and printing it on the terminal.

************************************************************************************************************************************************

CS = 0;
PORTCbits.RC0 = 1; //start pin making high
spiwritecommand(ADC_START_CMD);
CS = 1;

CLOCK = 0;
__delay_us(10);
CLOCK = 1;

PORTCbits.RC1 = 1; //making DRDY pin as low

//as per Data sheet Issue this command after DRDY goes low to read the conversion result
CS = 0;
spiwritecommand(ADC_READ_DATA_CMD);
CS = 1;

char pri[15];
int x;
CS = 0;
for(x=0;x<27;x++)
{
adcArray[adcArrayIndex] = spi_write(0x00);
adcArrayIndex++;
}
CS = 1;
adcvalue1 = Parse_24bit_adc_values(CHANNEL1_INDEX);
sprintf(pri,"%ld",adcvalue1);

sendResponseViaUart(pri);
uartWriteByte(0x0D);
PORTCbits.RC0 = 0;

*******************************************************************************************************************************************************

i am converting the Values read by ADC into voltage by using below equation,

voltage = ADC value * Vref / ADC resolution

where Vref = 2.4V

these are the values and corresponding voltages i am getting, while applying force on the Force sensor

ADC value                                                   Voltage

12615897 1.797199
14409920 2.052767
14729408 2.098279

I have tried connecting a potentiometer to the channel 1 and applied a fixed voltage 

0.348V(fixed voltage) on potentiometer
16711696 2.380666
65552 0.009338
262120 0.03734
0.257V(fixed voltage)on potentiometer 8323072 1.185664
589840 0.084026
393232 0.056018
196624 0.02801
720912 0.102698
655376 0.093362

Everytime the values are keep on changing. Even if applied any fixed voltage also the values(Read by ADC) s changing.

Kindly advice how to proceed further.

  • Hello Rekha, 

    Welcome to our forum and thank you for your post. 

    PORTCbits.RC1 = 1; //making DRDY pin as low

    The /DRDY pin is a digital output from the ADS131E08S. This signal is used as an interrupt to your controller, where you will enter a routine to read the data each time you detect /DRDY goes low. It looks like here you are setting the pin on your uC to be an output logic 0b.

    Regarding the data format, our device uses binary two's complement as shown in table 7 and 8. The full-scale range for this device is 2xVREF and the LSB is calculated using equation 9.

    Best regards,

    Ryan

  • Regarding the data format, our device uses binary two's complement as shown in table 7 and 8. The full-scale range for this device is 2xVREF and the LSB is calculated using equation 9.

    As per this, The value read by ADC will be in 2's complement format.. so i need to convert it into decimal and then to voltage correct? 

  • Also please advice my coding sequence is correct or not for reading data from ADC 

  • Hi Rekha - yes that is correct.

  • The order of operations appears correct. Again - /DRDY is an input to your uC, not an output that you should be configuring as high or low. When /DRDY = low, the procedure to send the RDATA command followed by the 27 null bytes (0x00) in the next frame is correct (you could also keep /CS low and do this all in one frame).

    Keep in mind that in order to read data on-demand with RDATA, you must first exit the RDATAC mode (Read Data Continuous), which is the default setting. SDATAC is the command to exit RDATAC mode. 

    If you are monitoring /DRDY and your SCLK is fast enough to read all 27 bytes within one data rate period, you should be able to leave the device in RDATAC mode and not need to use the RDATA command.

    Regards,

    Ryan

  • Hi Rekha - yes that is correct.

    So do i need to convert each byte From binary 2's complement to Decimal?

    as i am reading 27bytes from ADC in one shot... 

    3bytes(status words) + 3bytes * 8 channel = 216 bits...

    currently i have connected a potentiometer to channel 1 and reading values from it..  Inorder to get channel 1 voltage , first i need to convert the ADC value which is in binary 2's complement and to decimal and then to voltage....

  • The STATUS word and each channel conversion result are 24 bits (3 bytes) each. You will need to parse the data before converting each 24-bit value to decimal.