flex_set_port_pol |
Set I/O Port Polarity
Usage
status = flex_set_port_pol(u8 boardID, u8 port, u16 portPolarityMap);
Purpose
Sets the bit polarity in a general-purpose 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 control |
portPolarityMap | u16 | bitmap of active polarities |
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.
portPolarityMap is the bitmap of active polarities for the I/O port:
D15 | ... | D9 | D8 | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
0 | ... | 0 | 0 | Bit 7 | Bit 6 | Bit 5 | Bit 4 | Bit 3 | Bit 2 | Bit 1 | Bit 0 |
For D0 through D7:
1 = active low/active open (default)
0 = active high/active closed
Using This Function
This function sets the polarity (active state) of the general-purpose I/O port on an individual bit basis.
When configured as active low, the input or output is active when there is a low signal on the pin. Conversely, active high means that the input or output is active when there is a high signal on the pin.
Configuring an active state of active open or active closed does not correspond to the level of the signal on the input or output pin. Instead, an active open state means that the input or output is active when current is not flowing through the optocoupled input. Conversely, an active closed state means that the input or output is active when current is flowing through the optocoupled input.
Typically, ports and their pins are configured for direction and polarity at initialization. After configuration, you can then read or write logical states (True or False, On or Off) to ports without worrying about the physical states of signals on the port pins.
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:
- 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 configure the polarity of the output port on axis 2, port is NIMC_DIGITAL_OUTPUT_PORT2. To configure the polarity of the input port on axis 3, port is NIMC_DIGITAL_INPUT_PORT3. - The polarity also defines the latching behavior for the RTSI port. To detect short pulses on RTSI lines, the hardware latches active-going signals and holds that state until the port is read. For example, if you configure a bit for active low polarity, a transition from high to low is latched until read, even if the signal goes high again. If the signal starts low, it also is latched until read, even if the signal is high when you read the bit.
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 configure the polarity of the output port on axis 2, port is NIMC_DIGITAL_OUTPUT_PORT2. To configure the polarity of the input port on axis 3, port is NIMC_DIGITAL_INPUT_PORT3. - The RTSI port is not supported by the NI SoftMotion Controller.