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)