mccdaq / daqhats

MCC DAQ HAT Library for Raspberry Pi
Other
128 stars 89 forks source link

Reading more DAQ HATs than are Present #35

Closed monacles closed 3 years ago

monacles commented 3 years ago

I'm using some of the sample Python code to understand how to read data from MCC 134 and 152 HATs and when I run the hat_list function I get back that Board0, Board1, and Board2 are connected when I only have two HATs connected. After that I'm trying to read data from both boards and I get the following result.

Board0: Board1: Board2: Board 323: MCC 134 Ch 0: 23.582 Ch 1: -9999.000 Ch 2: -9999.000 Ch 3: -9999.000 Board 323: MCC 134 Ch 0: -127.341 Ch 1: -127.406 Ch 2: -127.363 Ch 3: -127.383 Board 324: MCC 152 Traceback (most recent call last): File "/home/pi/daqhats/mcc134test.py", line 32, in board = mcc152(entry.address) File "/home/pi/daqhats/daqhats/mcc152.py", line 141, in init raise HatError(self._address, "Board not responding.") daqhats.hats.HatError: Addr 2: Board not responding.

Here is the Python code I'm using. Any helped would be appreciated.

//!/usr/bin/env python import sys from daqhats import hat_list, HatIDs, mcc134,mcc152

get hat list of MCC daqhat boards

board_list = hat_list(filter_by_id = HatIDs.ANY) for entry in board_list: print("Board{}: ".format(entry.address)) if not board_list: print("No boards found") sys.exit()

Read and display every channel

for entry in board_list: if entry.id == HatIDs.MCC_134: print("Board {}: MCC 134".format(entry.id)) board = mcc134(entry.address) for channel in range(board.info().NUM_AI_CHANNELS): board.tc_type_write(channel,1) value = board.t_in_read(channel) print("Ch {0}: {1:.3f}".format(channel, value)) elif entry.id == HatIDs.MCC_152: print("Board {}: MCC 152".format(entry.id)) board = mcc152(entry.address) for channel in range(board.info().NUM_AI_CHANNELS): value = board.a_in_read(channel) print("Ch {0}: {1:.3f}".format(channel, value))