Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phaser updates #37

Draft
wants to merge 14 commits into
base: tfcollins/phaser-tdd
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions +adi/+internal/ADAR100x.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
end

properties
%Mode Mode
%Mode ADAR1000 Mode
% Mode is a cellarray where each element addresses individual ADAR1000's.
% Each cell must contain a string of value
% 'Rx', 'Tx', or 'disabled' to set the modes.
Expand Down Expand Up @@ -110,7 +110,7 @@
% External Bias for External LNAs. LNABiasOff is an array
% where each element addresses individual ADAR1000's.
LNABiasOff = -2
%PolState Pol State
%PolState ADAR1000 Switch Polarity
% Control for External Polarity Switch Drivers.
% PolSwitchEnable is an array where each element addresses
% individual ADAR1000's. Each element must be a logical
Expand Down
34 changes: 20 additions & 14 deletions +adi/+internal/ADF4159.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@
% IIO Driver: https://wiki.analog.com/resources/tools-software/linux-drivers

properties
%Frequency Frequency
%Frequency LO Output Frequency
% Set output frequency of synthesizer in Hz. When the synthesizer
% is ramping this is the start frequency
Frequency = 1e9;
%FrequencyDeviationRange Frequency Deviation Range
%FrequencyDeviationRange LO Chirp Frequency BW
% Set upper bound on frequency ramp from Frequency property in Hz.
% This is only applicable when RampMode is not set to "disabled"
FrequencyDeviationRange = 1e6;
%FrequencyDeviationStep Frequency Deviation Step
%FrequencyDeviationStep LO Chirp Frequency Steps
% Set step size in Hz of synthesizer ramp. This is only
% applicable when RampMode is not set to "disabled".
FrequencyDeviationStep = 500e6 / 4 / 1000;
%FrequencyDeviationTime Frequency Deviation Time
%FrequencyDeviationTime LO Chirp Time
% Set time in uSeconds to reach ramp peak value. This is only
% applicable when RampMode is not set to "disabled"
FrequencyDeviationTime = 0;
%RampMode Ramp Mode
%RampMode LO Chirp Ramp Mode
% Set ramp waveform. Options are:
% - "disabled"
% - "continuous_sawtooth"
Expand All @@ -31,38 +31,38 @@
end

properties(Logical)
%Powerdown
%Powerdown ADF4159 PLL Powerdown
% When true output will be disabled. Writing to this value will
% also update all settings of device
Powerdown = false;
end

properties% Advanced
%DelayStartWord Delay Start Word
%DelayStartWord LO Ramp Delay Start
% Set start delay of each ramp in PFD or PFD*CLK1 clock cycles.
% This is a 12-bit number
DelayStartWord = 0;
%DelayClockSource Delay Clock Source
%DelayClockSource LO Ramp Delay Clock Selection
% Set clock use to determine ramp delay. Options are:
% - "PFD"
% - "PFD*CLK1"
DelayClockSource (1,1) string {mustBeMember(DelayClockSource, ["PFD","PFD*CLK1"])} = "PFD";
end

