Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| daq-and-datalogging:documents:raspberry-pi-acquisition-with-ul-for-linux [2023/06/14 05:38] – created Scandiweb | daq-and-datalogging:documents:raspberry-pi-acquisition-with-ul-for-linux [2023/07/28 01:07] (current) – Arthur Brown | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== TechTip: ====== | + | ====== TechTip: |
| - | ===== Utilizing Digital Inputs / Outputs with MCC DAQ ===== | + | **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**\\ | **Objective**\\ | ||
| - | To show how to write to a single digital I/O bit using an MCC data acquisition | + | Acquire data from an MCC DAQ device |
| + | 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 | ||
| **Intended Audience**\\ | **Intended Audience**\\ | ||
| - | Data acquisition system | + | This document is intended for application |
| - | **Overview**\\ | + | **Equipment**\\ |
| - | Digital signals, by definition, are those which can represent just two states, such as on or off. Examples include a warning lamp being lit or dark, a door being latched or unlatched, and a relay being closed or open. Numerically the two states are represented as 1 and 0, or Boolean (true and false). As in most hardware architectures, | + | The following equipment is needed |
| - | In some applications you will want to control or monitor a set of signals exactly at the same time, so be sure to group those signals onto the same port. But for some signals, while you may physically wire them to the same port, you may decide to read or write to them sequentially. In addition to port-wise operations, | + | *Raspberry Pi single-board computer – For this example, Raspberry Pi 3 model b is used, but you can use any Raspberry Pi model |
| + | *microSD 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 | ||
| + | *Keyboard | ||
| + | *MCC DAQ device – I'm using a USB-1808X to perform data acquisition tasks | ||
| - | A common question is “how fast should I sample my digital inputs?”, and the answer invariably is: frequently enough so you do not miss a change-of-state. Note that digital inputs generally are not self-latching, nor do they automatically detect input changes. You must read (poll) them on a regular basis, | + | [[https://files.digilent.com/ |
| - | While real-world digital signals are predominantly unidirectional, | + | The image below shows the Raspberry Pi configuration |
| - | For a software-paced digital output operation, independent of the software platform, two steps are required: Set the direction of the port to output, then later write a value to the port/bit. The former is performed just once, while the latter can be repeated as needed throughout the application. | + | {{https://files.digilent.com/ |
| - | The following information | + | **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.\\ |
| - | *Port Direction | + | |
| - | *Data value to output | + | **Watch the Video!** Go to [[ https:// |
| + | |||
| + | **Format the microSD card**\\ | ||
| + | Perform the following steps to format the microSD card: | ||
| + | |||
| + | *Go to www.sdcard.org and click **SD Memory Card Formatter** button. | ||
| + | *Scroll | ||
| + | *Install the SD card into your PC or Mac and run the **SD Card Formatter 5.0.1 Setup.exe** (SD formatter executable). | ||
| + | |||
| + | **Write the Raspberry Pi image to the microSD card**\\ | ||
| + | |||
| + | *Insert the microSD card into a computer or SD card reader connected to a computer. | ||
| + | *Go to https:// | ||
| + | *Connect an SD card reader with the formatted SD card inside. | ||
| + | *Run the Raspberry Pi Imager exe and select an operating system. | ||
| + | *Choose the SD card you wish to write your image to. | ||
| + | *Click ' | ||
| + | |||
| + | For additional information and options go to the Installing operating system images page on the Raspberry Pi website.\\ | ||
| + | |||
| + | **Use the Raspberry Pi**\\ | ||
| + | |||
| + | *Insert the microSD card into the Raspberry Pi. | ||
| + | *Open the setup options menu and configure various options such as the language and regional settings to match your location | ||
| + | *Tap < | ||
| + | *The command prompt displays pi@raspberrypi~$ | ||
| | | ||
| - | And the following information is returned: | + | Congratulations! You have now ready to use the Raspberry Pi!\\ |
| - | | + | **Logging In**\\ |
| - | The examples below show how to perform a non-continuous scan using the Universal Library™, UL for Android™, NI LabVIEW™, DASYLab®, and DAQami. | + | Each time you boot up the Raspberry Pi you are prompted |
| + | | ||
| + | | ||
| + | The command prompt displays pi@raspberrypi~$\\ | ||
| - | **Universal Library**\\ | + | **Verify Internet Access**\\ |
| - | The following example shows how to first configure, and then control, a digital output using the Universal Library (UL) and Visual Basic: | + | Before downloading UL for Linux, verify that the Raspberry Pi can access the internet. You can connect an Ethernet cable or connect |
| - | PortType = MccDaq.DigitalPortType.AuxPort ‘Specify which digital port\\ | + | *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. |
| - | Direction = MccDaq.DigitalPortDirection.DigitalOut ‘Specify | + | |
| - | ULStat = DaqBoard.DConfigPort(PortType, Direction) ‘Configure the port\\ | + | *Double click on the service set identifier |
| - | BitNum = 0 ‘Specify | + | *Verify the Authentication and Encryption fields on the connection window, and enter the password |
| - | BitValue = 1 ‘Specify | + | *Click Add. |
| - | ULStat = DaqBoard.DBitOut(PortType, | + | The configuration program automatically connects |
| + | | ||
| - | **UL for Android**\\ | + | After logging in, the command prompt displays pi@raspberrypi~$.\\ |
| - | The following example shows how to configure and control a digital output using UL for Android and Java:\\ | + | |
| - | DigitalPortType = AUXPORT; //Specify which digital port\\ | + | **Update the Raspberry Pi Package List**\\ |
| - | DigitalDirection = OUTPUT; // | + | To ensure that you have the latest Raspberry Pi software versions for each package installed, enter the following code from the terminal window |
| - | mDioDevice.dConfigPort(DigitalPortType, DigitalDirection); | + | $ sudo apt-get update |
| - | bitNum = 0; //Specify which bit in the port to control\\ | + | |
| - | bitState = true; Specify | + | |
| - | **NI LabVIEW**\\ | + | **UL for Linux**\\ |
| - | The following example shows how to control a digital output bit using LabVIEW. The wiring diagram below shows the pertinent VIs and settings. Here just the first bit (Do0) of the Auxport on hardware device #0 is configured for output, and then it is tasked with outputting | + | To build and install |
| - | {{https:// | + | **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, | ||
| - | DASYLab\\ | + | Refer to the [[https:// |
| - | Non-programmers with digital signals | + | |
| + | **Running Examples**\\ | ||
| + | Example apps are located in the examples folder. Run the following commands to execute the analog input example: | ||
| - | {{https://files.digilent.com/resources/ | + | C: |
| + | $./Ain | ||
| - | Double clicking on the Switch module allows you to access a menu where you can specify how often the switch position will be monitored. Below we see that 1 Hz is selected, resulting in digital output bit D0 on the DAQ hardware being updated every second to match the operator’s selection. | + | Python: |
| + | $ ./a_in.py | ||
| + | There are example apps for each feature of supported devices, for example: | ||
| - | {{https:// | + | ^ 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 | | ||
| - | More Information\\ | + | Each example performs a specific function of a supported device and is well commented for your review. Additional prompts appear |
| - | Please contact Measurement Computing Corporation | + | |
| - | *Knowledgebase: [[https://kb.mccdaq.com/Default.aspx | kb.mccdaq.com]] | + | More Information\\ |
| - | *Phone: 508-946-5100 | + | Please reach out to our support team on the Digilent Forum if you have any questions: [[https://forum.digilent.com/]] |
| - | **Fax: 508-946-9500 | + | |
| | | ||
| - | Additional TechTips are available | + | Additional TechTips are available |

