flex_config_axis

NI-Motion Functions

flex_config_axis

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

Configure Axis Resources

Usage

status = flex_config_axis(u8 boardID, u8 axis, u8 primaryFeedback, u8 secondaryFeedback, u8 primaryOutput, u8 secondaryOutput);

Purpose

Configures an axis by defining its feedback and output resources.

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)
axis u8 axis to configure
primaryFeedback u8 primary encoder or ADC feedback resource
secondaryFeedback u8 secondary encoder
primaryOutput u8 primary DAC or step output resource
secondaryOutput u8 secondary DAC

Parameter Discussion

axis is the axis to configure. Valid values are NIMC_AXIS1 through NIMC_AXIS30. On motion controllers that support fewer than thirty axes, configuring non-existent axes returns error –70006 (NIMC_badResourceIDOrAxisError). Refer to Axes for axis resource IDs.

primaryFeedback is the number for the primary feedback resource being mapped to the axis. The primary feedback resource is used for position feedback, derivative (Kd) damping, and velocity feedback (Kv) if a secondary resource is not configured. Enter 0 (zero) to configure no primary feedback resource.

secondaryFeedback is the number for an optional secondary feedback resource being mapped to the axis. If a secondary feedback resource is mapped, it is used for velocity feedback (Kv). Enter 0 (zero) to configure no secondary feedback resource. Refer to the Velocity Feedback Gain section of Load Single PID Parameter for more information about Kv.

primaryOutput is the number for the primary output resource being mapped to the axis. This is the main command output. Enter 0 (zero) to configure no primary output resource.

secondaryOutput is the number for an optional secondary output resource being mapped to the axis. This is an optional command output. Enter 0 (zero) to configure no secondary output resource.

Using This Function

This function defines the feedback and output devices for an axis. You can configure up to two feedback resources and two output resources for each axis. This flexible mapping of resources to axes allows for advanced servo and stepper configurations such as: independent velocity and position feedback devices (dual-loop control), dual DAC outputs with different offsets, and changing feedback on the fly.

The various feedback and output resources on the NI motion controller have different interface, performance, and functionality characteristics. This function allows you to define the axis and tailor its performance.

The following table lists valid resources:

Resource Type 7330 7340 7350 7390
Primary Feedback Encoder/ADC Encoder/ADC Encoder/ADC Encoder
Secondary Feedback Encoder Encoder Encoder/ADC
Primary Output Stepper Stepper/DAC Stepper/DAC Stepper
Secondary Output DAC DAC
Tip  Refer to Motion Resources for more information about resource IDs.

This function must be called for each axis that is used by an application prior to enabling the axis. The factory default mapping of resources to axes is as follows:

Axis Primary Feedback Secondary
Feedback
Primary Output Secondary
Output
Resource ID Constant Resource ID Constant
1 0x21 (Enc 1) NIMC_ENCODER1 0 0x31 (DAC 1) NIMC_DAC1 0
2 0x22 (Enc 2) NIMC_ENCODER2 0 0x32 (DAC 2) NIMC_DAC2 0
3 0x23 (Enc 3) NIMC_ENCODER3 0 0x33 (DAC 3) NIMC_DAC3 0
4 0x24 (Enc 4) NIMC_ENCODER4 0 0x34 (DAC 4) NIMC_DAC4 0
5 0x25 (Enc 5) NIMC_ENCODER5 0 0x35 (DAC 5) NIMC_DAC5 0
6 0x26 (Enc 6) NIMC_ENCODER6 0 0x36 (DAC 6) NIMC_DAC6 0
7 0x27 (Enc 7) NIMC_ENCODER7 0 0x37 (DAC 7) NIMC_DAC7 0
8 0x28 (Enc 8) NIMC_ENCODER8 0 0x38 (DAC 8) NIMC_DAC8 0
9 0x29 (Enc 9) NIMC_ENCODER9 0 0x39 (DAC 9) NIMC_DAC9 0
10 0x3A (Enc 10) NIMC_ENCODER10 0 0x4A (DAC 10) NIMC_DAC10 0
11 0x3B (Enc 11) NIMC_ENCODER11 0 0x4B (DAC 11) NIMC_DAC11 0
12 0x3C (Enc 12) NIMC_ENCODER12 0 0x4C (DAC 12) NIMC_DAC12 0
13 0x3D (Enc 13) NIMC_ENCODER13 0 0x4D (DAC 13) NIMC_DAC13 0
14 0x3E (Enc 14) NIMC_ENCODER14 0 0x4E (DAC 14) NIMC_DAC14 0
15 0x3F (Enc 15) NIMC_ENCODER15 0 0x4F (DAC 15) NIMC_DAC15 0
16 0xC1 (Enc 16) NIMC_ENCODER16 0 0xD1 (DAC 16) NIMC_DAC16 0
17 0xC2 (Enc 17) NIMC_ENCODER17 0 0xD2 (DAC 17) NIMC_DAC17 0
18 0xC3 (Enc 18) NIMC_ENCODER18 0 0xD3 (DAC 18) NIMC_DAC18 0
19 0xC4 (Enc 19) NIMC_ENCODER19 0 0xD4 (DAC 19) NIMC_DAC19 0
20 0xC5 (Enc 20) NIMC_ENCODER20 0 0xD5 (DAC 20) NIMC_DAC20 0
21 0xC6 (Enc 21) NIMC_ENCODER21 0 0xD6 (DAC 21) NIMC_DAC21 0
22 0xC7 (Enc 22) NIMC_ENCODER22 0 0xD7 (DAC 22) NIMC_DAC22 0
23 0xC8 (Enc 23) NIMC_ENCODER23 0 0xD8 (DAC 23) NIMC_DAC23 0
24 0xC9 (Enc 24) NIMC_ENCODER24 0 0xD9 (DAC 24) NIMC_DAC24 0
25 0xCA (Enc 25) NIMC_ENCODER25 0 0xDA (DAC 25) NIMC_DAC25 0
26 0xCB (Enc 26) NIMC_ENCODER26 0 0xDB (DAC 26) NIMC_DAC26 0
27 0xCC (Enc 27) NIMC_ENCODER27 0 0xDC (DAC 27) NIMC_DAC27 0
28 0xCD (Enc 28) NIMC_ENCODER28 0 0xDD (DAC 28) NIMC_DAC28 0
29 0xCE (Enc 29) NIMC_ENCODER29 0 0xDE (DAC 29) NIMC_DAC29 0
30 0xCF (Enc 30) NIMC_ENCODER30 0 0xDF (DAC 30) NIMC_DAC30 0

