Skip to content

About

mcxa366-tamagawa-tformat-interface-using-flexio

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

NXP Application Code Hub

AN15146 Tamagawa T-format Encoder Master Interface using FlexIO on MCXA366

This software accompanies the application note AN15146 Tamagawa T-format Encoder Master Interface using FlexIO on MCXA366, which describes a FlexIO-based T-format master implemented on the FRDM-MCXA366. The project transmits the request byte stream (TXD), holds the RS-485 driver-enable signal (DIR) for exactly the request duration, captures the encoder response (RXD), validates the returned frame, and then publishes position, encoder ID, temperature and status.

The target encoder is a Tamagawa TS5700N8501: 17-bit single-turn absolute data (ABS), 16-bit multi-turn data (ABM), 2.5 Mbps asynchronous differential NRZ communication. Position is read with the DID3 full-position transaction (CF = 0x1A), which returns ABS, encoder ID, ABM, ALMC and SF in an 11-byte response. The bit rate is fixed at 2.5 Mbps inside the driver and derived from the 90 MHz FlexIO root clock, so the rate is changed through the clock configuration rather than through a baud-rate parameter. The supplied example uses polling transfers.

Key Features

  • FlexIO0 drives TXD on D17, samples RXD on D18, and controls the external RS-485 DE/DIR line on D16.
  • One TX shifter, one RX shifter and three timers implement transmit, receive and direction control.
  • DID3 (CF = 0x1A) returns ABS, ENCID, ABM, ALMC, SF and CRC8 in a single 11-byte response.
  • The parser checks the echoed CF and the CRC8, masks ABS to 17 bits, sign-extends ABM from 16 bits, and reports whether the multi-turn count can be trusted.
  • ALMC and SF are decoded bit by bit, so a communication alarm cannot hide a concurrent encoder error (over-speed, counter overflow, over-heat, multi-turn error, battery error, battery alarm).
  • Encoder ID and encoder temperature are read through the EEPROM transactions.
  • Optional reset transactions are provided: error reset (ID7, CF = 0xBA) and multi-turn plus error reset (IDC, CF = 0x62). The start-up reset is disabled by default and enabled with the T_FORMAT_RESET_ERRORS_AT_STARTUP macro in source/t-format_polling_transfer.c.
  • Polling transfers use bounded retry loops and restore the FlexIO state after a timeout.

Boards: FRDM-MCXA366

Categories: Motor Control

Peripherals: FlexIO

Toolchains: MCUXpresso IDE

Table of Contents

  1. Software
  2. Hardware
  3. Setup
  4. Results
  5. Support
  6. Release Notes

1. Software

2. Hardware

  • FRDM-MCXA366
  • Tamagawa T-format encoder (TS5700N8501)
  • RS-485 transceiver module with direction control (for example MAX485 or SN65HVD series)
  • Encoder power supply (5 V) and, for multi-turn operation, a VBAT backup supply
  • USB Type-C cable
  • Personal Computer

3. Setup

3.1 Hardware Setup

  1. Connect the T-format encoder to the FRDM-MCXA366 through the RS-485 transceiver according to the pin mapping table below. The pads listed are the MCXA366 logic side of the interface: TXD and RXD reach the encoder as the single differential SD/DS pair, while DIR is a board-local transceiver direction control and is not an encoder cable signal. Do not connect the MCU pins directly to the encoder differential pair.

    Project
    Signal
    FlexIO
    Signal
    MCXA366
    Pad
    Direction Purpose
    DIR FLEXIO0_D16 P2_8 Output RS-485
    drive/receive control
    TXD FLEXIO0_D17 P2_9 Output Request
    data to encoder
    RXD FLEXIO0_D18 P2_10 Input Encoder
    response data
    GND - GND Reference Common
    logic ground
  2. Connect the FRDM-MCXA366 to the computer via a USB Type-C cable. The hardware setup is shown below:

3.2 Import Project

  1. Open MCUXpresso IDE, in the Quick Start Panel, choose Import from Application Code Hub.

  2. Enter the demo name in the search bar.

  3. Click Copy GitHub link, MCUXpresso IDE will automatically retrieve project attributes, then click Next>.

  4. Select main branch and then click Next>, Select the MCUXpresso project, click Finish button to complete import.

3.3 Demo hands-on

  1. Compile the project and download it to FRDM-MCXA366 board.
  2. Open serial port assistant, set baud rate to 115200, connect to FRDM-MCXA366 debug UART port.
  3. Press the reset button on FRDM-MCXA366 to begin operation, then observe the real-time encoder position values via UART.

4. Results

  1. The serial assistant connected to the FRDM-MCXA366 serial port will display the result below. Multi-turn data is the signed revolution count from ABM, and single-turn data is the position within one revolution, spanning 0 to 131071 (2^17 - 1). A new line is printed on significant shaft motion, on a change of the status flags, or once per second.
Encoder T-format example
FlexIO Root Clock is 90 MHz
[T-format] Encoder ID: 0x11
        Logic-OR of Over-heat, Multi-turn error, Battery error and Battery alarm
[T-format] Multi-turn data: 1, single-turn data: 66765
        Logic-OR of Over-heat, Multi-turn error, Battery error and Battery alarm
[T-format] Temperature: 34
[1.00s] Encoder ID: 0x11
         Multi-turn data: 1, single-turn data: 66765
         Temperature: 34
[2.00s] Encoder ID: 0x11
         Multi-turn data: 1, single-turn data: 66765
         Temperature: 34
  1. The Logic-OR ... line is the encoder's own latched hardware status reported through the SF byte, not a software error, and is typically a battery alarm on a unit powered off without a VBAT backup supply. To clear it, keep the shaft stationary with the backup supply present and build once with T_FORMAT_RESET_ERRORS_AT_STARTUP set to 1 in source/t-format_polling_transfer.c. This uses the IDC transaction, which also zeroes the multi-turn count and so redefines the multi-turn reference at the current shaft position.

5. Support

Project Metadata

Board badge

Category badge

Peripheral badge

Toolchain badge

Questions regarding the content/correctness of this example can be entered as Issues within this GitHub repository.

Note: For more general technical questions regarding NXP Microcontrollers and the difference in expected functionality, enter your questions on the NXP Community Forum

Follow us on Youtube Follow us on LinkedIn Follow us on Facebook Follow us on Twitter

6. Release Notes

Version Description / Update Date
1.0 Initial release on Application Code Hub September 21th 2026

About

mcxa366-tamagawa-tformat-interface-using-flexio

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages