Preliminary Technical Data
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
ElseIf ((real > 0) And (img < 0)) Then
theta = Atn(img / real)
phase2 = ((theta * 180) / pi ) +360
ElseIf ((real < 0) And (img < 0)) Then
theta = -pi + Atn(img / real)
phase2 = (theta * 180) / pi
ElseIf ((real < 0) And (img > 0)) Then
theta = pi + Atn(img / real)
phase2 = (theta * 180) / pi
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
Increment = NumberIncrements + 1 'number of increments in the sweep.
Frequency = StartFrequency
'------------------------- PROGRAM 30K Hz to the START FREQUENCY register ---------------------------------
DDSRefClockFrequency = 16E6
StartFrequency = 30E3
TempStartFrequency = (StartFrequency / (DDSRefClockFrequency / 16)) * 2^27 'dial up code for the DDS
TempStartFrequency = Int(TempStartFrequency)
StartFrequencybyte0 = 163
StartFrequencybyte1 = 112
StartFrequencybyte2 =
'Write in data to Start frequency register
WritetToPart &H84, StartFrequencybyte0
WritetToPart &H83, StartFrequencybyte1
WritetToPart &H82, StartFrequencybyte2
'--------------------------------- 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
WritetToPart &H88, 00
'--------------------------------- 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
TempStartFrequency = (FrequencyIncrements / (DDSRefClockFrequency / 16)) * 2^27 'dial up code for the DDS
TempStartFrequency = Int(TempStartFrequency)
FrequencyIncrementbyt0 = 42
' theta = arctan (imaginary part/real part)
'initialize counter variable.
'the sweep starts from here.
'Assuming a 16M Hz clock connected to MCLK
'frequency sweep starts at 30K Hz
'163
DECIMAL
'112 DECIMAL = 70 HEX
61
'3D
DECIMAL
=
'84 hex lsb
'83 hex
'82 hex
'lsb
'msb
'Assuming a 16M Hz clock connected to MCLK
'frequency increment of 10Hz
'1342 decimal = 53E hex
'convert from radians to degrees
'4th quadrant theta = minus angle
'3rd quadrant theta img/real is positive
'2nd quadrant img/real is neg
'30K Hz = 3D70A3 hex
=
A3 HEX
61 HEX
'10 Hz =
335 decimal = 00053E hex
Rev. PrC | Page 17 of 32
EVAL-AD5934EB
Need help?
Do you have a question about the EVAL-AD5934EB and is the answer not in the manual?