Remarks

This section includes information about how the behavior of this function differs among the controllers that support it.

NI 73xx Controller Considerations

  • If you are using an NI 73xx motion controller, you cannot configure an axis when any axes are enabled. You must first disable all axes using the Enable Axis function.
  • To change feedback on the fly (NI 7350 controllers only), call this function when the axis is not moving (move complete).
Note Note  The feedback resources used for switching feedback on the fly must meet the following conditions:
  • The feedback device must be enabled.
  • The feedback device being switched to must not be used by another axis.
Refer to Switching Feedback on the Fly in the NI-Motion Help for detailed information about configuring your system to switch between two feedback devices.

Example 1

To change axis 3 to use the fourth encoder channel and the first DAC output, call the Configure Axis Resources function with the following configuration:

Axis PrimaryFeedback SecondaryFeedback Primary Output SecondaryOutput
3 NIMC_ENCODER4 0 NIMC_DAC1 0

To avoid potential contention for output resources, this function always honors the configuration of the last time it is called. In this example, both axis 1 (by default) and axis 3 want to use DAC 1. Similarly, both axis 4 (by default) and axis 3 want to use encoder 4. To avoid contention, DAC 1 is assigned to axis 3 and removed from axis 1, and encoder 4 is assigned to axis 3 and removed from axis 4, resulting in the following configuration:

Axis PrimaryFeedback SecondaryFeedback Primary Output SecondaryOutput
1 NIMC_ENCODER1 0 0 0
4 0 0 NIMC_DAC4 0

You must now call this function again to configure axis 4 with a different feedback resource and axis 1 with a different output resource.

Example 2

To configure axis 2 for dual-loop control you can use the following parameters:

Axis PrimaryFeedback SecondaryFeedback Primary Output SecondaryOutput
2 NIMC_ADC1 NIMC_ENCODER2 NIMC_DAC2 0

In this example, an ADC channel is used for the primary position feedback (kp, ki, kd) while an encoder is used for the secondary velocity feedback. This application typically uses velocity feedback (Kv) from the encoder for stability. Refer to Load Single PID Parameter for information about setting Kv.

NI SoftMotion Controller Considerations

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

  • When you are using the NI SoftMotion Controller, you cannot map an axis resource to another axis. For example, encoder 3 (NIMC_ENCODER3) cannot be mapped to axis 1.
  • To enable dual-loop feedback on the NI SoftMotion Controller, your motion control system must include a second encoder on the axis. Otherwise, an error is returned. To configure the secondary encoder for axis 1, set secondaryFeedback to NIMC_SECONDARY_ENCODER1. To enable dual-loop feedback on axis 1, set primaryFeedback to NIMC_ENCODER1 and set the secondaryFeedback to NIMC_SECONDARY_ENCODER1.
  • The NI SoftMotion Controller supports secondary feedback devices on axes 1 to 15 only.
    • Secondary Encoders

      Use secondary encoders in a dual-loop feedback system to provide a more accurate velocity feedback estimation.

      Resource Name Resource ID Constant
      Secondary Encoder 1 0X71 NIMC_SECONDARY_ENCODER1
      Secondary Encoder 2 0X72 NIMC_SECONDARY_ENCODER2
      . . .
      . . .
      . . .
      Secondary Encoder 15 0X7F NIMC_SECONDARY_ENCODER15
    • Secondary ADCs

      Resource Name Resource ID Constant
      Secondary ADC 1 0X91 NIMC_SECONDARY_ADC1
      Secondary ADC 2 0X92 NIMC_SECONDARY_ADC2
      . . .
      . . .
      . . .
      Secondary ADC 15 0X9F NIMC_SECONDARY_ADC15