Connecting Digital Input Signals to a DAQ Device

Included in the Section

Before You Begin

This document provides step-by-step instructions for wiring and configuring your NI DAQ device for digital input signals. Before you begin using your NI DAQ hardware, you must install your application development environment and NI-DAQmx driver software. Refer to the Installing LabVIEW and NI-DAQmx document for more information.

Digital Input Measurement Fundamentals

All digital signals have two discrete levels – a high level and a low level. Digital input devices monitor the state of the digital signals and can transition from one digital pulse to another. Digital input lines can be programmed on a line-by-line basis or programmed collectively as a port (typically four or eight lines). A counter device can also monitor the state as well as detect rising edges, a transition from logic low to logic high, and falling edges, a transition from logic high to logic low.

The three main types of digital input signals correspond to different digital logic families: TTL, sinking, and sourcing. Your signal connections vary based on your signal source and your DAQ device.

TTL Digital Inputs

A transistor-transistor logic (TTL) compatible signal has the following characteristics:

  • 0 V to 0.8 V = logic low
  • 2 V to 5 V = logic high

Many NI DAQ devices feature TTL digital I/O lines. The number of digital lines varies from device to device, but all are bidirectional and all support the same logic levels. You can configure a line or a port as an input or output in software. Most devices also feature pull-up or pull-down (or both) resistors on digital I/O lines to control the state of the lines when no signals are connected. Digital input applications include receiving TTL signals and sensing external device states, such as the state of the switch shown in the figure. Digital output applications include sending TTL signals and driving external devices, such as the LED shown in the figure.

Figure 1. TTL Digital I/O Connections

Sinking Digital Inputs

A sinking digital input means that when an external device drives current or applies voltage to the digital input terminal or pin (DI), the digital input provides a path to the device ground reference for the current or voltage. A sinking input cannot provide power to an external device. Common terms for a sinking device include NPN, Open Collector, Normally High, and IEC Negative Logic.

You can connect 2-, 3-, and 4-wire sourcing-output devices to a sinking input. A sourcing-output device drives current or applies voltage to the digital input. An example of a sourcing-output device is an open collector PNP.

Connect the output of the sourcing-output device to a sinking digital input. Connect the common of the external device to the COM/DGND terminal or pin.

Figure 2. Connecting a Sourcing-Output Device to a Sinking Digital Input (3-Wire Device Shown)

The digital input channel registers as ON when the sourcing-output device applies a voltage or drives a current that is in the input ON range. The channel registers as OFF when the device applies a voltage or drives a current that is in the input OFF range. If no device is connected to the input terminal, the channel registers as OFF. Refer to your device specifications section for ON and OFF state ranges.

Sourcing Digital Inputs

A sourcing digital input means that the digital input (DI) terminal sources current from Vsup to a sinking output device. A sourcing digital input therefore provides power to an external device. Common terms for referring to a sourcing device include PNP, Open Emitter, Normally Low, and IEC Positive Logic.

You can connect 2-, 3-, and 4-wire sinking-output devices to the NI 9426 C Series sourcing digital input module. A sinking-output device provides a path from the DI pin to a voltage below Vsup. An example of a sinking-output device is an open collector NPN.

Connect the sinking-output device to the DI pin of the digital input channel. Connect the positive power supply lead of the external device to the Vsup pin. Refer to Figure 2 for an illustration of connecting a sinking-output device to a sourcing-digital input.

Figure 3. Connecting a Sinking-Output Device to a Sourcing-Digital Input (3-Wire Device Shown)

The digital input channel registers as ON when the sinking-output device drives the input below Vsup and meets the input ON range. The channel registers as OFF when the device does not drive the input low and is in the input OFF range. If no device is connected to the DI terminal, the channel registers as OFF. Refer to your device specifications section for ON and OFF state ranges.

Locating Your DAQ Device Pinout

Before connecting any signals, locate your device pinout.

  1. Open Measurement & Automation Explorer (MAX) and expand Devices and Interfaces.
  2. Right-click on your device name, and select Device Pinouts.

Figure 4. Device Terminals Help

The following terminal types correspond with digital input measurements:

  • DI x: Digital Input — This is usually followed by a number corresponding to a channel number. For instance, if your DAQ device has 8 digital input channels, your pinout diagram shows terminals for DI 0 through DI 7 located throughout the connector.
  • PFI: Programmable Function Input — This terminal can be configured through software to be a digital input or digital output channel.
  • Px.y: Port X Line Y— This is the same as a digital input terminal (DI) specified as a line in a port for convenience.
  • D GND: Digital Ground— This terminal is the ground reference for DI channels. On some multifunction DAQ devices D GND may be electrically connected with AI GND and AO GND.
  • COM: Common — Common ground terminal for all DI channels. This ground may or may not be isolated from earth ground, depending on your device.

Configuring a Digital Input

You can use MAX to quickly verify the accuracy of your measurement system Set Up. Using an NI-DAQmx Global Virtual Channel you can configure a digital input measurement without any programming. A virtual channel is a concept of the NI-DAQmx driver architecture used to represent a collection of device property settings that can include a name, a physical channel, input terminal connections, the type of measurement or generation, and scaling information.

Follow these steps to begin:

  1. With NI MAX open, select Data Neighborhood and click Create New.
  2. Select NI-DAQmx Global Virtual Channel and click Next.
  3. Select Acquire Signals » Digital Input » Line Input

Figure 5. Creating an NI-DAQmx Virtual Channel

  1. Select line0 or whichever physical channel you intend to use to connect your digital input. A physical channel is a terminal or pin at which you can measure or generate an analog or digital signal.

Figure 6. Device Physical Channels

  1. Click Next and enter a name for the global virtual channel or leave the default.
  2. Click Finish and you should see the following screen in MAX:

Figure 7. Setting Up a Digital Input Channel in MAX

  1. On the Settings tab, click the Invert Line if you want to reverse the polarity of the line.

Wiring a Digital Signal to Your Device

The next step is to physically connect the digital signal to your digital input device. Your digital signal should match your input configuration. Connect a TTL signal to a bidirectional TTL input terminal (Figure 1). Connect a sourcing digital output device to a sinking digital input terminal (Figure 2). Connect a sinking digital output device to a sourcing digital input terminal (Figure 3).

Testing the Signal

Use NI-DAQmx global virtual channels to preview your measurements.

  1. With MAX still open, click back on the NI-DAQmx Global Channel tab and click on the Run button to see the digital value of your measurement displayed at the top of the screen.

Figure 8. Previewing a Digital Input Measurement in MAX

You also have the option of saving your NI-DAQmx Global Virtual Channel should you wish to refer to this configuration screen again in the future.

Prev Connect and Set Up Hardware
Introduction to LabVIEW Next