Shopping Cart Summary
Total:
  • ShopSHOP
  • ShopLEARN
  • ShopSUPPORT
Live Chat Software
Measurement Computing
search
Part Number Site
  Advanced Product Search
EmailEmail Call MeCall Me
1.800.234.4232
We're here to help
International Languages Easy to Use  |  Easy to Integrate  |  Easy to Support International Distributors
Data Acquisition Companion Software   DASYLab DAQ Software

Data Acquisition Product Selection Catalog   MCC Data Acquisition eNews

Learn about Data Acquisition

MCC Data Acquisition Handbook

TechTip: Raspberry Pi Data Acquisition using MCC DAQ

Introduction
The Raspberry Pi® is a single-board computer that plugs into a monitor and keyboard and runs the Linux® kernel-based operating system. With a cost of less than $40, the Raspberry Pi provides a cost-effective way to perform data acquisition. You can acquire data from most Measurement Computing USB, Ethernet, and Bluetooth DAQ devices using the Raspberry Pi.

Objective
Acquire data from an MCC DAQ device using a test application installed on a Raspberry Pi computer.
This document provides information about how to perform the following tasks:

  • Format an SD card
  • Install an operating system onto the Raspberry Pi
  • Configure Raspberry Pi options
  • Install Linux drivers
  • Install MCC DAQ drivers and compile MCC Linux test apps
  • Run an MCC Linux test app

Intended Audience
This document is intended for application developers familiar with MCC DAQ devices who are interested in acquiring data on a Linux platform using a Raspberry Pi.

Equipment
The following equipment is needed to perform the exercises:

  • Raspberry Pi single-board computer – I'm using model B, but you can use any Raspberry Pi model
  • SD card (8 GB or higher)
  • PC or Mac® with internet access
  • Ethernet® cable or wireless adapter
  • Monitor or television
  • Power supply
  • Mouse or trackball
  • Keyboard
  • MCC DAQ device – I'm using a USB-1608FS to perform the tasks

Click here for a listing of MCC DAQ devices supported under Linux® and compatible with Raspberry Pi.

Use of a self-powered USB hub is recommended to connect the peripherals to the Raspberry Pi.

The image below shows the Raspberry Pi configuration used to perform these exercises.

Raspberry Pi

Note that a keyboard and mouse are connected to the USB hub but are not shown in the above photo.

Install an Operating System
You must install an operating system onto the Raspberry Pi before it can be used. I am installing Raspbian, which is a free operating system based on Debian that is optimized for the Raspberry Pi hardware. I am using NOOBS (New Out Of the Box Software) to install Raspbian. NOOBS is an operating system install manager for the Raspberry Pi.

You use an SD card to transfer NOOBS onto the Raspberry Pi. The SD card must be formatted to remove all information. The following procedures show you how to perform these steps.

Watch the Video! Go to http://www.raspberrypi.org/help/noobs-setup/ to see a video showing how to format the SD card, download NOOBS, and install the Raspbian OS onto the Raspberry Pi.

Format the SD card
Perform the following steps to format the SD card:

  1. Go to www.sdcard.org and click Download.
  2. Scroll to the page bottom and select the SD formatter for Windows or Mac, and then save the download on the computer.
  3. Install the SD card into your PC or MAC, and run the setup.exe SD formatter executable.

Install the operating system onto the Raspberry Pi
Perform the following steps to download NOOBS and install an OS onto the Raspberry Pi:

  1. Go to www.raspberrypi.org and click Downloads.
    Under the NOOBS section click Download Zip and save the file to your PC or Mac.
  2. Expand the zip file and copy all files to the SD Card.
  3. Remove the SD card from your PC or Mac, and install it into the Raspberry Pi.
  4. Connect the monitor, keyboard, mouse, and power.
    Connecting power will boot the Raspberry Pi.
    The Raspberry Pi Logo displays, followed by a NOOBS dialog box which shows a list of operating systems to install.
  5. Check the Raspbian checkbox and click Install, then select Yes on the Confirm dialog box to install Rasbian.
    A dialog box notifies you when installation is complete.
  6. Click OK; the Raspberry Pi starts loading Raspbian.
    If this is the first time booting Raspbian, a Setup Options menu appears. Use the keyboard arrow keys to navigate the menu.
  7. Set the configuration options, such as the language and regional settings to match your location.
  8. Tap <Finish> and press <Enter> when done setting configuration options.
    The command prompt displays pi@raspberrypi~$
    Congratulations! You have now installed the Raspberry Pi operating system.

