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

AD7124: update code to match newer linux drivers #39

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
12 changes: 10 additions & 2 deletions +adi/+AD7124/Base.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ function delete(obj)
% Set device sampling rate
obj.SampleRate = value;
if obj.ConnectedToDevice
obj.setDeviceAttributeRAW('sampling_frequency', value);
for i=1:length(obj.channel_names)
if (ismember(i, obj.EnabledChannels))
obj.setAttributeRAW(obj.channel_names{i}, 'sampling_frequency', value, false);
end
end
end
end
end
Expand All @@ -79,7 +83,11 @@ function setupInit(obj)
% Do writes directly to hardware without using set methods.
% This is required since Simulink support doesn't support
% modification to nontunable variables at SetupImpl
obj.setDeviceAttributeRAW('sampling_frequency',num2str(obj.SampleRate));
for i=1:length(obj.channel_names)
if (ismember(i, obj.EnabledChannels))
obj.setAttributeRAW(obj.channel_names{i}, 'sampling_frequency', num2str(obj.SampleRate), false);
end
end
end
end

Expand Down
4 changes: 2 additions & 2 deletions +adi/+AD7124_4/Rx.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
% `AD7124-4 Datasheet <https://www.analog.com/media/en/technical-documentation/data-sheets/ad7124-4.pdf>`_

properties (Nontunable, Hidden)
channel_names = {'voltage0','voltage1','voltage2'...
'voltage3','voltage4','voltage5','voltage6','voltage7'};
channel_names = {'voltage0-voltage1','voltage2-voltage3',...
'voltage4-voltage5','voltage6-voltage7'};
end

methods
Expand Down
8 changes: 4 additions & 4 deletions +adi/+AD7124_8/Rx.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@


properties (Nontunable, Hidden)
channel_names = {'voltage0','voltage1','voltage2','voltage3',...
'voltage4','voltage5','voltage6','voltage7','voltage8','voltage9',...
'voltage10','voltage11','voltage12','voltage13','voltage14','voltage15'};
channel_names = {'voltage0-voltage1','voltage2-voltage3',...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity- why do the channel names look different here? the Shouldn't the differential configuration be considered in the fW?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, it's how the implementation of the AD7124 driver is, in the Linux IIO framework;
since the inputs on the AD7124 are differential, the IIO framework decided to represented this as 2 channel-pairs (i.e. voltage0-voltage1 and so on); this is how they show up, when a channel is defined as differential;

what puzzles me, is why this was represented as voltage0','voltage1, etc in the first place

the AD7124 driver has been implemented in Linux (as differential) for a number of years;
so, the channels should have looked more like 'voltage0-voltage1','voltage2-voltage3',

unless, the no-OS implementation was used to test this initially;

'voltage4-voltage5','voltage6-voltage7','voltage8-voltage9',...
'voltage10-voltage11','voltage12-voltage13','voltage14-voltage15'};
end

methods
Expand All @@ -25,4 +25,4 @@
end
end

end
end