The Raspberry Pi® is a single-board computer that runs the Linux® kernel-based operating system and provides easy connections to peripheral devices, including a monitor, mouse, keyboard, and MCC data acquisition devices. 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 DAQ devices using the Raspberry Pi and UL for Linux.
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 Universal Library for Linux drivers and build the library
- Run an MCC Linux test app
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.
The following equipment is needed to perform the exercises:
- Raspberry Pi single-board computer – For this example, Raspberry Pi 3 model b is used, 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 (The Pi model used here has built in WiFi)
- Monitor or television + HDMI cable
- Power supply
- Mouse or trackball
- MCC DAQ device – I'm using a USB-1808X to perform data acquisition tasks
Click here for a listing of MCC DAQ devices supported under Linux® and compatible with Raspberry Pi.
The image below shows the Raspberry Pi configuration used to perform these exercises.
Using an SD to Install the Operating System
You must install an operating system onto the Raspberry Pi before it can be used. This example uses Raspbian, which is a free operating system based on Debian, optimized for the Raspberry Pi hardware. NOOBS (New Out Of the Box Software) is an operating system install manager for the Raspberry Pi, and is used to install Raspbian in this example.
You use an SD card to transfer NOOBS onto the Raspberry Pi. The SD card must be formatted to remove all previous 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:
- Go to www.sdcard.org and click SD Memory Card Formatter button.
- Scroll to the page bottom and select the SD formatter for Windows or Mac, follow the on-screen prompts, and then save the download on the computer.
- Install the SD card into your PC or Mac and run the SD_CardFormatter0500SetupEN.exe (SD formatter executable).
Install the Operating System onto the Raspberry Pi
Perform the following steps to download NOOBS and install the OS onto the Raspberry Pi:
- Go to www.raspberrypi.org and click Downloads.
Under the NOOBS section click Download Zip and save the file to your PC or Mac.
- Expand the zip file and copy all files to the SD Card.
- Remove the SD card from your PC or Mac, and install it into the Raspberry Pi.
- 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.
- Check the Raspbian checkbox and click Install, then select Yes on the Confirm dialog box to install Raspbian.
A dialog box notifies you when installation is complete.
- 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.
- Set the configuration options, such as the language and regional settings to match your location.
- 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.
Each time you boot up the Raspberry Pi you are prompted for the following login information:
raspberrypi login: pi
The command prompt displays pi@raspberrypi~$
Verify Internet Access
Before downloading UL for Linux, 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. This example uses the Pi’s built in WiFi adapter.
- 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.
- Click Scan to list the available wireless networks.
- Double click on the service set identifier (SSID) network name to which you want to connect.
- Verify the Authentication and Encryption fields on the connection window, and enter the password in the PSK (pre-shared key) field.
- Click Add.
The configuration program automatically connects to the newly configured network.
- 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 Pi software versions for each package installed, enter the following code from the terminal window to update the Raspberry Pi package list.
$ sudo apt-get update
To use the UL for Linux, you need to install the following prerequisites:
- C, C++ compilers and Make tool
- Development package for libusb
To install them, enter the following commands from the terminal window:
$ sudo apt-get install gcc g++ make
$ sudo apt-get install libusb-1.0-0-dev
Download the UL for Linux for C
The MCC Linux drivers are currently available for USB MCC devices (with more to come). They are stored on GitHub at: https://github.com/mccdaq/uldaq
- To download the UL for Linux, enter the following in the terminal window:
$ wget https://github.com/mccdaq/uldaq/releases/download/v1.0.0/libuldaq-1.0.0.tar.bz2
- Extract the tar file
$ tar -xvjf libuldaq-1.0.0.tar.bz2
- Run the following commands to build and install the library
$ cd libuldaq-1.0.0
$ ./configure && make
$ sudo make install
- The C examples are located in the examples folder and ready to run
$ cd examples
Python Interface for UL for Linux
If you would like to use the UL for Linux with Python, you still need to follow the steps above, and then proceed here with pip:
$ sudo pip install uldaq
Open the Raspberry Pi’s browser and navigate to: pypi.org/project/uldaq
Under Navigation click the Download files link
Click the uldaq-1.0.0.tar.gz link to download the file.
A dialog box appears, select Save file and click OK. The file is now downloaded.
- Copy the file from the Downloads folder to the folder where you installed libuldaq-1.0.0:
Make a directory:
$ mkdir python
Change to the directory:
$ cd python
Copy the file from downloads:
$ cp ~/Downloads/uldaq-1.0.0.tar.gz ~/libuldaq-1.0.0
- Extract the tar file:
$ tar -xvf uldaq-1.0.0.tar.gz
- The Python examples are in the examples folder:
$ cd uldaq-1.0.0/examples
MCC Test Apps and Source
MCC test apps are developed on Linux and are available for Linux supported MCC devices in C and Python. The test apps perform all the device functions such as acquire analog, counter, and digital data (as supported), test device functionality, and display device information.
Refer to https://github.com/mccdaq/uldaq, click on the link for ULHELP and select Index.html for the names of each test/example app. Pick an appropriate test app for your device.
Example: Running an example app with an MCC USB DAQ Device and Raspberry Pi
Change to the libuldaq directory to run an example app and enter the following commands at the pi@raspberrypi~$ command prompt. For example, if you have an USB-1808X, you can run an analog input example:
- In C:
$ cd libuldaq-1.0.0/examples
- In Python:
There are example apps for each feature of supported devices, for example:
Each example performs a specific function of a supported device and is well commented for your review. Additional prompts appear if more information is needed, such as a channel number or frequency value. The examples run and the results displayed on the monitor.
任何关于Raspberry Pi的数据采集问题，请联系Measurement Computing Corporation：
Measurement Computing Corporation 和 Measurement Computing logo是属于Measurement Computing公司的商标或注册商标
Raspberry Pi是属于Raspberry Pi基金会的商标