flex_read_port_rtn |
Read I/O Port Return
Usage
status = flex_read_port_rtn(u8 boardID, u8 port, u16* portData);
Purpose
Reads the logical state of the bits in an I/O port.
![]() |
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 read |
portData | u16* | bitmap of the logical state of the I/O port |
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, NIMC_DIGITAL_INPUT_PORT1 through NIMC_DIGITAL_INPUT_PORT30 or 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.
portData is the bitmap of the logical state of the I/O port.
D15 | ... | D10 | D9 | D8 | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
XXX | ... | XXX | XXX | XXX | Bit 7 | Bit 6 | Bit 5 | Bit 4 | Bit 3 | Bit 2 | Bit 1 | Bit 0 |
For D0 through D7:
1 = I/O bit True (On)
0 = I/O bit False (Off)
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 anytime 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.
![]() |
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. |
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 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.
NI SoftMotion Controller Considerations
The following list includes considerations you must make when you are using this function with the NI SoftMotion Controller:
- 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 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. - The RTSI port is not supported by the NI SoftMotion Controller.