Other Parts Discussed in Thread: REF5045, OPA333, REF6045, OPA197
Hello,
Me and my colleagues are struggling with ADS8887 18-BIT ADC Component (ADS8887IDRCR). We have desired to read the voltage value with 0.1 mV error tolerance.Therefore, we chose this component but unfortunately we only achieved to get adc results with 7-8 bit resolution even though we apply the same signals (manually) which demonstrated on the datasheet (4-WIRE OPERATION) .I am going to share my main code , raw data and oscilloscope results.
Every feedback and advise would be so helpful.
Here are some raw data examples => 0.0 Volts->75760
0.1 Volts->75776
0.5 Volts->79856
1.0 Volts->84976
2.4 Volts->98288
3.8 Volts->112624
Figure shows the Raw ADC Values we have received
(PS: These values doesn't change even one integer)
Here are Oscilloscope Screen shots =>
MAIN CODE/////////////////////////////////
#define CS 47 //PL2(DIN)
#define SCK 52 //PB1
#define MISO 50 //PB3
#define M0SI 51 //PB2
#define CONVST 45 //PL4
byte val;
void setup() {
pinMode(39,OUTPUT); //adc ch1 power enable
digitalWrite(39,HIGH);
Serial.begin(115200);
DDRB = DDRB | B00000010; //SCK is output
DDRL = DDRL | B00010100; //DIN and CONVST are output
DDRB = DDRB & B11110111;
PORTL = PORTL & B11101011; //CS and CONVST LOW
PORTB = PORTB & B11111001; //SCK LOW
}
unsigned long MISO_;
unsigned long clk=0,clk2=0; //these two parameters are used in delay operation
void loop() {
delay(10);
PORTL = PORTL | B00000100; //CS HIGH
delayMicroseconds(1);
PORTL = PORTL | B00010000; //CONVST HIGH
MISO_ = 0;
delayMicroseconds(1);
for(int i=0;i<50;i++) // 5 cycle boyunca SCK
{
PORTB = PORTB | B00000010; //SCK HIGH
while(micros-clk <1)
{
clk=micros(); //OR AND Operation takes different amount of time so we make them equal
}
PORTB = PORTB & B11111101; // SCK LOW
}
delayMicroseconds(10);
PORTL = PORTL & B11111011; //CS LOW
//delayMicroseconds(100);
byte val = 0;
MISO_ = 0;
for(int i=0;i<18;i++)
{
PORTB = PORTB | B00000010; //SCK HIGH
delayMicroseconds(1);
val = (byte)PINB & B00001000; // READ DOUT PIN
val = val >> 3; // shift it to LSB
val = val & B00000001;
MISO_ = (MISO_<< 1) | val ; //Shift the value 1 bit left to get next bit
/*
Serial.print(i);
Serial.print(" = ");
Serial.println(val);
*/
/*
while(micros-clk2 <1)
{
clk2=micros();
}
*/
PORTB = PORTB & B11111101; //SCK LOW
delayMicroseconds(1);
}
PORTL = PORTL & B11101111; // CONVST LOW
delayMicroseconds(50);
Serial.println(MISO_);
}