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.

Only getting negative values in ADS1231

Other Parts Discussed in Thread: ADS1231

Hi guys,

 

I'm using the ADS1231 for a school project that will collect data from a sensor and then send it wirelessly to a phone. The ADS1231 interfaces with the EZ430 RF2560. I have almost everything working except the ADS1231 values are incorrect. They seem to be for the most part negative. When I tested it at my school's lab, I got negative values going to I think -10mV when I inputted a 20mV sine wave at 5 Hz. I don't have access to my school's lab over the weekend and I unfortunately forgot to take pictures at the lab when I was testing, but I know that I was getting an SCLK signal and DRDY/DOUT signal on the oscope. 

Now, I'm testing at home so I don't have a function generator or an oscope. I have my Ainn and Ainp connected to nothing so it just reads noise but it seems all the data is negative. Here is my setup at home. I'm using 2 double AA's for my AVDD & DVDD so I'm inputting approximately 3V. This also goes to my Vrefp. I had my MSP430 interfacing with the ADS1231 via SPI with an SCLK freq of 1MHz (I also tried 4 MHz). I've ran my MSP430 through a debugger and I know that it reaches all the correct initializations and I've used LED's as well to verify it. However, I do get a positive value when I place a AAA battery across the Ain's. I get  7FFFFFh and when I flip the polarity of the AAA battery, I get  800000h which corresponds to the given values in the data sheet for the ADS1231: http://focus.ti.com/lit/ds/symlink/ads1231.pdf . 

 

This is the function that's called when DRDY is low (using a polling method to collect data):

void halADCRead(unsigned char *coord)

