-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #446 from nsacut/dev/ad7768_4
Adding Support for AD7768-4
- Loading branch information
Showing
7 changed files
with
158 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Copyright (C) 2023 Analog Devices, Inc. | ||
# | ||
# SPDX short identifier: ADIBSD | ||
|
||
import sys | ||
from time import sleep | ||
|
||
import adi | ||
import matplotlib.pyplot as plt | ||
|
||
|
||
def display_settings(power_mode, sampling_frequency, filter_type, rx_enabled_channels): | ||
print("Power Mode: ", power_mode) | ||
print("Sampling Frequency: ", sampling_frequency) | ||
print("Filter Type: ", filter_type) | ||
print("Enabled Channels: ", rx_enabled_channels) | ||
|
||
|
||
# Optionally pass URI as command line argument, | ||
# else use default ip:analog.local | ||
my_uri = sys.argv[1] if len(sys.argv) >= 2 else "ip:analog.local" | ||
print("uri: " + str(my_uri)) | ||
|
||
my_adc = adi.ad7768_4(uri=my_uri, device_name="ad7768-4") | ||
my_adc.rx_buffer_size = 1024 | ||
|
||
# Set Sample Rate. Options are 1ksps to 256ksps, 1k* power of 2. | ||
# Note that sample rate and power mode are not orthogonal - refer | ||
# to datasheet. | ||
my_adc.sampling_frequency = 8000 | ||
|
||
# Choose a power mode: | ||
# my_adc.power_mode_avail = [LOW_POWER_MODE, MEDIAN_MODE, FAST_MODE] | ||
my_adc.power_mode = "FAST_MODE" | ||
|
||
# Choose a filter type: | ||
# my_adc.filter_type_avail = [WIDEBAND, SINC5] | ||
my_adc.filter_type = "WIDEBAND" | ||
|
||
# Choose output format: | ||
my_adc.rx_output_type = "SI" | ||
|
||
# Verify settings: | ||
display_settings( | ||
my_adc.power_mode, | ||
my_adc.sampling_frequency, | ||
my_adc.filter_type, | ||
my_adc.rx_enabled_channels, | ||
) | ||
|
||
plt.clf() | ||
sleep(0.5) | ||
data = my_adc.rx() | ||
for ch in my_adc.rx_enabled_channels: | ||
plt.plot(range(0, len(data[0])), data[ch], label="voltage" + str(ch)) | ||
plt.xlabel("Data Point") | ||
if my_adc.rx_output_type == "SI": | ||
plt.ylabel("Millivolts") | ||
else: | ||
plt.ylabel("ADC counts") | ||
plt.legend( | ||
bbox_to_anchor=(0.0, 1.02, 1.0, 0.102), | ||
loc="lower left", | ||
ncol=4, | ||
mode="expand", | ||
borderaxespad=0.0, | ||
) | ||
plt.pause(0.01) | ||
|
||
del my_adc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,7 @@ | |
- AD7195 | ||
- AD7291 | ||
- AD7768 | ||
- AD7768-4 | ||
- AD7770 | ||
- AD7771 | ||
- AD7779 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE context [<!ELEMENT context (device | context-attribute)*><!ELEMENT context-attribute EMPTY><!ELEMENT device (channel | attribute | debug-attribute | buffer-attribute)*><!ELEMENT channel (scan-element?, attribute*)><!ELEMENT attribute EMPTY><!ELEMENT scan-element EMPTY><!ELEMENT debug-attribute EMPTY><!ELEMENT buffer-attribute EMPTY><!ATTLIST context name CDATA #REQUIRED description CDATA #IMPLIED><!ATTLIST context-attribute name CDATA #REQUIRED value CDATA #REQUIRED><!ATTLIST device id CDATA #REQUIRED name CDATA #IMPLIED><!ATTLIST channel id CDATA #REQUIRED type (input|output) #REQUIRED name CDATA #IMPLIED><!ATTLIST scan-element index CDATA #REQUIRED format CDATA #REQUIRED scale CDATA #IMPLIED><!ATTLIST attribute name CDATA #REQUIRED filename CDATA #IMPLIED value CDATA #IMPLIED><!ATTLIST debug-attribute name CDATA #REQUIRED value CDATA #IMPLIED><!ATTLIST buffer-attribute name CDATA #REQUIRED value CDATA #IMPLIED>]><context name="network" description="192.168.10.102 Linux analog 5.10.0-98744-g64e7a607b659 #1788 SMP PREEMPT Fri Mar 31 16:51:05 EEST 2023 armv7l" ><context-attribute name="hdl_system_id" value="[ad7768evb] on [zed] git branch [hdl_2021_r2] git [a83056b11d6b092d342b72c68ef713b362b10521] clean [2023-03-31 19:46:25] UTC" /><context-attribute name="hw_model" value="EVAL-AD7768FMCZ on Xilinx Zynq ZED" /><context-attribute name="hw_carrier" value="Xilinx Zynq ZED" /><context-attribute name="hw_mezzanine" value="EVAL-AD7768FMCZ" /><context-attribute name="hw_name" value="AD7768" /><context-attribute name="hw_vendor" value="Analog Devices" /><context-attribute name="hw_serial" value="Empty Field" /><context-attribute name="local,kernel" value="5.10.0-98744-g64e7a607b659" /><context-attribute name="uri" value="ip:192.168.10.102" /><context-attribute name="ip,ip-addr" value="192.168.10.102" /><device id="hwmon0" name="e000b000ethernetffffffff00" ><channel id="temp1" type="input" ><attribute name="crit" filename="temp1_crit" value="100000" /><attribute name="input" filename="temp1_input" value="49000" /><attribute name="max_alarm" filename="temp1_max_alarm" value="0" /></channel></device><device id="iio:device1" name="cf_axi_adc" ><channel id="voltage0" type="input" ><scan-element index="0" format="le:s24/32>>0" scale="0.000488" /><attribute name="label" filename="in_voltage0_label" value="ERROR" /><attribute name="scale" filename="in_voltage_scale" value="0.000488281" /></channel><channel id="voltage1" type="input" ><scan-element index="1" format="le:s24/32>>0" scale="0.000488" /><attribute name="label" filename="in_voltage1_label" value="ERROR" /><attribute name="scale" filename="in_voltage_scale" value="0.000488281" /></channel><channel id="voltage2" type="input" ><scan-element index="2" format="le:s24/32>>0" scale="0.000488" /><attribute name="label" filename="in_voltage2_label" value="ERROR" /><attribute name="scale" filename="in_voltage_scale" value="0.000488281" /></channel><channel id="voltage3" type="input" ><scan-element index="3" format="le:s24/32>>0" scale="0.000488" /><attribute name="label" filename="in_voltage3_label" value="ERROR" /><attribute name="scale" filename="in_voltage_scale" value="0.000488281" /></channel><attribute name="filter_type" value="SINC5" /><attribute name="filter_type_available" value="WIDEBAND SINC5" /><attribute name="power_mode" value="FAST_MODE" /><attribute name="power_mode_available" value="LOW_POWER_MODE MEDIAN_MODE FAST_MODE" /><attribute name="sampling_frequency" value="32000" /><attribute name="sampling_frequency_available" value="1000 2000 4000 8000 16000 32000 64000 128000 256000" /><attribute name="sync_start_enable" value="arm" /><attribute name="sync_start_enable_available" value="arm" /><buffer-attribute name="data_available" value="0" /><buffer-attribute name="length_align_bytes" value="8" /><debug-attribute name="pseudorandom_err_check" value="ERROR" /><debug-attribute name="direct_reg_access" value="0x0" /></device><device id="iio:device2" name="xadc" ><channel id="voltage5" name="vccoddr" type="input" ><attribute name="raw" filename="in_voltage5_vccoddr_raw" value="2056" /><attribute name="scale" filename="in_voltage5_vccoddr_scale" value="0.732421875" /></channel><channel id="voltage0" name="vccint" type="input" ><attribute name="raw" filename="in_voltage0_vccint_raw" value="1399" /><attribute name="scale" filename="in_voltage0_vccint_scale" value="0.732421875" /></channel><channel id="voltage4" name="vccpaux" type="input" ><attribute name="raw" filename="in_voltage4_vccpaux_raw" value="2465" /><attribute name="scale" filename="in_voltage4_vccpaux_scale" value="0.732421875" /></channel><channel id="temp0" type="input" ><attribute name="offset" filename="in_temp0_offset" value="-2219" /><attribute name="raw" filename="in_temp0_raw" value="2649" /><attribute name="scale" filename="in_temp0_scale" value="123.040771484" /></channel><channel id="voltage7" name="vrefn" type="input" ><attribute name="raw" filename="in_voltage7_vrefn_raw" value="14" /><attribute name="scale" filename="in_voltage7_vrefn_scale" value="0.732421875" /></channel><channel id="voltage1" name="vccaux" type="input" ><attribute name="raw" filename="in_voltage1_vccaux_raw" value="2467" /><attribute name="scale" filename="in_voltage1_vccaux_scale" value="0.732421875" /></channel><channel id="voltage2" name="vccbram" type="input" ><attribute name="raw" filename="in_voltage2_vccbram_raw" value="1396" /><attribute name="scale" filename="in_voltage2_vccbram_scale" value="0.732421875" /></channel><channel id="voltage3" name="vccpint" type="input" ><attribute name="raw" filename="in_voltage3_vccpint_raw" value="1394" /><attribute name="scale" filename="in_voltage3_vccpint_scale" value="0.732421875" /></channel><channel id="voltage6" name="vrefp" type="input" ><attribute name="raw" filename="in_voltage6_vrefp_raw" value="1718" /><attribute name="scale" filename="in_voltage6_vrefp_scale" value="0.732421875" /></channel><attribute name="sampling_frequency" value="961538" /></device><device id="iio_sysfs_trigger" ><attribute name="add_trigger" value="ERROR" /><attribute name="remove_trigger" value="ERROR" /></device></context> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import pytest | ||
|
||
hardware = ["ad7768-4"] | ||
classname = "adi.ad7768_4" | ||
|
||
######################################### | ||
@pytest.mark.iio_hardware(hardware, True) | ||
@pytest.mark.parametrize("classname", [(classname)]) | ||
@pytest.mark.parametrize("channel", [0, 1, 2, 3]) | ||
def test_ad7768_4_rx_data(test_dma_rx, iio_uri, classname, channel): | ||
test_dma_rx(iio_uri, classname, channel) | ||
|
||
|
||
######################################### | ||
@pytest.mark.iio_hardware(hardware) | ||
@pytest.mark.parametrize("classname", [(classname)]) | ||
@pytest.mark.parametrize( | ||
"attr, val", | ||
[ | ||
( | ||
"sampling_frequency", | ||
[ | ||
1000, | ||
2000, | ||
4000, | ||
8000, | ||
16000, | ||
32000, | ||
64000, | ||
128000, | ||
256000, | ||
32000, | ||
], # End on a rate compatible with all power modes | ||
), | ||
("filter_type", ["WIDEBAND", "SINC5"],), | ||
("power_mode", ["MEDIAN_MODE", "FAST_MODE"],), | ||
("sync_start_enable", ["arm"],), | ||
], | ||
) | ||
def test_ad7768_4_attr(test_attribute_multipe_values, iio_uri, classname, attr, val): | ||
test_attribute_multipe_values(iio_uri, classname, attr, val, 0) |