Login information
Each time you boot up the Raspberry Pi you are prompted for the following login information:
   raspberrypi login: pi
   password: raspberry
The command prompt displays pi@raspberrypi~$

Verify Internet Access
Before you download the MCC drivers for the Raspberry Pi, verify that the Raspberry Pi can access the internet. You can connect an Ethernet cable or connect a USB WiFi adapter to connect with a wireless network. I am using a WiFi adapter.

  1. Double-click the WiFi Config icon on the desktop to start the wireless configuration program. The Adapter: field lists the name of the USB wireless adapter (for example wlan0); the Network: field is empty.
  2. Click Scan to list the available wireless networks.
  3. Double click on the service set identifier (SSID) network name to which you want to connect.
  4. Verify the Authentication and Encryption fields on the connection window, and enter the password in the PSK (pre-shared key) field.
  5. Click Add.
    The configuration program automatically connects to the newly configured network.
  6. Cycle the device power to reboot the Raspberry Pi and enter the login information above.

After logging in, the command prompt displays pi@raspberrypi~$.

Update the Raspberry Pi Package List
To ensure that you have the latest Raspberry P package installed, enter the following code.
       sudo apt-get update

Download the MCC Linux drivers
The MCC Linux drivers for Raspberry Pi are available for USB, Bluetooth, and Ethernet devices, and are stored on GitHub. Navigate to the Git repository and download the latest driver suite.

  1. Go to the GitHub web page that hosts the Raspberry Pi drivers.
    https://github.com/wjasper/Linux_Drivers
  2. Click the Download button and select Download Zip.
  3. Install the unzip utility using the command:
    sudo apt-get install unzip
  4. In the terminal window, navigate to the download directory (using the cd command), and unzip the driver files to the home/pi directory:
    unzip Linux_Drivers-master.zip -d ~pi

The MCC drivers are periodically updated to add support for additional devices.
Click the device type below to go to the procedure for installing the driver:

Install the USB Linux driver and compile the test programs
Before compiling the MCC USB drivers, you must install additional packages required for communication with USB devices.

  1. Download and install the development packages for both libusb and libudev.
    libusb is a C library that provides generic access to USB devices.
    sudo apt-get install libusb-1.0-0 libusb-1.0-0-dev
  2. Copy the mcc USB rules file to the /etc/udev/rules.d directory, renaming it to 99-mcc.rules (preventing an issue with the standard naming on the Raspberry Pi):
    sudo cp 61-mcc.rules /etc/udev/rules.d/99-mcc.rules
  3. Clone the hidapi GIT repository to the home/pi directory:
    HIDAPI is required to interface with Human Interface Devices (HID).
    git clone git://github.com/signal11/hidapi.git
  4. Follow the instructions in the hidapi README.txt to install the hidapi library:
    a. Install autotools, a suite of programming tools designed to assist in making source code packages portable to Unix-like systems.
        The autotools package is required for building the hidapi library.
        sudo apt-get install libudev-dev libfox-1.6-dev autotools-dev autoconf automake libtool
    b. Compile the hidapi library:
        cd ~pi/hidapi
        ./bootstrap
        ./configure
        make
        sudo make install

  5. Reboot the Raspberry Pi, and enter your login information when prompted.
  6. Install the Linux drivers.
    Enter the following code to install the USB drivers and compile the test apps:
    cd ~pi/usb/mcc-libusb
    make
    sudo make install
    sudo ldconfi
    g

