NI-DAQmx
National Instruments data acquisition hardware (cDAQ chassis and modules, USB and PCI Express devices, and the simulated devices of NI MAX) read one sample per poll through the NI-DAQmx installed on this computer: the NI-DAQmx device card, a tag's physical channel and measurement, reading and writing, discovery, and a worked example on a cDAQ chassis.
The NI-DAQmx driver reads and writes National Instruments data acquisition hardware: cDAQ
chassis and their C Series modules, USB devices such as the USB-6001 or the USB-6211, and PCI Express
devices, through NI-DAQmx, the driver National Instruments gives away for its hardware. It is the
hardware a LabVIEW program reads with the DAQmx blocks, set up on a panel instead of wired in a block
diagram: each tag is one physical channel, as NI MAX names it (ai0, port0/line3, ao0, ctr0),
with what the channel measures or drives, and its values land where every other tag's do: in Logic,
on dashboards, in the runs of a Process test bench.
The driver reads one sample per poll: at each tag's poll interval it takes one value of the channel, as every other driver does. It serves slow signals (temperatures, pressures, levels, states, counts), not the continuous acquisition the hardware does on its own clock; see Limits worth knowing.
A device of this driver is one device of NI MAX, found by the name NI MAX gives it, wherever it is attached: on USB, in a PCI Express slot, in a cDAQ chassis on USB or Ethernet. The simulated devices NI MAX creates for free, of most NI hardware, are read like real ones, so a configuration can be built and tried before the hardware arrives. Simulated devices can also be created through NI's configuration API, which an AI assistant with access to this computer can use once you agree. The devices sit under the driver and may be filed in folders, Driver → Folder → Device → Tag, as under any driver without a serial line or a broker.
NI-DAQmx on this computer
The product does not include NI-DAQmx and installs none of its files. The driver reads the hardware through the NI-DAQmx installed on this computer, the one NI MAX and LabVIEW use. The station checks by itself whether it is there: the first time the driver's page, the page of one of its devices or the agent asks, and again every 30 seconds while it is missing. Until the Connector has started, whether NI-DAQmx is there is not known, and nothing is said about it. While it is missing:
| Where | What happens |
|---|---|
| The driver's page | A caution notice, "NI-DAQmx is not installed on this computer", with the steps below. Its link opens NI's page in the computer's browser. |
| The page of each device | The same notice. |
| The devices | Can be added and configured, tags included; they stay offline, and the last error of each gives the same steps, in English, as the driver's own causes are written. |
| Discover | Lists nothing, and says that NI-DAQmx is not installed and that the notice on the driver's page gives the download and the installation steps. |
| The agent | driver_capabilities gives the steps under prerequisite, with installed false. |
To install it:
- Open NI's page NI-DAQ™mx Download. It asks you to sign in with an NI account before the download.
- In its Version list, take the newest version whose readme (View Readme) lists this computer's Windows and, under Device Support, your device. NI-DAQmx runs only on 64-bit Windows.
- Run the installer as administrator: it installs NI-DAQmx through NI Package Manager. Restart the computer if the installer asks.
The newest NI-DAQmx no longer supports some older devices: if its readme does not list yours, choose an earlier version in the Version list, one whose readme lists it.
Within 30 seconds of the installation the notice goes away and the devices of this driver connect with the configuration they have, without restarting Ganter Lab. NI MAX (NI Measurement & Automation Explorer) shows each device with the name to enter in the NI-DAQmx device card.
The driver's page
The page holds the Devices table of any driver (see The device table), grown by Add device at the right of its title; empty, it reads "No devices yet." The driver's bar carries Discover, and the page has no Scan scope card, because the scan asks NI-DAQmx and nothing else.
Device
The NI-DAQmx device card
A device of this driver has no Connection card: there is no host, port or route to write, since NI-DAQmx finds the device by its name. In its place, the NI-DAQmx device card says which device of NI MAX it reads.
| Field | Meaning | Default |
|---|---|---|
| Device name | "The name NI MAX gives the device, such as Dev1, or cDAQ1Mod1 for a module of a cDAQ chassis. A device renamed in NI MAX is read again once its new name is written here." | empty |
| Product | Read only: "What NI-DAQmx says the device is, such as NI 9211, read each time the station connects to it." It reads "Not read yet" until the device connects, and again once it is no longer connected. Nothing of it is stored. |
A cDAQ chassis is a device of NI MAX of its own (cDAQ1), and so is each of its modules
(cDAQ1Mod1, cDAQ1Mod2). A module's channels are read on the module's device; the counters of the
chassis (_ctr0 to _ctr3) are read on the chassis's device. The Poll interval (ms) of the
Device card works as on any driver, and each tag may override it.
A new device has no name yet, and the station does not try to reach it until it has one: its row reads "NI-DAQmx device not entered yet", its tags read as gaps, and its page carries the notice "The station does not try to reach this device until it has the name of an NI-DAQmx device, so nothing is read from it yet and there is no error to show. Enter the name NI MAX gives the device in the NI-DAQmx device card below and the station connects to it." On a computer without NI-DAQmx, the notice that NI-DAQmx is not installed stands there instead.
A name NI-DAQmx could never read is refused under the box: "A device name has no '/', ',' or ':'. Write the name exactly as NI MAX shows it, such as Dev1 or cDAQ1Mod1."
A slash is what separates a device from its channel, so Dev1/ai0 is a tag's channel and not a
device. Whether NI MAX knows the name is NI-DAQmx's own answer, given when the station connects: a
device NI MAX does not know stays offline with NI-DAQmx's words as its last error.
The Base URI the header shows is the device's name behind the driver's scheme: nidaqmx://cDAQ1Mod1.
Two devices of this driver may read the same device of NI MAX, for example the same module at two
different poll intervals; the name is not required to be unique.
Tag addressing
The physical channel
A tag of this driver reads or drives one channel of its device. The tag's Source card holds the Physical channel box, with a hint under it that follows the measurement: "Analog input channel, e.g. ai0 or cDAQ1Mod1/ai0", "Digital line, e.g. port0/line3 or Dev1/port0/line3", "Analog output channel, e.g. ao0 or Dev1/ao0" or "Counter, e.g. ctr0, or _ctr0 on a cDAQ chassis".
The channel is stored relative to its device (ai0), so a device renamed in NI MAX changes one
field, the device's. A channel written whole as NI MAX writes it (cDAQ1Mod1/ai0) is stored relative
when it names the tag's own device, and refused when it names another:
"This channel belongs to device Dev1, not to cDAQ1Mod1. Write a channel of this device, or the channel alone, such as ai0."
Measurements
Under the channel, Measurement says what the channel measures or drives. The measurement decides the data types the tag is read as, the access it allows, its unit and the fields drawn under it.
| Measurement | Channel | Data type | Access | Unit |
|---|---|---|---|---|
| Voltage input | an analog input, ai0 |
Double or Float | Read only | volts |
| Current input | an analog input, ai0 |
Double or Float | Read only | milliamperes |
| Thermocouple | an analog input, ai0 |
Double or Float | Read only | degrees Celsius |
| Digital input line | a digital line, port0/line3 |
Boolean | Read only | |
| Digital output line | a digital line, port0/line3 |
Boolean | Read and write (the default), Write only or Read only | |
| Voltage output | an analog output, ao0 |
Double or Float | Write only | volts |
| Edge count | a counter, ctr0 (_ctr0 on a cDAQ chassis) |
Int64 or Double | Read only | counts |
A new tag is a voltage input, read as a Double. A channel typed that the measurement in force does not read brings the measurement it reads most naturally: an analog input a voltage input, a digital line a digital input line, an analog output a voltage output and a counter an edge count. Picking another measurement brings that measurement's range, and a data type or an access it does not allow becomes the one it takes, so the Data type and Access lists offer only what the measurement allows. Current is read in milliamperes (NI-DAQmx reads amperes and the driver multiplies by 1000), so a 4 to 20 mA loop is written as it is said.
Each measurement says under its picker what it does:
| Measurement | The line under it |
|---|---|
| Voltage input | "Reads one sample in volts at each poll." |
| Current input | "Reads one sample in milliamperes at each poll." |
| Thermocouple | "Reads one sample in degrees Celsius at each poll, with the cold junction compensated." |
| Digital input line | "Reads the line as true (high) or false (low)." |
| Digital output line | "Drives the line with the value written and reads back the state it holds." |
| Voltage output | "Drives the output with the voltage written. NI-DAQmx does not read an analog output back, so the tag is write only." |
| Edge count | "Counts edges from the moment the station connects to the device and reads the count at each poll. A reconnection starts again from the initial count." |
The measurement's fields
A field the measurement does not read is not drawn, and is not saved with the tag.
| Field | Measurements | Meaning | Default |
|---|---|---|---|
| Range (V), Range (mA) or Range (°C) | Voltage input, Current input, Thermocouple, Voltage output | Two boxes, Minimum and Maximum, in the measurement's unit. On an input: "NI-DAQmx picks the device's input range that holds this one, so a narrow range reads a small signal more finely." On the voltage output: "The output takes only values inside this range; a write outside it is refused before it reaches the device." | -10 to 10 V; 0 to 20 mA; 0 to 100 °C |
| Terminal configuration | Voltage input, Current input | Channel default, Differential, Referenced single-ended (RSE), Non-referenced single-ended (NRSE) or Pseudodifferential: "How the input is wired: a differential input measures between two terminals of the channel, a single-ended one against a common reference. The channel default is what NI-DAQmx picks for this channel." | Channel default |
| Shunt resistor | Current input | Channel default, Internal or External: "The resistor the current crosses to be measured: the one built into the device, or an external one wired across the input, with its resistance written here." | Channel default |
| Shunt resistance (Ω) | Current input, with an External shunt | The external resistor's resistance, in ohms. | 249 |
| Thermocouple type | Thermocouple | Type J, Type K, Type N, Type R, Type S, Type T, Type B or Type E. | Type K |
| Cold-junction compensation (CJC) | Thermocouple | Built-in sensor or Fixed temperature: "The temperature of the thermocouple's cold junction: measured by the sensor built into the device or its terminal block, or a fixed temperature written here when the junction is held at a known one." | Built-in sensor |
| CJC temperature (°C) | Thermocouple, with a Fixed temperature | The cold junction's temperature, in degrees Celsius. | 25 |
| Edge counted | Edge count | Rising or Falling. | Rising |
| Count direction | Edge count | Count up or Count down. | Count up |
| Initial count | Edge count | The count the counter starts from each time the device connects, 0 to 4294967295. | 0 |
| Input terminal | Edge count | "The terminal whose pulses are counted, such as /Dev1/PFI8. Left empty, the counter counts on its own default input terminal." Empty, the box reads "Counter default". A terminal written without its device (PFI8) is read on the tag's own device. On a counter of a cDAQ chassis (_ctr0), which has no input terminal of its own, the box names no default and the note reads "The terminal whose pulses are counted, such as /cDAQ1Mod2/PFI0. A counter of a cDAQ chassis has no input terminal of its own, so this one is required." |
empty |
A tag whose fields cannot work is not saved, and the tag's page says what it lacks:
| You enter | The tag's page says |
|---|---|
| No channel | "Write the physical channel, such as ai0 or Dev1/ai0." |
A channel of another kind than the measurement reads, such as ao0 under a thermocouple |
"This measurement reads an analog input channel, such as ai0.", "A voltage output drives an analog output channel, such as ao0.", "A digital line is written as its port and line, such as port0/line3." or "An edge count reads a counter, such as ctr0." |
| A minimum that is not below the maximum | "The minimum has to be below the maximum." |
| An external shunt without a resistance above zero | "An external shunt needs its resistance in ohms, above zero." |
| A fixed cold-junction temperature at or below absolute zero | "The CJC temperature has to be a temperature in degrees Celsius above absolute zero." |
| An initial count outside what a 32-bit counter holds | "The initial count is a whole number from 0 to 4294967295." |
| An input terminal with a space or a comma | "Write the input terminal as NI-DAQmx names it, such as /Dev1/PFI8, with no space or comma." |
An edge count on a counter of a cDAQ chassis (_ctr0) with no input terminal |
"A counter of a cDAQ chassis has no input terminal of its own: write the terminal its pulses arrive on, such as /cDAQ1Mod2/PFI0." |
| A data type or an access the measurement does not allow | "This measurement is read as Double, Float.", and for an access, the sentence that names the accesses the measurement allows |
The save holds the same rules as the panels, and the feed says so when it refuses one: "Device 'Module voltages' names an NI-DAQmx device the driver cannot read. Open it and correct the device name its panel marks." or "Tag 'Pressure' has a setting the NI-DAQmx driver cannot use. Open it and correct the field the tag panel marks."
The read-only Source address (wire) line shows what the driver receives: the channel as NI-DAQmx
names it and every setting of the measurement, such as
cDAQ1Mod1/ai0?measurement=voltageInput&terminal=diff&min=0&max=10,
cDAQ1Mod2/ai0?measurement=thermocouple&type=K&cjc=builtIn&min=0&max=400,
Dev1/port0/line3?measurement=digitalOutput or
cDAQ1/_ctr0?measurement=edgeCount&edge=rising&direction=up&initial=0&input=%2FcDAQ1Mod3%2FPFI0.
Reading
The driver creates the NI-DAQmx tasks of a device when the station connects to it, and keeps them until it disconnects. What a read does, and what NI-DAQmx answers, decide what the tag shows (see The value pipeline):
| Tags | How they are read |
|---|---|
| Analog inputs (voltage, current, thermocouple) | All of a device's analog inputs share one task, which each read starts, takes one sample per channel from and stops. A device has one analog timing engine, and a cDAQ chassis three for all its modules, so a task kept started would stop another module from reading. A read that finds the engine held by another task (NI MAX, LabVIEW) asks again twice, 25 ms apart. One sample serves every analog tag of the device for half the shortest poll interval among them, so a slow thermocouple module converts once per pass. |
| A channel NI-DAQmx refuses | Each analog channel is tried alone first: a channel NI-DAQmx refuses (a range the module does not have, a thermocouple on a channel that reads none) fails its own tag, not every analog tag of the device. |
| Digital lines, the voltage output, counters | One task per tag, started when the device connects. A counter counts from then on, starting again from its initial count when the device reconnects. |
| NI-DAQmx answers | What the read does |
|---|---|
| A value, or a warning | The value, in the measurement's unit, before the tag's own stages convert it. |
| The device removed, unreachable or reset | A lost connection: the device reconnects and its tasks are created again. |
| No answer within 10 seconds | Silence: the device reconnects, and the tag's policy for a device that did not answer decides what it shows. |
| Any other error | That tag's failed read, named with NI-DAQmx's own text and its code; the device goes on reading its other tags. |
The scaling is the tag's own pipeline: the driver hands over volts, milliamperes or degrees, and the Scale and Calibration stages turn them into the engineering value (0 to 10 V into 0 to 16 bar). No custom scale of NI MAX is created or read.
Writing
A Digital output line and a Voltage output are written; every other measurement is read only. A write goes through the same funnel as any other driver's: the write box takes the engineering value, and the conversion stages are reversed before the raw value is sent (see Connector).
| Measurement | What a write does |
|---|---|
| Digital output line | Drives the line high for true and low for false. The tag reads back the state the line holds, unless it is Write only. |
| Voltage output | Drives the output with the voltage written. A value outside the tag's range is refused before anything reaches the device. NI-DAQmx does not read an analog output back, so the tag is Write only and shows no value of its own. |
A value NI-DAQmx refuses comes back as "Write refused by the equipment: <reason>.", with NI-DAQmx's
own words (in another language, NI-DAQmx's error number, NI-DAQmx -200561, which reads the same in
every language, the words going to the journal); no answer within 10 seconds reads "Write not confirmed: the equipment did not answer in time."
A write waits for the read in progress on the same device.
Discovery
Discover on the driver's bar asks NI-DAQmx for every device NI MAX knows, simulated devices included, and nothing is sent to the hardware. It takes no address. While it runs the progress line names the device it is reading: "Reading cDAQ1Mod1 from NI-DAQmx…". Without NI-DAQmx it lists nothing and says "NI-DAQmx is not installed on this computer, so no device can be listed. The notice on this driver's panel gives the download and the installation steps."
Each device is a candidate named by its name and its product (cDAQ1Mod1 (NI 9205)), with its
channels as candidate tags, each at its measurement's defaults:
| Channels | Offered as |
|---|---|
| Analog inputs | Thermocouple on a thermocouple module, a device that reads millivolts only and says it reads a thermocouple (an NI 9211): type K, the Built-in sensor and 0 to 100 °C. Otherwise Voltage input where the channel reads a voltage, on -10 to 10 V or on the device's own range where it is narrower, and Current input or Thermocouple where NI-DAQmx says the channel reads no voltage. A universal module, which reads a real voltage as well as a thermocouple, offers voltage inputs: pick the measurement on the tag once it is added. |
| Digital lines | Digital input line, or Digital output line where the line only drives. |
| Analog outputs | Voltage output, Write only. |
| Counters | Edge count. NI-DAQmx does not list the counters of a cDAQ chassis, so the chassis comes without tags: add a tag on _ctr0 by hand, with the Input terminal where the pulses arrive, since a chassis counter has none of its own. |
A candidate whose name a device of the driver already reads is marked as already configured and offers Open instead of Add. The rest of the scan's behaviour is on Discovery.
A device you already have reads its channels again from its own page: Discover tags, on the head of its Tags card, asks NI-DAQmx for that device alone and offers only the channels it has no tag for yet, at their measurement's defaults (see Discovering a device's tags).
Example: a cDAQ chassis
A cDAQ-9178 chassis, which NI MAX names cDAQ1, holds an NI 9205 voltage module in slot 1, with a
0 to 10 V pressure transmitter wired differentially on its first channel, and an NI 9211
thermocouple module in slot 2, with a type K thermocouple in an oven. Read both:
- On the driver's page, Add device; name it
Module voltagesand writecDAQ1Mod1in Device name. Once connected, Product reads NI 9205. - Add tag; name it
Pressure, Physical channelai0, keep Voltage input, set the range to 0 and 10 and the Terminal configuration to Differential. On the Conversion card, turn on the Scale stage with a factor of 1.6, and give the tag the unit bar: 0 to 10 V reads 0 to 16 bar. - Add device again; name it
Oven thermocouples, Device namecDAQ1Mod2. - Add tag
Zone1, Physical channelai0, Measurement Thermocouple, keep Type K and Built-in sensor, and set the range to 0 and 400. - To count pulses on the chassis, a device whose Device name is
cDAQ1holds the counters: a tag on_ctr0is an Edge count, with the Input terminal where the pulses arrive, such as/cDAQ1Mod3/PFI0.
The Pressure tag's wire address reads
cDAQ1Mod1/ai0?measurement=voltageInput&terminal=diff&min=0&max=10. An agent does the same with the
tools; the thermocouple names its measurement, because ai0 alone is read as a voltage input:
device_upsert name="Module voltages" driver="NiDaqmx" daqmxDevice="cDAQ1Mod1"
tag_upsert device="Module voltages" name="Pressure" address="ai0" daqmxMinimum=0 daqmxMaximum=10 daqmxTerminal="Differential"
device_upsert name="Oven thermocouples" driver="NiDaqmx" daqmxDevice="cDAQ1Mod2"
tag_upsert device="Oven thermocouples" name="Zone1" address="ai0" daqmxMeasurement="Thermocouple" daqmxThermocouple="K" daqmxMaximum=400
device_upsert name="Chassis counters" driver="NiDaqmx" daqmxDevice="cDAQ1"
tag_upsert device="Chassis counters" name="Pulses" address="_ctr0" daqmxCounterTerminal="/cDAQ1Mod3/PFI0"
Agent tools
driver_capabilities describes this driver under niDaqmx: the device name, and for
each measurement an example channel, the unit, its fields, the data types and accesses it allows, with
the choice lists of every field, how reads and writes behave and what discovery offers.
device_upsert driver=NiDaqmx takes daqmxDevice, the name NI MAX gives the device ('' clears it,
and the device waits for one). tag_upsert takes the channel as address and the fields of its
measurement: daqmxMeasurement (VoltageInput, CurrentInput, Thermocouple, DigitalInput,
DigitalOutput, VoltageOutput or EdgeCount; omitted, the channel brings its own), daqmxMinimum
and daqmxMaximum, daqmxTerminal (Default, Differential, ReferencedSingleEnded,
NonReferencedSingleEnded or PseudoDifferential), daqmxShunt (Default, Internal or
External) and daqmxShuntOhms, daqmxThermocouple (J, K, N, R, S, T, B or E),
daqmxCjcSource (BuiltIn or ConstantValue) and daqmxCjcTemperature, daqmxEdge (Rising or
Falling), daqmxCountDirection (Up or Down), daqmxInitialCount and daqmxCounterTerminal. A
field the measurement does not read is refused, so the call names only what applies. A device and a
tag the tools return carry niDaqmx: the device's name, its product once connected and whether
NI-DAQmx is installed. device_discover driver=NiDaqmx lists every device NI MAX knows with its
channels as candidate tags. The other tools are on Agent tools.
Limits worth knowing
- Continuous acquisition is not done. The hardware can sample on its own clock, thousands of points a second into a buffer; this driver reads one sample per poll, so it serves slow signals, and a waveform or a vibration is not read.
- The product does not include NI-DAQmx: without it on this computer the devices stay offline, and the driver's page says how to install it (NI-DAQmx on this computer). The station takes it up with no restart.
- The cold junction of a thermocouple comes from the module's built-in sensor or a fixed temperature; a cold junction read from another channel is not offered.
- An analog output is not read back: a voltage output tag is Write only.
- A task, a global channel or a custom scale saved in NI MAX is not used: each tag names a physical channel, the driver builds its own tasks, and the scaling is the tag's pipeline.