Go Down

Topic: Interfacing ADS1244 (Read 2232 times) previous topic - next topic

wally123

Hello,

does anybody know where to find an example code to drive
an ADS1244 ADC using its serial interface ?

http://www.bg-electronics.de/datenblaetter/Schaltkreise/ADS1244.pdf

thx wally

pylon

I don't know of any implementation but it should be quite easy to do one yourself. Have you tried it?

wally123

Hi,

I'm preparing to try,
Yes, looks simple, but I'm not sure about the interface. Seems to be neither SPI nor I2C
It does not have a CS pin and usess 2 clocks, the system clock at 2,5 MHz.
I fear it's not entirely trivial.
I did not find anything useful on the web , e.g. example code

wally

pylon

Quote
Seems to be neither SPI nor I2C


No, it's much simpler.

Quote
It does not have a CS pin and usess 2 clocks, the system clock at 2,5 MHz.


No, it doesn't have a CS pin, so the "bus" isn't sharable. What do you mean with 2 clocks? You have to provide it's chip clock, which is a simple rectangular signal, you can use a PWM for that. The SCLK is the serial clock, you have to provide an edge for every bit you wanna read. You can do this with 2 digital pins. So for the whole chip you need 3 Arduino pins, one of them has to be a PWM output with a free timer.

wally123

Pylon,

already little simpler now, thank you.

All kind of further help highly welcome

wally

pylon

With that code in setup you get a 2.4MHz clock signal on pin 3.

Code: [Select]
void setup() {
  pinMode(3, OUTPUT);
  TCCR2A = 0x33;
  TCCR2B = 0x09;
  OCR2A = 0x06;
  OCR2B = 0x03;
}


Code for reading the data:

Code: [Select]
while (digitalRead(DATA_PIN) == HIGH); // wait for data ready
uint32_t value = shiftIn(DATA_PIN, CLOCK_PIN, MSBFIRST);
value <<= 8;
value |= shiftIn(DATA_PIN, CLOCK_PIN, MSBFIRST);
value <<= 8;
value |= shiftIn(DATA_PIN, CLOCK_PIN, MSBFIRST);
digitalWrite(CLOCK_PIN, HIGH);
digitalWrite(CLOCK_PIN, LOW); // 25th pulse to keep DATA high till next data ready


Keep in mind that DATA_PIN has to be in input mode while CLOCK_PIN has to be an output.

Hope that helps to get you started.

wally123

Pylon,

thanks a lot !   :)
I am  ashamed but i must say i see the 'shiftIn/ shiftOut' commands the first time.
I still get some errors when compiling, but i think i can fix it after some readings.
And i must solder the ADC on a adapter-PCB (MSOP) now to test during weekend.

regards
Wally

pylon

Take care of the different voltages, the analog is running at about 5V while the digital part must be below 3V6. Maybe you even have to have some voltage divider for the clock signal.

wally123

Works !

i get :
16.772.xxx   on  0V
2.794.xxx  on   3.3V
700.xxx on 5V



wally123

better results with pos.Vref = +2.5V
+5V     7FFFFF      8.388.607
+2,5V  40ACA4  ~4.238.500
+0,1V  5DC        ~1,500
<+0,1  FFXXXX  16.xxx.xxx

Code: [Select]
/*
  ADS1244
 
*/

int DATA = 4;
int SCLK = 5;

void setup() {
 
  pinMode(DATA, INPUT);
  pinMode(SCLK, OUTPUT);
 
  Serial.begin(115200);
 
  // generate a 2.4MHz clock signal on pin 3
  pinMode(3, OUTPUT);      //CLK
 
  // 17.11 Register Description
  TCCR2A = 0x33;  // 0011 0011 
  TCCR2B = 0x09;  // 0000 1001
  OCR2A  = 0x06;  // 0000 0110
  OCR2B  = 0x03;  // 0000 0011
 
  Serial.print("ADS1244");    // output 'AADS1244' (?) additional 'A' in front
  delay(100);
}

void loop() {
 
  // Code for reading the data:
     
  int32_t value = 0;
 
  //digitalWrite(SCLK, HIGH);  //enter slleep mode
  delay(1000);
  digitalWrite(SCLK, LOW);  // wake up ADC
 
     
  // wait for data ready, stay in while-loop until LOW
  while (digitalRead(DATA) == HIGH);     

  value = shiftIn(DATA, SCLK, MSBFIRST);
  value <<= 8;
  value |= shiftIn(DATA, SCLK, MSBFIRST);
  value <<= 8;
  value |= shiftIn(DATA, SCLK, MSBFIRST);

  digitalWrite(SCLK, HIGH);  // enter sleep mode
  //digitalWrite(SCLK, LOW); // 25th pulse to keep DATA high till next data ready
   
  Serial.println(value, DEC);
  Serial.flush();

}


wally123

some fine tuning to make it human readable:
thanks a smart solution from "dhenry"

Code: [Select]
/*
  ADS1244
 
*/

int DATA = 4;
int SCLK = 5;

void setup() {
 
  pinMode(DATA, INPUT);
  pinMode(SCLK, OUTPUT);
 
  Serial.begin(115200);
 
  // generate a 2.4MHz clock signal on pin 3
  pinMode(3, OUTPUT);      //CLK
 
  // 17.11 Register Description
  TCCR2A = 0x33;  // 0011 0011 
  TCCR2B = 0x09;  // 0000 1001
  OCR2A  = 0x06;  // 0000 0110
  OCR2B  = 0x03;  // 0000 0011
 
  Serial.print("ADS1244\n");    // output 'AADS1244' (?) additional 'A' in front
  delay(100);
}

void loop() {
 
  // Code for reading the data:
     
  int32_t value = 0;
 
  //digitalWrite(SCLK, HIGH);  //enter slleep mode
  delay(300);
  digitalWrite(SCLK, LOW);  // wake up ADC
 
     
  // wait for data ready, stay in while-loop until LOW
  while (digitalRead(DATA) == HIGH);     

  value = shiftIn(DATA, SCLK, MSBFIRST);
  value <<= 8;
  value |= shiftIn(DATA, SCLK, MSBFIRST);
  value <<= 8;
  value |= shiftIn(DATA, SCLK, MSBFIRST);

  digitalWrite(SCLK, HIGH);  // enter sleep mode
  //digitalWrite(SCLK, LOW); // 25th pulse to keep DATA high till next data ready
   
  // process as int24_t (two's compliment 24bit) 
  value = ((signed long) (value << 8)) >> 8;   
   
   
  Serial.println(value, DEC);
  Serial.flush();

}




Hello, Could you share the code for the ads1232 with Arduino loadcell reading, I saw a post that could make reading, need to do a project and I'm having difficulty.

rweller

I am designing a load cell application and need fast response time to weight changes. Looking at the ADS1244 along with this post and was wondering if you could provide input.

I am using this for a filling application and need constant weight information feedback in order to stop fill process at correct time.

Go Up