Você está na página 1de 17

TOPICS

Lesson 8
Digital I/O
A. Digital I/O Overview
ni.com/training
A. Digital I/O Overview
B. DAQmx Read and Write for Digital I/O
C. Triggering
Digital Signals
Digital lines on a DAQ device accept and generate TTL
compatible signals
+5.0 V
high
ni.com/training
+0.8 V
0 V
low
+2.0 V
high
indeterminate
Definition of a TTL Signal
Digital Terminology
Bit The smallest unit of data. Each bit is either a 1 or a 0
Byte A binary number consisting of 8 related bits of data
Line One individual signal in a port. Bit refers to the data
transferred. Line refers to the hardware
ni.com/training
transferred. Line refers to the hardware
Port A collection of digital lines (usually four or eight)
Port Width Number of lines per port (usually four or eight)
Mask Determines which lines are read from or written to
NI-DAQmx Digital Terminology
Port Notation (specifying a single port)
Dev x / Port y
cDAQ a Mod b / Port c
ni.com/training
Line Notation (specifying single or multiple lines)
Dev x / Port y / Line a
cDAQ a Mod b / Port c / Line m : n
Dev x / Port y / Line a, Dev x / Port y / Line b
Digital Virtual Channel Options
Create a digital channel to
be a port, line or collection
of lines
ni.com/training
Choose to create one
channel for all lines
specified in the channel, or
one channel for each line
specified
Digital Channel Data Formats
Line Formats (Boolean)
One line per channel
Represented by a single Boolean value
Multiple lines per channel
ni.com/training
Represented by a 1D array of Booleans with each element
corresponding to a line in the channel in the order in which they
are specified
Line formats are only provided for single sample read and
writes (multiple samples must use integers)
Digital Channel Data Formats (cont)
Port Format (Integer)
A port organizes individual lines into collection
Represented by a U8 or U32 integer where each line
requires one bit
ni.com/training
requires one bit
Most efficient in terms of space
Waveform Format
Couples channel and timing information to data
Not used for static digital I/O
DAQmx Read VI Digital
Line data types are
only available for
single sample read
and writes
ni.com/training
Reading and writing multiple samples for static I/O is not very practical Use
handshaking or clocked operations instead
Read Single Sample, Single Line Channel
Using line format with Read.vi, a single Boolean returned from
reading one sample from a channel with one line
ni.com/training
OR
DAQmx Write VI Digital
Auto Start TRUE for Single Sample
Line data types
are only available
for single sample
read and writes
ni.com/training
Auto Start FALSE for Multiple Samples
Write Single Sample, Single Line Channel
By default, auto start is true
OR
ni.com/training
OR
Exercise 8-1: Digital Read
ni.com/training
G
O
A
L
To input digital data from a digital trigger line and display
the state in LabVIEW
Exercise 8-2: Digital Write
ni.com/training
G
O
A
L
To output digital data and display updates on the DAQ
Signal Accessory
Correlated Digital I/O
Correlated Digital I/O is digital input or output that is correlated
to a clock signal
Subject to same rules as buffered analog input and output
Not all devices support correlated digital I/O
ni.com/training
Not all devices support correlated digital I/O
CompactDAQ only supports correlated DIO in Slots 1-4
Multifunction boards and CompactDAQ have no digital
timing circuitry
Must import clock from another source
Correlated Digital I/O
Can use correlated digital I/O to create a digital waveform
Waveform can be used to transfer digital data
Digital input can read information from a port
ni.com/training
Exercise 8-3: Correlated Digital Output
ni.com/training
G
O
A
L
CompactDAQ Only:
Create a clocked waveform of digital data. Use the clock
from an analog output task as the clock source for the
digital waveform.
Quiz
1. Digital Signals are always
between 0 and 5 Volts.
a. True
b. False
2. All devices support clocked
digital I/O.
a. True
b. False
ni.com/training
b. False b. False