Evaluation Board Source Code Extract - Analog Devices EVAL-AD5933EBZ User Manual

Evaluating the ad5933 1 msps, 12-bit impedance converter network analyzer
Table of Contents

Advertisement

Evaluation Board User Guide

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
Dim RealData As Double
Dim RealDataUpper As Long
Dim RealDataLower As Long
Dim ImagineryData As Double
Dim ImagineryDataLower As Long
Dim ImagineryDataUpper As Long
Dim Magnitude As Double
Dim Impedance As Double
Dim MaxMagnitude As Double
Dim MinMagnitude As Double
Dim sweep_phase As Double
Dim Frequency As Double
Dim Increment As Long
Dim i As Integer
Dim xy As Variant
Dim varray As Variant
Dim Gainfactor as double
Dim TempStartFrequency
Dim StartFrequencybyte0
Dim StartFrequencybyte2
Dim StartFrequencybyte1A
Dim StartFrequencybyte1B
Dim DDSRefClockFrequency
Dim NumberIncrementsbyte0
Dim NumberIncrementsbyte1
Dim FrequencyIncrementbyt0 As Long
Dim FrequencyIncrementbyt1 As Long
Dim FrequencyIncrementbyt2 As Long
Dim SettlingTimebyte0
Dim SettlingTimebyte1
'-------------------------------------- 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
'stores the contents of the status register.
'used to store the 16 bit 2s complement real data.
'used to store the upper byte of the real data.
'used to store the lower byte of the real data.
'used to store the 16 bit 2s complement real data.
'used to store the upper byte of the imaginary data.
'used to store the lower byte of the imaginary data.
'used to store the sqrt (real^2+imaginary^2).
'used to store the calculated impedance.
'used to store the max impedance for the y axis plot.
'used to store the min impedance for the y axis plot.
'used to temporarily store the phase of each sweep point.
'used to temporarily store the current sweep frequency.
'used as a temporary counter
'used as a temporary counter in (max/min) mag,phase loop
'used in the stripx profile
'either a single mid point calibration or an array of calibration points
As Double
As Long
As Long
As Long
As Long
As Double
As Long
As Long
As Long
As Long
' theta = arctan (imaginary part/real part)
'convert from radians to degrees
Rev. 0 | Page 13 of 28
UG-364

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the EVAL-AD5933EBZ and is the answer not in the manual?

Questions and answers

Table of Contents