ADS1230 (strain gauge amplifier) with Arduino

Greetings all,

Well, my project is to read data from a strain gauge using programmable gain amplifier ( chip: ADS1230) Then I will be reading the converted data from the ADS1230 using Arduino.. I believe to answer this question you should probably have some experience in using ADS chips.. if not, I am posting the code any way:

so, it is my first time to use ADS1230.. I followed the datasheet of ADS1230 and did what is required but still not getting the proper results.

The datasheet is in the attachment..

I am using a 300kg , 2mV/V output, Gain 64, 10SPS speed load cell

The code I am using is:

// this program is to test the ADS1230 using arduino only
int cal=1;
double power[20]={1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288};
void setup() {
  Serial.begin(9600);
  pinMode(2, INPUT);
  pinMode(4, INPUT);
  pinMode(5, OUTPUT);
  pinMode(8,OUTPUT);
  pinMode(1,OUTPUT);
  digitalWrite(8,LOW);
  
}

void loop() {
  double force=0;
  int values[20];
  
 // start callibration 
 while (cal == 1)
  {
    Serial.println("start callibration");
    for( int c=0 ; c<26 ; c++)
    {
      digitalWrite(5,HIGH); // the rising edge of the serial clock
      delayMicroseconds(0.1);  
      digitalWrite(5,LOW);  //falling edge of SCLK
      delayMicroseconds(0.1);
    }
    delay(801.03); // t(callibration)
      if (digitalRead(4) == 0)// checking the output pin from the ADS1230
      {
            
        cal++;
      }
  }
        
        // reading the data
        for (int i(0) ; i<20 ; i++) // applying the serial clock (SCLK)
        {
          digitalWrite(5,HIGH); // the rising edge of the serial clock
          delayMicroseconds(0.1);
          pinMode(4,INPUT);
          values[i] = digitalRead(4);// reading from  the output pin
          Serial.print(values[i]);
          // delayMicroseconds(0.001);  
          digitalWrite(5,LOW);  //falling edge of SCLK
          delayMicroseconds(0.1);
     
        }
        // applying additional 4 clocks
         for (int f=0 ; f<4; f++) 
        {
          digitalWrite(5,HIGH); // the rising edge of the serial clock
          delayMicroseconds(0.1);
          if (digitalRead(4) != 1)
         {
          Serial.println("error: the output pin is not 1");
         } 
          digitalWrite(5,LOW);  //falling edge of SCLK
          delayMicroseconds(0.1);
        }
        
        
      
      

    // converting the array values to decimal.
    for (int j(0); j<20; j++)
    {
      force = force + values[19-j]*power[j]; //(values[19-j]*pow(2,j));
          
    }// end conversion
    
     Serial.println(force); // print value..
     
     while(digitalRead(4) != 1)
     {
       //do nothing
       delayMicroseconds(1);
     }

 
}

Am I right??

ads1230.pdf (604 KB)

ads1230.pdf (604 KB)

Am I right??

Well, no.

First, you posted your code wrong. You need to modify your post, delete the code, select the # button, and then re-post your code.

Then, you need to read the reference documentation on some of the functions you are using. There will be a quiz later.

delay(801.03); // t(callibration)

So, now, what is wrong with this code? The delay function takes what kind of argument?

  Serial.begin(9600);
  pinMode(1,OUTPUT);

Which pins are used by the Hardware Serial port? Hint: Pin 1 is one of them.

          delayMicroseconds(0.1);

What kind of argument does delayMicroseconds take?

          delayMicroseconds(0.1);
          if (digitalRead(4) != 1)
         {
          Serial.println("error: the output pin is not 1");
         }

Delay a very small amount of time, then a whole bunch of time while shifting out the serial data. Works for me...Not.

          Serial.print(values);

Serial data transmission is ssslllooowww. Doing so in the middle of time-critical code is not a good idea.

     while(digitalRead(4) != 1)
     {
       //do nothing
       delayMicroseconds(1);
     }

Pssst. Calling delayMicroseconds is NOT doing nothing. It is also not necessary.

Thanks for your notes .. and you are probably right .. but I did not really right the code from my mind .. as I said I followed the datasheet of the ADS1230 .. and it requires to do some of the things u noted if not all..

Those things does critically affect the job the code is doing ..

Well ,, thank you for your observations .. but my question is Am I right using this code FOR this chip??

Why is "force" a floating-point variable?
Wouldn't a "long" be simpler?

double power[20]={1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288};

Digital computers (like the Arduino) are really good at this sort of thing; you don't have to be.

