Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| daq-and-datalogging:documents:raspberry-pi-acquisition-with-ul-for-linux [2023/06/14 05:43] – 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**\\ |
| + | Each time you boot up the Raspberry Pi you are prompted for the following login information: | ||
| + | | ||
| + | | ||
| + | The command prompt displays pi@raspberrypi~$\\ | ||
| - | The examples below show how to perform a non-continuous scan using the Universal Library™, | + | **Verify Internet Access**\\ |
| + | Before downloading | ||
| - | **Universal Library**\\ | + | |
| - | The following | + | *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 | ||
| + | *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. | ||
| - | PortType = MccDaq.DigitalPortType.AuxPort ‘Specify which digital port\\ | + | After logging in, the command prompt displays pi@raspberrypi~$.\\ |
| - | Direction = MccDaq.DigitalPortDirection.DigitalOut ‘Specify the output direction\\ | + | |
| - | ULStat = DaqBoard.DConfigPort(PortType, Direction) ‘Configure | + | |
| - | BitNum = 0 ‘Specify which bit in the port to control\\ | + | |
| - | BitValue = 1 ‘Specify the value to write\\ | + | |
| - | ULStat = DaqBoard.DBitOut(PortType, | + | |
| - | **UL for Android**\\ | + | **Update the Raspberry Pi Package List**\\ |
| - | The following | + | To ensure that you have the latest Raspberry Pi software versions for each package installed, enter the following |
| + | $ sudo apt-get update | ||
| - | DigitalPortType = AUXPORT; //Specify which digital port\\ | + | **UL for Linux**\\ |
| - | DigitalDirection = OUTPUT; // | + | To build and install |
| - | mDioDevice.dConfigPort(DigitalPortType, DigitalDirection); | + | |
| - | bitNum = 0; //Specify which bit in the port to control\\ | + | |
| - | bitState = true; Specify the Boolean value to write mDioDevice.dBitOut(DigitalPortType, | + | |
| - | **NI LabVIEW**\\ | + | **Examples**\\ |
| - | The following | + | MCC example |
| - | {{https:// | + | Refer to the [[https:// |
| - | DASYLab\\ | + | **Running Examples**\\ |
| - | Non-programmers with digital signals to monitor and control can consider | + | Example apps are located in the examples folder. Run the following commands |
| + | C: | ||
| + | $./Ain | ||
| - | {{https://files.digilent.com/resources/ | + | Python: |
| + | $ ./a_in.py | ||
| + | There are example apps for each feature of supported devices, for example: | ||
| - | 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.\\ | + | ^ 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 | | ||
| - | {{https:// | + | 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\\ | More Information\\ | ||
| - | Please | + | Please |
| - | + | ||
| - | Knowledgebase: [[https://kb.mccdaq.com/Default.aspx | kb.mccdaq.com]]\\ | + | |
| - | Phone: 508-946-5100\\ | + | |
| - | Fax: 508-946-9500\\ | + | |
| | | ||
| - | Additional TechTips are available | + | Additional TechTips are available |

