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.

ADS1282 Programming

Other Parts Discussed in Thread: ADS1282, ADCPRO, REF5025-HT

Hi,

I am trying to communicate with ADS1282(ADC) via SPI. I am not able to write or read registers. Is there any sample code on how to write and read this ADC. It would be really helpful for me. I am using SM470R1B1M controller.

I have gone through data sheet and implemented code based on it but not able to succeed. 

If anyone using this ADC please let me know. any suggestions.

Regards,

Pavan.

  • Pavan,


    There isn't much sample code available. However, there was some firmware written for the ADCPro plug-in.

    Go to the following E2E post:

    e2e.ti.com/.../1352533

    and copy the given ftp site. Then remove Plugins/ads1282-adcproplugin-2.0.0.exe and replace that with ADCPro2/Source/ and you can find more info on the ADS1282.

    I don't know how much what you find will help you because most of this is pretty specialized.

    At this point, are you able to get any communications going? Can you get out SCLK and DIN? Does DOUT respond? Really, you'll need an oscilloscope or logic analyzer to determine if your micro is putting out any control signals or receiving anything. If you can, post a scope photo or a logic analyzer output to help with debugging.


    Joseph Wu
  • Hi Joseph,

    Thanks for quick reply,

    I managed to write and read data from ADS1282.

    I have checked CLK and SCLK pins both seems ok. I am providing 3.75MHz on CLk pin and SCLK is 750KHz.  Attached images of oscilloscope Yellow is SCLK, Blue is DOUT. 

    I have powered up and running at default settings. It means "Read Data Continuous mode". I don't need to send any commands to read data (according to data sheet). I means gain=1, 1000sps, PGA chope enabled.

    I am receiving data from ADC but i am not able to understand this data is correct or not? 

    I am receiving data like

    9769642 = 9512AA, 15161788 = E759BC, 13117080 = E759BC, 16655786 =FE25AA, 17452124 = 10A4C5C, 14908740=E37D44, 18463082 =119B96A e.t.c

    My reference voltage is 0 to 2.5V.

    How to convert this data into intpu voltage? I would like to know this data is correct or not?

    It seems i am not able see repeated data because I am not changing input to ADC at AINP1&AINN1. 

    Regards,

    Pavan.

  • Pavan,


    It looks like your data is a bit noisy. Are you using the FIR filter or Sinc filter? What do you have as an input that gives you that data? What are you using as your reference voltage (not the voltage itself, but what device are you using as the reference?

    Generally, I like to start by shorting the inputs to something that is mid supply. With that as an input, you can generally expect 0 output.

    The data format of the ADS1282 is given on page 26 of the datasheet. It is 32 bits in binary twos complement, but the LSB is a redundant sign bit. Read through Table 14 to get some examples of the conversion.

    Going back to the data you took, the scope photos of the SPI transaction look moderately clean, but the data you get back is a bit noisy. Assuming that you are using the FIR filter, and that the reference is 2.5V (giving an input full scale range of +/-1.25V), you can make the conversion:

    9769642 => (9769642/2)*1.25/2^30 = 5.687mV
    15161788 => (15161788/2)*1.25/2^30 = 8.825mV
    13117080 => (13117080/2)*1.25/2^30 = 7.635mV
    etc.

    You should check my conversion. It's been a long time since I've looked at the ADS1282, and the formula is different than most of the other data converters that I usually work on.

    I start with the divide by 2 to remove the redundant sign bit. Multiply by my full scale range which is the +/-VREF/2 and then divide by 2^30 which is the number of bits in the positive full scale range.

    I'm not sure what your noise is coming from, but going back to my questions at the start, what are you measuring? You need to ensure that both the input and the reference are both low noise to take advantage of the precision measurment.


    Joseph Wu
  • Hi Joseph,

    I am using REF5025-HT as 2.5V reference source. As well the reference voltage is  VREF+ =2.5V , VREF-=0V.

    I have connected some sensors as input values to ADC, sensors output values are very low in voltage nV to mV range. 

    Now i changed my configuration with PGA (64) factor and data rate to 250SPS. I am using Sinc + LPF filter blocks as well.

    I am able to read almost constant values in each iteration compared to yesterday.

    I am reading values almost around 4233865853 ; according formula (4233865853/2)*1.25/2^30 = 2.33mV.  

    1) In the conversion calculation you used 1.25V, we need to use -1.25 to +1.25 V even when we apply reference voltage 0 to 2.5V. 

    2) need to change conversion formula when we change PGA.

    I have checked today the clock and DOUT images it seems less noisy than yesterday. 

    Any suggestion to get better noise performance.

    Regards,

    Pavan.

  • Pavan,


    I'm glad you were able to get better results.

    1. The converter will be able to measure from negative result (when AINN is higher than AINP, and when they are still within the input range of the device). The data is arranged in twos complement notation and it will report negative results, even when you apply a 0 to 2.5V reference.

    2. With the PGA=64, the conversion is the same, except that you divide the reference by 64. With a reference of 2.5V, the positive full scale input is 1.25V and you divide that by 64 to get about 19.53mV as a positive full scale.

    As for improving the noise performance, there are lots of ways to improve the performance. Adding filtering may help. The noise that you read may come from either the input or reference and it's important that they both have low noise if you want the ADC reading to be low in noise as well. Another problem may be layout. It's important to keep wires short so that they don't create loops that can pick up EMI. You also want to make sure that you route power and ground planes to help shield signal paths to protect from EMI. Also, you want to route analog and digital return paths away from the ADC so that the digital ground bounce doesn't couple into the device. I would try to keep the inputs minimal and not add a lot of extra circuitry to the signal path. The power supplies must also be clean, so that you don't rely on the power supply rejection to clean up noisy supplies.

    These are just a few generic suggestions to help improve the noise performance. I just listed off a few here that might help.


    Joseph Wu
  • Hi Joseph,

    Thanks for everything, I will check where the noise coming from.

    Regards,

    Pavan.

  • Hi joseph,

    I have some more questions about this ADS1282, I don't want to start new thread so i am asking here itself. I am trying to read from two channels simultaniously and i have configured the ADC configure register like that.

    I have 0V as the diffrential voltage at channel one inputs AINP1+, AINP1-. I am getting a reading arround 37000(0x9088) to 43000(0xA7F8). Its not giving constant readings, any idea? I am using PGA =2, 250SPS, Sinc + LPF filter blocks. I am not getting readings as 0.

    I have 70mV as the diffrential voltage at channel one inputs AINP2+, AINP2-. I am getting a reading arround 5000(0x1388) to 9000(0x2328). Its not giving constant readings either,using the same settings. for 70mV i am getting less reading values than 0V input. when i convert these reading values to voltage it almost nothing. I am able to see using multimeter that i have constant 70mV at channel2.

    I am giving FCLK as 7.5MHz, will it be ok to give that much FCLK?

    Regards,
    Pavan.
  • Hi Pavan,

    I'll be happy to help you with this issue...

    The maximum fCLK frequency specified in the datasheet is 4.096 MHz. Above that, you may get poor performance or the device may not function at all. Typically, I've seen people get away with overclocking the ADC by about 10% (even though performance is no longer guaranteed in this condition); however, I'd expect that overclocking it by 80% would certainly have some consequences.

    First, try reducing fclk back into the 1-4.096 MHz range and collect data again to see if the results make more sense. (Note that the SCLK frequency must be in the range of 1/2 to 1/16 of the fCLK frequency.)

    If you need a faster data rate, you'll need to configure it with the DR[2:0] bits in the CONFIG0 register.

    If you find that the 0V input is not quite resulting in output codes near 0x00000000 or 0xFFFFFFFF, then you may need to perform offset calibration to improve the result.

    Best Regards,
    Chris

  • Hi Christopher HAll,

    Thanks for your reply,

    I was trying as you suggested. I changed my design little bit and working on 3.75MHz FCLK as i can't get exactly 4MHz with my controller. SPI clk SCLK is 1.875MHz. I have 0 to 5V reference.

    I have PGA=2, 1000SPS,linear pahse, SINC+LPF filters. (CONFIG0=0x52).

    On chaneel one inputs (AINP1+, AINN1- )I have diffrential voltage of 0V (2.6-2.6). I am reading a value via SPI = 4278223117 (0xFF00810D). when i look at Oscilloscope code value it is like this 4294939449 =0xFFFF9339.this is near to FFFFFFFF.  have a look at oscilloscope image.  can say i am reading correct?

    I don't know why i am not able to read same value as oscillocope. Then i tried on channel two. which is strange for me.

    Channel two intputs(AINP2+, AINN2- ) have diffrential voltage change from 0.217V to 0,223V. I am reading a values

    1694520226 (0x650053A2) ,

    2684409570 (0xA000D6E2),

    3439355800 (0xCD006798) .....

    in between those ranges its changing but when i measure with osclloscope the code values is diffrent than what i am reading. Have a look at oscilloscope images.

    From oscilloscope i am always getting 365744896 (0x15CCD300), 358744806 (0x156202E6), 354225176 (0x151D0C18), 369138436 (0x16009B04)........

    These values are almost near values i am getting always in this range with oscilloscope codes.

    I have some questions

    1) when i use the conversion fromula provided by joseph, the oscilloscope values are also not equal to 0.217 to 0.223 V. Even with readings i have got from SPI also not matching when i use the same fromula from joseph?

    2) I am not understanding why i am getting diffrent values when i read via SPI than oscilloscope code measurements?

    but if i can say i am reading wrong then i am getting near values with channel one (ov input. at that case my spi reading values and oscilloscope code values are nearly matching.

    am i converting wrong or reading wrong?

    My  SPi reading code is like this

    unsigned int ADC1282_16(unsigned char cmd, unsigned int value) 
    { 
        unsigned int data; 
        SW_Delay(DELAY_10US);
        spi(cmd);                   //Place instruction to read
        while (I2C2DIN & 0x0001);
        data = spi(0);     // read hi-byte 
        data = (data << 24)| spi(0);
        data = (data << 16) | spi(0);    
        data = (data << 8) | spi(0);    // and lo-byte
        return data; 
    } 
    
    unsigned int readADC(void)  
      {                 
                              // wait till ADC is ready 
           value = ADC1282_16(0x10, 0);                           // read registe
    //       printf("%d ", value);
           return value;
      } 

    Any suggestions.

    Regards,

    Pavan.

  • Hi Pavan,

    To answer your questions...

    1. I'm getting the correct answer using Joseph's formula: For example (365744896/2)*1.25/2^30 = 0.212 V. This formula first right shifts (i.e. divides by 2) the ADC code to remove the redundant sign bit, then that result is multiplied by the 31-bit LSB size. The LSB size is FSR/2^31 or Vref/2^31 or 1/2*Vref / 2^30 (these are all equivalent).

    2. I think I see the issue in your code...
      pavan said:
          data = spi(0);     // read hi-byte
          data = (data << 24)| spi(0);
          data = (data << 16) | spi(0);   
          data = (data << 8) | spi(0);    // and lo-byte
          return data;


      Here you seem to left-shift the data bytes too many times. I think what you intended to do is this...
          data = spi(0);     // read hi-byte 
          data = (data << 8) | spi(0);
          data = (data << 8) | spi(0);    
          data = (data << 8) | spi(0);    // and lo-byte
          return data; 

      Give that a try and see if you get better results!

    Best Regards,
    Chris

  • Hi Chris,

    Thanks for you reply, I am sorry for late reply because i am out of office.
    With your corrections in the code now i am able to read exactly same value with SPI and oscilloscope.

    I have small doubt with your converstion formula (365744896/2)*1.25/2^30 = 0.212 V or The LSB size is FSR/2^31 or Vref/2^31 or 1/2*Vref / 2^30 (these are all equivalent)..

    I am using reference as 0 to 5V. I was wondering about the formula (365744896/2)*2.5/2^31 = 0.212 V which giving correct result. when i use 0 to 5V reference voltage, my FSR will be -/+2.5 V isn't it? for example my Vref is 0 to 5V then if i use this formula (365744896/2)*Vref/2^31 then it will be wrong (365744896/2)*5/2^31 = 0.406V.

    Regards,
    Pavan.
  • Hi Pavan,

    The full-scale input range is +/- Vref / (2*PGA), so you are correct, with a 5V reference the FSR becomes +/- 2.5V / PGA.

    If you change the reference voltage, than the ADC code will also change. You're using the same code (365744896) in each equation, but if you were to measure the 0.212V signal with the ADC, you would see different results based on the reference voltage..

    For a 1.25V reference (and PGA = 1 V/V), the ADC will output: 379388778
    For a 2.5V reference (and PGA = 1 V/V), the ADC will output: 182106613
    For a 5.V reference (and PGA = 1 V/V), the ADC will output:  91053307


    Best Regards,
    Chris

  • Hi chris,

    Thanks for your reply and help.

    I am using 0 to 5V reference, I am getting ADC output as 351844706 with oscilloscope and SPI reading. with PGA= 2, I am converting it like this (351844706/2)*2.5/2^31= 0.204V, which giving correct result. correct me if i am wrong?

    Thanks for your suggestion and help to solve my issue.

    Regards,

    Pavan.

  • Hi Pavan,

    That is correct!

    Let me know if you have any additional questions.

    Best Regards,
    Chris