|
|
Switzerland
Offline
Faraday Member
Karma: 69
Posts: 3256
|
 |
« Reply #1 on: October 24, 2012, 10:35:37 am » |
I don't know of any implementation but it should be quite easy to do one yourself. Have you tried it?
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Full Member
Karma: 0
Posts: 136
Arduino rocks
|
 |
« Reply #2 on: October 24, 2012, 11:01:10 am » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Switzerland
Offline
Faraday Member
Karma: 69
Posts: 3256
|
 |
« Reply #3 on: October 24, 2012, 11:21:48 am » |
Seems to be neither SPI nor I2C No, it's much simpler. 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.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Full Member
Karma: 0
Posts: 136
Arduino rocks
|
 |
« Reply #4 on: October 24, 2012, 12:15:06 pm » |
Pylon,
already little simpler now, thank you.
All kind of further help highly welcome
wally
|
|
|
|
|
Logged
|
|
|
|
|
Switzerland
Offline
Faraday Member
Karma: 69
Posts: 3256
|
 |
« Reply #5 on: October 24, 2012, 05:51:28 pm » |
With that code in setup you get a 2.4MHz clock signal on pin 3. void setup() { pinMode(3, OUTPUT); TCCR2A = 0x33; TCCR2B = 0x09; OCR2A = 0x06; OCR2B = 0x03; }
Code for reading the data: 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.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Full Member
Karma: 0
Posts: 136
Arduino rocks
|
 |
« Reply #6 on: October 25, 2012, 01:28:23 am » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Switzerland
Offline
Faraday Member
Karma: 69
Posts: 3256
|
 |
« Reply #7 on: October 25, 2012, 03:27:06 am » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Full Member
Karma: 0
Posts: 136
Arduino rocks
|
 |
« Reply #8 on: October 25, 2012, 01:24:45 pm » |
Works !
i get : 16.772.xxx on 0V 2.794.xxx on 3.3V 700.xxx on 5V
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Full Member
Karma: 0
Posts: 136
Arduino rocks
|
 |
« Reply #9 on: October 26, 2012, 03:58:09 am » |
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 /* 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();
}
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Full Member
Karma: 0
Posts: 136
Arduino rocks
|
 |
« Reply #10 on: October 26, 2012, 09:47:48 am » |
some fine tuning to make it human readable: thanks a smart solution from "dhenry" /* 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();
}
|
|
|
|
|
Logged
|
|
|
|
|
|