Some nice names for the pins would be useful - you may know what they're wired to, but we don't

I followed the datasheet of ADS1230 and did what is required but still not getting the proper results.

"It doesn't work" is not really conducive to getting good answers. "I expected xxx, but I got yyy, when I did zzz" is much better.

Then, we can tell you whether zzz was the right thing to do, and, if so, whether xxx or yyy was the correct result. The problem could be that you are expecting yyy, but should be expecting xxx, or it could be that the code should indeed have returned xxx, and needs some tweaks to get there.

But, without defining what xxx, yyy, and zzz are, we are just guessing as to what your problem is, and what the solution is.

my question is Am I right using this code FOR this chip??

A link to the data sheet for the chip in question would be useful. Otherwise, more guessing.

Clearly, there are problems with that code. In fact, there is a thread going on now that describes the unexpected/incorrect behavior of delayMicroseconds when called with a value of less than 3. You are calling it with a value of 0.1, which, as an int, is 0. That is wrong.

You are using one of the HardwareSerial port pins for two different functions. That will NOT work.

On the basis of just these two issues, I would have to say that no, that is not the right code for this chip. Whether the code can be fixed to work with the chip, or not, depends on what the data sheet says about the chip.

Those things does critically affect the job the code is doing ..

If the chip requires toggling the pin at a rate faster than the Arduino can toggle it, you won't be able to use that chip. Again, we need to see the data sheet for the chip.

If you read the datasheet carefully, you'll see that the timing is NOT as critical as you seem to think it is; there is, for instance, a minimum length for tsclk, but no maximum.

PaulS:

I followed the datasheet of ADS1230 and did what is required but still not getting the proper results.

"It doesn't work" is not really conducive to getting good answers. "I expected xxx, but I got yyy, when I did zzz" is much better.

Then, we can tell you whether zzz was the right thing to do, and, if so, whether xxx or yyy was the correct result. The problem could be that you are expecting yyy, but should be expecting xxx, or it could be that the code should indeed have returned xxx, and needs some tweaks to get there.

But, without defining what xxx, yyy, and zzz are, we are just guessing as to what your problem is, and what the solution is.

my question is Am I right using this code FOR this chip??

A link to the data sheet for the chip in question would be useful. Otherwise, more guessing.

Clearly, there are problems with that code. In fact, there is a thread going on now that describes the unexpected/incorrect behavior of delayMicroseconds when called with a value of less than 3. You are calling it with a value of 0.1, which, as an int, is 0. That is wrong.

You are using one of the HardwareSerial port pins for two different functions. That will NOT work.

On the basis of just these two issues, I would have to say that no, that is not the right code for this chip. Whether the code can be fixed to work with the chip, or not, depends on what the data sheet says about the chip.

Those things does critically affect the job the code is doing ..

If the chip requires toggling the pin at a rate faster than the Arduino can toggle it, you won't be able to use that chip. Again, we need to see the data sheet for the chip.

Well ,, I attachd the datasheet on the original post .. I did not say it did not work.. I did not get the proper results..

Well ,, I attachd the datasheet on the original post .

Attachments are not visible when replying, for some reason.

I did not say it did not work.. I did not get the proper results..

You didn't define what you expected. You did not define what you did get. You did not define how the chip is connected to the Arduino. So, I still think you are missing a few things.

Well , Sorry for that .. I assumed that someone who has used the ADS1230 would answer without me providing the connection diagram ... but I will do that today .. Al though If you see the datasheet you will se an example which is the same as my project..

In short :

the objective of the chip is to convert the output of a strain gauge into digital .. but how? Well, the chip is a 20 bit output resolution.. in order to get those 20 bits( the converted analog signal) we have to apply a serial clock to SCLK pin on the chip in order to shift out the data bit by bit MSB first .. In order to start reading from the output pin of the ADS1230 we have to wait untill it goes low ( that means new data are ready) .. and my specific problem is that the output pin never goes low in order to read data from it!!! .. so my strong guess that it could be the code thats why I need your help guys...

You haven't even told us how you have it wired - we can infer that pin 5 is SCLK, and the pin 4 is DOUT.
How is /PDWN connected?

You are right ... I will add the wiring today ... PDOWN is used to reset the converter .. so I guessed I woudnt need it? or I would?

only those three pins can be connected to the arduino..

Hello this is Harshad,
Did you have any luck in getting the output our of ADS1230. I am also currently working on the same project.
It would be nice if you could share your tips on the same.
Regards