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.

ADS1256: Not able to read and write the values to the configuration registers.

Part Number: ADS1256

hi.

I have ADS 1256 development board and trying to interface with STM32F446ZE using STM cube and SW4 (Eclipse based workspace). 

sometimes i'm able to read the default values from the configuration registers only when i write specific data to the any of the register. I meant after the write command is sent. if i write the data (with LSB bit 1 in it) then i will get the default register value in response to the read command.   if i write the data (with LSB bit 0 in it) then i will get the register value as 0x00 in response to the read command.  

Also i'm not able to write the registers with any values. Here i have attached the SPI communication details captured with logic analyzer.

6201.SPI.zip

Thanks,

Harsha 

  • Hi Harsha,

    Welcome to the TI E2E Forums and thanks for sharing your logic analyzer screenshots!

    I noticed that you are reading and writing to different registers, is that intentional, or did you mean to read back the value that you are trying to program?

    Currently, you are sending the "0x54 0x00" command which writes to the "I/O" register, and when you send the "0x10 0x00" command bytes, you are reading from the "STATUS" register.

    The WREG command is being ignored because the "I/O" register does not allow you to write to the lower nibble bits when the upper nibble bits are all set to "0". Please refer to the I/O register description below:
    I/O: GPIO Control Register description

    Your RREG command is currently only reading the STATUS register. The first result of "0x31" seems valid. Do note that the LSB of this register follows the state of the /DRDY pin, so it may differ between consecutive readings; however, you should still see the same values in the upper nibble. In your second reading it looks like the ADS1256 is not responding to the RREG command. Is it possible that perhaps either the /RESET or /PWDN pins was set low, or for another device on the same SPI bus to also be active during this time? If not, do you see a regular /DRDY pulse on the ADS1256 to indicate that it is active?

    One last and important recommendation... Make sure to send the SDATAC command before you read or write to the device registers. If you are in RDATAC mode, then this device might ignore the RREG and WREG commands. I would recommend sending the SDATAC command first thing to ensure that you are not in the RDATAC mode.

    Best regards,
    Chris

  • hi christopher,

    Thanks for the fast reply.
    Yes, it is intentional reading and writing. First i tried only to read the 'status' register but only few times i got the correct response. so i added the WREG commands. I do see a regular pulses on the DRDY pin. RESET and SYNC/PWDN pins are pulled up. only ADS1256 is on the SPI bus.
    I was not using the SDATAC command before reading and writing registers. Now i will check the response after disabling the continuous data read mode and let you know the result.

    Thanks&Regards,
    Harsha B S
  • Hi Christopher,

    I have couple of doubts.

    1).How often do we need to do the synchronization process?

    2).What is the difference between self calibration and system calibration? If we issue the SELFOCAL or SYSOCAL commands, the OFC registers are being updated. so which one do we need to perform? and how often do we need to do this calibration?

    Thanks&Regards,
    Harsha B S
  • Hi Christopher,
    I have few queries to ask. Please help me!

    Now I'm able to read and write the ADS1256 configuration register values. In my current setup Vref is 2.5V . If i measure 5v from ADC channel 0, i get 8388607 decimal and this value is correct (2^23 = 8388608) . when i connect ground to channel 0, i get 17543 decimal value from the read command. I think this value should be 0 decimal. am i correct??


    Thanks&Regards,
    Harsha B S
  • Hi Harsha,

    I'm glad you were able to get the RREG and WREG commands working over the weekend!

    In response to your latest questions...

    Harsha B S said:
    1).How often do we need to do the synchronization process?

    Synchronization is only needed when you need to restart an ADC conversion (e.g. when multiplexing through multiple channels) or if you need conversions to begin at a fixed time (e.g. if you need multiple ADS1256's to sample voltage from multiple sensors simultaneously). Other than those use cases, you probably don't need to worry about synchronization.

    Harsha B S said:
    2).What is the difference between self calibration and system calibration? If we issue the SELFOCAL or SYSOCAL commands, the OFC registers are being updated. so which one do we need to perform? and how often do we need to do this calibration?

    The difference between "self" calibration and "system" calibration has to do with which errors you are trying to account for and remove...

    ...when performing "self" calibration you are removing the initial offset and gain errors of the ADC by itself. "System" calibration is used to remove the total offset and gain error of the system; resulting from the combination of errors coming from the sensor, signal conditioning circuitry, and ADC, for example.

    "Self" calibration is much easier to perform, because all you have to do is issue the self calibration command and the ADC will  internally measure it's own offset and gain error for you. "System" calibration requires that you provide the correct 0V and full-scale voltages externally. Often times system offset calibration is possible, but system gain error calibration is not, since it requires a very precise full-scale voltage.

    Which type of calibration you perform and how often you perform it is up to you... Whenever possible, I would recommend "system" calibration as it removes more errors than just the ADC errors alone. How often you calibrate will depend on how often you expect the offset and gain to change. If your system operates in an environment with a wide ambient temperature range, you might need to re-calibrate every so often to remove the offset and gain error dependence on temperature, or otherwise recall the calibration coefficients from a previous calibration performed at a similar temperature, for example.

    Harsha B S said:
    when i connect ground to channel 0, i get 17543 decimal value from the read command. I think this value should be 0 decimal. am i correct??

    In theory, yes.... A conversion result of "17543" corresponds to a voltage of ~10mV (for VREF = 2.5 and PGA = 1 V/V). Either the negative input channel is connected to -10mV, OR the ADC + any signal conditioning circuitry + the input signal source itself is contributing a offset error of 10 mV.

    You might try shoring the positive and negative inputs together (to 0V) to see how much of this error is coming from your signal source. Whatever error remains is the offset voltage, and you should be able to remove it through "system" offset calibration.

    Best regards,
    Chris

  • Hi Christopher,
    Thanks for the detailed explanation. It helped me a lot. while performing calibration and synchronization i got few more queries.

    I followed the below steps to read the multiple sensors connected to the ADC channels AIN0 to AIN3. Please confirm me whether my procedure is correct or not.
    > SRDATAC command (stop read data continuously)
    > select ADC channel (MUX register write)
    > perform synchronization (SYNC + WAKEUP commands)
    > read the data from the sensor
    > back to first step.
    1). Is it necessary to perform the synchronization every time i change the MUX register to select the ADC channel?


    I have followed these steps to perform the system offset and gain calibration.

    SYSTEM OFFSET CALIBRATION:
    I selected the single ended reading mode with positive input connected to ground and negative input connected to AINCOM (also connected to AGND). And then issued the SYSOCAL command.

    SYSTEM GAIN CALIBRATION:
    I selected the single ended reading mode with positive input connected to 5V and negative input connected to AINCOM (also connected to AGND). And then issued the SYSGCAL command.

    2). please confirm whether these calibration methods are correct. Do we need to follow this procedure for each and every channel??
    3). If i have the calibrated OFC and FSC values, can i use these values to directly write into these registers instead of re-calibrating again
    with ground and 5v?

    4). How does the buffer enable in the ADS1256 help us? what is effect of buffer on ADC reading when it is enabled?

    5). I need to know the procedure to detect the sensor connected to the channel for the first time and then start reading the sensor.
    Basically need to know how to handle the sensor detect current source to detect the sensors.


    Thanks&Regards,
    Harsha B S
  • Hi Harsha,

    Your welcome! Regarding your multiplexing procedure, the sequence looks correct; just remember to wait for /DRDY to go low before repeating step 1. And regarding your additional questions...

    1) I'm not 100% sure if it is necessary, but issuing it will make the ADC switch channels faster.

    2) Yes, they look correct from what you've described.

    3) Yes, you can save the calibration coefficients and recall them again later. [6/20 UPDATE]: This is especially useful if you need to calibrate each channel separately.

    4) The buffer increases the ADC's input impedance. If your sensor does not have a low-output impedance, then the buffer may be necessary to prevent loading.

    5) To detect the presence of the sensor, you would follow a similar procedure as you have for multiplexing through the ADC channels, but for one (or more) of these channels you would enable the sensor detect current sources and measure the input voltage. If the voltage measurement is around ~5V or close to ~0V it can indicate that there is an open or short circuit, respectively.

    Please note, that when trying to measure the actual sensor voltage, you need to disable the sensor detect current sources to get the best measurement accuracy.

    I hope that helps,
    Chris

  • hi Christopher,

    Thanks for your reply.

    Today i tested with the sensor detect feature of ADS1256. I tested this by enabling the 0.5uA current source.
    While testing i selected single ended mode and tested with all the channels.

    when ADC channel is open , i read ADC value around 2161753 decimal.
    when ADC channel is shorted that means Psel and Nsel are shorted, i read 16772893 decimal. This is full scale value and enough to identify.

    Here, i can easily differentiate the 'short circuit' but 'open circuit' is little difficult is identify.
    This is because of the values are colliding when i connected the sensor which is providing the same voltage as that during the open circuit condition. Open circuit condition value is not zero. These are not same as you said "If the voltage measurement is around ~5V or close to ~0V it can indicate that there is an open or short circuit, respectively." but its inverted in my case. Please let me know anything is missing in our understanding.



    Thanks&Regards,
    Harsha B S
  • Hi Harsha,

    I'm sorry, I was in a hurry to get you a reply yesterday and I was incorrect about the OPEN-CIRCUIT voltage...Because there is a 3V clamp that gets enabled, the open circuit voltage should be closer to 3V (not 5V, as I stated above).

    I did a quick test on the ADS1256EVM-PDK and for the OPEN-CIRCUIT voltage, with the 0.5 uA SDCS  enabled, I measure about 2.71 V when the inputs are floating, as shown below:

    In your OPEN-CIRCUIT case, you appear to be measuring a voltage of 1.28 V, is that correct? This would correspond to an effective impedance of about 2.5 MOhms connected to the inputs. Perhaps, with the sensor disconnected you still have this weak conductance path between the inputs? Do be sure to clean your PCB, if you haven't as solder flux residue can be responsible for this conductance.

    NOTE: If I increase the SDCS to 2 or 10 uA, then I measure a voltage slightly greater than 3V. You might also try increasing the SDCS currents to 2 or 10 uA to increase the measured voltage when the inputs are OPEN. However, do make sure that when your sensor is connected that you still measure a voltage well below 3V with these higher currents, so as not to mistake a connected sensor for an open-circuit.

    Best regards,
    Chris

  • Hi Christopher,

    I have used ADS1256 development board by wave share. In this board a RC circuit is connected to each ADC pin . RC circuit is having the values of 1kohm resistance and 0.1uF capacitance. The measured open circuit voltage seems to be approximately 640 millivolts . Its not around 3 Volts. I checked with the 2uA and 10uA current source also but its not around 3V. For 10uA we get around 4.4 volts and for 2uA we get around   2.4 Volts during open circuit condition.

    Theoretically we should read '0' ADC value when it is short circuited but i'm getting full scale ADC value as i mentioned yesterday. why this full scale voltage is been read by the ADC when it is short circuited ?

    In my application if i want to check for the sensor integration periodically then  how can i make sure that the sensor output voltage is within 3 Volts limit? I think its not possible to implement this feature practically with 5v analog sensors. Am i correct???

    Please find the details of measurements in the below table. 

    0.5uA SDCS

    2uA SDCS

    10uA SDCS

    ADC Value

    CRO Voltage

    ADC Value

    CRO Voltage

    ADC Value

    CRO Voltage

    Open Circuit

    1103365

    624mV

    4209867

    2.3V

    6966209

    4.4V

    Short Circuit

    16772508

    0V

    16775703

    0V

    15413

    0V

    Shorted with 33k Resistor

    32702

    24mV

    143194

    80mV

    731592

    400mV

    Thanks&Regards,

    Harsha B S

  • Hi Harsha,

    The large decimal values you are reading are actually negative numbers. For example "16772508" (decimal) is "FFED9C" (hex), which actually represents "-4708" when you sign-extend the 24-bit ADC code. When I convert your decimal codes into resistance values I get the following results...

    Overall, the results seem okay with perhaps some offset voltages affecting the shorted-input case...

    How do you have the OFC[2:0] registers configured when measuring the shorted-inputs? Make sure you that you either reset them to their default values, or else make sure the calibration coefficients are correct for those channels (for example, if you correct for a large offset on another channel and don't reprogram these registers for this channel you would get a large offset error).

    For reference, when I measure the short-circuited inputs on the ADS1256EVM-PDK, I get  results of about -270 Ohms @ 0.5 uA, -95 Ohms @ 2 uA, and -20 Ohms @ 10 uA.

    The error with the open-circuit case @ 10 uA is likely due to the input voltage clamping, otherwise 10 uA * 1.2 MOhm would be 12V. I still think with the inputs open there might be a leakage path for the current (with an approximate resistance of 1.2 MOhm). Are their any other components (other than the RC filters) on the ADC inputs that might account for this?

    Best regards,
    Chris

  • Hi Christopher,

    Thank you for your reply.

    Yes. I wasn't considering that the ADC output is in 2's compliment form. Now i rectified this conversion process. It would be more helpful for me if you provide an efficient conversion code patch which i can implement to convert ADC bytes into voltage/integer value. 

    I have checked the schematics of the ADC development board and found that only RC circuit is connected to the inputs. (1 K ohm & 0.1uF)

    Newer measurement values are tabulated below.

    0.5uA SDCS

    2uA SDCS

    10uA SDCS

    ADC Value

    Voltage

    ADC Value

    Voltage

    ADC Value

    Voltage

    Open Circuit

    4892259

    2916mV

    6125239

    3650.9242mV

    7058076

    4206.93mV

    Short Circuit

    -4704

    -2.803V

    -1562

    -0.9310mV

    15339

    +9.142mV

    Shorted with 33k Resistor

    34262

    +20.42mV

    147885

    +88.1462mV

    756079

    +450.658mV

    These are the calibration coefficients.  I do perform self calibration after every reset. These values remains almost same (1 or 2 decimal changes)

    OFC0 : 160 Decimal

    OFC1: 253 Decimal

    OFC2: 255 Decimal

    FSC0: 025 Decimal

    FSC1: 167 Decimal

    FSC2: 073 Decimal

    "if you correct for a large offset on another channel and don't reprogram these registers for this channel you would get a large offset error"

    I did not understand what you had mentioned. Please explain this . Do we need to perform calibration for every channel? 

    Thanks&Regards,

    Harsha B S

  • Hi Harsha,

    Harsha B S said:
    It would be more helpful for me if you provide an efficient conversion code patch which i can implement to convert ADC bytes into voltage/integer value. 

    I wrote a blog with some example code explaining how to the sign-extension in C. You can find it here: https://e2e.ti.com/blogs_/archives/b/precisionhub/archive/2016/04/01/it-s-in-the-math-how-to-convert-adc-code-to-a-voltage-part-1

    Since then, I still use this same method but I prefer to write the code more like the example below, as I believe this is a bit cleaner and less prone to errors...

    // Copyright (c) 2018 Texas Instruments Incorporated
    
    // Example read data function
    int32_t readData()
    {
    	uint8_t ADC_data[3];
    
    	// INSERT SPI COMMUNICATION HERE
    	// Collect data in ADC_data array
    	// where ADC_data[0] holds the MSB
    	// and ADC_data[2] holds the LSB
    
    	/* Return the 32-bit sign-extended conversion result */
    	int32_t signByte;
    	if (ADC_data[0] & 0x80u)	{ signByte = 0xFF000000; }
    	else						{ signByte = 0x00000000; }
    
    	int32_t upperByte	= ((int32_t) ADC_data[0] & 0xFF) << 16;
    	int32_t middleByte	= ((int32_t) ADC_data[1] & 0xFF) << 8;
    	int32_t lowerByte	= ((int32_t) ADC_data[2] & 0xFF) << 0;
    
    	return (signByte | upperByte | middleByte | lowerByte);
    }

    NOTE: This code snippet is taken out of the example code found at http://www.ti.com/product/ADS1261/toolssoftware

    Harsha B S said:
    I have checked the schematics of the ADC development board and found that only RC circuit is connected to the inputs. (1 K ohm & 0.1uF)

    OK. I don't think it is too big of an issue that your open circuit impedance is only 1.2 MOhms, especially since I only measure 5 MOhms on the EVM. However, if you want to be sure, you might try removing the capacitors and cleaning the PCB to double check that there isn't a parasitic leakage path.

    Harsha B S said:

    "if you correct for a large offset on another channel and don't reprogram these registers for this channel you would get a large offset error"

    I did not understand what you had mentioned. Please explain this . Do we need to perform calibration for every channel? 

    For best performance, yes, you would want to perform system calibration on every channel. Every channel is likely to have a unique offset and gain error, especially when you consider external effects from signal conditioning or filtering.

    However, if you are only performing self-calibration, then this probably not necessary. Self-calibration removes the majority of ADC errors (and only ADC errors), and so the calibration coefficients will likely be very similar for each channel.

    Best regards,
    Chris

  • hi Christopher,

    Thanks for your reply.

    May i know how exactly offset and full scale register values affect the ADC reading value? 

    could please explain with an example ? or could you guide me where i can get these details ?

    For example, If the input voltage is 10mV and based on these register values how the ADC reading will be changing.

    Thanks & Regards,

    Harsha B S

  • Hi Harsha,

    Check out the ADS1255-7 Design Calculator found on the "Tools & Software" tab on the ADS1256 product page and see if that helps. There is a "Calibration" tab that that show how to convert the OFC[2:0] and FSC[2:0] register values to "V" and "V/V" units.

    Best regards,
    Chris