{

int data3;

    UCB0CTL1 |= UCSWRST;       // Put I2C state machine in reset to set SA

    UCB0CTL1 &= ~UCSWRST;      // Start I2C state machine

    

   if(UCB0CTL0 == UCMSB + UCMST + UCSYNC)

      P1OUT ^= LED_2;


  while (!(UCB0IFG&UCTXIFG));            // USCI_B0 TX buffer ready?

   UCB0TXBUF = 0x00;                       // Dummy write to start SPI

   while (!(UCB0IFG&UCRXIFG));            // USCI_B0 TX buffer ready?

    *(coord + 0) = UCB0RXBUF;                      // R15 = 00|MSB

     if(UCB0RXBUF < 128)

        P1OUT ^= LED_1;

    

  while (!(UCB0IFG&UCTXIFG));            // USCI_B0 TX buffer ready?

   UCB0TXBUF = 0x00;

   while (!(UCB0IFG&UCRXIFG));            // USCI_B0 TX buffer ready? 

    *(coord + 1) = UCB0RXBUF;

    

  while (!(UCB0IFG&UCTXIFG));            // USCI_B0 TX buffer ready?

   UCB0TXBUF = 0x00;

   while (!(UCB0IFG&UCRXIFG));            // USCI_B0 TX buffer ready?  

   *(coord + 2) = UCB0RXBUF;


   UCB0TXBUF = 0x00;

   while (!(UCB0IFG&UCRXIFG));            // reading a 4th byte so that the DRDY goes high  

   data3 = UCB0RXBUF;     


 

As you can see, I've used LED's to try and debug this.... LED1 never lights indicating I never get a positive value and LED2 always toggles indicating my SPI is setup correctly. One more thing, my VREFP wire fell off during the middle of my testing and I noticed that my results didn't really change. Does this behavior seem correct?

Other details on how I set up my ADS1231 (besides the ~3v for my AVDD, DVDD, and Vrefp): A cap is placed across DVDD and gnd to prevent noise; a cap is placed across AVDD and gnd to prevent noise. CLKIN is grounded. A cap is placed across the specified CAP pins. PWDN is held high. PSW is connected to nothing (I did try putting ground on this but nothing changed in my results). SCLK is tied to its respective pin on the MSP430. DRDY/DOUT is connected to two pins on the MSP430 (one is selected as the SOMI and the other is just input pin checking whether DRDY is low).

 

Can someone explain why I'm only getting negative readings? Appreciate any help. I've attached pictures of my ADC readings of noise(so nothing between AINN and AINP)  that I streamed from my computer.

  • Hi Wesley,

    If you're getting 7FFFFFh with your AAA battery positive polarity, and 800000h with a negative polarity it would seem that you're capable of getting positive and negative voltage swings on your data converter at home, the trouble is it doesn't show much in the way of resolution. I think the nominal voltage of a AAA battery is around 1.5 V, assuming VREFN is GND with your AA supplying VREFP should give your a reference around 3.0 V so you're railing the converter pretty hard since full scale for this converter is 0.5Vref/128.

    If your VREFP connection was disconnected during testing it's hard to say what you could expect to see. You would have had a free floating reference voltage for your ADC which is just going to produce unpredictable, unreliable results. If you couldn't tell any difference in your data when your reference was connected or wasn't connected, that would seem to indicate you have a very noisy system. Is this on a PCB? Milled Copper Board? What are you using do supply your reference voltage at the lab?

  • Thanks Kevin for the reply.

     

    The ADC is placed on a PCB bought from Radioshack and I used a DC power supply outputting 3.3V(verified with a DMM) to provide my reference voltage at the labs. I use the 3.3V to power my AVDD and DVDD as well at the labs. I was planning on going to the labs today and feeding a square wave into my ADC to check the values I get. Is there anything I can do to limit the noise?

  • Can you post a schematic with notes of what inputs you're applying and from what source at the lab? That will help understand precisely what you've got built up now. When you say PCB from Radioshack do you mean a breadboard? Perfboard? Or one of those general purpose SOIC boards?

  • Wesley,

    Note the following from the ADS1231 datasheet:

     

    So at 3V your input needs to be exactly at the common-mode point, which is 1.5V from the rails.  This really gives you no range for error.  Second issue is your input signal is 20mV which is outside the range of 11.7mV peak.  So to be able to read your signal with a function generator, it needs to be offset 1.5V from ground, and the maximum input can only be 11.7mV peak.

    Best regards,

    Bob B

  • Wesley,

    In addition to what we've already offered you, a coworker and I noticed some other observations that you may find useful. From looking at the code snippet you posted, you're giving the device 32 SPI clock cycles. When you issue a fourth cycle of 8 clocks to toggle DRDY, the data you collect seems to get appended to your "result data" numbers in the attachment you posted (noise.png). What you've called "packet 3 data" should not be included in your resulting data.

    Additionally, I'm not exactly sure what will happen if you continue issuing that many extra clock cycles, maybe Bob has some more experience with this device in particular. Once you've issued the 25th clock cycle, you still issue the device another 7 clocks afterwards. This is mildly concerning because your 25th SPI clock should move DRDY/DOUT high, so the data you store in "packet 3 data" should read FF each time. The data in "packet 3 data" reads 255 most times, but I see a few 127, 63, 31, etc. that have me a little worried. Maybe go back and check your SPI polarity/phase or issue only one more clock cycle through a GPIO or something. Again, hopefully Bob can give us some insight on what happens if you issue more clocks, it could be a moot point.

  • Wesley,

    Just to fill in the blanks for Kevin and whoever else might read this post, due to the construction of the MSP430 peripheral, a fourth series of clocks are needed to force the DOUT/DRDY pin high when polling the DRDY/DOUT pin for new data.  The ADS1231 has no problem receiving the extra clock cycles as long as the clocks appear before the next conversion result is posted to the output register.

    As Kevin mentioned, the fourth series of SCLKs will post invalid data to the RX buffer of the MSP430, and that data should be ignored.

    Best regards,

    Bob B

  • Thanks Kevin and Bob,

     

    For Kevin's post: I actually don't do anything with data3. I read it but I don't do anything else with it. Here is my code that packs the data into their packets.

        firstBuffer = *(adc + 0);
        secondBuffer = *(adc + 1);
        thirdBuffer = *(adc + 2);    
        sign = (firstBuffer&0x80)?0xff:0;         //sign extension

     

    Where packet[0] is sign and packet [3] is thirdBuffer. Bob actually helped me write this part of the code...so I think it should be fine. If you were still wondering about my PCB, here is the PCB used: http://www.radioshack.com/product/index.jsp?productId=2103799. I don't have a sch on me unfortunately.

     

    For Bob's post. I thought about that. But I'm not sure because then when I put a AAA battery across the AIN's shouldn't it read zero? Since I'm putting about 1.5 V across AIN? It steadily reads the maximum positive value for the ADC so 7FFFFFh.  Anyway, I'm going to head to the lab later and try what you said.

    Thanks for the advice!

  • Wesley,

    With the battery "across the AINs" you're still not in the common-mode range for the device. AIN Negative has GND or a floating voltage from the battery and AIN Positive has 1.5 Volts from the battery. For the common mode range you'd need to apply a 1.5 V offset on your negative terminal as well to read "in theory" 0 from the converter, the battery is probably not outputting exactly 1.5 V. Right now your common mode voltage is floating where-ever the negative terminal of the AAA is.

  • Hi,

    Regarding the code for sign-extend  cptr[3]=(cptr[2]&0x80)?0xff:0x00;  I have some doubts.

    It fullfills cptr[3] with 1s if bit 8 of cptr[2] is 1 (negative value). Is this correct?  Shouldn't we insert a 1 only at bit 31?

    Best regards,

    Theo

  • Hi and sorry for my silly question.

    Thats the way 2s complement work.

    Best regards,

    Theo