This design implements an EnDat3 receiver (subsequent electronics) on TI Sitara™ processors/microcontrollers. EnDat3 is the latest generation of the digital bidirectional serial interface for position encoders, offering enhanced safety features and higher data rates compared to EnDat 2.2.
Key improvements in EnDat3:
Only two differential signal pairs are required: bidirectional data. Clock is not needed here and data is bidirectional and asynchronous. Transfer between receiver and encoder at the physical layer is in accordance with RS485, with transceivers at both ends.
The position feedback system consists of a position encoder attached to a motor, up to 100 meters of cable which provides power and serial communication, and the receiver interface for the position encoder.
In the case of the Sitara™ processor/microcontroller, the receiver interface for the position encoder is just one function of a connected drive controller. The AM243x/AM261x/AM263Px provides, in addition to the resources for Industrial Ethernet and motor control applications, including on-chip ADCs, Delta Sigma demodulator for current measurement.
EnDat3 receiver on Sitara™ processor/microcontroller uses one PRU-ICSS slice. Data transmit and data receive signals from PRU of ICSS are available in Sitara™ processors/microcontrollers.
The EnDat3 receiver function is implemented on TI Sitara™ processors/microcontrollers.
Design is split into three parts:
Application is supposed to use the EnDat3 driver APIs to leverage EnDat3 functionality.
Default SDK example uses PRU-ICSSG0 PRU0 or PRU1 based on SysConfig selection.
| Parameter | Value | Details |
|---|---|---|
| Maximum Cable Length | 100m | Supported at 12.5 Mbps with proper cable quality |
| Data Transfer Rates | 12.5 Mbps, 25 Mbps | Configurable via RATE command |
| Initialization Rate | 12.5 Mbps | Default rate after HELLO command |
| Frame Types | HPF, LPH, LPF | Three frame types with individual CRC protection |
| CRC Algorithm | Custom | Polynomial: 0x1A7 |
| Encoding | Manchester | Self-clocking encoding with lookup table decoding |
| Oversample Ratio | 8x | 8x oversampling for robust data reception |
The PRU-ICSS provides hardware support for EnDat3 communication through its peripheral interface.
Refer to the device TRM for details on PRU-ICSS peripheral interface configuration.
The following section describes the firmware implementation of EnDat3 receiver on PRU-ICSS. The deterministic behavior of the 32-bit RISC core provides precise control for sampling external signals and generating timing-critical outputs. It makes use of 3 channel peripheral interface support in PRU for data transmission/reception.
The PRU-ICSS firmware supports the following configuration:
The firmware first initializes the local variables and configures the PRU-ICSS peripheral interface. Then it checks the operating mode: host trigger mode, periodic CMP mode, or periodic CAP mode.
The firmware operates in a state machine architecture with the following main phases:
Before executing the firmware, the Arm-based core needs to:
The firmware initialization sequence:
After initialization, the encoder must be initialized with the HELLO command:
EnDat3 uses Manchester encoding for robust data transmission:
Encoding (TX):
Decoding (RX):
The LUT is generated based on:
Command transmission sequence:
Reception sequence:
Preamble:
Postamble:
The firmware supports three operating modes: host trigger mode, periodic CMP mode, and periodic CAP mode.
Upon triggering (from any mode), the transmit data is set up based on the command code and the data is transmitted. The firmware then waits until receiving all frames from the encoder. CRC verification is performed on all received frames and the interface is updated with the result. The firmware then waits for the next command trigger from the interface or IEP compare/capture event.
Host Trigger Mode: The firmware waits until a command has been triggered through the interface by the host application.
Following is the operation flow for host trigger mode:
Periodic CMP Mode (Compare Event Mode): In CMP mode, IEP timer compare event triggers position sampling. The firmware monitors the configured IEP compare event and automatically initiates EnDat3 transactions when the IEP timer counter matches the compare value. This enables fixed-rate periodic sampling.
Periodic CAP Mode (Capture Event Mode): In CAP mode, external signals trigger position sampling through IEP capture events. The capture event is triggered on the rising edge of the external input pulse, enabling event-driven position capture. Internal signals can also be mapped to IEP capture events via TIMESYNC/GPIOMUX router. Following is the operation flow for periodic mode:
Background communication uses a multi-cycle protocol:
LPH Status States:
Command Cycle Requirements:
Depending on LPH status, different numbers of command cycles are required:
| LPH Status | State | Cycles Required | Behavior |
|---|---|---|---|
| 0 | IDLE | 4 | Send request in 4 cycles, response in 4th cycle |
| 1 | RX_START | 6 | Send request for 2 NOP cycles, then send request acc. to IDLE state |
| 2 | RX_LAST | 5 | Send request for 1 NOP cycle, then send request acc. to IDLE state |
| 3 | BUSY | N/A | Wait, cannot send request |
The firmware uses precise delay cycles for timing-critical operations:
| Delay Parameter | Purpose | Typical Value |
|---|---|---|
| delay_tx_start_1 | Delay before TX preamble | Calculated based on PRU freq |
| delay_tx_start_2 | Delay before command transmission | Calculated based on PRU freq |
| delay_rx_start | Delay before RX enable | Calculated based on PRU freq |
| delay_rx_to_tx | Turnaround time RX to TX | Calculated based on PRU freq |
| delay_timeout | Timeout for encoder response | Calculated based on PRU freq |
All delay values are computed by R5F driver based on actual PRU frequency to ensure timing accuracy across different clock configurations.
The physical data transmission in EnDat3 is done using RS-485 standard. The data is transmitted as differential signals using RS485 between the EnDat3 receiver and the encoder. The design uses differential signal pairs for bidirectional data.
EnDat3 receiver and encoder are connected using RS-485 transceivers. Data is transmitted differentially over RS-485 with advantages of high noise immunity and long-distance transmission capabilities.
| Pin name | Signal name | Function |
|---|---|---|
| PRG<k>_PRU<n>_GPO0 | pru<n>_endat3_0_clk | Channel 0 clock |
| PRG<k>_PRU<n>_GPO1 | pru<n>_endat3_0_out | Channel 0 transmit |
| PRG<k>_PRU<n>_GPO2 | pru<n>_endat3_0_out_en | Channel 0 transmit enable |
| PRG<k>_PRU<n>_GPI13/PRG<k>_PRU<n>_GPI9 | pru<n>_endat3_0_in | Channel 0 receive |
| PRG<k>_PRU<n>_GPO3 | pru<n>_endat3_1_clk | Channel 1 clock |
| PRG<k>_PRU<n>_GPO4 | pru<n>_endat3_1_out | Channel 1 transmit |
| PRG<k>_PRU<n>_GPO5 | pru<n>_endat3_1_out_en | Channel 1 transmit enable |
| PRG<k>_PRU<n>_GPI14/PRG<k>_PRU<n>_GPI10 | pru<n>_endat3_1_in | Channel 1 receive |
| PRG<k>_PRU<n>_GPO6 | pru<n>_endat3_2_clk | Channel 2 clock |
| PRG<k>_PRU<n>_GPO12/PRG<k>_PRU<n>_GPO7 | pru<n>_endat3_2_out | Channel 2 transmit |
| PRG<k>_PRU<n>_GPO8 | pru<n>_endat3_2_out_en | Channel 2 transmit enable |
| PRG<k>_PRU<n>_GPI11 | pru<n>_endat3_2_in | Channel 2 receive |
| Pin name | Signal name | Function |
|---|---|---|
| PRG0_PRU1_GPO0 | pru1_endat3_0_clk | PRU1 Channel 0 clock |
| PRG0_PRU1_GPO1 | pru1_endat3_0_out | PRU1 Channel 0 transmit |
| PRG0_PRU1_GPO2 | pru1_endat3_0_out_en | PRU1 Channel 0 transmit enable |
| PRG0_PRU1_GPI13 | pru1_endat3_0_in | PRU1 Channel 0 receive when SA mux selection is enabled (ICSSG_SA_MX_REG[7] G_MUX_EN = 1) |
| GPIO Pin (GPIO1_78/C16) | ENC0_EN | Enable encoder voltage in Axis 1 of BP (Fix this pin to high with SoC GPIO mode) |
The EnDat3 software is organized into three layers:
The driver provides comprehensive APIs for EnDat3 communication:
Initialization APIs:
endat3_init() - Initialize EnDat3 interfaceendat3_set_operating_mode() - Configure operating mode (host trigger, periodic CMP, or periodic CAP)endat3_release_start_trigger() - Enable communicationendat3_clear_start_trigger() - Disable communicationCommand APIs:
endat3_set_foreground_op_code() - Set foreground commandendat3_set_background_op_code() - Set background commandendat3_set_expected_tx_frame_count() - Configure frame countendat3_set_bg_data() - Set background dataendat3_send_command() - Transmit commandendat3_receive_response() - Receive and parse responseData Access APIs:
endat3_get_hpf_data() - Get position data from HPFendat3_get_hpf_status() - Get HPF statusendat3_get_hpf_crc() - Get HPF CRCendat3_get_lph_status() - Get LPH statusendat3_get_lph_state() - Get background communication stateendat3_get_lpf_status() - Get LPF status for frame Nendat3_get_lpf_data() - Get LPF data for frame Nendat3_get_lpf_crc() - Get LPF CRC for frame NStatus Check APIs:
endat3_has_hpf_error() - Check HPF error flagendat3_has_hpf_warning() - Check HPF warning flagendat3_is_hpf_data_valid() - Check HPF data validityendat3_has_absolute_value() - Check absolute value availabilityendat3_is_busy() - Check if transfer in progressendat3_get_error_code() - Get detailed error codePeriodic Trigger APIs:
endat3_config_iep_cmp_event() - Configure IEP CMP event number for periodic CMP modeendat3_config_iep_cap_event() - Configure IEP CAP event number for periodic CAP modeendat3_config_periodic_mode() - Configure and start periodic trigger mode (example code)endat3_stop_periodic_mode() - Stop periodic trigger mode (example code)The driver provides comprehensive error detection and reporting:
Driver Error Codes:
ENDAT3_ERR_INVALID_HANDLE - Invalid handle or interfaceENDAT3_ERR_CHANNEL_CONFIG - Channel configuration failedENDAT3_ERR_DELAY_CONFIG - Delay configuration failedENDAT3_ERR_INVALID_CORE - Invalid PRU core specifiedENDAT3_ERR_CLOCK_CONFIG - Clock configuration failedENDAT3_ERR_SAMPLING_ERROR - Sampling error detectedENDAT3_ERR_LPF_CRC_FAIL - LPF CRC verification failedENDAT3_ERR_HPF_CRC_FAIL - HPF CRC verification failedENDAT3_ERR_LPH_CRC_FAIL - LPH CRC verification failedENDAT3_ERR_TIMEOUT - Communication timeoutENDAT3_ERR_RX_FAIL - Reception failedENDAT3_ERR_INVALID_PARAM - Invalid parameterProtocol Error Codes: Extracted from encoder response, with descriptive strings and recommended actions.