Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 09, 2016, 10:36:38 10:36


Login with username, password and session length


Pages: [1]
Print
Author Topic: AD7731 Communication Issues  (Read 1691 times)
0 Members and 1 Guest are viewing this topic.
Some Anon Guy
Junior Member
**
Offline Offline

Posts: 39

Thank You
-Given: 46
-Receive: 16



« on: April 25, 2014, 07:23:48 19:23 »

Hello all,
I am pulling my hair out. I cannot get any communication from either of the 2 AD7731 ADCs I have.
I am creating a new hardware rev of a  water sanitation system.
The OLD hardware was AD7731 and Atmel128.
New hardware is AD7731 and PIC18f45k22.
 
I have ported the code from the atmel to the PIC. I am confident in the Code as I can talk to other SPI devices on the board just fine.
 
As for the AD7731 I cannot get any response from the IC at all. No !RDY pin low, no ability to read the registers, etc.
!RDY stays high at all times.
 
I received the parts as Analog.com samples.
 
I have attached schematics for the MCU and the ADC

The !RDY pin NEVER goes LOW. No matter how long I wait.
 
Here are snippets of my setup and communication code...
 
Code:
// Initialize SPI
// MCU is running @32Mhz, divide  FOSC/64 to run SPI @ 500Khz.
//(Have tried, 2Mhz, 4Mhz, and 8Mhz)
  SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV64, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
 
 
void Setup_AD7731(void){
    write_register(0x03, 0x13, 0x34);   //Initialize filter register.
 
// Self calibrate millivolt input  (Electrode Inputs)
/*----------------------------------------------------------------------------*/
// Calibrate Zero point
  write_register(0x02, 0x90, 0xF6); //Self calibrate mV input zero.
  while(AD7731_DR != LOW); //Wait for the ready pin to go low.
 
  // Set to Full Scale
  write_register(0x02, 0xB0, 0xF6); //Self calibrate mV input full scale.
  while(AD7731_DR != LOW); //Wait for the ready pin to go low.
}
}
 
 
void write_register(char reg, char msb, char lsb)
{
 
  SELECT_AD7731;         //Select the a/d converter.
  SPI1_Write(reg);            //Select the required a/d register.
  SPI1_Write(msb);          //Send msb byte.
  SPI1_Write(lsb);            //Send lsb byte.
  DISABLE_AD7731;       //De-select a/d converter.
 
}

 
This is a direct port from a working system. I am loosing my mind here.
Anyone see what I am doing wrong?
Logged
hate
Hero Member
*****
Offline Offline

Posts: 556

Thank You
-Given: 156
-Receive: 354


« Reply #1 on: April 25, 2014, 10:19:50 22:19 »

A couple of things to try:

1- What is the status of 'AD_CS'? It must be low to activate the chip.
2- Check the port direction bits of PIC for SPI interface (RC3, RC4, RC5).
3- Do you have the signal output of the working system? If yes, what's the difference?
4- Do you have the code for the working system? Which compiler? Also which compiler do you use for PIC?
Logged

Regards...
Some Anon Guy
Junior Member
**
Offline Offline

Posts: 39

Thank You
-Given: 46
-Receive: 16



« Reply #2 on: April 26, 2014, 01:13:05 01:13 »

A couple of things to try:

1- What is the status of 'AD_CS'? It must be low to activate the chip.
2- Check the port direction bits of PIC for SPI interface (RC3, RC4, RC5).
3- Do you have the signal output of the working system? If yes, what's the difference?
4- Do you have the code for the working system? Which compiler? Also which compiler do you use for PIC?



1 - In the attached picture Chanel 0 (ENABLE) is the AD_CS pin. You can see it go LOW to enable the IC.
2 - MikroC Pro automatically updates these when using the Hardware SPI routines. (I can also talk to other SPI devices on the board)
3 - Ill hook up the Logic to the OLD system and take a look. That is something I did not do. Great Idea.
4 - I do have the OLD source. Not sure how current. It was written in Imagecraft ICC5 I think. I am using MikroC Pro for the PIC.

I took the setup routines straight from the old source and compared them to the datasheet. They should work... But I have to be missing something.

I even rebuilt on a bread board, and did not hook the AD_RDY to the PIC and it still never goes LOW. Sad

I am stumped.
Logged
hate
Hero Member
*****
Offline Offline

Posts: 556

Thank You
-Given: 156
-Receive: 354


« Reply #3 on: April 26, 2014, 01:44:16 01:44 »

