
Preliminary Technical Data
EVAL-AD5934EB
Rev. PrC | Page 19 of 32
'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 <= &H7FFF Then ' h7fff 32767
' Positive
Else
' Negative
' RealData = RealData And &H7FFF
RealData = RealData - 65536
End If
ImagineryDataUpper = PortRead(&HD, &H96)
ImagineryDataLower = PortRead(&HD, &H97)
ImagineryData = ImagineryDat (ImagineryDataUpper * 256)
'The imaginary 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 ImagineryData <= &H7FFF Then
' Positive Data.
Else
' Negative
' ImagineryData = ImagineryData And &H7FFF
ImagineryData = ImagineryData - 65536
End If
‘-----------------Calculate the Impedance and Phase of the data at this frequency sweep point -----------
Magnitude = ((RealData ^ 2) + (ImagineryData ^ 2)) ^ 0.5
'the next section calculates the phase of the dft real and imaginary components
‘phase_sweep calculates the phase of the sweep data.
sweep_phase = (phase_sweep(ImagineryData, RealData) - calibration_phase_mid_point)
GainFactor =
xx ‘this is determined at calibration.see gain factor section and Datasheet.
Impedance = 1 / (Magnitude * GainFactor)
' Write Data to each global array.
MagnitudeArray(IndexArray) = Impedance
PhaseArray(IndexArray) = sweep_phase
ImagineryDataArray(IndexArray) = ImagineryData
code(IndexArray) = Magnitude
RealDataArray(IndexArray) = RealData
Increment = Increment - 1 ' increment was set to number of increments of sweep at the start
FrequencyPoints(IndexArray) = Frequency
Frequency = Fre FrequencyIncrements ' holds the current value of the sweep freq
IndexArray = Inde 1
------------- Check to see if sweep complete ----------------------
ReadbackStatusRegister = PortRead (&HD, &H8F)
ReadbackStatusRegister = ReadbackStatusRegister And &H4 ' mask off bit D2
'Increment to next frequency point Frequency
WritetToControlRegister &H80, &H30
Loop
‘--------------------- END OF SWEEP: Place device into POWERDOWN mode------------------------------------
'Enter Powerdown Mode,Set Bits D15,D13 in Control Register.
WritetToPart &H80, &HA0
END SUB
‘--------------------------------------------------------------------------------------------------------
‘The programmed sweep is now complete and the impedance and phase data is available to read in the two
‘arrays MagnitudeArray() = Impedance and PhaseArray() = phase.
sweepErrorMsg:
MsgBox "Error completing sweep check values"
End Sub
‘The programmed sweep is now complete and the impedance and phase data is available to read in the two
‘arrays MagnitudeArray() = Impedance and PhaseArray() = phase.