Friday 04 2020

AD5933 Part 3 (Pinout and Arduino Library Introduction)

 AD5933 Part 3










AD5933 Data Sheet Rev. F | Page 4 of 40 SPECIFICATIONS

VDD = 3.3 V, 

MCLK = 16.776 MHz, 

2 V p-p output excitation voltage @ 30 kHz, 

200 kΩ connected between Pin 5 and Pin 6; feedback resistor = 200 kΩ connected between Pin 4 and Pin 5; 

PGA gain = ×1, unless otherwise noted.


AD5933 Arduino Library 

mjmeli/arduino-ad5933 Library - Michael Meli, GitHub 2016may04 


The AD5933 is developed by Analog Devices. From the AD5933 page:

The AD5933 is a high precision impedance converter system solution that combines an on-board frequency generator with a 12-bit, 1 MSPS, analog-to-digital converter (ADC).

The frequency generator allows an external complex impedance to be excited with a known frequency. The response signal from the impedance is sampled by the on-board ADC and a discrete Fourier transform (DFT) is processed by an on-board DSP engine. The DFT algorithm returns a real (R) and imaginary (I) data-word at each output frequency.

Once calibrated, the magnitude of the impedance and relative phase of the impedance at each frequency point along the sweep is easily calculated. This is done off chip using the real and imaginary register contents, which can be read from the serial I2C interface.

In other words, the AD5933 lets you measure the complex impedance of something.


Example

Perhaps the easiest way to see how to use the library is to look at the example code in the examples directory. Once you install the library, you can easily open this code in the Arduino editor by going to File > Examples > arduino-ad5933 > ad5933-test.

This example will show you how to initially setup the AD5933 and run frequency sweeps. 

There are two methods for doing a frequency sweep. 

The first is by using the frequencySweep() function. 

This function is very easy to use, but you have to wait until the entire sweep is complete before handling data in bulk and this requires more memory, especially for large sweeps. 

The other method is by manipulating the AD5933 at the I2C level directly, which is slightly more complex, but allows you to handle data immediately after a reading and has significantly lower memory overhead.


Brief Overview

There are an assortment of functions in AD5933.h that can be used with numerous constants. Each one of the functions are static, so be sure to include AD5933:: in front. Here I cover a few of the main ones.

NOTE: Many of these functions return booleans indicating their success. This may be useful for debugging.

To reset the board: AD5933::reset();

To enable on-board temperature measurement: AD5933::enableTemperature()

To get a temperature reading: double temp = AD5933::getTemperature()

To set the clock source to 

internal: AD5933::setInternalClock(true) OR AD5933::setClockSource(CTRL_CLOCK_INTERNAL)

To set the clock source to external: AD5933::setClockSource(CTRL_CLOCK_EXTERNAL)

