Arduino MEGA 2560 and AD7606B connected via SPI

Hey guys

i need your help! can you give me feedback, is there any misstake i made in my code?

i have a PCB with an Arduino Mega 2560 Rev3 and an AD7606B connected via SPI

the problem is i can only read 0.0V from all Channels but there should be voltage on all Channels
the second problem is, i never get FRSTDATA high when i start reading data.

PAR/SER SEL is tied to a logic high,

there is an external Ref with 2.5V connected

PIN-LIST:

|Analog 00|ADC1|REF_SELECT|
|Digital 31|ADC1|RESET|
|Digital 32|ADC1|BUSY|
|Digital 34|ADC1|CONVSTA, CONVSTB|
|Digital 37|ADC1|OS0|
|Digital 38|ADC1|OS1|
|Digital 39|ADC1|OS2|
|Digital 40|ADC1|!STBY|
|Digital 41|ADC1|RANGE|
|Digital 46|ADC1|DOUTC|
|Digital 47|ADC1|DOUTB|
|Digital 48|ADC1|FRSTDATA|
|Digital 49|ADC1|DOUTD|
|Digital 50|ADC1|DOUTA (MISO)|
|Digital 51|ADC1|SDI (MOSI)|
|Digital 52|ADC1|SCLK|
|Digital 53|ADC1|CS|

#include <SPI.h>

#define REFSEL 0

#define STBY 40

#define BUSY 32

#define RESET 31

#define START_CONVERSION 34 //

#define OS0 37

#define OS1 38

#define OS2 39

#define CS 53

#define MISO 50

#define SCLK 52

#define RANGE 41

#define TOTAL_RAW_BYTES 16//num

uint16_t parsed[8];

float data[8];

void setup()

{

initADC();

Serial.begin(115200);

while(!Serial){}

SPI.begin();

}

void loop()

{

readConversion();

delay(5000);

}

bool initADC()

{

pinMode(BUSY, INPUT);

pinMode(FRSTDATA, INPUT);

pinMode(RESET, OUTPUT);

pinMode(START_CONVERSION, OUTPUT);

pinMode(CS, OUTPUT);

pinMode(STBY, OUTPUT);

pinMode(REFSEL, OUTPUT);

pinMode(RANGE, OUTPUT);

analogWrite(REFSEL, 0);

digitalWrite(START_CONVERSION, LOW);

digitalWrite(CS, HIGH);

digitalWrite(STBY,HIGH);

pulse(RESET);

return true;

}

//-----------------------------------------

/*pulse signal*/

void pulse(uint8_t port)

{

digitalWrite(port, HIGH);

delayMicroseconds(10);

digitalWrite(port, LOW);

// delayMicroseconds(1);

}

//-----------------------------------------

void conversionPulse(uint8_t port)

{

digitalWrite(port, LOW);

delayMicroseconds(10);

digitalWrite(port, HIGH);

}

void readConversion() {

Serial.println("doRead");

pulse(START_CONVERSION);

while (digitalRead(BUSY) == HIGH) {

//delayMicroseconds(1);

}

Serial.println("BusygetLOW");

SPISettings _setting(1000000,MSBFIRST,SPI_MODE3);

SPI.beginTransaction(_setting);

digitalWrite(CS, LOW);

for (int i = 0 ; i<8 ; i++)

{

if(digitalRead(FRSTDATA) == HIGH)

{

Serial.println("FRSTDATA is HIGH");

}

parsed[i]=SPI.transfer16(0x0000);

}

digitalWrite(CS, HIGH);

SPI.endTransaction();

//END OF RECEPTION

Serial.println("end");

//parseRawBytes();

//DISPLAY THE DATA

for (size_t i = 0; i<8; i++)

{

data[i]=(float)parsed[i] * 2500.0f / 65536.0f; // REF-voltage is 2.5V

Serial.print(data[i]);

Serial.println("mV");

}

}

have you tried the AD7606 arduino library and the example programs?

i have tried this, but is give me the same results.

what does the serial monitor display? - upload as text - select < CODE/ > and paste text where it says “type or paste code here”
how have you connected the AD7606 to the MEGA?
upload a schematic showing the wiring?

Schematic_ADC.pdf (286,4 KB)
the output is:

doRead
BusygetLOW
end
0.00mV
0.00mV
0.00mV
0.00mV
0.00mV
0.00mV
0.00mV
0.00mV

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.