Introduction
The Raspberry Pi is a single-board computer system that can easily connect peripherals such as mouse, keyboard, and display, and run a Linux®-based operating system at a cost of less than 300 RMB, making it particularly suitable for cost-effective data acquisition applications. Now, most USB, Ethernet, and Bluetooth data acquisition devices from Measurement Computing are compatible with Raspberry Pi.
Purpose
Run applications on Raspberry Pi to control MCC DAQ devices to perform data acquisition tasks. This article details the following key steps:
-
Formatting SD card
-
Installing operating system
-
Configuring Raspberry Pi
-
Installing Linux device drivers
-
Installing MCC DAQ device drivers and compiling the test program provided by MCC
-
Running MCC test program
Target Audience
Those working on the Raspberry Pi (Linux) platform, familiar with MCC data acquisition cards, and wishing to achieve data acquisition functionality on this platform.
Prerequisites
Please prepare the following items in advance:
-
Raspberry Pi hardware board (this article uses model B, you can use any model according to your actual situation)
-
SD card (8GB or larger)
-
PC or Mac®, with internet access
-
Ethernet cable or wireless adapter
-
Monitor or TV
-
Power supply
-
Mouse or trackball
-
Keyboard
-
MCC DAQ device (this article uses USB-1608FS)
Learn about MCC data acquisition cards that support Linux® and are compatible with Raspberry Pi:
http://china.mccdaq.com/MCC-Linux-Support-Selection.aspx
It is recommended to use a self-powered USB Hub to connect peripherals to the Raspberry Pi.
The following image shows the configuration of the Raspberry Pi used in this article: The mouse and keyboard are connected to the Raspberry Pi through a USB Hub and are not shown in the image.
Installing Operating System
Before using the Raspberry Pi, the operating system must be installed. This article will install Raspbian, an open-source operating system based on Debian, which has been extensively optimized for Raspberry Pi and is installed via NOOBS (New Out Of the Box Software), an open-source operating system installation manager officially released by Raspberry Pi.
Using an SD card to copy NOOBS to the Raspberry Pi, you first need to format the SD card. Please refer to the detailed steps below: Video tutorial! Go to http://www.raspberrypi.org/help/noobs-setup/ for detailed video tutorials, including formatting the SD card, downloading NOOBS, and installing the Raspbian system. Formatting the SD card The following steps will guide you in downloading NOOBS and installing the operating system on the Raspberry Pi:
1. Visit www.sdcard.org, click Download
2. Download the SD formatter for Windows or Mac at the bottom of the download page
3. Insert the SD card into your PC or MAC, run setup.exe, and format the SD card
Installing Operating System The following steps will guide you in downloading NOOBS and installing the operating system on the Raspberry Pi:
1. Visit www.raspberrypi.org, click Downloads. Click Download ZIP under NOOBS, and save it to your PC or MAC
2. Unzip the zip file and copy all files to the SD card
3. Eject the SD card and insert it into the Raspberry Pi
4. Connect the monitor, mouse, keyboard, and power supply After powering on, the Raspberry Pi will start immediately First, you will see the Raspberry Pi logo, followed by the NOOBS main window, which lists all the installable operating systems
5. Check the Raspbian checkbox, click Install, and select Yes in the Confirm dialog The installation progress will be displayed in real-time
6. Select OK, and the Raspberry Pi begins loading Raspbian On the first boot of Raspbian, the Setup Options menu will pop up, and you can operate using the arrow keys on the keyboard
7. Configure relevant options as needed, such as language, locale, etc.
8. After configuration is complete, switch to <Finish> and press <Enter> Command line prompt: pi@raspberrypi~$ Congratulations! You have successfully installed the operating system on the Raspberry Pi.
Login Information Each time you start the Raspberry Pi, you will be prompted with the following login information: raspberrypi login: pi password: raspberry Command line prompt: pi@raspberrypi~$
Check Network Connection Before downloading the MCC driver on the Raspberry Pi, please confirm that the network connection is correct. You can connect to the network via an Ethernet cable or USB WiFi adapter. This article uses a WiFi adapter.
1. Double-click the WiFi Config icon on the desktop to configure the wireless network connection. Adapter: Lists all USB wireless adapters (e.g., wlan0); the Network: is empty
2. Click Scan to view available wireless networks
3. Double-click the wireless network you want to connect to in the service set identifier (SSID)
4. Verify the Authentication and Encryption in the current window, and enter the password in PSK (pre-shared key)
5. Click Add to configure and automatically connect to the wireless network
6. Restart the Raspberry Pi and enter the login information above
After logging in, the command will immediately display pi@raspberrypi~$.
Upgrade Raspberry Pi Packages To ensure you are using the latest Raspberry Pi packages, enter the following command
sudo apt-get update
Download MCC Linux Driver The Linux drivers for MCC USB, Bluetooth, and Ethernet devices are stored on GitHub. Log into the Git repository and download the latest driver package.
1. Log into the GitHub page to get the Raspberry Pi driver:https://github.com/wjasper/Linux_Drivers
2. Click the download button and choose to download the compressed package
3. Use the following command to install the unzip utility:
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 driver will continue to be updated to support more devices. Click on the device type below to go to the installation process:
-
USB
-
Bluetooth
-
Ethernet
Install Linux Driver for MCC USB Device and Compile Test Program Before modifying the USB driver, you must install the required packages for communication with the USB device.
1. Download and install the libusb and libudev development packages. libusb provides a generic C language library for USB devices.
sudo apt-get install libusb-1.0-0 libusb-1.0-0-dev
2. Copy the USB rules file to the following path /etc/udev/rules.d and rename it to 99-mcc.rules (to avoid standard naming issues 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 needs to connect 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 set of programming tools designed to help port source code packages to Unix-like systems. The autotools package is necessary 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. Restart the Raspberry Pi and enter the login information as prompted
6. Install the Linux driver. Enter the following code to install the USB driver and compile the test application:
cd ~pi/usb/mcc-libusb
make
sudo make install
sudo ldconfig
Install Linux Driver for MCC USB Device and Compile Test Program Execute the following steps to download the Bluetooth library and compile the Bluetooth driver. Before performing this process, ensure you have downloaded the Bluetooth driver using the “Download Third Party MCC Linux Driver” process.
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 files.
3. Run the example test application using the MCC Bluetooth DAQ device a. Insert the MCC Bluetooth device. b. Enter the name of a test program exactly as it is written, for example:
./test-bth1208LS
The test application will display a list of tests you can perform. c. Enter the letter for the command you wish to execute.
Install Ethernet Linux Driver and Compile Test Program Execute the following steps to compile the Ethernet driver. Before performing this process, ensure you have downloaded the Ethernet driver using the “Download Third Party MCC Linux Driver” process.
1. Compile the driver
cd ~pi/Ethernet
make
sudo make install
Type ls to list all files. The MCC Ethernet device needs to be connected through a network router.
2. Run the example test application using the MCC Ethernet DAQ device. a. Insert your Ethernet device b. Enter the full test program name, for example:
cd ~pi/usb
./test-E-1608<IP ADDR>
The test application will display a list of tests you can perform. c. Enter the letter for the command you wish to execute.
MCC Test Program The test program developed for Linux supports most MCC USB devices. The program will perform data acquisition on analog channels, counter channels, and digital channels while testing device functionality and displaying device information.
For more details on the test program, see the USB/Mcc-libusb, Bluetooth, Ethernet folders on https://github.com/wjasper/Linux_Drivers, the program names cover the corresponding device models. If the device belongs to a certain series, this program supports all devices in that series. When running the program, be sure to correctly type the device name as listed.
For example, when using USB-1608GX-2AO, run the program “test-usb1608G”.
Run MCC DAQ Device Test Program on Raspberry Pi Go to the mcc-libhid directory and enter the following command at the command prompt (pi@raspberrypi~) to run the USB-1608FS test program:
cd ~pi/mcc-libusb
./test-usb1608FS
The test program first detects the device and creates a table containing the calibration parameters (slope and offset) for the device’s analog input. After the table is established, all executable device test functions will be displayed Each test function has a corresponding hotkey, which can be executed by pressing the keyboard. The program may prompt you to enter more information, such as the number of channels or frequency, and the execution results will be printed on the monitor.
More Information
For any questions regarding data acquisition with Raspberry Pi, please contact Measurement Computing Corporation:
-
Knowledge Base: kb.mccdaq.com
-
Email: [email protected]
-
Technical Support Request Form: china.mccdaq.com/support/support_form.aspx
-
Contact Number: 021 – 50509819
For more information related to Raspberry Pi, please refer to www.raspberrypi.org.
Measurement Computing Corporation and the Measurement Computing logo are trademarks or registered trademarks of Measurement Computing Corporation. Raspberry Pi is a trademark of the Raspberry Pi Foundation. Linux® is a registered trademark of Linus Torvalds in the United States and other countries. All other trademarks belong to their respective owners.
Acknowledgments Special thanks to Dr. Warren Jasper (PE, Professor, Textile Engineering Program Director) at North Carolina State University. Dr. Jasper has long helped and supported the development of Linux device drivers for Measurement Computing’s USB and PCI data acquisition cards. We respect and appreciate Dr. Jasper’s tireless efforts and contributions to the Linux community; without his hard work and unwavering support, this article and the engineering applications mentioned would not have been possible.
Click “Read Original” to learn more
Product and Technical Consultation: 021-50509819
Email:[email protected]
Website:china.mccdaq.com
Easy to use | Easy integration | Fast support
MCC Data Acquisition HATs Module Based on Raspberry Pi®
Ethernet DAQ Remote Measurement and Control
[Getting Started Video] DASYLab® Free Trial for 28 Days
High-speed, high-precision synchronous data acquisition card USB-1808 Series
Leave a Comment
Your email address will not be published. Required fields are marked *