Skip to content

Commit 33aeb03

Browse files
projects:ad7191_iio:Added the python support for ad7191
1) Modified to_volts so that it gives the correct value for both unipolar and bipolar mode Signed-off-by: Kantipudi-Supriya <supriya.kantipudi@analog.com>
1 parent 16fe567 commit 33aeb03

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

adi/ad719x.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def __init__(self, uri="", device_name=""):
2323
"""Constructor for AD719x class."""
2424
context_manager.__init__(self, uri, self._device_name)
2525

26-
compatible_parts = ["ad7190", "ad7192", "ad7193", "ad7194", "ad7195"]
26+
compatible_parts = ["ad7190", "ad7191","ad7192", "ad7193", "ad7194", "ad7195"]
2727

2828
self._ctrl = None
2929

@@ -89,14 +89,15 @@ def offset(self, value):
8989
def to_volts(self, index, val):
9090
"""Converts raw value to SI."""
9191
_scale = self.channel[index].scale
92+
_offset = self.channel[index].offset
9293

9394
ret = None
9495

9596
if isinstance(val, np.int32):
96-
ret = val * _scale
97+
ret = (val + _offset) / 1000 * _scale
9798

9899
if isinstance(val, np.ndarray):
99-
ret = [x * _scale for x in val]
100+
ret = [((x + _offset) / 1000) * _scale for x in val]
100101

101102
if ret is None:
102103
raise Exception("Error in converting to actual voltage")

supported_parts.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
- AD7176-2
8383
- AD7177-2
8484
- AD7190
85+
- AD7191
8586
- AD7192
8687
- AD7193
8788
- AD7194

0 commit comments

Comments
 (0)