Did you set the SPI to the correct mode of operation? Afaik there are 4 of them.

Also if you can post more info about my comments 3 and 4, I may be more helpful.
Logged

Regards...
Some Anon Guy
Junior Member
**
Offline Offline

Posts: 39

Thank You
-Given: 46
-Receive: 16



« Reply #4 on: April 28, 2014, 07:18:05 19:18 »

I do have the source. Written in ICCv5 or ICCv6 for the AVR. The code for the init of the AD7731 is very similar. (I have even tried the exact settings although we are not using all the same inputs).
I am using MikroC Pro for the PIC.

The signal out on the working system (Old units) is different in that the AD7731 actually responds and takes readings then sets the Data Ready Pin LOW.

I captured the signals, adjusted my program to be identical and still nothing.

After some suggestions from Analog Devices Support, I created an arduino sketch that cycles through all 4 SPI modes and, resets (sends 32 1's) the AD7731 and sets to continuous conversion mode.
According to them, this should reset the device and make the device enter normal conversion and start cycling the Data Ready pin at normal intervals.

Although, its still not working...

Here is the arduino code.

Code:
// include the SPI library:

#include <SPI.h>

 

 

// set pin 10 as the slave select for the digital pot:

const int slaveSelectPin = 10;

int dataReadyPin = 9;

 

void setup() {

  // set the slaveSelectPin as an output:

  pinMode (slaveSelectPin, OUTPUT);

  pinMode (dataReadyPin, INPUT );

  // initialize SPI:

  SPI.begin();

 

}

 

void setupADC(void){

  // reset ADC

    // reset ADC

  digitalWrite(slaveSelectPin, LOW); 

  SPI.transfer(0xff);

  SPI.transfer(0xff);

  SPI.transfer(0xff);

  SPI.transfer(0xff);

  //SPI.transfer(0xff);

  digitalWrite(slaveSelectPin, HIGH);

 

  digitalWrite(slaveSelectPin, LOW); 

  SPI.transfer(0x02);

  SPI.transfer(0x31);

  SPI.transfer(0xf4);

  digitalWrite(slaveSelectPin, HIGH);

 

  delay(100);

}

 

void loop() {

  SPI.setDataMode(SPI_MODE0);

  setupADC();

  SPI.setDataMode(SPI_MODE1);

  setupADC();

  SPI.setDataMode(SPI_MODE2);

  setupADC();

  SPI.setDataMode(SPI_MODE3);

  setupADC();

 

}

The device is wired up as follows on the breadboard.

Pin1 to Arduino Pin 13 (SCK)
Pin 2 to 4Mhz crystal with 22pf cap
Pin 3 to 4Mhz crystal with 22pf cap
pin 4 to GND
pin 5 to vcc (+5v from arduino)
pin 6 to vcc (+5v from arduino)
pin 8 to GND
pin 9 to vcc (+5v from arduino)
Pins 10 - 13 are floating
pin 14 to vcc (+5v from arduino)
pin 15 to GND
pins 16 and 17 floating
pin 18 to vcc (+5v from arduino)
pin 19 to Arduino pin 10 (SlaveSelect)
pin 20 to Arduino pin 9  (DataReady)
pin 21 to Arduino pin 12 (MISO)
pin 22 to Arduino pin 11 (MOSI)
pin 23 to vcc (+5v from arduino)
pin 24 to GND

 

After looping through all 4 SPI modes and pausing for 100ms in between each mode, the Data Ready Pin never changes from a HIGH state as measured by my Saleae Logic 8.

I see there are 3 possible scenarios here:
1. I am a moron and cannot see what I am doing wrong...
2. I destroyed the devices somehow... (Most likely)
3. I received 2 bad DIP samples. (Not likely)

I have 2 additional SOIC AD7731 devices. I have ordered SOIC socket to DIP adapters so that I can test with these devices without soldering them to adapters.
Logged
b555b
Newbie
*
Offline Offline

Posts: 27

Thank You
-Given: 27
-Receive: 23


« Reply #5 on: April 28, 2014, 08:02:23 20:02 »

Have you tried with the POL pin high instead of low (as it affect the mode of the SPI interface of the AD7731) ?

You could also try to pulse the RESET pin with your microcontroller instead of pulling it always high. Maybe the internal power-up reset circuit of the AD7731 is not working properly (this can happen with some circuits if the power voltage rises too slowly).
Logged
Some Anon Guy
Junior Member
**
Offline Offline

Posts: 39

Thank You
-Given: 46
-Receive: 16



« Reply #6 on: April 28, 2014, 08:33:39 20:33 »

Have you tried with the POL pin high instead of low (as it affect the mode of the SPI interface of the AD7731) ?

You could also try to pulse the RESET pin with your microcontroller instead of pulling it always high. Maybe the internal power-up reset circuit of the AD7731 is not working properly (this can happen with some circuits if the power voltage rises too slowly).

Yes, I did try the POL pin high (With the same looping SPI mode code) Same result.
I just added the RESET pin to the arduino code instead of sending 32 1's and same result.

Great suggestions.

I think I must have killed these chips somehow...
Logged
hate
Hero Member
*****
Offline Offline

Posts: 556

Thank You
-Given: 156
-Receive: 354


« Reply #7 on: April 28, 2014, 08:50:22 20:50 »

I captured the signals, adjusted my program to be identical and still nothing.
In that case, you should try replacing the original chips with the chips you try to make work if possible and see if the new ones work too. Btw if you have experience with Basic, there is thread about the same chip here:
http://www.picbasic.co.uk/forum/showthread.php?t=5020
and the guy actually claims to make it work.
Logged

Regards...
pickit2
Moderator
Hero Member
*****
Offline Offline

Posts: 3816

Thank You
-Given: 567
-Receive: 2049


There is no evidence that I muted SoNsIvRi


« Reply #8 on: April 29, 2014, 10:29:31 10:29 »

reading this, If your not getting any response, and your thinking you killed your chip.
The same would be if the xtal was working, we had a problem where someone used the wrong xtal, and it took an age to find.

I see the chip has Mclk_in & Mclk_out what if you feed just the Mclk_in from a known working osc, this could be from a pic device.
Logged

Note: If you have no posts other than, I want or reporting a dead link Then you can't complain If I remove your post So Stop Leeching
Some Anon Guy
Junior Member
**
Offline Offline

Posts: 39

Thank You
-Given: 46
-Receive: 16



« Reply #9 on: April 29, 2014, 04:54:15 16:54 »

reading this, If your not getting any response, and your thinking you killed your chip.
The same would be if the xtal was working, we had a problem where someone used the wrong xtal, and it took an age to find.

I see the chip has Mclk_in & Mclk_out what if you feed just the Mclk_in from a known working osc, this could be from a pic device.

I was hopeful that this might finally be it, but after generating a 1Mhz clock on a pin to drive the MCLK IN pin there was no change.
(I can see the clock on the Logic 8 @ 1Mhz)
Logged
pickit2
Moderator
Hero Member
*****
Offline Offline

Posts: 3816

Thank You
-Given: 567
-Receive: 2049


There is no evidence that I muted SoNsIvRi


« Reply #10 on: April 29, 2014, 08:51:17 20:51 »

I was hopeful that this might finally be it, but after generating a 1Mhz clock on a pin to drive the MCLK IN pin there was no change.
(I can see the clock on the Logic 8 @ 1Mhz)
and you get a clock pulse on Mclk_out ?
maybe the data sheet has a test setup to show logic levels under test.
Logged

Note: If you have no posts other than, I want or reporting a dead link Then you can't complain If I remove your post So Stop Leeching
Some Anon Guy
Junior Member
**
Offline Offline

Posts: 39

Thank You
-Given: 46
-Receive: 16



« Reply #11 on: April 29, 2014, 09:24:01 21:24 »

and you get a clock pulse on Mclk_out ?
maybe the data sheet has a test setup to show logic levels under test.

I didn't test the mclk_out. I will test that tonight, and I'll scour the datasheet again.

I was able to order more samples, should be here in a few days. As well as an SOIC to DIP socket adapter, and SOIC test clip. So I can easily test the SOIC parts without soldering.
Logged
Some Anon Guy
Junior Member
**
Offline Offline

Posts: 39

Thank You
-Given: 46
-Receive: 16



« Reply #12 on: April 30, 2014, 07:16:35 07:16 »

Well, I was surprised to find my SOIC to DIP socket at the house today when I got home.
So I removed the DIP part from the breadboard and replaced it with the SOIC part in the socket, and....

IT WORKS!  Cheesy Cheesy Cheesy

So, now I have to find out how I killed the PDIP parts. I'm guessing that there must be something wrong with the new PCB that is shorting out the chip or something.

Thanks to everyone for their help.
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC