From 38a8c25eaaceb98cef2b47b97eab891e3fc16d6f Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Fri, 1 Nov 2024 18:41:14 +0200 Subject: [PATCH 1/2] AD7124/Base: fix sampling_frequency setting In newer versions of the AD7124 driver, the sampling_frequency is no longer a device-level attribute, but a per-channel attribute. This means that the AD7124 base driver should set this attribute for all enabled channels. Signed-off-by: Alexandru Ardelean --- +adi/+AD7124/Base.m | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/+adi/+AD7124/Base.m b/+adi/+AD7124/Base.m index b426306..be2d0c5 100644 --- a/+adi/+AD7124/Base.m +++ b/+adi/+AD7124/Base.m @@ -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 @@ -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 From 76240ce259bc1b6ef975a405c0ee9f389294113b Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Fri, 1 Nov 2024 18:43:07 +0200 Subject: [PATCH 2/2] AD7124-{4,8}: adjust channel names for both parts In a newer version of the AD7124 driver, the channels were all made differential. That means that the channel names need to be updated. This change updates the channel names to the new (differential channel names). Signed-off-by: Alexandru Ardelean --- +adi/+AD7124_4/Rx.m | 4 ++-- +adi/+AD7124_8/Rx.m | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/+adi/+AD7124_4/Rx.m b/+adi/+AD7124_4/Rx.m index 3a17cfe..6f6cc36 100644 --- a/+adi/+AD7124_4/Rx.m +++ b/+adi/+AD7124_4/Rx.m @@ -12,8 +12,8 @@ % `AD7124-4 Datasheet `_ 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 diff --git a/+adi/+AD7124_8/Rx.m b/+adi/+AD7124_8/Rx.m index b0688fb..bac4d09 100644 --- a/+adi/+AD7124_8/Rx.m +++ b/+adi/+AD7124_8/Rx.m @@ -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',... + 'voltage4-voltage5','voltage6-voltage7','voltage8-voltage9',... + 'voltage10-voltage11','voltage12-voltage13','voltage14-voltage15'}; end methods @@ -25,4 +25,4 @@ end end -end \ No newline at end of file +end