Breakout Board Digital Inputs
The following excerpt from the Breakout Board example workflow demonstrates digital inputs functionality by responding to button presses and saves digital inputs data.
The DigitalInput operator generates a sequence of
DigitalInputDataFrames. In this workflow, digital inputs
are configured to be asynchronous. This means that although the digital inputs
are sampled in hardware at 4 Mhz, data frames are only emitted when the port
status changes (i.e., when a pin, button, or switch is toggled). Digital inputs
can also be
configured
to be sampled at regular intervals. The digital input ports on the Breakout
Board use 3.3V logic levels but are also 5V tolerant. In the Breakout
Board example workflow, the DigitalInput
's DeviceName
property is set to
"BreakoutBoard/DigitalInput". This links the DigitalInput
operator to the
corresponding configuration operator.
Clock
, DigitalInputs
, and Buttons
are all members of
DigitalInputDataFrame
which are each selected by a
MemberSelector operator. They
contain the AcquisitionClockHz-based sample
times, digital port status, and buttons' status, respectively. The
MatrixWriter operators save the selected members
to files with the following format: digital-clock_<filecount>.raw
, and
digital-pins_<filecount>.raw
, and digital-buttons_<filecount>.raw
,
respectively.
Because MatrixWriter
is a sink operator, its output sequence is equivalent
to its input sequence. For example, the output of the MatrixWriter
connected
to Button
is equivalent to Button
's output. Therefore, it's possible to
process digital data by branching directly off the MatrixWriter
operators. The
selected DigitalInputs
and Buttons
members are both enumerator types:
DigitalPortState and
BreakoutButtonState, respectively. Enumerators assign
names to values. When DigitalPortState
or BreakoutButtonState
is connected
to a HasFlags
operator, these names appear in the HasFlags
's Value
property's dropdown menu. In this case, the values that these names represent
correspond to bit positions of the breakout board's digital ports. In this
workflow, the top HasFlags
operator checks if Pin0
is True
, and the bottom
HasFlags
operator checks if Triangle
or X
are True
.