From 78397db7140a4ffad4100ec043a58bd8e601407a Mon Sep 17 00:00:00 2001 From: Bdale Garbee Date: Sat, 18 Jan 2025 19:43:41 -0700 Subject: [PATCH] updated application, now configuring chip here so setup.sh obsolete --- application/quantimotor.py | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/application/quantimotor.py b/application/quantimotor.py index 99ee421..9947382 100755 --- a/application/quantimotor.py +++ b/application/quantimotor.py @@ -2,10 +2,19 @@ # Copyright (C) 2025 Bdale Garbee . GPLv3+ import gpiod +import iio import signal import sys import time +ctx = iio.LocalContext() +ctrl = ctx.find_device('ads8688') +# configuration for each channel on ADS8688 +OFFSET = "0" +SCALE = "0.078127104" +#VOLTAGES = ['voltage0', 'voltage1', 'voltage2', 'voltage3', 'voltage4', 'voltage5', 'voltage6', 'voltage7'] +VOLTAGES = ['voltage0', 'voltage1'] + from gpiod.line import Direction, Value def handler(signum, frame): @@ -13,9 +22,12 @@ def handler(signum, frame): set_line_values( "/dev/gpiochip0", { 4: Value.INACTIVE, # indicate 'not ready' to LPC + 16: Value.INACTIVE, # pyro off + 17: Value.INACTIVE, # alarm b off 20: Value.INACTIVE, # turn continuity LED off 21: Value.INACTIVE, # turn armed LED off - 25: Value.ACTIVE # put ADS8688 in reset + 25: Value.INACTIVE, # put ADS8688 in reset + 27: Value.INACTIVE # alarm a off } ) exit(1) @@ -41,13 +53,28 @@ if __name__ == "__main__": "/dev/gpiochip0", {25: Value.ACTIVE, # take ADS8688 out of reset 4: Value.ACTIVE, # indicate 'ready' to LPC + 16: Value.ACTIVE, # pyro on + 17: Value.ACTIVE, # alarm b on 20: Value.ACTIVE, # turn continuity LED on - 21: Value.INACTIVE # turn armed LED off + 21: Value.INACTIVE, # turn armed LED off + 27: Value.ACTIVE # alarm a on } ) + + # configure ADC channels + for id in VOLTAGES: + chan = ctrl.find_channel(id) + chan.attrs['offset'].value = OFFSET + chan.attrs['scale'].value = SCALE + # Iterate until ctrl/c while True: - print('tick') + for id in VOLTAGES: + chan = ctrl.find_channel(id) + rawstring = chan.attrs['raw'].value + voltage = (float(rawstring) + float(OFFSET)) * float(SCALE) / 1000 + print("{0}: {1:0.3f}, ".format( chan.id, voltage), end="") + print() time.sleep(1) except OSError as ex: -- 2.47.2