MCUXpresso SDK Documentation

eqdc_index_interrupt

eqdc_index_interrupt#

Overview#

The eqdc_index_interrupt example shows how to use the interrupt of EQDC module with EQDC driver.

In this example, user needs to connect a real encoder to the board. Actually, only PHASE A and PHASE B are enough for the basic application. However, the additional INDEX/HOME/TRIGGER could be used as the event detector.

INDEX: This pulse can optionally reset the position counter and the pulse accumulator of the quadrature decoder module. It also causes a change of state on the revolution counter. The direction of this change, increment or decrement, is calculated from the PHASEA and PHASEB inputs.

HOME: This input can be used to trigger the initialization of the position counters. Often this signal is connected to a sensor signalling the motor or machine, sending notification that it has reached a defined home position.

TRIGGER: This input can be used to clear the position counters or to take a snapshot of the POS, REV, and POSD registers. Often this signal is connected to a periodic pulse generator or timer to indicate an elapsed time period.

This example uses INDEX to response the external event. When running the project, user can turn the encoder so that EQDC module can monitor the position change. Also, a variable counter would count the time of INDEX interrupt for rising edge on INDEX signal line.

Running the demo#

Turn the encoder feed the negative pulse into INDEX and type in any key into terminal. When the demo runs successfully, the log would be seen on the OpenSDA terminal like:

EQDC INDEX Interrupt Example. Press any key to get the encoder values …

Current position value: 0 Current position differential value: 0 Current position revolution value: 0 g_EqdcIndexCounter: 0

Current position value: 20 Current position differential value: 20 Current position revolution value: 1 g_EqdcIndexCounter: 1

Current position value: 25 Current position differential value: 5 Current position revolution value: 2 g_EqdcIndexCounter: 2

Supported Boards#

MIMXRT1180-EVK
Hardware requirements
  • Mini/micro USB cable

  • EVK-MIMXRT1180 board

  • Personal Computer

  • An encoder with PHASE A/B signals.

Board settings
  1. For pin connection between board and encoder, J44.6 -> kXBAR1_InputRESERVED22 -> kXBAR1_OutputEnc1Phasea -> EQDC_PHA J44.8 -> kXBAR1_InputRESERVED20 -> kXBAR1_OutputEnc1Phaseb -> EQDC_PHB J39.10 -> kXBAR1_InputRESERVED18 -> kXBAR1_OutputEnc1Index -> EQDC_INDEX

Prepare the Demo
  1. Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.

  2. Connect the wires between encoder and the MCU board. See to the code for pin mux setting in function “BOARD_InitPins()”.

  3. Open a serial terminal on PC for OpenSDA serial device with these settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  4. Download the program to the target board.

  5. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

FRDM-MCXA153
Hardware requirements
  • Type-C USB cable

  • FRDM-MCXA153 board

  • Personal Computer

  • An encoder with PHASE A/B and INDEX signals.

Board settings
  1. For pin connection between board and encoder, J3_3 -> IOMUXC_GPIO_AD_B0_09_GPIO1_IO09 -> kINPUTMUX_TrigIn10ToQdc0Phasea -> EQDC_PHA J3_1 -> IOMUXC_GPIO_AD_B0_10_GPIO1_IO10 -> kINPUTMUX_TrigIn5ToQdc0Phaseb -> EQDC_PHB J1_3 -> IOMUXC_GPIO_AD_B0_11_GPIO1_IO11 -> kINPUTMUX_TrigIn2ToQdc0Index -> EQDC_INDEX

Prepare the Demo
  1. Connect a Type-C USB cable between the host PC and the MCU-Link port(J15) on the target board.

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

FRDM-MCXA156
Hardware requirements
  • Type-C USB cable

  • FRDM-MCXA156 board

  • Personal Computer

  • An encoder with PHASE A/B signals.

Board settings
  1. For pin connection between board and encoder, J4_5 -> kINPUTMUX_TrigIn10ToQdc0Phasea -> EQDC_PHA J4_3 -> kINPUTMUX_TrigIn9ToQdc0Phaseb -> EQDC_PHB J4_1 -> kINPUTMUX_TrigIn4ToQdc0Index -> EQDC_INDEX

Prepare the Demo
  1. Connect a Type-C USB cable between the host PC and the MCU-Link USB port on the target board.

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

FRDM-MCXA346
Hardware requirements
  • Type-C USB cable

  • FRDM-MCXA346 board

  • Personal Computer

  • An encoder with PHASE A/B signals.

Board settings
  1. For pin connection between board and encoder, J3_3 -> kINPUTMUX_TrigIn3ToQdc0Phasea -> EQDC_PHA J3_1 -> kINPUTMUX_TrigIn10ToQdc0Phaseb -> EQDC_PHB J1_3 -> kINPUTMUX_TrigIn5ToQdc0Index -> EQDC_INDEX

Prepare the Demo
  1. Connect a Type-C USB cable between the host PC and the MCU-Link USB port on the target board.

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

FRDM-MCXA174
Hardware requirements
  • Type-C USB cable

  • FRDM-MCXA174 board

  • Personal Computer

  • An encoder with PHASE A/B signals.