Install the Bluetooth Linux driver and compile the test programs
Perform the procedure below to download the Bluetooth library and compile the Bluetooth driver.
Before performing this procedure, make sure you already downloaded the Bluetooth drivers using the Download the MCC Linux drivers procedure.

  1. Install the Bluetooth library.
    To compile the Bluetooth library you need to add the bluez-libs-devel package.
    sudo apt-get install libbluetooth-dev bluez-tools
  2. Compile the Bluetooth driver.          
    cd ~pi/Bluetooth
    make
    sudo make install

    Type ls to list all of the files.
  3. Run an example test app with an MCC Bluetooth DAQ device.
    a. Plug in your MCC Bluetooth device.
    b) Enter the name of a test program exactly as it is written, for example:
        ./test-bth1208LS
        The test app will display a list of tests that you can perform.
    c) Enter the letter of a command to execute.

Install the Ethernet Linux driver and compile the test programs
Perform the procedure below to compile the Ethernet driver.
Before performing this procedure, make sure you already downloaded the Ethernet drivers using the Download the MCC Linux drivers procedure.

  1. Compile the driver:
    cd ~pi/Ethernet
    make
    sudo make install

    Type ls to list all of the files. MCC Ethernet devices require a connection through a network router.  
  2. Run an example test app with an MCC Ethernet DAQ device.
    a. Plug in your MCC Ethernet device.
    b. Enter the name of a test program exactly as it is written, for example:
        cd ~pi/usb
        ./test-E-1608<IP ADDR>

        The test app will display a list of tests that you can perform.
    c. Enter the letter of a command to execute.

MCC Test Apps
MCC test apps are developed on Linux and are available for most MCC devices. The test apps acquire analog, counter, and digital data (as supported), test device functionality, and display device information.

Refer to the USB/mcc-libusb, Bluetooth, and Ethernet folders at https://github.com/wjasper/Linux_Drivers for the name of each test app. The app name includes the name of the device that it is run with. Note that when a device is part of a Series, one test app applies to each device in the Series. When you run the app, enter the name exactly as it is listed.

For example, when using a USB-1608GX-2AO, run the test app named "test-usb1608G".

Example: Running a Test App with an MCC USB DAQ Device and Raspberry Pi
Go to the mcc-libusb directory to run the test app and enter the following commands at the pi@raspberrypi~ command prompt. This example runs the test app for a USB‑1608FS:
      cd ~pi/mcc-libusb
      ./test-usb1608FS

The test app first detects the device and builds a calibration table that includes a slope and offset from the device analog inputs.

Raspberry Pi

AfAfter the calibration table is built, the app displays a list of tests that you can perform.

Raspberry Pi

Each task has a corresponding letter that you enter to run the task. Additional prompts appear if more information is needed, such as a channel number or frequency value. The task will run and the results display on the monitor.

More Information
Contact Measurement Computing Corporation if you have questions about acquiring data with the Raspberry Pi:

Knowledgebase: kb.mccdaq.com

Email: techsupport@mccdaq.com

Tech Support Form: www.mccdaq.com/support/support_form.aspx

Phone: 508-946-5100 and follow the instructions for reaching Tech Support

For more information about the Raspberry Pi, go to www.raspberrypi.org.

Measurement Computing Corporation and the Measurement Computing logo are either trademarks or registered trademarks of Measurement Computing Corporation.
Raspberry Pi is a trademark of the Raspberry Pi Foundation.
Linux® is the registered trademark of Linus Torvalds in the U.S. and other countries.
All other trademarks are the property of their respective holders.

Acknowledgement
A special thanks to Warren Jasper, PhD, PE, Professor and Textile Engineering Program Director at North Carolina State University. Dr. Jasper remains instrumental to the development and support of Linux drivers for Measurement Computing USB and PCI DAQ devices. We applaud his tireless efforts and dedication to the Linux community. Without his work and continued support, this article and application would not have been possible.

Additional TechTips are available on our Data Acquisition Technical Articles web page.