Hi
I'am playing with an ADS1231 (
http://www.ti.com/lit/ds/sbas414c/sbas414c.pdf) chip to read a load cell value.
#include <SPI.h>
const int dataReadyPin = 9;
void setup() {
Serial.begin(9600);
SPI.begin();
SPI.setDataMode(SPI_MODE0);
pinMode(dataReadyPin, INPUT);
}
void loop() {
if (digitalRead(dataReadyPin) == LOW) {
unsigned int result1 = 0;
byte inByte = 0;
for (int c = 0; c <= 3; c++) {
result = result << 8;
inByte = SPI.transfer(0x00);
Serial.print(inByte);
Serial.print("<<");
result = result | inByte;
}
Serial.print("=");
Serial.println(result);
delay(1000);
}
}
With a progressive pressure on the load cell (with my hand) the output looks like :
1+139+170+255+=43775
1+200+219+127+=56191
2+156+31+255+=8191
3+59+255+255+=65535
3+225+95+255+=24575
0+175+159+127+=40831 <== Problem !
4+7+15+255+=4095
I thinks it's realy noisy, but it seems to be working.
So my questions about this :
- My line with "if (digitalRead(dataReadyPin) == LOW)" is really bad, because it will not be only true in falling. I don't want to use an interrupt, so how can I do that ?
- Is there a cleaner way to read the SPI bus than writing 0 on it ?
- About noise, have you any clues ?
- What do you think about the "problem" of 0 on the output ?
Thank you very mutch.
Jul