Skip to content

Commit

Permalink
Merge pull request #25 from nwright-mcc/master
Browse files Browse the repository at this point in the history
Merge support for MCC 128
  • Loading branch information
nwright-mcc authored Dec 11, 2020
2 parents a99bc15 + 59820ee commit 33df598
Show file tree
Hide file tree
Showing 119 changed files with 13,118 additions and 622 deletions.
69 changes: 37 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# MCC DAQ HAT Library for Raspberry Pi
<table>
<tr><td>Info</td><td>Contains C and Python Libraries for interacting with
<tr><td>Info</td><td>Contains C and Python Libraries for interacting with
Measurement Computing DAQ HAT boards.</td></tr>
<tr><td>Author</td><td>Measurement Computing</td></tr>
<tr><td>Library Version<td>1.3.0.6</td></tr>
<tr><td>Author</td><td>Measurement Computing</td></tr>
<tr><td>Library Version<td>1.4.0.0</td></tr>
</table>

## About
Expand All @@ -12,17 +12,18 @@ This is the development repository for Measurement Computing DAQ HAT boards. The

#### Supported MCC DAQ HAT hardware
Hardware supported by this version of the MCC DAQ HAT Library:
- [MCC 118](https://mccdaq.github.io/daqhats/overview.html#mcc-118)
- [MCC 134](https://mccdaq.github.io/daqhats/overview.html#mcc-134)
- [MCC 152](https://mccdaq.github.io/daqhats/overview.html#mcc-152)
- [MCC 172](https://mccdaq.github.io/daqhats/overview.html#mcc-172)
- [MCC 118](https://nwright-mcc.github.io/daqhats/overview.html#mcc-118)
- [MCC 128](https://nwright-mcc.github.io/daqhats/overview.html#mcc-128)
- [MCC 134](https://nwright-mcc.github.io/daqhats/overview.html#mcc-134)
- [MCC 152](https://nwright-mcc.github.io/daqhats/overview.html#mcc-152)
- [MCC 172](https://nwright-mcc.github.io/daqhats/overview.html#mcc-172)

#### Hardware Compatibility
The MCC DAQ HATs are compatible with all Raspberry Pi models with the 40-pin
GPIO header (not the original Pi 1 A or B with the 26-pin header.) They are
generally not compatible with any other brand of Raspberry Pi HAT or add-on
board that attaches to the GPIO header, or devices that use the Raspberry Pi
SPI interface.
GPIO header (not the original Pi 1 A or B with the 26-pin header.) They are
generally not compatible with any other brand of Raspberry Pi HAT or add-on
board that attaches to the GPIO header, or devices that use the Raspberry Pi
SPI interface.

In particular, LCD displays that use the GPIO header (not HDMI) usually use the
SPI interface and will prevent the DAQ HATs from working. Even if the display is
Expand All @@ -43,11 +44,11 @@ specifications for that device.
Follow the instructions at https://www.raspberrypi.org/help/ for setting up a Raspberry Pi.

## Install Instructions
1. Power off the Raspberry Pi and attach one or more DAQ HAT boards, using unique
address settings for each. Refer to
[Installing the HAT board](https://mccdaq.github.io/daqhats/hardware.html)
1. Power off the Raspberry Pi and attach one or more DAQ HAT boards, using unique
address settings for each. Refer to
[Installing the HAT board](https://nwright-mcc.github.io/daqhats/hardware.html)
for detailed information.
When using a single board, leave it at address 0 (all address jumpers removed.)
When using a single board, leave it at address 0 (all address jumpers removed.)
One board must always be at address 0 to ensure that the OS reads a HAT EEPROM
and initializes the hardware correctly.
2. Power on the Pi, log in, and open a terminal window (if using the graphical interface.)
Expand All @@ -71,22 +72,22 @@ Follow the instructions at https://www.raspberrypi.org/help/ for setting up a Ra

```sh
cd ~
git clone https://github.com/mccdaq/daqhats.git
git clone https://github.com/nwright-mcc/daqhats.git
```
7. Build and install the shared library, tools, and optional Python support. The
7. Build and install the shared library, tools, and optional Python support. The
installer will install Python 3 support by default and ask if you want to install
Python 2 support. It will also detect the HAT board EEPROMs and save the contents,
if needed.

```sh
cd ~/daqhats
sudo ./install.sh
```
```
**Note:** If you encounter any errors during steps 5 - 7 then uininstall the daqhats
library (if installed), go back to step 4, update your installed packages and reboot,
library (if installed), go back to step 4, update your installed packages and reboot,
then repeat steps 5 - 7.
You can now run the example programs under ~/daqhats/examples and create your own

You can now run the example programs under ~/daqhats/examples and create your own
programs. Refer to the [Examples](#examples) section below for more information.

If you are using the Raspbian desktop interface, the DAQ HAT Manager utility will be
Expand All @@ -102,7 +103,7 @@ it will not be correct if you change the board stack without updating the EEPROM
images (see below.)

#### Update the EEPROM images
If you change your board stack, you must update the saved EEPROM images so that
If you change your board stack, you must update the saved EEPROM images so that
the library has the correct board information. You can use the DAQ HAT Manager or the
command:

Expand Down Expand Up @@ -134,13 +135,17 @@ firmware on the MCC 118 that is installed at address 0.
```sh
mcc118_firmware_update 0 ~/daqhats/tools/MCC_118.hex
```
#### MCC 128
```sh
mcc128_firmware_update 0 ~/daqhats/tools/MCC_128.fw
```
#### MCC 172
```sh
mcc172_firmware_update 0 ~/daqhats/tools/MCC_172.fw
```
## Examples
The daqhats library includes example programs developed with C/C++ and Python.
The examples are available under ~/daqhats/examples, and are provided in the
The daqhats library includes example programs developed with C/C++ and Python.
The examples are available under ~/daqhats/examples, and are provided in the
following formats:

- console-based (C/C++ and Python)
Expand All @@ -152,7 +157,7 @@ following formats:
Refer to the README.md file in each example folder for more information.

## Usage
The following is a basic Python example demonstrating how to read MCC 118 voltage
The following is a basic Python example demonstrating how to read MCC 118 voltage
inputs and display channel values.

```python
Expand All @@ -171,19 +176,19 @@ if not board_list:
sys.exit()
# Read and display every channel
for entry in board_list:
for entry in board_list:
if entry.id == HatIDs.MCC_118:
print("Board {}: MCC 118".format(entry.address))
board = mcc118(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))
print("Ch {0}: {1:.3f}".format(channel, value))
```
## Support/Feedback
The **daqhats** library is supported by MCC. Contact technical support through
The **daqhats** library is supported by MCC. Contact technical support through
our [support page](https://www.mccdaq.com/support/support_form.aspx).
## Documentation
Documentation for the daqhats library is available at
https://mccdaq.github.io/daqhats/index.html.
## Documentation
Documentation for the daqhats library is available at
https://nwright-mcc.github.io/daqhats/index.html.
1 change: 1 addition & 0 deletions daqhats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
OptionFlags, wait_for_interrupt, interrupt_state, \
interrupt_callback_enable, interrupt_callback_disable, HatCallback
from daqhats.mcc118 import mcc118
from daqhats.mcc128 import mcc128, AnalogInputMode, AnalogInputRange
from daqhats.mcc152 import mcc152, DIOConfigItem
from daqhats.mcc134 import mcc134, TcTypes
from daqhats.mcc172 import mcc172, SourceType
3 changes: 2 additions & 1 deletion daqhats/hats.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class HatIDs(IntEnum):
"""Known MCC HAT IDs."""
ANY = 0 #: Match any MCC ID in :py:func:`hat_list`
MCC_118 = 0x0142 #: MCC 118 ID
MCC_128 = 0x0146 #: MCC 128 ID
MCC_134 = 0x0143 #: MCC 134 ID
MCC_152 = 0x0144 #: MCC 152 ID
MCC_172 = 0x0145 #: MCC 172 ID
Expand Down Expand Up @@ -137,7 +138,7 @@ def hat_list(filter_by_id=0):
Returns:
list: A list of namedtuples, the number of elements match the number of
DAQ HATs found. Each namedtuple will contain the following field names
DAQ HATs found. Each namedtuple will contain the following field names:
* **address** (int): device address
* **id** (int): device product ID, identifies the type of DAQ HAT
Expand Down
29 changes: 17 additions & 12 deletions daqhats/mcc118.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pylint: disable=too-many-lines
"""
Wraps all of the methods from the MCC 118 library for use in Python.
"""
Expand Down Expand Up @@ -141,7 +142,7 @@ def info():
Return constant information about this type of device.
Returns:
namedtuple: a namedtuple containing the following field names
namedtuple: A namedtuple containing the following field names:
* **NUM_AI_CHANNELS** (int): The number of analog input channels
(8.)
Expand All @@ -163,7 +164,7 @@ def firmware_version(self):
Read the board firmware and bootloader versions.
Returns:
namedtuple: a namedtuple containing the following field names
namedtuple: A namedtuple containing the following field names:
* **version** (string): The firmware version, i.e "1.03".
* **bootloader_version** (string): The bootloader version,
Expand Down Expand Up @@ -262,8 +263,11 @@ def calibration_coefficient_read(self, channel):
calibrated_ADC_code = (raw_ADC_code * slope) + offset
Args:
channel (int): The analog input channel (0-7.)
Returns:
namedtuple: a namedtuple containing the following field names
namedtuple: A namedtuple containing the following field names.
* **slope** (float): The slope.
* **offset** (float): The offset.
Expand Down Expand Up @@ -299,6 +303,7 @@ def calibration_coefficient_write(self, channel, slope, offset):
calibrated_ADC_code = (raw_ADC_code * slope) + offset
Args:
channel (int): The analog input channel (0-7.)
slope (float): The new slope value.
offset (float): The new offset value.
Expand Down Expand Up @@ -364,7 +369,7 @@ def a_in_read(self, channel, options=OptionFlags.DEFAULT):
:py:const:`OptionFlags.DEFAULT` if unspecified.
Returns:
float: the read value
float: The read value.
Raises:
HatError: the board is not initialized, does not respond, or
Expand Down Expand Up @@ -403,7 +408,7 @@ def a_in_scan_actual_rate(self, channel_count, sample_rate_per_channel):
internal sampling clock, max 100,000.0.
Returns:
float: the actual sample rate
float: The actual sample rate.
Raises:
ValueError: a scan argument is invalid.
Expand Down Expand Up @@ -553,7 +558,7 @@ def a_in_scan_buffer_size(self):
size of that buffer in samples.
Returns:
int: the buffer size in samples
int: The buffer size in samples.
Raises:
HatError: the board is not initialized or no scan buffer is
Expand Down Expand Up @@ -583,7 +588,7 @@ def a_in_scan_status(self):
the scan thread buffer.
Returns:
namedtuple: a namedtuple containing the following field names:
namedtuple: A namedtuple containing the following field names:
* **running** (bool): True if the scan is running, False if it has
stopped or completed.
Expand Down Expand Up @@ -649,7 +654,7 @@ def a_in_scan_read(self, samples_per_channel, timeout):
samples and the timeout status set.
Returns:
namedtuple: a namedtuple containing the following field names:
namedtuple: A namedtuple containing the following field names:
* **running** (bool): True if the scan is running, False if it has
stopped or completed.
Expand Down Expand Up @@ -772,7 +777,7 @@ def a_in_scan_read_numpy(self, samples_per_channel, timeout):
timeout status set.
Returns:
namedtuple: a namedtuple containing the following field names:
namedtuple: A namedtuple containing the following field names:
* **running** (bool): True if the scan is running, False if it has
stopped or completed.
Expand Down Expand Up @@ -880,7 +885,7 @@ def a_in_scan_channel_count(self):
Read the number of channels in the current analog input scan.
Returns:
int: the number of channels (0 if no scan is active, 1-8 otherwise)
int: The number of channels (0 if no scan is active, 1-8 otherwise.)
Raises:
HatError: the board is not initialized, does not respond, or
Expand Down Expand Up @@ -951,7 +956,7 @@ def test_clock(self, mode):
* 3 = output 1 kHz square wave
Returns:
int: the value read at the CLK pin after applying the mode (0 or 1).
int: The value read at the CLK pin after applying the mode (0 or 1.)
Raises:
HatError: the board is not initialized, does not respond, or
Expand Down Expand Up @@ -981,7 +986,7 @@ def test_trigger(self):
This value read at the pin for input testing.
Returns:
int: the value read at the TRIG pin (0 or 1).
int: The value read at the TRIG pin (0 or 1.)
Raises:
HatError: the board is not initialized, does not respond, or
Expand Down
Loading

0 comments on commit 33df598

Please sign in to comment.