nimcReadDigitalIOData

NI-Motion Functions

nimcReadDigitalIOData

Device Compatibility

Device Compatibility
7330
Y
7340
Y
7344
N
7350
Y
7390
Y
NI SoftMotion Controller for CANopen—Xenus
Y
NI SoftMotion Controller for CANopen—Accelnet
Y

Read Digital I/O Data

Usage

status = nimcReadDigitalIOData(TnimcDeviceHandle deviceHandle, TnimcAxisHandle axisHandle, u32 line, TnimcDigitalIOData attribute, TnimcData* data);

Purpose

Reads the attribute on a single digital I/O line.

Tip  Refer to the Remarks section for information about how the behavior of this function differs between controllers.

Parameters

Name Type Description
deviceHandle TnimcDeviceHandle assigned by Measurement & Automation Explorer (MAX)
axisHandle TnimcAxisHandle axis to read
line u32 digital line to read attribute from
attribute TnimcDigitalIOData attribute to read
data TnimcData* the value for the attribute you are reading

Parameter Discussion

axisHandle is the axis to read with this function. Valid values are 1 through 30. On motion controllers that support fewer than thirty axes, reading non-existent axes returns error -70006 (NIMC_badResourceIDOrAxisError).

line is the digital line of the axis to read. Valid range is 1 to 32.

attribute is the attribute to read. The following are valid attributes:

attribute Description
TnimcDigitalIODataOutputActiveState Returns the active state of the specified output line. TnimcTrue indicates active low/active open. TnimcFalse indicates active high/active closed.
TnimcDigitalIODataInputActiveState Returns the active state of the specified input line. TnimcTrue indicates active low/active open. TnimcFalse indicates active high/active closed.
TnimcDigitalIODataOutputActive Returns the current output state of the specified line. TnimcTrue indicates the output line is active. TnimcFalse indicates the output line is inactive.
Note  Reading this attribute on a line configured for input returns error -70102 (NIMC_wrongIODirectionError).
TnimcDigitalIODataInputActive Returns the input state of the specified line. TnimcTrue indicates the input line is active. TnimcFalse indicates the input line is inactive.
Note  Reading this attribute on a line configured for output returns error -70102 (NIMC_wrongIODirectionError).
TnimcDigitalIODataIOConfigureAsInput Returns the direction of the specified line. TnimcTrue indicates input, TnimcFalse indicates output.

data is the value for the attribute you are reading in the following structure:

struct{
   i32 longData;
   u8 boolData;
   f64 doubleData;
} TnimcData;

Based on the attribute, the correct member of TnimcData will be returned by the motion controller. The values of the other elements in the structure are undefined.

Using This Function

Use this function to read the attribute on a single digital I/O line. The digital I/O lines are divided among the axes.

Caution  If this function uses reflective memory, it should not be used for event checking. In this case, only use the information returned by this function for display purposes. Refer to Reflective Memory Functions for more information.

Remarks

This section includes information about how the behavior of this function differs among the controllers that support it.

NI 73xx Controller Considerations

The following includes considerations you must make when you are using this function with a 73xx controller:

  • The PCI-7390 does not support TnimcDigitalIODataIOConfigureAsInput attribute.
  • The PCI-7390 has dedicated direction I/O lines. On these controllers, the pin you read (input or output) is determined by the value specified in line and attribute.

    For example, to read the input active state attribute of General-Purpose Input Bit 1 on axis 2, call the Read Digital I/O Data function with the following parameters:

    axisHandle = 2
    line = 1
    attribute = TnimcDigitalIODataInputActiveState

    To read the output active state of General-Purpose Output Bit 1 on axis 2, call the Read Digital I/O Data function with the following parameters:

    axisHandle = 2
    line = 1
    attribute = TnimcDigitalIODataOutputActiveState

  • 7330, 7340, and 7350 controllers have configurable direction I/O lines. On these controllers, the line number is translated to port and line number. For example, a call to Read Digital I/O Data on a four axis controller with eight digital I/O ports and

    axisHandle = NIMC_AXIS2
    line = 15
    attribute = TnimcDigitalIODataInputActiveState

    reads the active state of port 6 bit 7.

  • The following table lists the port to axis and line mapping for 7350 controllers:

    Number of Axes Axis Number Line 0 to 7 Line 8 to 15 Line 16 to 23 Line 24 to 31
    2 1 Port 1 Port 3 Port 5 Port 7
    2 Port 2 Port 4 Port 6 Port 8
    4 1 Port 1 Port 5
    2 Port 2 Port 6
    3 Port 3 Port 7
    4 Port 4 Port 8
    6 1 Port 1
    2 Port 2
    3 Port 3
    4 Port 4
    5 Port 5 Port 7
    6 Port 6 Port 8
    8 1 Port 1
    2 Port 2
    3 Port 3
    4 Port 4
    5 Port 5
    6 Port 6
    7 Port 7
    8 Port 8
  • The following table lists the port to axis and line mapping for 7330 and 7340 controllers:

    Number of Axes Axis Number Line 0 to 7 Line 8 to 15
    2 1 Port 1 Port 3
    2 Port 2 Port 4
    4 1 Port 1
    2 Port 2
    3 Port 3
    4 Port 4

NI SoftMotion Controller Considerations

The following includes considerations you must make when you are using this function with the NI SoftMotion Controller:

The NI SoftMotion Controller does not support the TnimcDigitalIODataIOConfigureAsInput attribute.