PC-based Data Acquisition

1y ago
14 Views
2 Downloads
1.85 MB
47 Pages
Last View : 13d ago
Last Download : 3m ago
Upload by : Ophelia Arruda
Transcription

FYS3240- 4240 Data acquisition & control PC-based data acquisition Spring 2021 – Lecture #4 Bekkeng, 19.01.2021

Introduction

Data acquisition (DAQ) Data acquisition involves measuring signals (from a real-world physical system) from different sensors, and digitizing the signals for storage, analysis and display or for use in a controls system. Analog/digital input channels can vary in number from one to several hundred or even thousands

Computer-based DAQ system FYS3240/4240 Configuration Signal processing Display Data Storage PCI DAQ card USB DAQ box PXI DAQ system .

From Simple to advanced PC-based DAQ systems . DAQ using the PC sound card – AC, low frequencies (10 – 20 kHz) PC with plug-in PCI DAQ card(s) PC with a USB DAQ device DAQ system with hundreds of measurement channels – using for instance PXI (PCI eXtensions for Instrumentation).

Multifunction DAQ-cards/devices – These DAQ-units have: Analog Input Analog Output Digital I/O DAQ Device Counters – Frequency measurements (digital edge counting) – Angular measurements from angular encoders (quadrature encoders) Computer – Connects to the bus of your computer Typically PCI, PCIe or USB. DAQ-cards/units (usually) do not include an anti-aliasing low-pass filter!

Hardware acceleration Normally, processors (CPUs) are sequential, and instructions are executed one by one. In computing, hardware acceleration is the use of computer hardware to perform some function faster than is possible in software running on the general-purpose CPU. The main difference between hardware and software is concurrency, allowing hardware to be much faster than software. Hardware accelerators are designed for computationally intensive software code Examples of hardware accelerators includes graphics processing units (GPUs) and field-programmable gate array (FPGA)

Move data between memory - for instance from DAQ-card to PC-memory

Interrupts One method to move acquired data to system memory (from a DAQ-card) is to generate an interrupt request (IRQ). signal. This signal can be generated when one sample is acquired or when multiple samples are acquired. The process of transferring data to system memory via interrupts is given below: – When data is ready for transfer, the CPU stops whatever it is doing and runs a special interrupt handler routine that saves the current machine registers, and then sets them to access the board. – The data is extracted from the board and placed into system memory. – The saved machine registers are restored, and the CPU returns to the original interrupted process. The actual data move is fairly quick, but there is a lot of overhead time spent saving, setting up, and restoring the register information.

DMA introduction Direct memory access (DMA) is a system whereby samples are automatically stored in system memory while the processor (CPU) does something else. A computer usually supports several DMA channels.

DMA (direct memory access) I DMA permits peripherals, such as a DAQ-card, to transfer data directly to or from memory without having each byte handled by the processor (CPU). Thus DMA enables more efficient use of interrupts, and increases data throughput. The process of transferring data via DMA is given below: – When data is ready for transfer, the DAQ-card notifies the DMA controller. – The DMA controller then asserts a DMA request signal to the CPU, asking its permission to use the bus (data bus, address bus, control bus). – The CPU completes its current bus activity, stops driving the bus, and returns a DMA acknowledge signal to the DMA controller. – The DMA controller then reads and writes one or more memory bytes, driving the address, data, and control signals as if it were itself the CPU.

DMA (direct memory access) II – When the transfer is complete, the DMA controller stops driving the bus and deasserts the DMA request signal. The CPU can then remove its DMA acknowledge signal and resume control of the bus. – In single-cycle mode, the DMA controller gives up the bus after each transfer. This minimizes the amount of time that the DMA controller keeps the processor off of the memory bus, but it requires that the bus request/acknowledge sequence be performed for every transfer. This overhead can result in a drop in overall system throughput if a lot of data needs to be transferred. – In burst mode, the DMA controller keeps control of the bus until all the data buffered by the requesting device has been transferred to memory (or when the output device buffer is full, if writing to a peripheral).

30 Hz sinus signal sampled at 3 kHz (top figure) Assume a non real-time system used, without DMA and FIFO. – If the CPU get busy with something else between 0.02 seconds and 0.03 seconds, this section of the sine wave does not get sampled (middle figure) The computer will then interpret the sine wave as shown in the bottom figure, unaware that the samples are not evenly spaced in time – This will give a wrong result if we do a frequency analysis of the signal. Therefore, DMA and FIFO buffers are used to compensate for non real-time properties of the operating system CPU busy CPU busy example

DAQ using LabVIEW

NI-DAQmx – NI-DAQmx (multithreaded) driver software provides ease of use, flexibility, and performance in multiple programming environments – Driver level software DLL that makes direct calls to your DAQ device – Supports the following software: NI LabVIEW NI LabWindows CVI C/C C# Visual Basic .NET.

NI Measurement & Automation Explorer (MAX) Icon on your Desktop All NI-DAQmx devices include MAX, a configuration and test utility You can use MAX to – – – – – – Configure and test NI-DAQmx hardware with interactive test panels Perform self-test sequences Create simulated devices Reference wiring diagrams and documentation Save, import, and export configuration files Create NI-DAQmx virtual channels that can be referenced in any programming language

MAX Example

LabVIEW Express: DAQ assistant Using the the DAQ assistant is the easy way to configure and read from a DAQ card!

DAQ Assistant Express VI to standard VIs

LabVIEW - Sequential DAQ design Configure Acquire data Analyze data Visualize data Save data Loop time: T1 T2 T3 T1 T2 T3

Software timing functions in LabVIEW

Use hardware timing for DAQ If you use software timer functions to control a loop, then you can expect differences in the time interval between each iteration (jitter) of the loop, depending on what other processes are running on the computer at that instant. – If you have several windows open at the same time and you are switching between different windows during your data acquisition, then you can expect a lot of overhead on the Central Processing Unit (CPU), which might slow down the loop that is performing the data acquisition. – In DAQ applications you should use hardware timing instead of software timing, if possible. jitter

LabVIEW: Low-speed DAQ Sequential architecture DAQ assistant Express VI used in the block diagram Data written to file using the Write to Measurement File Express VI Necessary ?

LabVIEW: Medium-speed DAQ Example: Cont Acq&Graph Voltage -To File (Binary).vi Sequential (serial) architecture Standard VIs used, and data written to a binary file Create header Create file Write Necessary ? Create analog input channel Set sample rate Start acquisition Read data Close file Stop acquisition

High speed write to disk Write to disk is us usually (much) slower than to acquire the data ! Streaming to disk/memory at high data rates requires: Parallel programming Binary file formats

High-speed DAQ Based on the producer-consumer architecture – Parallel programming architecture using data Queues Hardware timing, since no Wait function is used in the producer loop. The producer loop rate is given by the DAQ-card setup Producer loop 𝑓 𝑝𝑟𝑜𝑑𝑢𝑐𝑒𝑟 Consumer loop 𝑠𝑎𝑚𝑝𝑙𝑒 𝑟𝑎𝑡𝑒 (𝐻𝑧) 𝐷𝐴𝑄 𝑐𝑎𝑟𝑑 𝑏𝑢𝑓𝑓𝑒𝑟 𝑠𝑖𝑧𝑒

Producer – consumer DAQ Example When we have multiple tasks that run at different speeds and cannot afford to be slowed down. Hardware timing; no Wait function is used in the producer loop. The producer loop rate is given by the DAQcard setup: 𝑓 𝑝𝑟𝑜𝑑𝑢𝑐𝑒𝑟 𝑠𝑎𝑚𝑝𝑙𝑒 𝑟𝑎𝑡𝑒 (𝐻𝑧) 𝐷𝐴𝑄 𝑐𝑎𝑟𝑑 𝑏𝑢𝑓𝑓𝑒𝑟 𝑠𝑖𝑧𝑒 From File – New:

Common parallel programming challenges Thread (loop) Synchronization – Data loss (too slow data read vs. data write) – Reading the same data point multiple times Race Conditions – Uncertain result due to shared resources A queue is a FIFO buffer in computer RAM Can be solved using queues and by avoiding global variables!