properties(Logical)%Advanced
%DelayStartEnable Ramp Delay Enable
%DelayStartEnable LO Ramp Start Delay Enable
% Enable delaying of ramp signal at start of first ramp generation
DelayStartEnable = false;
%RampDelayEnable Ramp Delay Enable
%RampDelayEnable LO Ramp Delay Enable
% Enable delaying of ramp signal at start of each ramp generation
RampDelayEnable = false;
%TriggerDelayEnable Trigger Delay Enable
%TriggerDelayEnable LO Ramp Trigger Delay Enable
% Enable ramp start delay when controlled by external trigger
TriggerDelayEnable = false;
%TriggerEnable Trigger Enable
%TriggerEnable LO Ramp Trigger Enable
% Allow for use of external trigger on TX Data pin to start ramp
TriggerEnable = false;
%SingleFullTriangleEnable Single Full Triangle Enable
%SingleFullTriangleEnable LO Ramp Full Triangle Enable
% Enable sending of single full triangular wave. This is
% applicable when RampMode is in "single_ramp_burst"
SingleFullTriangleEnable = false;
Expand Down Expand Up @@ -91,8 +91,14 @@
obj.FrequencyDeviationStep = rvalue;
end
function set.FrequencyDeviationTime(obj,value)
setAttributeLongLong(obj, 'altvoltage0', 'frequency_deviation_time', int64(value), true, 40, obj.iioDeviceADF4159);
setAttributeLongLong(obj, 'altvoltage0', 'frequency_deviation_time', int64(value), true, 40, obj.iioDeviceADF4159, false);
rvalue = obj.getAttributeLongLong('altvoltage0', 'frequency_deviation_time',true, obj.iioDeviceADF4159);
if rvalue ~= value
disp(['[', 8, 'Warning: Requested FrequencyDeviationTime is not possible for the given value of FrequencyDeviationStep.]', 8])
fprintf(' You requested %d us, but %d us is the closest available FrequencyDeviationTime.\n', value, rvalue)
fprintf(' FrequencyDeviationTime has been changed to %d us.\n', rvalue)
fprintf(' For a value closer to the %d us, try choosing a different FrequencyDeviationStep.\n', value)
end
obj.FrequencyDeviationTime = rvalue;
end
function set.RampMode(obj,value)
Expand Down
52 changes: 22 additions & 30 deletions +adi/+internal/ADF4371.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
%ADF4371Name ADF4371 Name
% Configure programmable divider for ADF4371
% Options: 'RF16x' or 'RF32x'
ADF4371Name = 'RF16x'
ADF4371Name (1,1) string {mustBeMember(ADF4371Name, ["RF16x", "RF32x"])} = "RF16x";
%ADF4371Frequency ADF4371 Frequency
% Configure ADF4371 output frequency
% Allowed range:
Expand Down Expand Up @@ -46,52 +46,52 @@

methods
function set.ADF4371Name(obj, value)
obj.ADF4371Name = value;
if obj.ConnectedToDevice
switch value
% inverted logic to enable the correct channel
case 'RF16x'
setAttributeBool(obj,'altvoltage0','powerdown',true,true,obj.ADF4371Device);
setAttributeBool(obj,'altvoltage1','powerdown',true,true,obj.ADF4371Device);
setAttributeBool(obj,'altvoltage2','powerdown',false,true,obj.ADF4371Device);
setAttributeBool(obj,'altvoltage3','powerdown',true,true,obj.ADF4371Device);
setAttributeBool(obj,'altvoltage0','powerdown',true,true,obj.ADF4371Device,false);
setAttributeBool(obj,'altvoltage1','powerdown',true,true,obj.ADF4371Device,false);
setAttributeBool(obj,'altvoltage2','powerdown',false,true,obj.ADF4371Device,false);
setAttributeBool(obj,'altvoltage3','powerdown',true,true,obj.ADF4371Device,false);
obj.ADF4371Channel = 'altvoltage2';
case 'RF32x'
setAttributeBool(obj,'altvoltage0','powerdown',true,true,obj.ADF4371Device);
setAttributeBool(obj,'altvoltage1','powerdown',true,true,obj.ADF4371Device);
setAttributeBool(obj,'altvoltage2','powerdown',true,true,obj.ADF4371Device);
setAttributeBool(obj,'altvoltage3','powerdown',false,true,obj.ADF4371Device);
setAttributeBool(obj,'altvoltage0','powerdown',true,true,obj.ADF4371Device,false);
setAttributeBool(obj,'altvoltage1','powerdown',true,true,obj.ADF4371Device,false);
setAttributeBool(obj,'altvoltage2','powerdown',true,true,obj.ADF4371Device,false);
setAttributeBool(obj,'altvoltage3','powerdown',false,true,obj.ADF4371Device,false);
obj.ADF4371Channel = 'altvoltage3';
otherwise
error('Invalid setting chosen for ADF4371Name');
end
end
obj.ADF4371Name = value;
end

