MCUXpresso SDK Documentation

eqdc_basic#

Overview#

The eqdc_basic example shows how to quickly start using 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. When running the project, user can turn the encoder so that EQDC module can monitor the position change. Then, the internal counter would also count for the position. User can also type keys into terminal, and the current position values recorded by EQDC would display.

The EQDC hardware is created with a special synchronize mechanism. There are actually 4 counters (the 32-bit position counter is combined with the two 16-bit counter registers) for position with responding hold registers. When any of the counter registers is read, the contents of each counter register is written to the corresponding hold register. Taking a snapshot of the counters’ values provides a consistent view of a system position and a velocity to be attained.

Running the demo#

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

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

Current position value: 0 Position differential value: 0 Position revolution value: 0

Current position value: 10 Position differential value: 10 Position revolution value: 0

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 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.