Transferring Data from DAQ-card to hard drive Acquired data are stored in the hardware's first-in first-out (FIFO) buffer. Data is transferred from the DAQ-card FIFO buffer (of fixed size) to PC RAM using interrupts or DMA, across e.g. the PCI/PCI Express bus and the computer I/O bus. The samples are then transferred from RAM to hard drive via the computer I/O bus. PC DMA controller Data acquisition card Analog signals ADC sclk FIFO buffer MB CPU Hard drive Digital Data bus RAM GB TB

Continuous data acquisition To implement a continuous data acquisition on a non real-time system a PC buffer is needed in addition to the FIFO buffer on the DAQ card The PC buffer is a circular buffer in the computer RAM When we perform a DAQ-read in our application software we read the values out of the circular buffer and into a “variable” in our application program Circular buffer DMA/Interrupt transfer Data acquisition card Data From sensor ADC sclk FIFO buffer RAM (in the PC) Data To PC buffer PC buffer Application memory

LabVIEW DAQ - hardware setup When the sample clock (DAQmx Timing.vi) is configured, DAQmx configures the board for hardwared-timed I/O – DAQ card sample clock or external sample clock By enabling continuous sampling DAQmx automatically sets up a circular buffer in RAM. DMA is the default method of data transfer for DAQ devices that support DMA Circular buffer DMA transfer Data acquisition card Data From sensor ADC sclk FIFO buffer RAM (in the PC) Data To PC buffer PC buffer Application memory

DAQ data overwrite and overflow An overwrite error indicates that information is lost and occurs when the software program does not read data from the PC buffer quickly enough. Samples that are written to the circular PC buffer are overwritten before they are read into the application memory. – Solution: use Producer-Consumer architecture. An overflow error indicate that information has been lost earlier in the data acquisition process. Overflow errors indicate that the First In First Out (FIFO) memory buffer onboard the data acquisition card has reached its maximum capacity for storing acquired samples and can no longer accept new samples. An overflow error is symptomatic of a bus transfer rate that falls short of the requested data input rate. – Solution: use a Direct Memory Access (DMA) transfer mechanism.

Extra How Is Buffer Size Determined in LabVIEW DAQmx ? If the acquisition is continuous (sample mode in DAQmx Timing.vi set to Continuous Samples), NI-DAQmx allocates a PC buffer equal in size to the value of the samples per channel (gives the number of samples to acquire) property, unless that value is less than the value listed in the following table. If the value of the samples per channel property is less than the value in the table below, NIDAQmx uses the value in the table. Sample Rate PC Buffer Size No rate specified 10 kS 0–100 S/s 1 kS 101–10,000 S/s 10 kS 10,001–1,000,000 S/s 100 kS 1,000,000 S/s 1 MS You can override the default buffer size using the function DAQmx Configure Input Buffer.vi

Advanced DAQ with multiple while loops A DAQ program usually have several while loops running in parallel, and data (and messages) should be distributed between the loops using queues Black Blue Red : Messages transfer (using queue) : Data transfer using Queue (NB: queues have memory – no data is lost) : Data transfer using Notifier (NB: notifiers do not have memory/FIFO) Sample project in LabVIEW – queued message handler

Sample projects File – Create project A very god starting point for advanced (parallel and scalable) DAQ programs! See lab 2

How to handle noise in signals?

