Author Topic: TM7705 / AD7705 getting both channels to work with Arduino  (Read 5947 times)

0 Members and 3 Guests are viewing this topic.

Offline ziplock9000Topic starter

  • Regular Contributor
  • *
  • Posts: 173
  • Country: gb
TM7705 / AD7705 getting both channels to work with Arduino
« on: October 01, 2018, 05:15:43 pm »
I followed the instructions on this page: https://www.instructables.com/id/Arduino-16-bit-500SPS-Dual-Channel-DAQ/
Using KDW's revised library: http://www.kerrywong.com/2012/04/18/ad7705ad7706-library-revisited/

When supplying a voltage to Channel 1 only. Channel 1 shows a wrong value intermittently, Channel 2 shows zero
When supplying a voltage to Channel 2 only. Channel 2 shows a meaningful value as does Channel 1!

There only seems to be one library out there that has some issues, has anyone been able to get both channels working?

I've checked SCK and it's at a solid 250Khz
DRDY isn't connected to anything.. could that be an issue?
 

Offline tombi

  • Regular Contributor
  • *
  • Posts: 163
  • Country: au
Re: TM7705 / AD7705 getting both channels to work with Arduino
« Reply #1 on: October 03, 2018, 04:03:13 am »
Yes I did. See here although it was a bit of a bear to work with.

https://github.com/tom-biskupic/LabPSU/blob/master/Firmware/LabPSU/AD7705ADC.cpp

Code is a bit rough-and-ready and uses my own SPI code (long story).

I had a similar experience to you for a while and found I had damaged my device. Swapped in another one and it all worked.
 
The following users thanked this post: ziplock9000

Offline ziplock9000Topic starter

  • Regular Contributor
  • *
  • Posts: 173
  • Country: gb
Re: TM7705 / AD7705 getting both channels to work with Arduino
« Reply #2 on: October 03, 2018, 09:18:23 am »
Thanks mate. I'll have a look at your library.

« Last Edit: October 03, 2018, 09:24:07 am by ziplock9000 »
 

Offline ziplock9000Topic starter

  • Regular Contributor
  • *
  • Posts: 173
  • Country: gb
Re: TM7705 / AD7705 getting both channels to work with Arduino
« Reply #3 on: October 03, 2018, 01:14:06 pm »
Yes I did. See here although it was a bit of a bear to work with.

https://github.com/tom-biskupic/LabPSU/blob/master/Firmware/LabPSU/AD7705ADC.cpp

Code is a bit rough-and-ready and uses my own SPI code (long story).

I had a similar experience to you for a while and found I had damaged my device. Swapped in another one and it all worked.

In the immortal words of AvE, IT VURRRKS!. The two channels now work independently!

So this very clearly demonstrates that the Adafruit kerrydwong/AD770X library does not work properly!

My clock crystal is 4.9152 Mhz, but using CLOCK_4_9152 doesn't work, so I have to use CLOCK_2 for some reason, any idea why?

Many thanks!

Here's the Arduino IDE compatible code that I used with your library:
Code: [Select]
/*
Parts of this code and the entirety of the SPI and AD7705ADC libraries have been taken from the repo of tom-biskupic
https://github.com/tom-biskupic/LabPSU
*/

#include <AD7705ADC.h>

const float RANGE_TO_5V = 0.00007629510948348210879682612344549;
const float RANGE_TO_5000mV = 0.07629510948348210879682612344549;

const int ADC_SS_PIN = 0;
const int ADC_DATA_READY_PIN = 4; // PORTD

AD7705ADC m_adc(ADC_SS_PIN, ADC_DATA_READY_PIN);

const AD7705ADC::Channel VOLTAGE_ADC_CHANNEL = AD7705ADC::CHANNEL_0;
const AD7705ADC::Channel CURRENT_ADC_CHANNEL = AD7705ADC::CHANNEL_1;

void initADC()
{
//
// We run the ADC in bipolar mode so we can get the full 0..5V range.
// The AIN- is tied to the reference so the input is a bipolar number
// relative to that.
//
// Because of the bipolar requirement we can't use gain.
// I am using a 2MHz crystal which means clockdiv is 1.
// An update rate of 50Hz or less is fine so filter select is 0
//
m_adc.reset();
m_adc.setClockRegister(AD7705ADC::CLOCK_2, 0);

m_adc.setSetupRegister(
VOLTAGE_ADC_CHANNEL,                    //  Channel
AD7705ADC::AD7705ADC::MODE_NORMAL,      // CAL mode
AD7705ADC::GAIN_1,     // Gain = 1
AD7705ADC::UNIPOLAR,             // Polarity
false,     // Not buffered
false);     // F Sync off

m_adc.reset();

m_adc.setSetupRegister(
CURRENT_ADC_CHANNEL,                    //  Channel
AD7705ADC::AD7705ADC::MODE_NORMAL,      // CAL mode
AD7705ADC::GAIN_1,     // Gain = 1
AD7705ADC::UNIPOLAR,                    // Polarity
false,     // Not buffered
false);     // F Sync off
}

uint16_t readADC(const AD7705ADC::Channel channel)
{
m_adc.reset();

uint16_t value = m_adc.getValue(channel);

return value;
}

void setup()
{
    Serial.begin(9600);

initADC();
}

void loop()
{
Serial.print(readADC(VOLTAGE_ADC_CHANNEL)*RANGE_TO_5000mV * 2,0);
Serial.print("mV :");
Serial.print(readADC(CURRENT_ADC_CHANNEL)*RANGE_TO_5000mV * 2,0);
Serial.println("mA");
delay(1000);
}
« Last Edit: October 03, 2018, 02:06:25 pm by ziplock9000 »
 

Offline tombi

  • Regular Contributor
  • *
  • Posts: 163
  • Country: au
Re: TM7705 / AD7705 getting both channels to work with Arduino
« Reply #4 on: October 03, 2018, 01:28:06 pm »
Hmm - no not really.

From looking at the datasheet it should be CLOCK_4_9152

Might be a bug in my code but I can't see it right now.

Glad it worked though! I also found the part pretty bloody slow although I didn't mess with the filters too much.

Tom
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf