AD7124-8
Recommended for New Designs
The AD7124-8 is a low power, low noise, completely integrated
analog front end for high precision measurement applications. The
AD7124-8 W grade is AEC...
Datasheet
AD7124-8 on Analog.com
Kuiper linux downloaded from here (2022_r2) swdownloads.analog.com/.../image_2023-12-13-ADI-Kuiper-full.zip and use it on Raspberry Pi Model B.
I am using eval-ad7124-8sdz board using SPI connection following wiki.analog.com/.../precision_adc_toolbox.
Strangely under /boot/overlays, it only has rpi-ad7124-8-all-diff.dtbo, and does not have rpi-ad7124-8-all-diff-cs0-int25-overlay.dtbo. So in order to use the interruption line GPIO 25, I downloaded https://github.com/analogdevicesinc/linux/blob/rpi-5.4.y/arch/arm/boot/dts/overlays/rpi-ad7124-8-all-diff-cs0-int25-overlay.dts
and compiled using
sudo bash -c 'dtc -I dts -O dtb /home/analog/Downloads/rpi-ad7124-8-all-diff-cs0-int25-overlay.dts > /boot/overlays/rpi-ad7124-8-all-diff-cs0-int25-overlay.dtbo'
When I run https://github.com/mthoren-adi/precision_adc_toolbox/blob/master/ad7124_simple_capture.py, the data returned by rx() is a constant array, instead of a sin function that I used as input.
When I tune the input to a constant DC voltage, rx() indeed returns (roughly) that voltage, repeated 1024 times (as rx_buffer_size = 1024). Therefore I believe the rx() function is only reading once, instead of continuously reading 1024 times.
Since the Kuiper linux does not contain rpi-ad7124-8-all-diff-cs0-int25-overlay.dtbo and I have to recompile it from scratch, my guess is the Kuiper linux that I am using is incorrect. Could you confirm what is the correct Kuiper linux download link that contains the correct code for ad7124-8, and also why rx() is returning a constant instead of a continuous read?
Bowei - Moved from Software Interface Tools to Precision ADCs. Post date updated from Monday, March 11, 2024 3:03 AM UTC to Monday, March 11, 2024 3:10 AM UTC to reflect the move.
JEstayo - Moved from Precision ADCs to Linux Software Drivers. Post date updated from Monday, March 11, 2024 3:10 AM UTC to Wednesday, March 13, 2024 2:11 AM UTC to reflect the move.
Hi Bowei , the link you have provided is correct. The move to change rpi-ad7124-8-all-diff-cs0-int25-overlay.dtbo to rpi-ad7124-8-all-diff.dtbo was to make the cs and interrupt pins reconfigurable at boot time via device tree overlay parameters. This way, we could use either of the 2 SPI ports of PMD-RPI-INTZ Evaluation Board | Analog Devices without the need to recompile the device tree.
To obtain the same configuration as rpi-ad7124-8-all-diff-cs0-int25-overlay.dtbo, we could use this in the /boot/config.txt instead:
dtoverlay=rpi-ad7124-8-all-diff,cs_pin=0,irq_gpio=25
As for the rx() being constant, there is an existing driver issue present in branch rpi-5.15.y (2022_r2) that is being looked upon. This might be the cause of rx() readings being constant.
(+) Inconsistent channel position in a libiio buffer - Q&A - Linux Software Drivers - EngineerZone (analog.com)
Sorry Bowei unfortunately, I don't have an eval-ad7124-8sdz I could use right now. The issue on the libiio buffer was communicated to the developers and looks like it affects any device using the ad7124 driver (cn0554, eval-ad7124-8-pmdz, cn0508). I believe there is a fix in rpi-6.1.y branch (analogdevicesinc/linux at rpi-6.1.y (github.com) which will be part of 2023_R2 (not yet released). I'm still trying this myself and would love to update you on the result
I see. Do I need to build the rpi-6.1.y branch linux driver according to https://wiki.analog.com/resources/tools-software/linux-build/generic/raspberrypi or is there a prebuilt version available for download?
Yes, there are pre-built files from the latest build of rpi-6.1.y.
Download them from:
https://swdownloads.analog.com/cse/linux_rpi/rpi-6.1.y/rpi_latest_boot.tar.gz (should be extracted in /boot)
https://swdownloads.analog.com/cse/linux_rpi/rpi-6.1.y/rpi_modules.tar.gz (should be extracted in /lib/modules)
Unfortunately, there is no rootfs yet for 2023_R2 but we could try the above files on an existing 2022_R2 image, though it is not guaranteed to work yet.
Thank you so much for the links! I am not very familiar with the Linux file structure. Right now on my Raspberry Pi, which has 2022_R2 Kuiper Linux installed, shall I delete the contents of /boot and /lib/modules directories, and put the files in your links into the respective directories? The rpi_modules link has 3 folders, which one should I use?
No need to delete, I just usually overwrite (/boot and /lib/modules) by copying all files as it is.
Its fine to copy all the 3 folders under rpi_modules to /lib/modules but if you are constrained with storage, you could just copy the folder that corresponds to your RPI variant,
ex. RPI4 -> 6.1.54-v7l+, RPI3 -> 6.1.54-v7+
Hi Kimpaller, I extracted the files as you said, but now when I use iio_info command, it can not find the ad7124 device. I also don't see an error loading the device tree overlay, so I guess the new kernel is not loading the device tree. Could you get the kernel to work properly for rpi-6.1.y?
Do you know which branch/pull request the fix corresponds to in github? I can't seem to find it.
Hi Bowei
Sorry for the late response as I was also waiting for the fix myself.
There was a commit to rpi-5.15.y branch that was supposed to fix issue when multiple channel is enabled. I have built this and loaded the boot files/modules to an existing 2022_R2 image and tried my eval-ad7124-8 to test it
Please refer to this script I used with the experiment. I have enabled 3 channels and so far the ouput shows as expected.
Sample ad7124 script (github.com)
Thank you so much! I noticed in your code
ad_channel0 = 0 #voltage0-voltage1 plug to CH1 on my m2k
ad_channel1 = 4 #voltage2-voltage3 plug to CH2 on my m2k
ad_channel2 = 5 #voltage4-voltage5 left open
which is the same as what I found using 2021_R2:
Voltage#-Voltage# |
Channel # in Device Tree Configuration |
Real Channel # in Python code |
0-1 |
0 |
0 |
2-3 |
1 |
4 |
4-5 |
2 |
5 |
6-7 |
3 |
6 |
8-9 |
4 |
7 |
10-11 |
5 |
1 |
12-13 |
6 |
2 |
14-15 |
7 |
3 |
I want to ask: why is the device tree configuration number different from the channel number in Python?
You're right, this ordering is a bug on pyadi-iio
I've investigated a bit and the culprit is on the sorting done here:
https://github.com/analogdevicesinc/pyadi-iio/blob/b579bbc055818537a0a28c291cee4cf0b323a048/adi/ad7124.py#L40
however, this was corrected on the latest version of pyadi-iio
https://github.com/analogdevicesinc/pyadi-iio/blob/2900d329d47a885ae443253dc90e94ce0b4d4d2c/adi/ad7124.py#L39-L43
another problem though in using the latest version is that a non-existing attribute "name" is referenced on a "channel" object, we could fix this by changing "chan.name" into "chan.id" on this line:
https://github.com/analogdevicesinc/pyadi-iio/blob/2900d329d47a885ae443253dc90e94ce0b4d4d2c/adi/ad7124.py#L39-L43