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

ad7606 tweaks and updates #590

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

commodo
Copy link

@commodo commodo commented Aug 19, 2024

Description

This changeset mostly targets support for the AD7606C-18 and AD7606C-16 parts.

The upstream support for these parts is pending here:

https://lore.kernel.org/linux-iio/20240819064721.91494-1-aardelean@baylibre.com/T/#t

But there were a couple of fixes required for existing parts.

For one thing the oversampling attributes need to be made device-level attributes.

There are no 'range' attributes. These are scale attributes.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How has this been tested?

Tested with a ZedBoard and an AD7606C-18 FMC board.
The HDL is a simplified version that uses the Zynq PS SPI controller, which kind of like using the AD7606 part directly connected to a simple RPi board; no fancy communication.

  • Test A
  • Test B

Test Configuration:

  • Hardware: ZedBoard + AD7606C-18
  • OS: Kuiper Linux + upstream IIO kernel + AD7606C-18/16 changes

Documentation

If this is a new feature or example please mention or link any documentation. All new hardware interface classes require documentation.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have signed off all commits and they contain "Signed-off by: "
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

adi/ad7606.py Outdated

return ret
return None
Copy link
Collaborator

Choose a reason for hiding this comment

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

If replacing with returns you can omit last line. Python always returns None if there is no explicit return statement

adi/ad7606.py Outdated
# We can't detect SW mode, so we use a try block
try:
return self._get_iio_attr_str(self.name, "scale_available", False)
except:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Need an exception type

With the upstream Linux version, the oversampling, oversampling_ratio
attributes are available at device level.

_get_iio_attr() is used for accessing channel attributes.

Signed-off-by: Alexandru Ardelean <aardelean@baylibre.com>
There seems to be a confusion between scale and range.
In the case of AD7606, the range (specified in the datasheet) determines
the scale of the device (or the channel in some cases).

Signed-off-by: Alexandru Ardelean <aardelean@baylibre.com>
Signed-off-by: Alexandru Ardelean <aardelean@baylibre.com>
The AD7606C-16 and AD7606C-18 support per-channel 'scale_availble' in SW
mode.
That is because each channel can be configured individually, to be
bipolar-differential, bipolar-single-ended or unipolar-single-ended.

Depending on the above configuration, the available scales change.
So, we need to tweak this per-channel.

Since there isn't a way to detect SW mode, we use some 'try' blocks in
Python.

Signed-off-by: Alexandru Ardelean <aardelean@baylibre.com>
For AD7606C-18 especially, there will be 32-bit samples getting returned
from the ADC.

Signed-off-by: Alexandru Ardelean <aardelean@baylibre.com>
The soft timestamp channel is a special IIO channel.
It's not an RX channel, so it hasn't any of the typically attributes (raw,
scale, etc) like the other RX channels.

So, just ignore it.

Signed-off-by: Alexandru Ardelean <aardelean@baylibre.com>
At least the 'raw' channel attribute returns int.
So,  'ad7606.to_volts(0, channel0.raw)' won't work with checking for numpy
types.

Signed-off-by: Alexandru Ardelean <aardelean@baylibre.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants