Ich habe ein kleines Problem mit meinem High Precision AD/DA Board auf dem RasPi 3B
Ich habe zum größten Teil den Beispiel Code von Github übernommen:
logging.getLogger("asyncio").setLevel(logging.WARNING)
screen = TextScreen()
logging.basicConfig(level=logging.DEBUG)
print("\x1B[2J\x1B[H") # Clear screen
print(__doc__)
print("\nPress CTRL-C to exit.\n")
# For in-place text-mode output
screen = TextScreen()
def text_format_8_ch(digits, volts):
digits_str = ", ".join([f"{i: 8d}" for i in digits])
volts_str = ", ".join([f"{i: 8.3f}" for i in volts])
text = (" AIN0, AIN1, AIN2, AIN3, "
" AIN4, AIN5, AIN6, AIN7\n"
f"{digits_str}\n\n"
"Values converted to volts:\n"
f"{volts_str}\n"
)
return text
### START EXAMPLE ###########################################################
#
###### STEP 0: Configure channels
# For channel code values (bitmask) definitions, see ADS1256_definitions.py.
# The values representing the negative and positive input pins connected to
# the ADS1256 hardware multiplexer must be bitwise OR-ed to form eight-bit
# values, which will later be sent to the ADS1256 MUX register. The register
# can be explicitly read and set via ADS1256.mux property, but here we define
# a list of differential channels to be input to the ADS1256.read_sequence()
# method which reads all of them one after another.
#
# ==> Each channel in this context represents a differential pair of physical
# input pins of the ADS1256 input multiplexer.
#
# ==> For single-ended measurements, select AINCOM as the negative input.
#
# AINCOM does not have to be connected to AGND (0V), but it is if the jumper
# on the Waveshare board is set.
POTI = POS_AIN0 | NEG_AINCOM
LDR = POS_AIN1 | NEG_AINCOM
CH2 = POS_AIN2 | NEG_AINCOM
CH3 = POS_AIN3 | NEG_AINCOM
CH4 = POS_AIN4 | NEG_AINCOM
CH5 = POS_AIN5 | NEG_AINCOM
CH6 = POS_AIN6 | NEG_AINCOM
CH7 = POS_AIN7 | NEG_AINCOM
# Arbitrary length tuple of input channel pair values to scan sequentially
CH_SEQUENCE = POTI, LDR, CH2, CH3, CH4, CH5, CH6, CH7
def loop_forever_measurements(ads):
while True:
# Returns list of integers, one result for each configured channel
raw_channels = ads.read_sequence(CH_SEQUENCE)
# Text-mode output
voltages = [i * ads.v_per_digit for i in raw_channels]
screen.put(text_format_8_ch(raw_channels, voltages))
screen.refresh()
time.sleep(0.5)
try:
###### STEP 1: ADS1256 now supports the context-manager API. [*]
# Use this to have ADS1256 automatically close the SPI device and
# pigpio resources at exit:
with ADS1256() as ads:
###### STEP 2: Configuration and control by setting ADS1256 properties:
ads.drate = DRATE_100
# Gain and offset self-calibration can be triggered at any time
ads.cal_self()
###### STEP 3: Get and process data
loop_forever_measurements(ads)
except KeyboardInterrupt:
print("\nUser Exit.\n")
Jetzt funktioniert es ab und zu aber vermehrt kommen die Fehlermeldungen :
DEBUG: PiPyADC: Setting as input: 22 (chip select)
DEBUG: PiPyADC: Setting as input: 23 (chip select)
DEBUG: PiPyADC: Setting as output: 18 (reset pin)
DEBUG: PiPyADC: Setting as output: 27 (pdwn pin)
DEBUG: PiPyADC: Activating SPI, SW chip select on GPIO: 22
DEBUG:PiPyADC:Obtained SPI device handle: 1
DEBUG:PiPyADC:Closing SPI handle: 1
DEBUG:PiPyADC:Closing PIGPIO instance
Das Board habe ich bereits mit dem gleichen getauscht und trotzdem der gleiche Fehler. Das Board funktioniert. Auch SPI ist auf dem RasPi 3 aktiviert.
Kann mir jemand helfen ?

Vielen Dank im Voraus