Introduction
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.
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:
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:
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.
Install the Raspberry Pi Operating System
You must install the Raspberry Pi operating system onto the Raspberry Pi before it can be used. The Raspberry Pi OS (previously called Raspbian) is the official supported OS for the Raspberry Pi.
Use the Raspberry Pi imager to install the Raspberry Pi OS to a microSD card. The SD card must be formatted to remove all previous information.
Watch the Video! Go to HOW TO INSTALL RASPBIAN OS to your Raspberry Pi with ease to see a brief video that shows how to image your microSD card with Raspberry Pi OS.
Format the microSD card
Perform the following steps to format the microSD card:
Write the Raspberry Pi image to the microSD card
For additional information and options go to the Installing operating system images page on the Raspberry Pi website.
Use the Raspberry Pi
Congratulations! You have now ready to use the Raspberry Pi!
Logging In
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 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.
The configuration program automatically connects to the newly configured network.
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
UL for Linux
To build and install the latest version of the library, refer to the instructions on GitHub at: https://github.com/mccdaq/uldaq
Examples
MCC example apps are developed on Linux and are available for Linux supported MCC devices in C and Python. The example 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 the online help for C/C++ or the online help for Python for an overview of each test/example app. Select an appropriate test app for your device.
Running Examples
Example apps are located in the examples folder. Run the following commands to execute the analog input example:
C: $./Ain
Python: $ ./a_in.py There are example apps for each feature of supported devices, for example:
Function | C Examples | Python Examples |
---|---|---|
Analog In | Ain AInScan AInScanWithEvents AInScanWithQueue AInScanWithTrigger | a_in a_in_scan a_in_scan_with_events a_in_scan_with_queue a_in_scan_with_trigger |
Analog Out | AOut AOutScan | a_out a_out_scan |
Digital IO | Din DBitIn\ DInScan DInScanWithTrigger DOut DBitOut DOutScan | d_in d_bit_in d_in_scan d_in_scan_with_trigger d_out d_bit_out d_out_scan |
Counter In | CIn CInScan CInScanWithEncoder | c_in c_in_scan\ c_in_scan_with_encoder |
Timer Out | TmrPulseOut | tmr_pulse_out |
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.
More Information
Please reach out to our support team on the Digilent Forum if you have any questions: https://forum.digilent.com/
Additional TechTips are available here in Digilent Reference: App Notes, Tech Tips, and Other Documents