flex_set_port

NI-Motion Functions

flex_set_port

Device Compatibility

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

Set I/O Port MOMO

Usage

status = flex_set_port(u8 boardID, u8 port, u8 mustOn, u8 mustOff, u8 inputVector);

Purpose

Sets an I/O port value using the MustOn/MustOff protocol.

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

Parameters

Name Type Description
boardID u8 assigned by Measurement & Automation Explorer (MAX)
port u8 general-purpose I/O port to control
mustOn u8 bitmap of I/O port bits to force on
mustOff u8 bitmap of I/O port bits to force off
inputVector u8 source of the data for this function

Parameter Discussion

port is the general-purpose I/O port. Valid values are NIMC_IO_PORT1 through NIMC_IO_PORT8 for 7330/40/50 motion controllers, NIMC_DIGITAL_OUTPUT_PORT1 through NIMC_DIGITAL_OUTPUT_PORT4 for the PCI-7390 motion controller, NIMC_DIGITAL_OUTPUT_PORT1 through NIMC_DIGITAL_OUTPUT_PORT30 for the NI SoftMotion Controller, or RTSI software port (NIMC_RTSI_PORT) to control. Refer to 73xx Controller General-Purpose I/O Port IDs and NI SoftMotion Controller General-Purpose I/O Port IDs for I/O port resource IDs and constants.

mustOn is the bitmap of I/O port bits to force on:

D7 D6 D5 D4 D3 D2 D1 D0
mustOn 7 mustOn 6 mustOn 5 mustOn 4 mustOn 3 mustOn 2 mustOn 1 mustOn 0

For D0 through D7:
   1 = I/O bit forced to logical On
   0 = I/O bit left unchanged (default)

mustOff is the bitmap of I/O port bits to force off:

D7 D6 D5 D4 D3 D2 D1 D0
mustOff 7 mustOff 6 mustOff 5 mustOff 4 mustOff 3 mustOff 2 mustOff 1 mustOff 0

For D0 through D7:
   1 = I/O bit forced to logical Off
   0 = I/O bit left unchanged (default)

inputVector indicates the source of the data for this function. Available input vectors include immediate (0xFF), variable (0x01 through 0x78), or indirect variable (0x81 through 0xF8). Refer to Input and Return Vectors for more detailed information.

Using This Function

This function sets the logical state of bits in the general-purpose I/O port selected.

Using the MustOn/MustOff protocol allows you to set or reset individual bits without affecting other output bits in the port. This gives you tri-state control over each bit: On, Off or Unchanged. A one (1) in a bit location of the MustOn bitmap turns the bit On, while a one (1) in the corresponding location of the MustOff bitmap turns the bit Off. A zero (0) in either bitmap has no effect, so leaving both the MustOn and MustOff bits at zero is effectively a hold and the state of the bit is unchanged. If you set both the MustOn and MustOff bits to one (1), it is interpreted as a MustOn condition and the bit is turned On.

Note  This function sets the logical state of a bit On or Off (True or False). The polarity of the bits in the port determines if an On state is active high or active low. Refer to the Set I/O Port Polarity function for more information.
Note  When executing this function in a program, there may be a delay of up to 0.5 ms before the output lines are physically updated. The program flow continues, even though the output may not have been updated yet.
Note  If the motion controller is programmed to use the port for output when it has been configured for input, the action is ignored.

The Set I/O Port MOMO function allows individual control of general-purpose output bits without requiring a shadow value or a read of the port to remember the state of other bits not being set or reset with the function.

Example

Tip  This section applies to all NI motion controllers.

In I/O port 2, to set bits 1 and 3 On, bits 0 and 5 Off and to leave the other bits (2, 4, 6, and 7) unchanged, call this function with the following parameters:

port = NIMC_IO_PORT2

mustOn = 0x0A, where the value 0x0A corresponds to the following bitmap:

D7 D6 D5 D4 D3 D2 D1 D0
mustOff 7 mustOff 6 mustOff 5 mustOff 4 mustOff 3 mustOff 2 mustOff 1 mustOff 0
0 0 0 0 1 0 1 0

mustOff = 0x21, where the value 0x21 corresponds to the following bitmap:

D7 D6 D5 D4 D3 D2 D1 D0
mustOff 7 mustOff 6 mustOff 5 mustOff 4 mustOff 3 mustOff 2 mustOff 1 mustOff 0
0 0 1 0 0 0 0 1
Note  Refer to Function Execution Times for benchmark timing information about your controller.

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 list includes considerations you must make when you are using this function with a 73xx motion controller:

  • A line configured for input is not affected by this function.
  • You can always write to the RTSI software port, but the actual RTSI lines on the physical RTSI port are only affected if the RTSI line has been configured properly by using the Select Signal function. By default, none of the RTSI lines are configured to output their corresponding bits in the RTSI software port; you must configure each RTSI line individually using the Select Signal function, rather than the Set I/O Port Direction function.
  • The PCI-7390 has dedicated direction I/O ports. Refer to 73xx Controller General-Purpose I/O Port IDs for the appropriate general-purpose I/O port digital input and output resource constants and IDs to use for port.

    For example, to set the state of output port 2, port is NIMC_DIGITAL_OUTPUT_PORT2. To set the state of input port 3, port is NIMC_DIGITAL_INPUT_PORT3.

NI SoftMotion Controller Considerations

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

  • Refer to General-Purpose I/O Ports for information about how the NI SoftMotion Controller supports digital input and output lines for each axis.
  • For inputVector, the NI SoftMotion Controller supports only the immediate vector (0XFF).
  • The NI SoftMotion Controller has dedicated direction I/O ports. Refer to NI SoftMotion Controller General-Purpose I/O Port IDs for the appropriate general-purpose I/O port digital input and output resource constants and IDs to use for port.

    For example, to set the state of output port 2, port is NIMC_DIGITAL_OUTPUT_PORT2. To set the state of input port 3, port is NIMC_DIGITAL_INPUT_PORT3.
  • The RTSI port is not supported by the NI SoftMotion Controller.