To set the frequency sweep start frequency: AD5933::setStartFrequency(#)

To set the frequency sweep increment frequency: AD5933::setIncrementFrequency(#)

To set the frequency sweep number of increments: AD5933::setNumberIncrements(#)

To set the PGA gain: AD5933::setPGAGain(PGA_GAIN_X1/PGA_GAIN_X5)

To set the power mode: AD5933:setPowerMode(POWER_ON/POWER_DOWN/POWER_STANDBY)

To perform a calibration sweep, which computes gain factor for each frequency step based on a known reference resistance (the results are stored in the gainFactor array, so make sure this is large enough): AD5933::calibration(double[] gainFactor, double[] phase, int referenceResistor, int numIncrements)

To perform an entire frequency sweep (the results are stored in the real and imaginary arrays): AD5933::frequencySweep(int[] real, int[] imag, int numIncrements)

To read a register: byte res = AD5933::readRegister(/* register address */)

That is sufficient for most things. Check out the header file for more functions and constants. Also check out the example code for better illustrations of usage.


 Apr 10, 2019 
148 lines (132 sloc)  4.42 KB

#ifndef AD5933_h
#define AD5933_h
/**
* Includes
*/
#include <Arduino.h>
#include <Wire.h>
/**
* AD5933 Register Map
* Datasheet p23
*/
// Device address and address pointer
#define AD5933_ADDR (0x0D)
#define ADDR_PTR (0xB0)
// Control Register
#define CTRL_REG1 (0x80)
#define CTRL_REG2 (0x81)
// Start Frequency Register
#define START_FREQ_1 (0x82)
#define START_FREQ_2 (0x83)
#define START_FREQ_3 (0x84)
// Frequency increment register
#define INC_FREQ_1 (0x85)
#define INC_FREQ_2 (0x86)
#define INC_FREQ_3 (0x87)
// Number of increments register
#define NUM_INC_1 (0x88)
#define NUM_INC_2 (0x89)
// Number of settling time cycles register
#define NUM_SCYCLES_1 (0x8A)
#define NUM_SCYCLES_2 (0x8B)
// Status register
#define STATUS_REG (0x8F)
// Temperature data register
#define TEMP_DATA_1 (0x92)
#define TEMP_DATA_2 (0x93)
// Real data register
#define REAL_DATA_1 (0x94)
#define REAL_DATA_2 (0x95)
// Imaginary data register
#define IMAG_DATA_1 (0x96)
#define IMAG_DATA_2 (0x97)
/**
* Constants
* Constants for use with the AD5933 library class.
*/
// Temperature measuring
#define TEMP_MEASURE (CTRL_TEMP_MEASURE)
#define TEMP_NO_MEASURE (CTRL_NO_OPERATION)
// Clock sources
#define CLOCK_INTERNAL (CTRL_CLOCK_INTERNAL)
#define CLOCK_EXTERNAL (CTRL_CLOCK_EXTERNAL)
// PGA gain options
#define PGA_GAIN_X1 (CTRL_PGA_GAIN_X1)
#define PGA_GAIN_X5 (CTRL_PGA_GAIN_X5)
// Power modes
#define POWER_STANDBY (CTRL_STANDBY_MODE)
#define POWER_DOWN (CTRL_POWER_DOWN_MODE)
#define POWER_ON (CTRL_NO_OPERATION)
// I2C result success/fail
#define I2C_RESULT_SUCCESS (0)
#define I2C_RESULT_DATA_TOO_LONG (1)
#define I2C_RESULT_ADDR_NAK (2)
#define I2C_RESULT_DATA_NAK (3)
#define I2C_RESULT_OTHER_FAIL (4)
// Control register options
#define CTRL_NO_OPERATION (0b00000000)
#define CTRL_INIT_START_FREQ (0b00010000)
#define CTRL_START_FREQ_SWEEP (0b00100000)
#define CTRL_INCREMENT_FREQ (0b00110000)
#define CTRL_REPEAT_FREQ (0b01000000)
#define CTRL_TEMP_MEASURE (0b10010000)
#define CTRL_POWER_DOWN_MODE (0b10100000)
#define CTRL_STANDBY_MODE (0b10110000)
#define CTRL_RESET (0b00010000)
#define CTRL_CLOCK_EXTERNAL (0b00001000)
#define CTRL_CLOCK_INTERNAL (0b00000000)
#define CTRL_PGA_GAIN_X1 (0b00000001)
#define CTRL_PGA_GAIN_X5 (0b00000000)
// Status register options
#define STATUS_TEMP_VALID (0x01)
#define STATUS_DATA_VALID (0x02)
#define STATUS_SWEEP_DONE (0x04)
#define STATUS_ERROR (0xFF)
// Frequency sweep parameters
#define SWEEP_DELAY (1)
/**
* AD5933 Library class
* Contains mainly functions for interfacing with the AD5933.
*/
class AD5933 {
public:
// Reset the board
static bool reset(void);
// Temperature measuring
static bool enableTemperature(byte);
static double getTemperature(void);
// Clock
static bool setClockSource(byte);
static bool setInternalClock(bool);
//bool setSettlingCycles(int); // not implemented - not used yet
// Frequency sweep configuration
static bool setStartFrequency(unsigned long);
static bool setIncrementFrequency(unsigned long);
static bool setNumberIncrements(unsigned int);
// Gain configuration
static bool setPGAGain(byte);
// Excitation range configuration
//bool setRange(byte, int); // not implemented - not used yet
// Read registers
static byte readRegister(byte);
static byte readStatusRegister(void);
static int readControlRegister(void);
// Impedance data
static bool getComplexData(int*, int*);
// Set control mode register (CTRL_REG1)
static bool setControlMode(byte);
// Power mode
static bool setPowerMode(byte);
// Perform frequency sweeps
static bool frequencySweep(int real[], int imag[], int);
static bool calibrate(double gain[], int phase[], int ref, int n);
static bool calibrate(double gain[], int phase[], int real[],
int imag[], int ref, int n);
private:
// Private data
static const unsigned long clockSpeed = 16776000;
// Sending/Receiving byte method, for easy re-use
static int getByte(byte, byte*);
static bool sendByte(byte, byte);
};
#endif


.END



1 comment:

Joe Biden

RCA Tunnel Diode Manual - RCA 1966

 RCA Tunnel Diode Manual - RCA 1966 https://www.yumpu.com/en/document/read/23901571/rca-tunnel-diode-manual