Board settings
  1. For pin connection between board and encoder, J3_3 -> kINPUTMUX_TrigIn3ToQdc0Phasea -> EQDC_PHA J3_1 -> kINPUTMUX_TrigIn10ToQdc0Phaseb -> EQDC_PHB J1_3 -> kINPUTMUX_TrigIn5ToQdc0Index -> EQDC_INDEX

Prepare the Demo
  1. Connect a Type-C USB cable between the host PC and the MCU-Link USB port on the target board.

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

${ANCHOR}

FRDM-MCXA344
Hardware requirements
  • Type-C USB cable

  • FRDM-MCXA344 board

  • Personal Computer

  • An encoder with PHASE A/B signals.

Board settings
  1. For pin connection between board and encoder, J3_3 -> kINPUTMUX_TrigIn3ToQdc0Phasea -> EQDC_PHA J3_1 -> kINPUTMUX_TrigIn10ToQdc0Phaseb -> EQDC_PHB J1_3 -> kINPUTMUX_TrigIn5ToQdc0Index -> EQDC_INDEX

Prepare the Demo
  1. Connect a Type-C USB cable between the host PC and the MCU-Link USB port on the target board.

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

${ANCHOR}

FRDM-IMXRT1186
Hardware requirements
  • Type-C USB cable

  • FRDM-IMXRT1186 board

  • Personal Computer

  • An encoder with PHASE A/B signals.

Board settings

Change Jumper J30 and J35 from 1-2 to 2-3

  1. For pin connection between board and encoder, J1.14 -> kXBAR1_InputRESERVED18 -> kXBAR1_OutputEnc1Phasea -> EQDC_PHA J51.10 -> kXBAR1_InputRESERVED19 -> kXBAR1_OutputEnc1Phaseb -> EQDC_PHB J3.21 -> kXBAR1_InputRESERVED23 -> kXBAR1_OutputEnc1Index -> EQDC_INDEX

Prepare the Demo
  1. Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.

  2. Connect the wires between encoder and the MCU board. See to the code for pin mux setting in function “BOARD_InitPins()”.

  3. Open a serial terminal on PC for OpenSDA serial device with these settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  4. Download the program to the target board.

  5. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

FRDM-MCXA266
Hardware requirements
  • Type-C USB cable

  • FRDM-MCXA266 board

  • Personal Computer

  • An encoder with PHASE A/B signals.

Board settings
  1. For pin connection between board and encoder, J3_3 -> kINPUTMUX_TrigIn3ToQdc0Phasea -> EQDC_PHA J3_1 -> kINPUTMUX_TrigIn10ToQdc0Phaseb -> EQDC_PHB J1_3 -> kINPUTMUX_TrigIn5ToQdc0Index -> EQDC_INDEX

Prepare the Demo
  1. Connect a Type-C USB cable between the host PC and the MCU-Link USB port on the target board.

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

${ANCHOR}

FRDM-MCXA366
Hardware requirements
  • Type-C USB cable

  • FRDM-MCXA366 board

  • Personal Computer

  • An encoder with PHASE A/B signals.

Board settings
  1. For pin connection between board and encoder, J3_3 -> kINPUTMUX_TrigIn3ToQdc0Phasea -> EQDC_PHA J3_1 -> kINPUTMUX_TrigIn10ToQdc0Phaseb -> EQDC_PHB J1_3 -> kINPUTMUX_TrigIn5ToQdc0Index -> EQDC_INDEX

Prepare the Demo
  1. Connect a Type-C USB cable between the host PC and the MCU-Link USB port on the target board.

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

${ANCHOR}

IMX943-EVK
Hardware requirements
  • Mini/micro USB cable

  • IMX943-EVK board

  • FRDM-LVPMSM-FA board

  • Personal Computer

  • An encoder with PHASE A/B signals.

Board settings
  1. Set SW8 from [00000000] to [00011000]

  2. Insert the FRDM board into the MC2 arduino interface on the IMX943-EVK board

  3. Set FRDM board

  • Set SW30 from [0000] to [0100]

  • Set SW90 from [0000] to [1000]

  • Set Jumper J61[2-3]

  1. Connection between board and encoder

  • J60-1 -> 5V cable of encoder

  • J60-2 -> GND cable of encoder

  • J60-3 -> ENC_A cable of encoder

  • J60-4 -> ENC_B cable of encoder

  • J60-5 -> ENC_I cable of encoder

  1. Connect 12V power to FRDM board

  2. If you don’t have FRDM-LVPMSM-FA board, you can connect it follows bellow:

  • J49-8 -> 3.3V cable of encoder

  • J49-14 -> GND cable of encoder

  • J49-3 -> ENC_A cable of encoder

  • J49-1 -> ENC_B cable of encoder

  • J48-3 -> ENC_I cable of encoder

Prepare the Demo
  1. Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.

  2. Connect the wires between encoder and the MCU board. See to the code for pin mux setting in function “BOARD_InitPins()”.

  3. Open a serial terminal on PC for OpenSDA serial device with these settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  4. Download the program to the target board.

  5. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.