flex_read_port

NI-Motion Functions

flex_read_port

Device Compatibility

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

Read I/O Port

Usage

status = flex_read_port(u8 boardID, u8 port, u8 returnVector);

Purpose

Reads the logical state of the bits in an I/O port.

Parameters

Name Type Description
boardID u8 assigned by Measurement & Automation Explorer (MAX)
port u8 general-purpose I/O port to read
returnVector u8 destination for the return data

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_INPUT_PORT1 through NIMC_DIGITAL_INPUT_PORT4 or NIMC_DIGITAL_OUTPUT_PORT1 through NIMC_DIGITAL_OUTPUT_PORT4 for the PCI-7390 motion controller, or the RTSI software port (NIMC_RTSI_PORT) to read. On motion controllers that support fewer than eight axes, reading non-existent ports returns error –70006 (NIMC_badResourceIDOrAxisError). 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.

returnVector indicates the destination for the return data generated by this function. Available return vectors include return data to the host (0xFF), to a variable (0x01 through 0x78), to an indirect variable (0x81 through 0xF8), and return no data (0). Refer to Input and Return Vectors for more detailed information.

Note  The suffix _rtn on the function indicates that the data must be returned to the host. When this calling convention is used, no returnVector is required.

Using This Function

This function reads the logical state of the bits in the general-purpose I/O port selected. You can execute this function at any time to monitor the signals connected to an input port. Reads of ports configured as outputs return the last value written to the port with the Set I/O Port MOMO 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 read the state of input port 3, port is NIMC_DIGITAL_INPUT_PORT3. To read the value previously set on output port 2, port is NIMC_DIGITAL_OUTPUT_PORT2.

Note  This function reads the logical state (On or Off, True or False) of the bits in a port. 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.

When reading the RTSI port, the value read is the latched data, so you can detect active pulses on the RTSI bus. After reading the latched data value, the function resets the latch. Use the Set I/O Port Polarity function to specify the polarity, and therefore the active state for latching.

Note  Refer to Function Execution Times for benchmark timing information about your controller.