function set.ADF4371Frequency(obj, value)
switch obj.ADF4371Name
case 'RF16x'
validateattributes( obj.ADF4371Frequency,{ 'double','single', 'uint32' }, ...
{ 'real', 'nonnegative','scalar','finite','nonnan', 'nonempty','integer',...
validateattributes( value,{ 'double','single', 'uint64' }, ...
{ 'real', 'nonnegative','scalar','finite','nonnan', 'nonempty',...
'>=',8000000000,'<=',16000000000},'', 'ADF4371Frequency');
case 'RF32x'
validateattributes( obj.ADF4371Frequency,{ 'double','single', 'uint32' }, ...
{ 'real', 'nonnegative','scalar','finite','nonnan', 'nonempty','integer',...
validateattributes( value,{ 'double','single', 'uint64' }, ...
{ 'real', 'nonnegative','scalar','finite','nonnan', 'nonempty',...
'>=',16000000000,'<=',32000000000},'', 'ADF4371Frequency');
end
obj.ADF4371Frequency = value;
if obj.ConnectedToDevice
setAttributeLongLong(obj,obj.ADF4371Channel,'frequency',value,true,0,obj.ADF4371Device);
setAttributeLongLong(obj,obj.ADF4371Channel,'frequency',value,true,0,obj.ADF4371Device,false);
end
end

function set.ADF4371Phase(obj, value)
validateattributes( obj.ADF4371Phase, { 'double','single', 'uint32' }, ...
validateattributes( value, { 'double','single', 'uint32' }, ...
{ 'real', 'nonnegative','scalar', 'finite', 'nonnan', 'nonempty','integer','>=',0,'<=',359999}, ...
'', 'ADF4371Phase');
obj.ADF4371Phase = value;
if obj.ConnectedToDevice
setAttributeLongLong(obj,obj.ADF4371Channel,'phase',value,true,1,obj.ADF4371Device);
setAttributeLongLong(obj,obj.ADF4371Channel,'phase',value,true,1,obj.ADF4371Device,false);
end
end

Expand All @@ -111,15 +111,7 @@

methods (Hidden, Access = protected)
function setupInit(obj)
numDevs = obj.iio_context_get_devices_count(obj.iioCtx);
obj.ADF4371Device = cell(1,length(obj.ADF4371DeviceName));
for k = 1:numDevs
devPtr = obj.iio_context_get_device(obj.iioCtx, k-1);
name = obj.iio_device_get_name(devPtr);
if strcmpi(obj.ADF4371DeviceName,name)
obj.ADF4371Device = devPtr;
end
end
obj.ADF4371Device = obj.getDev(obj.ADF4371DeviceName);
if isempty(obj.ADF4371Device)
error('%s not found',obj.ADF4371DeviceName);
end
Expand All @@ -134,10 +126,10 @@ function setupInit(obj)
otherwise
error('Invalid setting chosen for ADF4371Name');
end
setAttributeBool(obj,'altvoltage0','powerdown',true,true,obj.ADF4371Device);
setAttributeBool(obj,'altvoltage1','powerdown',true,true,obj.ADF4371Device);
setAttributeBool(obj,'altvoltage2','powerdown',false,true,obj.ADF4371Device);
setAttributeBool(obj,'altvoltage3','powerdown',true,true,obj.ADF4371Device);
setAttributeBool(obj,'altvoltage0','powerdown',true,true,obj.ADF4371Device, false);
setAttributeBool(obj,'altvoltage1','powerdown',true,true,obj.ADF4371Device, false);
setAttributeBool(obj,'altvoltage2','powerdown',false,true,obj.ADF4371Device, false);
setAttributeBool(obj,'altvoltage3','powerdown',true,true,obj.ADF4371Device, false);
obj.setAttributeLongLong(obj.ADF4371Channel,'frequency',obj.ADF4371Frequency,true,0,obj.ADF4371Device);
obj.setAttributeLongLong(obj.ADF4371Channel,'phase',obj.ADF4371Phase,true,1,obj.ADF4371Device);
obj.setDeviceAttributeRAW('muxout_enable', num2str(obj.MUXOutEnable), obj.ADF4371Device);
Expand Down
Loading
Loading