The University of Manchester · FACULTY OF ENGINEERING

AERO61021 Chap.10 Acquiring and Saving Data with DAQmx

- one subject, every graph, every model, every mark
7 Chapters5-page Bible
Our own words - no uploaded lecturer files
Updated for this semester
Chapter 10 of 10 · AERO61021

Acquiring and Saving Data with DAQmx

Acquiring and Saving Data with DAQmx follows a voltage from a sensor on a breadboard into a LabVIEW array and out to a file, which is the core task of the hands-on lab and of the later group project. The hardware is the NI mioDAQ, a USB-C multifunction device with analog inputs and outputs, digital lines and counter timers.

DAQmx is the function library that links code to it, and a working acquisition VI needs only a few functions chained by task and error wires: create the virtual channel, set the timing, read inside a While Loop, then close the link.

The chapter explains the settings that most often catch students out, including the default differential terminal mode, the default input range of minus 5 V to 5 V, the sample rate and samples per channel that decide how long each block takes, and the polymorphic Read function that returns 1D or 2D arrays.

It then wires a potentiometer as a single-ended and a differential signal, applies a linear calibration coefficient to turn volts into angle, compares charts with graphs, and sets up Write Delimited Spreadsheet correctly, while weighing CSV text files against TDMS for larger runs.

In this chapter

What this chapter covers

  • 01

    The mioDAQ multifunction device and the DAQmx library

  • 02

    Create Virtual Channel, timing, read and closing the task

  • 03

    Terminal modes: differential, RSE, NRSE and pseudodifferential

  • 04

    Sample rate, samples per channel and block duration

  • 05

    Single-ended and differential potentiometer wiring

  • 06

    Linear calibration coefficients and their units

  • 07

    Charts, graphs, CSV files and TDMS files

Worked example · free

Plan channel pairing and read timing

Q [6 marks]. A differential sensor signal is wired to the positive input AI2 of the mioDAQ. Three channels are then sampled at 2,000 samples per second each, with DAQmx Read set to 500 samples per channel, for a 45 s run. Identify the negative input paired with AI2, the time per read block, the number of reads and the total number of values acquired. The mark allocation below is an AskSia practice aid, not a published University scheme.
Purple task wires carry the channel definition from Create Channel through Timing into DAQmx Read inside the While Loop, whose data feed a graph and a file writPurple task wires carry the channel definition from Create Channel through Timing into DAQmx Read inside the While Loop, whose data feed a graph and a file writer before the task is closed; notice that only Read repeats. While Loop Create Channel Timing DAQmx Read Graph Write file Close task ai0, RSE rate, samples
Purple task wires carry the channel definition from Create Channel through Timing into DAQmx Read inside the While Loop, whose data feed a graph and a file writer before the task is closed; notice that only Read repeats.
  • 2In differential use channels 0 to 7 are positive inputs paired with 8 to 15, so AI2 pairs with AI10 as its negative input.
  • 2Each block takes 500 samples / 2,000 samples per second = 0.25 s, so a 45 s run needs 45 / 0.25 = 180 reads.
  • 2Each channel collects 2,000 x 45 = 90,000 samples, so three channels give 270,000 values in total.
AI10 is the negative partner of AI2; each read covers 0.25 s, the run needs 180 reads, and 270,000 values are acquired. This weighting is our own practice allocation, not an official University scheme.
Sia tip — Write block time as samples per channel divided by sample rate before you run; if it is several seconds, the front panel will look frozen even though the VI is working.
Glossary

Key terms

Multifunction device
Acquisition hardware combining analog input, analog output, digital input and output and counter timers.
Physical channel
The named hardware input or output, such as ai0 on Dev0, that a DAQmx task uses.
Referenced single-ended
A terminal mode in which one signal wire is measured against the device ground.
Calibration coefficient
The multiplier that converts a measured voltage into the physical quantity of interest.
TDMS file
A National Instruments binary file format that can hold many runs of an experiment in one file.
FAQ

Acquiring and Saving Data with DAQmx FAQ

Why does my potentiometer voltage drift when I am not touching it?

The DAQmx channel defaults to a differential connection, which expects a positive and a negative wire. With only the signal wire connected, the negative input is left floating and the value wanders. Change the terminal configuration to RSE so the internal earth acts as the negative; the handout shows that the reading then holds steady and can reach both 0 V and 5 V.

How do the sample rate and samples per channel affect what I see?

The Read function waits until it has the number of samples you asked for, so block duration equals samples per channel divided by the sample rate. At the default 1000 samples at 1000 samples per second, the display updates once a second. The lab therefore starts with very small blocks at a low rate so values appear almost live, then raises both.

Should I save experiment data as CSV or TDMS?

CSV text files are fine for small sets of a few thousand points and open anywhere, but they become slow with large files and each run needs its own file. TDMS stores a whole experiment with several runs in a single binary file and opens in Excel once the NI add-in is installed. For long, multi-channel or repeated runs, TDMS is the format the notes prefer.

Can I practise DAQmx code without the mioDAQ hardware?

Yes. NI-MAX, the configuration tool installed with LabVIEW, can create a simulated device so a VI with DAQmx functions can be run and debugged away from the lab, although not every device has a simulated version. For general LabVIEW practice you can also generate varying values with front-panel controls or a random number generator and plot or save them.

Study strategy

Assessment move

Prepare for acquisition work by separating three skills: wiring, configuring and recording. For wiring, sketch the potentiometer circuit on paper before each session, marking the 5 V pin, the 0 V pin and the wiper, and note which mioDAQ terminal each wire reaches. Then redraw it as a differential connection, adding the second wire to the negative input paired with your signal channel.

Being able to name the paired channel for any positive input from the numbering rule saves time at the bench. For configuring, build the minimal VI repeatedly until you can do it without notes: Create Virtual Channel with the physical channel selected, the Timing function with a rate and number of samples, Read inside a While Loop, a Stop button on the conditional terminal, and the closing function after the loop.

Open context help on each function and create constants for the unconnected terminals so you learn every default, especially the differential terminal mode and the minus 5 V to 5 V range. Practise predicting block duration and data volume before pressing Run, and practise switching Read between single-sample and multiple-sample forms while fixing the broken indicator that results.

For recording, add a calibration Multiply and state the coefficient units in a comment, then add Write Delimited Spreadsheet with append, transpose and delimiter set deliberately. Open the saved file and check whether the values landed in rows or columns, and whether a second run appended or overwrote.

Keep the raw voltages alongside any calibrated values, because the lectures warn that undoing a wrong calibration later is very difficult. Use NI-MAX simulated devices and front-panel controls to rehearse at home, since most departmental computers and your own installation can run LabVIEW without the hardware.

Finally, link the lab to the group project: list the sensors your project needs, their output ranges and the sample rates they demand, and decide in advance whether each signal is single-ended or differential and which file format will hold the results.

A+Everything unlocked
Unlocks this Bible + all 41 of your subjects at The University of Manchester, plus 1,000+ more Bibles across the AskSia library.
Sia - your AERO61021 tutor, unlimited, worked the way the exam marks it
The full 5-page Bible + practice bank with worked solutions
Chrome extension - sync your LMS so Sia knows your deadlines
Bilingual EN / Chinese on every Bible and every Sia answer
$0.99 Trial
30-day money-back · cancel in one tap · how it works