Editor’s note: Data acquisition solutions used in industry are generally based on Windows systems, but as Raspberry Pi is increasingly applied in the industrial field, products and applications based on Raspberry Pi have finally appeared in the data acquisition field. We previously introduced two data acquisition expansion boards suitable for Raspberry Pi, the MCC118 and MCC152, which greatly reduce the application cost of data acquisition solutions. What we will introduce next is how to install and use the MCC data acquisition card, which is commonly used in Windows, on Raspberry Pi. This will provide another great solution option for data acquisition.
Introduction
The Raspberry Pi is a single-board computer system that easily connects to peripherals such as a mouse, keyboard, and monitor, and runs a Linux®-based operating system, with a cost of less than 300 RMB, making it especially suitable for cost-effective data acquisition applications. Now, most of Measurement Computing’s USB, Ethernet, and Bluetooth data acquisition devices are compatible with Raspberry Pi.
Objective
To run applications on Raspberry Pi and control the MCC DAQ devices to perform data acquisition tasks. This article details the following key steps:
-
Format the SD card
-
Install the operating system
-
Configure Raspberry Pi
-
Install Linux device drivers
-
Install MCC DAQ device drivers and compile the test programs provided by MCC
-
Run the MCC test programs
Target Audience
Those who work on the Raspberry Pi (Linux) platform, are familiar with the MCC data acquisition cards, and wish to implement data acquisition functionality on this platform.
Prerequisites
Please prepare the following:
-
Raspberry Pi hardware board (this article uses model B, you can use any model according to actual conditions)
-
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 above.
Installing the Operating System
Before using the Raspberry Pi, you must install an operating system. This article will install Raspbian, an open-source operating system based on Debian, which has been optimized for Raspberry Pi, and will complete the installation of Raspbian via NOOBS (New Out Of the Box Software), which is the official open-source operating system installation manager released by the Raspberry Pi.
Using an SD card, copy NOOBS to the Raspberry Pi. First, you need to format the SD card. Please refer to the following detailed steps: Video Tutorial! Go to http://www.raspberrypi.org/help/noobs-setup/ for a detailed video tutorial, including formatting the SD card, downloading NOOBS, and installing the Raspbian system. Format the SD card The following steps will guide you to download NOOBS and install 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
Install the Operating System The following steps will guide you to download NOOBS and install 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 supplyAfter powering on, the Raspberry Pi will start immediatelyFirst, 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 dialogThe installation progress will be displayed in real-time
6. Select OK, and the Raspberry Pi will start loading RaspbianDuring the first boot of Raspbian, the Setup Options menu will pop up, and you can navigate using the arrow keys on the keyboard
7. Configure related options as needed, such as language, regional settings, 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 ensure 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 see 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 the program to 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 that you are using the latest Raspberry Pi packages, enter the following command
sudo apt-get update
Download MCC’s Linux Drivers The Linux drivers for MCC USB, Bluetooth, and Ethernet devices are stored on GitHub. Log in to the Git repository and download the latest driver package.
1. Log in to the GitHub webpage to obtain the Raspberry Pi drivers: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 program:
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 will continue to be updated to support more devices.Click below the device type to go to the installation process:
-
USB
-
Bluetooth
-
Ethernet
Install Linux Drivers for MCC USB Devices and Compile Test Programs Before modifying the USB drivers, you must install the packages required for communication with the USB device.
1. Download and install the libusb and libudev development packages. Libusb provides a generic C 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 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 to human interface devices (HID).
git clone git://github.com/signal11/hidapi.git
4. Install the hidapi library according to the instructions in the hidapi README.txt: a. Install autotools, a set of programming tools designed to help port source code packages to Unix-like systems. The autotools package is required to build 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 when prompted.
6. Install the Linux drivers. Enter the following code to install the USB drivers and compile the test application:
cd ~pi/usb/mcc-libusb
make
sudo make install
sudo ldconfig
Install Linux Drivers for MCC USB Devices and Compile Test Programs Execute the following steps to download the Bluetooth library and compile the Bluetooth driver. Before executing this process, ensure that you have downloaded the Bluetooth driver using the “Download Third-Party MCC Linux Drivers” 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 of the command you want to execute.
Install Ethernet Linux Drivers and Compile Test Programs Execute the following steps to compile the Ethernet driver. Before executing this process, ensure that you have downloaded the Ethernet driver using the “Download Third-Party MCC Linux Drivers” 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 name of the test program, 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 of the command you want to execute.
MCC Test Programs The test programs developed for Linux support 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 detailed test programs, 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 enter the device name correctly as listed.
For example, when using USB-1608GX-2AO, run the program “test-usb1608G”.
Running MCC DAQ Device Test Programs 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 for the device’s analog inputs (slope and offset). Once the table is established, all executable device test functions will be displayed Each test function has a corresponding hotkey that you can press on the keyboard to execute the test task. The program may prompt you for additional information, such as the number of channels or frequency size, and the execution results will be printed on the monitor.
More Information
If you have any questions about data acquisition using 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. Other trademarks are the property of 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 thank Dr. Jasper for his tireless efforts and contributions to the Linux community. Without his hard work and continued support, this article and the engineering applications mentioned would not have been possible.
The links in the text can be clicked to read the original text at the end
More Exciting Content
How exciting would it be to combine your Raspberry Pi with a night vision camera?
Raspberry Pi Video Monitoring Solution motionEyeOS
Arduino + Servo Making Finger Gyro Robot
Making LED Matrix Color Lights with Raspberry Pi Arduino
Making LED Scrolling Display with Arduino
Playing with micro:bit MicroPython on Raspberry Pi
Leave a Comment
Your email address will not be published. Required fields are marked *