nimcWriteDigitalIOData

NI-Motion Functions

nimcWriteDigitalIOData

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

Write Digital I/O Data

Usage

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

Purpose

Sets 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 configure digital lines on
line u32 digital line to modify attribute
attribute TnimcDigitalIOData attribute to set
data TnimcData* the data for the attribute you are writing

Parameter Discussion

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

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

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

attribute Description
TnimcDigitalIODataOutputActiveState Sets the active state of the specified output line.
TnimcDigitalIODataInputActiveState Sets the active state of the specified input line.
TnimcDigitalIODataOutputActive Sets the current output state of the specified line.
Note  Setting this attribute on a line configured for input returns an error.
TnimcDigitalIODataIOConfigureAsInput Sets the direction of the specified line.

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

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

Based on the attribute, the correct member of TnimcData must be set as follows:

  • For TnimcDigitalIODataOutputActiveState, set boolData in the TnimcData structure to TnimcTrue to set the active state to active low/active open, and set it to TnimcFalse to set the active state to active high/active closed.
  • For TnimcDigitalIODataInputActiveState, set boolData in the TnimcData structure to TnimcTrue to set the active state to active low/active open, and set it to TnimcFalse to set the active state to active high/active closed.
  • For TnimcDigitalIODataOutputActive, set boolData in the TnimcData structure to TnimcTrue to configure the output line as active, and set it to TnimcFalse to configure the output line as inactive.
  • For TnimcDigitalIODataIOConfigureAsInput, set boolData in the TnimcData structure to TnimcTrue to configure the line for input, and set it to TnimcFalse to configure the line for output.

Using This Function

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

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 the TnimcDigitalIODataIOConfigureAsInput attribute.
  • The PCI-7390 has dedicated direction I/O lines. On these controllers, the pin you write to (input or output) is determined by the value specified in line and attribute.

    For example, to change the input active state on line 1 on axis 2, call Write Digital I/O Data with the following parameters:

    axisHandle = 2
    line = 1
    attribute = TnimcDigitalIODataInputActiveState

    The active state is applied to axis 2 General-Purpose Input Bit 1.

    To change the output active state of line 1 on axis 2, call Write Digital I/O Data with the following parameters:

    axisHandle = 2
    line = 1
    attribute = TnimcDigitalIODataOutputActiveState

    The active state is applied to axis 2 General-Purpose Output Bit 1.

  • 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 Write Digital I/O Data on a four axis controller with eight digital I/O ports with

    axisHandle = 2
    line = 15
    attribute = TnimcDigitalIODataInputActiveState

    applies the active state to 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.