Evaluation Board User Guide
UG-364
One Technology Way • P.O. Box 9106 • Norwood, MA 02062-9106, U.S.A. • Tel: 781.329.4700 • Fax: 781.461.3113 • www.analog.com
Evaluating the AD5933 1 MSPS, 12-Bit Impedance Converter Network Analyzer
known frequency. The on-board ADC samples the response
signal from the impedance, and an on-board DSP engine at each
excitation frequency processes the DFT. The AD5933 also contains
an internal temperature sensor with 13-bit resolution. The part
operates from a 2.7 V to 5.5 V supply. Other on-board components
include a ADR423 3.0 V reference to act as a stable supply voltage
for the separate analog and digital sections of the device and a
ADP3303 ultrahigh precision regulator to act as a supply to the
on-board universal serial bus controller that interfaces to the
AD5933. The user has the option to power the entire circuitry
from the USB port of a computer.
FEATURES
Full-featured evaluation board for the AD5933
Graphic user interface software with frequency sweep
capability for board control and data analysis
Various power supply linking options
Standalone capability with serial I2C loading from on-board
microcontroller
Selectable system clock options including internal RC
oscillator or on-board 16 MHz crystal
APPLICATIONS
Electrochemical analysis
Impedance spectroscopy
Complex impedance measurement
Corrosion monitoring and protection equipment
Biomedical and automotive sensors
Proximity sensing
The evaluation board also has a high performance trimmed
16 MHz surface-mount crystal to act as a system clock to the
AD5933, if required. The various link options located around the
evaluation board are listed in Table 1. Interfacing to the AD5933
is through a USB microcontroller that generates the I2C signals
necessary to communicate with the AD5933. Interfacing to the
USB microcontroller is done through a Visual Basic® graphic user
interface located on and run from the PC. Complete specifications
for the AD5933 are available in the AD5933 data sheet available
from Analog Devices, Inc., and should be consulted in conjunction
with this user guide when using the evaluation board.
GENERAL DESCRIPTION
This user guide describes the EVAL-AD5933EBZ evaluation board,
and the application software developed to interface with the device.
The AD5933 is a high precision impedance converter system 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
EVALUATION BOARD BLOCK DIAGRAM
1.98V p-p
VDD
MCLK
AVDD
VDD
1.98V p-p
1.48V
VDD/2
DVDD
VDD
VDD
−
DDS
CORE
(27 BITS)
OSCILLATOR
DAC
ROUT
SCL
SDA
I2C
INTERFACE
REAL
REGISTER
+
47nF
50kΩ
TRANSMIT SIDE
OUTPUT AMPLIFIER
TEMPERATURE
SENSOR
ZUNKNOWN
A1, A2 ARE
½ AD8606
AD5933
IMAGINARY
REGISTER
A1
50kΩ
VOUT
RFB
RFB
1024-POINT DFT
20kΩ
GAIN
I-V
LPF
VDD/2
AGND
DGND
−
A2
+
VDD
50kΩ
50kΩ
Figure 1.
PLEASE SEE THE LAST PAGE FOR AN IMPORTANT
WARNING AND LEGAL TERMS AND CONDITIONS.
20kΩ
Rev. 0 | Page 1 of 28
10441-001
VIN
ADC
(12 BITS)
UG-364
Evaluation Board User Guide
TABLE OF CONTENTS
Features .............................................................................................. 1
Performing a Frequency Sweep...................................................6
Applications....................................................................................... 1
Two Installation Frequently Asked Questions ....................... 10
General Description ......................................................................... 1
Source Code for Impedance Sweep.............................................. 12
Evaluation Board Block Diagram................................................... 1
Evaluation Board Source Code Extract................................... 13
Revision History ............................................................................... 2
Gain Factor Calculation ............................................................ 17
Evaluation Board Hardware ............................................................ 3
Temperature Measurement ....................................................... 17
Terminal Block Functions ........................................................... 3
Impedance Measurement Tips ................................................. 18
Getting Started .................................................................................. 4
Evaluation Board Schematics and Artwork................................ 23
Setup Sequence Summary ........................................................... 4
Ordering Information.................................................................... 26
Installing the Software ................................................................. 4
Bill of Materials........................................................................... 26
Connecting the USB Cable.......................................................... 5
Related Links............................................................................... 27
Verifying the Links and Power Up the Evaluation Board....... 6
REVISION HISTORY
2/12—Revision 0: Initial Version
Rev. 0 | Page 2 of 28
Evaluation Board User Guide
UG-364
EVALUATION BOARD HARDWARE
TERMINAL BLOCK FUNCTIONS
Table 1. Link Functions
Link No.
LK1
LK2
LK3
LK4
LK5
LK6
Default Location
Out
Out
In
Out
In
A
Function
Option to remove external conditioning
Option to remove external conditioning
On-board, 16 MHz crystal connection, connects to Y2
SMB connected external clock
Connects 5 V from USB to ADP3303
AVDD and DVDD power supply connector
Rev. 0 | Page 3 of 28
UG-364
Evaluation Board User Guide
GETTING STARTED
SETUP SEQUENCE SUMMARY
1.
2.
3.
4.
Install the AD5933 graphical user interface software on the
CD that accompanies the evaluation board. Do not connect
the USB cable from the AD5933 evaluation board to the
computer USB hub until the evaluation software is properly
installed. See the Installing the Software section for
additional information.
Connect the computer USB port to the evaluation board
using the USB cable provided in the evaluation kit and run
the USB hardware installation wizard after the evaluation
software is correctly installed (the hardware installation
may happen automatically depending on the settings of the
current operating system). See the Connecting the USB
Cable section for additional information.
Ensure that the appropriate links are made throughout
the evaluation board. Prior to opening and running the
evaluation software program, power up the evaluation
board appropriately. See the Verifying the Links and Power
Up section for additional information.
Configure the front panel of the evaluation board software to
run the required sweep function. See the Performing a
Frequency Sweep section for additional information.
10441-004
The evaluation board installation instructions are for the
Windows XP® operating system with English (United States) set
for its language. The regional and language settings of a PC can
be changed in the Regional and Language directory within the
Control Panel (Start/Control Panel/Regional and Language/
Formats). The installation consists of the following steps that
are described in detail in the sections that follow.
Figure 3. Installation Wizard
3.
Install the evaluation board software in the default destination
folder path, C:\Program Files\Analog Devices\AD5933\
AD5933 Evaluation Software Rev 1.0 Setup (see Figure 4).
INSTALLING THE SOFTWARE
2.
Put the evaluation board CD into the CD drive of the PC
and click Start/My Computer.
The CD software installation may happen automatically
after the CD is inserted into the CD drive; however, this may
depend on the settings of the current operating system. If the
software installation does not automatically start, go to
AD5933 Installation/Setup.exe and double-click Setup.exe
to install the software on the PC through the installation
wizard (see Figure 2 and Figure 3).
10441-003
1.
Figure 2. Evaluation Software CD Contents
Rev. 0 | Page 4 of 28
10441-005
To install the evaluation board software, use the following steps:
Figure 4. Default Destination Folder
Evaluation Board User Guide
Choose the Analog Devices directory (see Figure 5). If the
Analog Devices folder does not yet exist, create an Analog
Devices folder and add the program icon to this new folder.
CONNECTING THE USB CABLE
To connect the USB cable, use the following steps:
1.
Plug the USB cable into the USB hub of the PC and connect
the other end of the USB cable into the AD5933 evaluation
board USB socket (see J1 in Figure 32). A message may
appear that a USB device has been detected on the host
computer and that new hardware has been found (see
Figure 8).
10441-006
10441-009
4.
UG-364
Figure 8. USB Device Detected by Host Computer
2.
Figure 5. Select Analog Devices Directory
10441-007
Figure 6. Opening the Evaluation Software
The following message appears (see Figure 7) because the
firmware code that the evaluation software operates from,
and that needs to be downloaded to the evaluation board USB
microcontroller memory each time the interface software
program is opened, cannot be successfully downloaded to
the evaluation board. The error message is presented because
there is currently no USB connection between the computer
and the AD5933 evaluation board at this stage; therefore,
this error message is to be expected. Click Cancel.
10441-010
6.
After installing the software, remove the CD from the CD
drive. You may be asked to reboot the computer at this stage.
Go to Start/All Programs/Analog Devices/AD5933/
AD5933 (see Figure 6).
Figure 9. Hardware Installation Wizard
10441-008
5.
The Found New Hardware Wizard then appears (see
Figure 9). This wizard locates and installs the appropriate
driver files for the AD5933 evaluation kit in the operating
system registry. Select Install the software automatically
(Recommended) and click Next > to continue (see Figure 9).
Figure 7. Expected Error Message
Rev. 0 | Page 5 of 28
UG-364
3.
Evaluation Board User Guide
A standard windows operating system warning message
then appears, as shown in Figure 10. It indicates that the
new hardware currently being installing on the Windows®
operating system (AD5933 evaluation kit) has not passed the
Windows logo testing to verify compatibility with Windows
XP. This warning appears because the installation is an
evaluation setup installation and is not intended to be used
in a production environment. Click Continue Anyway and
then click Finish.
PERFORMING A FREQUENCY SWEEP
The sequence for performing a linear frequency sweep across a
200 kΩ resistive impedance connected across the VOUT and
VIN pins within the frequency range of 30 kHz to 30.2 kHz is
outlined in this section. The default software settings for the
evaluation board are shown in Figure 12. (Note that a 200 kΩ
resistor must be connected across the VIN and VOUT pins of
the AD5933). The default link positions are outlined in Table 1,
see this before continuing.
To open the software, go to Start > Programs > Analog Devices >
AD5933 and click AD5933 Evaluation Software.
Figure 12 shows the graphic user interface program open and
running successfully. It also shows the interface panel along with
a frequency sweep impedance profile for a 200 kΩ resistive
impedance (note RFB = 200 kΩ).
To setup a typical sweep across a 200 kΩ impedance (RFB = 200 kΩ),
use the following steps:
•
10441-011
•
Figure 10. Expected Warning Message
•
10441-012
The message shown in Figure 11 appears once the hardware has
been successfully installed.
•
Figure 11. Successful Hardware Installation
VERIFYING THE LINKS AND POWER UP THE
EVALUATION BOARD
Ensure that the relevant links are in place on the evaluation board
(see Table 1) and that the proper power connections and supply
values have been made to the terminal blocks before applying
power to the evaluation board. The power supply terminal blocks
are outlined in evaluation board schematic (see Figure 32). Note
that the USB connector only supplies power to the Cypress USB
controller chip that interfaces to the AD5933. If required, a
dedicated external voltage supply to each terminal block can
be provided. Ensure that all relevant power supply connections
and links are made before running the evaluation software. For
optimum performance, supply the three supply signals (AVDD1,
AVDD2, and DVDD) from a stable external reference supply via the
power supply terminal blocks on the board.
Rev. 0 | Page 6 of 28
Set Start Frequency (Hz) to 30000 (Hz) within the Sweep
Parameters section (see 1 in Figure 12). The start frequency
is 24-bit accurate.
Set Delta Frequency (Hz) to 2 (Hz) within the Sweep
Parameters section (see 1 in Figure 12). The frequency step
size is also 24-bit accurate.
Set Number Increments (9 Bit) within the Sweep Parameters
section to 200 (see 1 in Figure 12) to set the number of
increments along the sweep to 200. The maximum number
of increments that the device can sweep across is 511, and
the value is stored in a register as a 9-bit value.
Set Number of Settling Time Cycles to 15 (see 1 in Figure 12).
Note that when sweeping across a high-Q structure, such
as resonant impedance, users must ensure that the contents
of the settling time cycles register is sufficient to ensure
that the impedance under test settles before incrementing
between each successive frequency in the programmed
sweep. This is achieved by increasing the Number of
Settling Time Cycles value.
The delay between the time a frequency increment takes place
on the output of the internal direct digital synthesizer (DDS)
core and the time the ADC samples the response signal at
this new frequency is determined by the contents of the
number of settling time cycles registers (Register 0x8A and
Register 0x8B), see the AD5933 data sheet for further details.
For example, if a value of 15 is programmed into the Number
of Settling Time Cycles box, and if the next output frequency
is 32 kHz, the delay between the time the DDS core starts
to output the 32 kHz signal and the time the ADC samples the
response signal is 15 × (1/32 kHz) ≈ 468.7 μs. The maximum
number of settling time cycle delays that can be programmed
to the board is 511 cycles. The value is stored in a register as
a 9-bit value, and this value can be further multiplied by a
factor of 2 or by a factor of 4.
Evaluation Board User Guide
2
3
4
5
10441-013
1
UG-364
Figure 12. AD5933 Evaluation Software Front Panel (Impedance Profile of 200 kΩ Resistor Displayed)
•
•
•
•
Choose the external clock as the system clock. Select
External clock in the System Clock section (see 2 in
Figure 12).
Set Output Excitation voltage range of the AD5933 at
Pin 6 (VOUT) to Range1:2v p-p (see 2 in Figure 12). The
four possible output ranges available are 2 V p-p, 1 V p-p,
0.4 V p-p, or 0.2 V p-p, typically.
Set the PGA gain of the ADC on the receive stage (either
×1 or ×5) in the PGA Control section to ×1 (see 2 in
Figure 12).
Refer to the Calibration Impedance panel (see 2 in Figure 12).
Prior to making any measurements, calibrate the AD5933
with a known (that is, accurately measured) calibration
impedance connected between the VIN and VOUT pins of
the AD5933. The choice of calibration impedance topology
(for example, R1 in series with C1, R1 in parallel with C1)
depends on the application in question. However, ensure
that each component of the measured calibration impedance
is entered correctly into each chosen topology component
text box (see 2 in Figure 12). For this example, Resistor
•
•
•
Rev. 0 | Page 7 of 28
only R1 was chosen in the Calibration Impedance
section, that is, to measure the impedance of a 200 kΩ
resistive impedance across frequency. Also for this example,
set Resistor value R1 to 200E3 (Ω).
Click Program Device Registers (see 3 in Figure 12) to
program the sweep parameters as previously chosen into
the appropriate on-board registers of the AD5933 through
the I2C interface.
The value programmed into the settling time cycles can be
further multiplied by a factor of 2 or a factor of 4 for a sweep.
Select ×1 (Default) in the DDS Settling Time Cycles section.
Now that the frequency sweep parameters and gain settings
are programmed, the next step is to calibrate the AD5933
system by calculating the gain factor.
The explanation of the system calibration gain factor, a term
calculated once at system calibration, is provided in detail
in the AD5933 data sheet. The AD5933 gain factor must be
calibrated correctly for a particular impedance range before
any subsequent valid impedance measurement (refer to the
AD5933 data sheet for further details).
UG-364
•
Evaluation Board User Guide
To automatically calculate the gain factor(s) for the
subsequent sweep, click Calculate Gain Factor. The
evaluation software evaluates either a single midpoint
frequency gain factor or multipoint frequency gain factors,
that is, a gain factor for each point in the programmed sweep
(see 4 in Figure 12). The midpoint gain factor is determined
at the midpoint of the programmed sweep, and the multipoint
gain factors are determined at each point in the programmed
frequency sweep.
•
•
When either the midpoint gain factor or the multipoint gain
factors are calculated, a message appears on the evaluation
board software front panel, as shown in Figure 13. The gain
factor(s) returned to the evaluation software are subsequently
used for the sweep across the impedance under test.
Click Measure in the Internal Temperature section of the
evaluation board software front panel to take a reading
from the on-board temperature sensor. This returns the
13-bit temperature of the device. See AD5933 data sheet
for more information on the temperature sensor.
Click Download Impedance Data to download the frequency
sweep data (that is, frequency, impedance phase, real,
imaginary, and magnitude data) from the DFT of the sweep
(see 5 in Figure 12). The common dialog front panel is
presented as shown in Figure 15. Choose a file name in a
directory of choice and click Save (see Figure 15). This
saves the sweep data to a comma separated variable file
(.CSV) located in the chosen directory.
1. CHOOSE
DIRECTORY
3. SAVE THE FILE
Figure 13. Confirmation of a Midpoint Calculation or
a Multipoint Gain Factors Calculation
Figure 15. Saving the Sweep Data
10441-015
Note that should any of the system gain settings (for example,
change in output excitation range or PGA gain) change after
the system is calibrated (that is, gain factor(s) are calculated),
it is necessary to recalculate the gain factor(s) to subsequently
measure accurate impedance results. The gain factor(s)
calculated in the software are not programmed into the
AD5933 RAM and are only valid when the evaluation
software program is open and running. The gain factor(s)
are not retained in the evaluation software when the software
program is closed.
Click Start Sweep (see 5 in Figure 12) to begin the sweep.
Once the evaluation software completes the sweep, it
automatically returns both a plot of the impedance vs.
frequency and phase vs. frequency for the impedance
under test (see Figure 12).The progress of the sweep is
outlined with a progress bar, as shown in Figure 14.
Figure 14. Sweep Progress Bar (Blue)
Rev. 0 | Page 8 of 28
The contents of this file can be accessed by using Notepad
or Microsoft Excel to plot the data. Each file contains a single
column of data. The format of the downloaded data is shown
in Figure 16.
10441-017
After the system interface software calculates the gain factor(s)
for the programmed sweep parameters, the results are shown
in the Calculated Gain Factor box.
•
10441-016
10441-014
2. CHOOSE
FILE NAME
Figure 16. Opening the Sweep Data in Excel
Evaluation Board User Guide
UG-364
Each data entry corresponds to a single measurement
(frequency) point; therefore, if the value for the number of
increments is programmed as 511 point, the array contains
a single column of data with 512 data points, starting at the
start frequency and ending at stop frequency value, which
is determined by
Start Frequency + (Number of Increments × Delta
Frequency)
10441-018
The impedance profile and phase profile vs. frequency appears
in the evaluation software front panel after the sweep has
completed. Click the individual tabs to switch between
Absolute Impedance |Z| and Impedance Phase Ø. Click
Absolute Impedance |Z| to show how the impedance under
analysis (ZUNKNOWN) varies across the programmed frequency
range. To view how the phase across the network under
analysis varies, click Impedance Phase Ø, as shown
in Figure 17.
Note that the phase measured by the AD5933 takes into
account the phase introduced through the entire signal path,
that is, the phase introduced through the output amplifiers,
receive current-to-voltage (I-V) amplifier, and the low-pass
filter, along with the phase through the impedance (ZØ) under
analysis connected between VOUT and VIN (Pin 6 and Pin 5
of the AD5933). Calibrate out the phase of the system using
a resistor before any subsequent impedance (ZØ) phase
measurement is calculated. Calibrate with a resistor in the
evaluation software to calibrate the system phase correctly
(refer to the Impedance Measurement Tips section for
further details).
Figure 17. The Phase Tab on the AD5933 Evaluation Software Front Panel, Phase of 200 kΩ Resistor (0°) Displayed
Rev. 0 | Page 9 of 28
UG-364
Evaluation Board User Guide
3.
TWO INSTALLATION FREQUENTLY ASKED
QUESTIONS
Scroll to Universal Serial Bus controllers and expand the
root directory (see Figure 19). When the AD5933 hardware is
correctly installed, each time the USB cable connecting the
evaluation board to the computer is plugged in, the items
within the Universal Serial Bus controllers are refreshed.
Q: How can I confirm that the hardware was correctly installed
on the PC?
A: To confirm the hardware was correctly installed on the PC,
use the following steps:
Right-click My Computer and left-click Properties.
Go to the Hardware tab, and click Device Manager (see
Figure 18).
EXPAND ROOT
DIRECTORY
10441-019
Figure 18. System Properties
10441-020
1.
2.
Figure 19 shows what to expect when the AD5933 evaluation
board is correctly installed and when the evaluation board and
USB cable are connected correctly to the computer. The root
directory is subsequently refreshed when the USB cable is
unplugged from evaluation board, and the AD5933 evaluation
kit icon is removed from the main root.
Figure 19. Correctly Installed Hardware
Rev. 0 | Page 10 of 28
Evaluation Board User Guide
UG-364
Q: During installation, when the board is plugged in for the first
time, the message shown in Figure 20 appears. When I click
Finish, the message shown in Figure 21 appears. What do I do
next?
2. RIGHT CLICK
ON THIS DEVICE
10441-023
1. EXPAND THIS
DIRECTORY
10441-021
Figure 22. USB Device Not Recognized
10441-022
Figure 20. Error During the Hardware Installation
Figure 21. Found New Hardware Issue
A: If the evaluation software is installed correctly (install the
software correctly prior to plugging in the board for the first
time), this message simply indicates that the AD5933 device
drivers have not been installed to the correct registry and,
therefore, could not be correctly located by the install wizard.
CORRECTLY INSTALLED
HARDWARE
1.
2.
3.
4.
5.
Right-click My Computer, and left-click Properties.
Go to the Hardware tab, select Device Manager, and
expand Other devices (see Figure 22). The computer has
not recognized the USB device, that is, the AD5933
evaluation board.
Right-click USB Device and select Uninstall Driver.
Unplug the evaluation board and wait approximately
30 seconds before plugging it in again.
Proceed through the installation wizard a second time. The
expanded root directory shown in Figure 19 is a correct
installation. If the same error message is encountered the
second time, uninstall the device driver, uninstall the
software, and contact Analog Devices applications support
at www.analog.com for further instructions regarding valid
driver files.
Rev. 0 | Page 11 of 28
10441-024
To reinstall the device drivers, use the following steps:
Figure 23. Correctly Installed Hardware
UG-364
Evaluation Board User Guide
SOURCE CODE FOR IMPEDANCE SWEEP
PROGRAM FREQUENCY SWEEP PARAMETERS
INTO RELEVANT REGISTERS
(1) START FREQUENCY REGISTER
(2) NUMBER OF INCREMENTS REGISTER
(3) FREQUENCY INCREMENT REGISTER
PLACE THE AD5933 INTO STANDBY MODE.
RESET: BY ISSUING A RESET COMMAND TO
THE CONTROL REGISTER, THE DEVICE IS
PLACED IN STANDBY MODE.
PROGRAM THE INITIALIZE WITH START
FREQUENCY COMMAND TO THE CONTROL
REGISTER.
AFTER A SUFFICIENT AMOUNT OF SETTLING
TIME HAS ELAPSED, PROGRAM THE START
FREQUENCY SWEEP COMMAND IN THE
CONTROL REGISTER.
POLL THE STATUS REGISTER TO CHECK IF
THE DFT CONVERSION IS COMPLETE.
N
Y
PROGRAM THE INCREMENT FREQUENCY OR
THE REPEAT FREQUENCY COMMAND TO THE
CONTROL REGISTER.
READ VALUES FROM THE REAL AND
IMAGINARY DATA REGISTER.
Y
POLL THE STATUS REGISTER TO CHECK IF
FREQUENCY SWEEP IS COMPLETE.
N
PROGRAM THE AD5933
INTO POWER-DOWN MODE.
10441-025
Y
Figure 24. Sweep Flow Outline
This section outlines the evaluation board code structure required
to set up the AD5933 frequency sweep. The sweep flow outline is
shown in Figure 24. Each section of the flow diagram is explained
with the help of the visual basic code extracts. The firmware
code (c code), which is downloaded to the USB microcontroller
connected to the AD5933, implements the low level I2C signal
control (that is, read and write vendor request).
The code extract, which is shown in the Evaluation Board
Source Code Extract section, shows how to program a single
frequency sweep starting at 30 kHz, with a frequency step of
10 Hz and with 150 points in the sweep. The code assumes
that a 16 MHz clock signal is connected to Pin 8 (MCLK) of
the AD5933. The impedance range under test is from 90 kΩ
to 110 kΩ. The gain factor is calculated at the midpoint of the
frequency sweep, that is, 30.750 kHz. The calibration is carried
out with a 100 kΩ resistor connected between VOUT and VIN.
The feedback resistor = 100 kΩ.
The first step in Figure 24 is to program the three sweep
parameters necessary to define the frequency sweep (that is,
the start frequency, number of increments, and frequency
increments). Refer to the AD5933 data sheet for more details.
Rev. 0 | Page 12 of 28
Evaluation Board User Guide
UG-364
EVALUATION BOARD SOURCE CODE EXTRACT
‘------------------------------------------------------------------------------------------------------‘Code developed using visual basic® 6.
‘Datatype
range
‘Byte
0-255
‘Double
-1.797e308 to – 4.94e-324 and 4.94e-324 to 1.7976e308
‘Integer
-32,768 to 32767
‘Long
-2,147,483,648 to 2,147,483,647
‘Variant‘...when storing numbers same range as double. When storing strings same range as string.
‘-------------------------------------- Variable Declarations ----------------------------------------Dim ReadbackStatusRegister As Long
'stores the contents of the status register.
Dim RealData As Double
'used to store the 16 bit 2s complement real data.
Dim RealDataUpper As Long
'used to store the upper byte of the real data.
Dim RealDataLower As Long
'used to store the lower byte of the real data.
Dim ImagineryData As Double
'used to store the 16 bit 2s complement real data.
Dim ImagineryDataLower As Long
'used to store the upper byte of the imaginary data.
Dim ImagineryDataUpper As Long
'used to store the lower byte of the imaginary data.
Dim Magnitude As Double
'used to store the sqrt (real^2+imaginary^2).
Dim Impedance As Double
'used to store the calculated impedance.
Dim MaxMagnitude As Double
'used to store the max impedance for the y axis plot.
Dim MinMagnitude As Double
'used to store the min impedance for the y axis plot.
Dim sweep_phase As Double
'used to temporarily store the phase of each sweep point.
Dim Frequency As Double
'used to temporarily store the current sweep frequency.
Dim Increment As Long
'used as a temporary counter
Dim i As Integer
'used as a temporary counter in (max/min) mag,phase loop
Dim xy As Variant
'used in the stripx profile
Dim varray As Variant
Dim Gainfactor as double
‘either a single mid point calibration or an array of calibration points
Dim TempStartFrequency
As Double
Dim StartFrequencybyte0
As Long
Dim StartFrequencybyte2
As Long
Dim StartFrequencybyte1A
As Long
Dim StartFrequencybyte1B
As Long
Dim DDSRefClockFrequency
As Double
Dim NumberIncrementsbyte0 As Long
Dim NumberIncrementsbyte1 As Long
Dim FrequencyIncrementbyt0 As Long
Dim FrequencyIncrementbyt1 As Long
Dim FrequencyIncrementbyt2 As Long
Dim SettlingTimebyte0
As Long
Dim SettlingTimebyte1
As Long
‘-------------------------------------- I^2C read/write definitions----------------------------------------‘used in the main sweep routine to read and write to AD5933.This is the vendor request routines in the
firmware
Private Sub WritetToPart(RegisterAddress As Long, RegisterData As Long)
PortWrite &HD, RegisterAddress, RegisterData
‘parameters = device address register address register data
End Sub
Public Function PortWrite(DeviceAddress As Long, AddrPtr As Long, DataOut As Long) As Integer
PortWrite = VendorRequest(VRSMBus, DeviceAddress, CLng(256 * DataOut + AddrPtr), VRWRITE, 0, 0)
End Function
Public Function PortRead(DeviceAddress As Long, AddrPtr As Long) As Integer
PortRead = VendorRequest(VRSMBus, DeviceAddress, AddrPtr, VRREAD, 1, DataBuffer(0))
PortRead = DataBuffer(0)
End Function
‘------------------------------------- PHASE CONVERSION FUNCTION DEFINITION -------------------------------‘This function accepts the real and imaginary data(R, I) at each measurement sweep point and converts it to
a degree
‘----------------------------------------------------------------------------------------------------------Public Function phase_sweep (ByVal img As Double, ByVal real As Double) As Double
Dim theta As Double
Dim pi As Double
pi = 3.141592654
If ((real > 0) And (img > 0)) Then
theta = Atn(img / real)
phase2 = (theta * 180) / pi
' theta = arctan (imaginary part/real part)
'convert from radians to degrees
Rev. 0 | Page 13 of 28
UG-364
Evaluation Board User Guide
ElseIf ((real > 0) And (img < 0)) Then
theta = Atn(img / real)
phase2 = ((theta * 180) / pi ) +360
'4th quadrant theta = minus angle
ElseIf ((real < 0) And (img < 0)) Then
theta = -pi + Atn(img / real)
phase2 = (theta * 180) / pi
'3rd quadrant theta img/real is positive
ElseIf ((real < 0) And (img > 0)) Then
theta = pi + Atn(img / real)
phase2 = (theta * 180) / pi
'2nd quadrant img/real is neg
End If
End Function
‘----------------------------------------------------------------------------------------------------------Private Sub Sweep ()
’ the main sweep routine
‘This routine coordinates a frequency sweep using a mid point gain factor (see datasheet).
'The gain factor at the mid-point is determined from the real and imaginary contents returned at this mid
‘point frequency and the calibration impedance.
'The bits of the status register are polled to determine when valid data is available and when the sweep is
‘complete.
'----------------------------------------------------------------------------------------------------------IndexArray = 0
'initialize counter variable.
Increment = NumberIncrements + 1 'number of increments in the sweep.
Frequency = StartFrequency
'the sweep starts from here.
‘------------------------- PROGRAM 30K Hz to the START FREQUENCY register --------------------------------DDSRefClockFrequency = 16E6
StartFrequency = 30E3
‘Assuming a 16M Hz clock connected to MCLK
‘frequency sweep starts at 30K Hz
TempStartFrequency = (StartFrequency / (DDSRefClockFrequency / 4)) * 2^27 ‘dial up code for the DDS
TempStartFrequency = Int(TempStartFrequency) ‘30K Hz = 0F5C28 hex
StartFrequencybyte0 = 40
StartFrequencybyte1 = 92
StartFrequencybyte2 = 15
‘40 DECIMAL = 28 HEX
‘92 DECIMAL = 5C HEX
’15 DECIMAL = 0F HEX
'Write in data to Start frequency register
WritetToPart &H84, StartFrequencybyte0
'84 hex lsb
WritetToPart &H83, StartFrequencybyte1
'83 hex
WritetToPart &H82, StartFrequencybyte2
'82 hex
‘--------------------------------- PROGRAM the NUMBER OF INCREMENTS register -----------------------------‘The sweep is going to have 150 points 150 DECIMAL = 96 hex
'Write in data to Number Increments register
WritetToPart &H89, 96
‘lsb
WritetToPart &H88, 00
‘msb
‘--------------------------------- PROGRAM the FREQUENCY INCREMENT register -----------------------------‘The sweep is going to have a frequency increment of 10Hz between successive points in the sweep
DDSRefClockFrequency = 16E6
FrequencyIncrements = 10
‘Assuming a 16M Hz clock connected to MCLK
‘frequency increment of 10Hz
TempStartFrequency = (FrequencyIncrements / (DDSRefClockFrequency / 4)) * 2^27 ‘dial up code for the DDS
TempStartFrequency = Int(TempStartFrequency) ’10 Hz = 335 decimal = 00014F hex
FrequencyIncrementbyt0 = 4F
FrequencyIncrementbyt1 = 01
FrequencyIncrementbyt2 = 00
‘335 decimal = 14f hex
'Write in data to frequency increment register
WritetToPart &H87, FrequencyIncrementbyt0
'87 hex lsb
WritetToPart &H86, FrequencyIncrementbyt1
'86 hex
WritetToPart &H85, FrequencyIncrementbyt2
'85 hex msb
‘--------------------------------- PROGRAM the SETTLING TIME CYCLES register -----------------------------‘The DDS is going to output 15 cycles of the output excitation voltage before the ADC will start sampling
‘the response signal. The settling time cycle multiplier is set to x1
Rev. 0 | Page 14 of 28
Evaluation Board User Guide
UG-364
SettlingTimebyte0 = 0F ‘15 cycles (decimal) = 0F hex
SettlingTimebyte1 = 00 ’00 = X1
WritetToPart &H8B, SettlingTimebyte0
WritetToPart &H8A, SettlingTimebyte1
‘-------------------------------------- PLACE AD5933 IN STANDBYMODE ---------------------------------------‘Standby mode command = B0 hex
WritetToPart &H80, &HB0
'------------------------- Program the system clock and output excitation range and PGA setting----------‘Enable external Oscillator
WritetToControlRegister2 &H81, &H8
‘Set the output excitation range to be 2vp-p and the PGA setting to = x1
WritetToControlRegister2 &H80, &H1
‘----------------------------------------------------------------------------------------------------------‘------------- ------------ Initialize impedance under test with start frequency --------------------------'Initialize Sensor with Start Frequency
WritetToControlRegister &H80, &H10
msDelay 2
'this is a user determined delay dependent upon the network under analysis (2ms delay)
‘-------------------------------------- Start the frequency sweep -----------------------------------------'Start Frequency Sweep
WritetToControlRegister &H80, &H20
'Enter Frequency Sweep Loop
ReadbackStatusRegister = PortRead(&HD, &H8F)
ReadbackStatusRegister = ReadbackStatusRegister And &H4 ' mask off bit D2 (i.e. is the sweep complete)
Do While ((ReadbackStatusRegister 4) And (Increment 0))
'check to see if current sweep point complete
ReadbackStatusRegister = PortRead(&HD, &H8F)
ReadbackStatusRegister = ReadbackStatusRegister And &H2
'mask off bit D1 (valid real and imaginary data available)
‘------------------------------------------------------------------------If (ReadbackStatusRegister = 2) Then
' this sweep point has returned valid data so we can proceed with sweep
Else
Do
‘if valid data has not been returned then we need to pole stat reg until such time as valid data
'has been returned
‘i.e. if point is not complete then Repeat sweep point and pole status reg until valid data
returned
WritetToControlRegister &H80, &H40 'repeat sweep point
Do
ReadbackStatusRegister = PortRead(&HD, &H8F)
ReadbackStatusRegister = ReadbackStatusRegister And &H2
' mask off bit D1- Wait until dft complete
Loop While (ReadbackStatusRegister 2)
Loop Until (ReadbackStatusRegister = 2)
End If
'-------------------------------------------------------------------------
'
RealDataUpper = PortRead(&HD, &H94)
RealDataLower = PortRead(&HD, &H95)
RealData = RealDataLower + (RealDataUpper * 256)
'The Real data is stored in a 16 bit 2's complement format.
'In order to use this data it must be converted from 2's complement to decimal format
If RealData