AnsweredAssumed Answered

Issues with AD7705 not sending data

Question asked by hanut123 on May 25, 2016
Latest reply on May 26, 2016 by hanut123

Hi,

I wanted to use the AD7705 with some load cells and was trying to set it up with a POT first.
My connection is with an arduino UNO with connection diagram attached.

Now, when working with it, i have analyzed the main signals on a DSO and have a Serial clock, Master clock (2Mhz), the /dataready pin goes every once in a while. But, i am unable to get any output from the SPI command (what i feel).
I am attaching the code for reference.

Arduino Code:

 

#include <SPI.h>

 

 

const int drdy = 6;

const int cs = 10;

const int freqOutputPin = 3; 

const int ocr2aval  = 3;

 

 

const int prescale  = 1;

const float period    = 2.0 * prescale * (ocr2aval+1) / (F_CPU/1.0e6);

const float freq      = 1.0e6 / period;

 

 

void setup()

{

  pinMode(freqOutputPin, OUTPUT);

  Serial.begin(9600);

  SPI.begin();

  //SPI.beginTransaction(SPISettings(200,MSBFIRST,SPI_MODE0));

  pinMode(drdy,INPUT);

  pinMode(cs,OUTPUT);

  digitalWrite(cs,LOW);

  TCCR2A = ((1 << WGM21) | (1 << COM2B0));

  TCCR2B = (1 << CS20);

  TIMSK2 = 0;

  OCR2A = ocr2aval;

 

 

  Serial.print("Period    = ");

  Serial.print(period);

  Serial.println(" microseconds");

  Serial.print("Frequency = ");

  Serial.print(freq);

  Serial.println(" Hz");

  writetoadc(0x20);

  delay(100);

  writetoadc(0x03);

  delay(100);

  writetoadc(0x10);

  delay(100);

  writetoadc(0x40);

  delay(100);

}

 

 

void loop()

{

  while(digitalRead(drdy)==1);

  writetoadc(0x38);

  int value = getadcdata();

  Serial.print("Value:");

  Serial.println(value);

}

 

 

void writetoadc(byte command)

{

  SPI.transfer(command);

  //SPI.endTransaction();

  digitalWrite(MOSI,HIGH);

  return;

}

 

 

int getadcdata()

{

  unsigned int result = 0;

  byte input = 0;

  result = SPI.transfer(0x00);

  result = result << 8;

  input = SPI.transfer(0x00);

  result = result | input;

  //SPI.endTransaction();

  //digitalWrite(MOSI,HIGH);

  return (result);

}

Thanks! Cheers!

 

 

P.S. the resistances are 2K4 each.

Untitled Sketch_schem.jpg

Outcomes