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.

Starting with the ADS1232

Other Parts Discussed in Thread: ADS1232

Hello,
I'm starting to use the ads1232. I will use for college work. I want to make a simple digital scale. I'm still not very good at programming and I am in doubt if I'm reading the data correctly. put down the way I'm doing the reading. This form is correct? would have otherwise? I'm using a pic of the family 18f

long read (void) {

   Long result = 0;
   long b;


   b = SPI1_Read (0xff) / / B3
   result = b << 8;
   b = SPI1_Read (0xff) / / B2
   result | = b;
   result = result << 8;
   b = SPI1_Read (0xff) / / B1
   result | = b;
   result = result << 8;
   b = SPI1_Read (0xff) / / B0
   result | = b;


   return (result);
}

  • Hi Joao,

    The output of the ADS1232 is a 24 bit result and you are reading 32 bits.  The confusion may be in what to do with the extra byte of 'result'. You should read B2 through B0. As the output of the ADS1232 is a signed value (binary two's complement), you don't need to make any changes if the output value is positive (up to 0x7FFFFF).  However, if the value is negative you will need to sign extend the sign bit through the B3 byte.  So, if the most significant bit is 1 (0x800000 through 0xFFFFFF) then B3 must also be 0xFF.

    Best regards,

    Bob B

  • Hi Bob,
    For now I'll use so it's working, I did the conversions to take weight measurements. But I'm with another problem often negative numbers appear in the display (I'm using a 16x2 lcd) are ranging between weighing and correct these negative numbers. How could I solve this? It is a read error or a problem in sync? I am using SPI communication

  • Hi Joao,

    It is hard for me to tell as you haven't given me enough information.  You may acutally be seeing a negative code.  Values close to 0 may go negative due to noise.  Send me the exact conditions you are using to measure the result and the code values you are seeing.

    Another problem may be due to when you are reading the data.  If a conversion update happens at the same time your are trying to read the result you may get corrupted data.  This may appear as large jumps in the result.  You should not see this problem with an interrupt driven system where DRDY/DOUT transitions from high to low signaling a conversion has completed.  If you use a polling method, you must make sure you have plenty of time to retrieve the data and that something else in your program loop does not interfere.

    Best regards,

    Bob B