Installing and Using the Library¶
The project is hosted at https://github.com/mccdaq/daqhats.
Installation¶
Power off the Raspberry Pi then attach one or more HAT boards (see Installing the DAQ HAT board).
Power on the Pi and log in. Open a terminal window if using the graphical interface.
Update your package list:
sudo apt update
Optional: Update your installed packages and reboot:
sudo apt full-upgrade sudo reboot
Install git (if not installed):
sudo apt install git
Download this package to your user folder with git:
cd ~ git clone https://github.com/mccdaq/daqhats.git
Build and install the shared library and optional Python support. The installer will ask if you want to install Python 2 and Python 3 support. It will also detect the HAT board EEPROMs and save the contents if needed:
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, then repeat steps 5 - 7.
You can now run the example programs under ~/daqhats/examples and create your own programs.
If you are using the Raspbian desktop interface, the DAQ HAT Manager utility will be available under the Accessories start menu. This utility will allow you to list the detected DAQ HATs, update the EEPROM files if you change your board stack, and launch control applications for each DAQ HAT to perform simple operations. The code for these programs is in the daqhats/tools/applications directory.
You may display a list of the detected boards at any time with the DAQ HAT Manager or the command:
daqhats_list_boards
If you change your board stackup and have more than one HAT board attached you must update the saved EEPROM images for the library to have the correct board information. You can use the DAQ HAT Manager or the command:
sudo daqhats_read_eeproms
To display the installed daqhats version use:
daqhats_version
To uninstall the package use:
cd ~/daqhats
sudo ./uninstall.sh
Firmware Updates¶
MCC 118¶
Use the firmware update tool to update the firmware on your MCC 118 board(s). The “0” in the example below is the board address. Repeat the command for each MCC 118 address in your board stack. This example demonstrates how to update the firmware on the MCC 118 that is installed at address 0:
mcc118_firmware_update 0 ~/daqhats/tools/MCC_118.hex
Creating a C program¶
- The daqhats headers are installed in /usr/local/include/daqhats. Add the compiler option
-I/usr/local/include
in order to find the header files when compiling, and the include line#include <daqhats/daqhats.h>
to your source code. - The shared library, libdaqhats.so, is installed in /usr/local/lib. Add the linker option
-ldaqhats
to include this library. - Study the example programs, example makefile, and library documentation for more information.
Creating a Python program¶
- The Python package is named daqhats. Use it in your code with
import daqhats
. - Study the example programs and library documentation for more information.