How to increase the signal-to-noise-ratio Use an amplifier (as close to the sensor as possible, to amplify the signal before the noise enter e.g. the transmission cable. Use an ADC with more bits per sample (The SNR of an ideal N-bit ADC is SNR(dB) 6.02*N 1.76 (for sinusoidal signals). Use oversampling (followed by digital Low pass filtering and down-sampling). Filtering (to remove noise and limit the signal bandwidth), in hardware or software – remember from basic electronics that thermal noise (Johnson noise) in a resistors is proportional to the square root of the signal bandwidth. Averaging of n samples 𝜎𝑎𝑣𝑔 𝜎 1 𝑛 𝑆/𝑁𝑛 𝑆/𝑁 𝑛

How to increase the signal-to-noise-ratio II Position noise sources away from data acquisition device, cable, and sensor. Place data acquisition device as close to sensor as possible to prevent noise from entering the system. Use twisted pairs and shielding, or coax cables. Use differential signals Avoid ground loops. (Lock-in amplifier) Coax cable

Extra Savitzky-Golay smoothing filters Savitzky-Golay filters are optimal in the sense that they minimize the leastsquares error in fitting a polynomial to frames of noisy data. Savitzky-Golay smoothing filters are typically used to "smooth out" a noisy signal whose frequency span (without noise) is large. In this type of application, Savitzky-Golay smoothing filters perform much better than standard averaging filters, which tend to filter out a significant portion of the signal's high frequency content along with the noise. Although Savitzky-Golay filters are more effective at preserving the pertinent high frequency components of the signal, they are less successful than standard averaging filters at rejecting noise. This filter preserve the amplitude of a time-varying signal much better than a sliding-average smoothing.

Which file type to use?

Determining Storage Format When determining the appropriate storage format for the data, consider the following: At what sample rate will you acquire data? How much data will you acquire? Will you need to exchange data with another program? Will you need to search your data files? Examples from LabVIEW Configuration files – – – – – – – – ASCII (text) CSV Binary TDMS INI Spreadsheet AVI XML

ASCII Files Pros – Human-readable – Easily portable to other applications such as Microsoft Excel – Can easily add text information (first line) for each data column Cons – Large file size – Slow read and write

Two different architectures for handling memory storage: Binary Files Pros – Compact file size – Fast streaming Cons – Not human-readable – Less easily exchangeable Need to know the file format to read the data Windows and Linux use Little Endian format. A big-endian machine stores the most significant byte first, at the lowest byte address. A little-endian machine stores the least significant byte first.

Data Types – file size

Unbuffered File I/O Possible to bypass file caching within the Windows operating system. Can use unbuffered file I/O to increase write/read speed. Supported in LabVIEW. Link to Microsoft - File Buffering

LabVIEW Express: DAQ assistant Using the the DAQ assistant is the easy way to configure and read from a DAQ card! DAQ Assistant Express VI to standard VIs. LabVIEW - Sequential DAQ design Configure Acquire data Analyze data Visualize data Save data T1 T2 T3 Loop time: T1 T2 T3.

Related Documents:

A Survey of Model-based Sensor Data Acquisition and Management 13 are surveyed. At the end, Section 6 contains a summary of the chapter along with conclusions. 2. Model-Based Sensor Data Acquisition In this section, we discuss various techniques for model-based 1 sensor data acquisition. Particularly, we discuss pull- and push-based sensor

AA001.003.01 Data Acquisition Didactic Panel (NI USB 6003) AA001.002.01 Data Acquisition Didactic Panel (NI USB 6002) AA001.001.01 Data Acquisition Didactic Panel (NI USB 6001) AA001.000.01 Data Acquisition Didactic Panel (NI USB 6008) 10 11 Data acquisition, processing and Monitoring The didactic panels

Selection Defense Business Systems Middle Tier of Acquisition Acquisition of Services Major Capability Acquisition . Reference Source: DoDI 5000.80, Paragraph 1.2.b The MTA pathway is intended to fill a gap in the Defense Acquisition System (DAS) for those capabilities that have a level of maturity . Acquisition programs intended to be .

Data Acquisition Toolbox Acquire and output data from data acquisition boards Immediately analyze live or acquired data in MATLAB and Simulink Configure hardware without leaving MATLAB Incorporate custom analysis into PC-based digital oscilloscope Ability to do "one-shot" or continuous acquisition Support multiple data acquisition devices .

Data Acquisition in P3700" In data acquisition systems, analog signals are digitized, operated on, and stored in a computer! With LabVIEW and LabVIEW specific DAQ devices this process becomes simple! - In the next lab you will develop your own LabVIEW based data acquisition software for demonstrating propagation of errors!

The right data acquisition system will provide box- to-box synchronization to help precisely correlate all acquired data. The more unified and integrated your system is, the faster and more efficient your data acquisition will be. When you can easily integrate and synchronize multiple devices, it also makes your data acquisition system very .

The data acquisition process can be divided into six parts: Signal processing is often integrated with data acquisition systems. Data cleansing, normalization compression and fusion is integrated in this process as well. Increasingly, the development of system-on-a-chip capability has allowed data acquisition components to be .

data the consumer has after data acquisition (i.e., D D ). The objective of the data acquisition process is to improve as much as possible the accuracy of M′on D . Proposed Solutions. We develop data acquisition strategies to address this problem. In particular, we consider the trade-off