MCUXpresso SDK Documentation

qdc_position

qdc_position#

Overview#

This project shows how to sample the shaft position based on quadrature signal (PHASEA and PHASEB). This project assumes that the shaft encoder disk has 1000 lines. To count the revolution, QDC modulo count mode is enabled, and modulus value set to 4x1000. User could also change to use the INDEX signal to count revolution.

This project setups a 1kHz signal as TRIGGER signal, the QDC position, revolution, and position difference are loaded to HOLD registers at the edge of TRIGGER signal. In the TRIGGER signal’s ISR, the hold position values are saved to global variables, user can check the variables through freemaster. Also, these global variables are output to the debug terminal every 500ms.

Supported Boards#

MC56F81000-EVK
Hardware requirements
  • 2 x Micro USB cable

  • MC56F81000-EVK board

  • Personal Computer

Board hardware common setting
  1. Power setting:

    Connect J8 pin2 and pin3 Connect J5 pin1 and pin2 Connect J6 pin1 and pin2

  2. Onboard PnE U-MultiLink debugger setting:

    Connet J11 pin2 and pin3 Connect J13 pin 1-2, 3-4, 5-6, 7-8, to setup onboard debugger PnE U-MultiLink. Note: when use external debugger(connected to J10), leave all J13 pins open.

Board settings
  • Connect PHASEA to J3-3, PHASEB to J3-1.

Prepare the Demo
  1. Connect USB cable between the host PC and the USB(J26) port on the target board to setup USB to UART bridge.

  2. Connect USB cable between the host PC and the USB(J12) port on the target baord to setup mulitlink debugger.

  3. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  4. Download the program to the target board with PnE U-MultiLink debug configuration.

  5. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo. Please be noted default FCF(flash configuration field) makes the MCU boot from flash.

Running the demo

When the demo running, the position, revolution are shown in the terminal periodically.

TWR-MC56F8400
Hardware requirements
  • Mini USB cable

  • TWR-MC56F8400 board

  • Personal Computer

Board hardware common setting
  1. Power setting:

    Connect J11 pin1 and pin2 Connect J6 pin1 and J7 pin2

  2. UART setting:

    Connect J8 pin3 and pin4 Connect J9 pin3 and pin4

  3. Onboard OSJTAG debugger setting:

    Connect J20 pin1 and pin2. Leave J17 open. Note: J17 is only used(connected) when firmware update for onboard debugger OSJTAG. Connect J21 pin 1-2, 3-4, 5-6, 7-8, to setup onboard debugger OSJTAG. Note: when use external debugger(connected to J14), leave all J21 pins open

Board settings
  • Connect PHASEA to J502-22, PHASEB to J502-3.

Prepare the Demo
  1. Connect USB cable between the host PC and the JM60 USB(J18) port on the target board. It setups OSJTAG and COM port in PC device manager.

  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 with OSJTAG debug configuration.

  4. Launch the debugger in your IDE to begin running the demo.

Running the demo

When the demo running, the position, revolution are shown in the terminal periodically.