Hi,
now it looks better. I'm only able to check the status byte due to my unfinished hardware, but the status byte reacts on different settings, so i guess it's right.
What was wrong?
First: I haven't set my ports correctly (output ports as output and input ports as inputs).
Second: @el_supremo your change of delay and rising/ falling clock was correct - may thanks!
So this is a simple code which can read the AD7780 and prints the result including the status byte (24bit result + 8bit status):
#define AD7780_VCC 30 // Give AD7780 5V or not
#define AD7780_PWDOWN 28 // Reset/ Power down pin -> High is on
#define AD7780_FILTER 18
#define AD7780_GAIN 19 // Gain on/ off LOW = GAIN = 128/ HIGH = GAIN = 1
#define AD7780_SCK 7 // Clock
#define AD7780_MISO 6 // MISO
#define AD7780_MOSI 5 // MOSI
void setup()
{
Serial1.begin(9600);
Serial1.println("Start...");
pinMode(AD7780_VCC, OUTPUT);
pinMode(AD7780_PWDOWN, OUTPUT);
pinMode(AD7780_SCK, OUTPUT); // SCK is output
pinMode(AD7780_FILTER, OUTPUT);
pinMode(AD7780_GAIN, OUTPUT);
pinMode(AD7780_MISO, INPUT); // MISO ist read
digitalWrite(AD7780_VCC, HIGH); // AD7080 VCC on
digitalWrite(AD7780_PWDOWN, LOW); // AD7080 in Standby
digitalWrite(AD7780_FILTER, HIGH);
digitalWrite(AD7780_GAIN, LOW);
Serial1.println("AD7780 initialisation finnished");
}
void loop()
{
Serial1.println("Start reading data");
delay(100);
digitalWrite(AD7780_SCK, HIGH); // Clock high from Arduino
delay(100);
digitalWrite(AD7780_PWDOWN, HIGH); // AD7080 Turn on
while(digitalRead(AD7780_MISO)==HIGH); // Wait until AD7780 sets RDY LOW
Serial1.println("MISO turned low Measuring is finnished, and we get the result");
int a = 0;
for(int i=0; i< 32; i++)
{
digitalWrite(AD7780_SCK, LOW);
delayMicroseconds(10);
digitalWrite(AD7780_SCK, HIGH);
a = digitalRead(AD7780_MISO);
Serial1.print(a);
delayMicroseconds(10);
}
Serial1.println("");
digitalWrite(AD7780_PWDOWN, LOW); // AD7080 Turn off
}
One more question:
Is there an easy way of extracting the fist 24-result-bits into a single number and the 8-status-bits into an other single number?
Thanky you!