Sprui 35
Sprui 35
Module
User's Guide
1 Introduction ......................................................................................................................... 4
1.1 EnDat interface ........................................................................................................... 4
1.2 Abbreviations/Acronyms................................................................................................. 4
1.3 System Description ...................................................................................................... 4
1.4 C2000 EnDat Master Solution .......................................................................................... 5
1.5 EnDat22 Master Implementation Details .............................................................................. 6
2 PM EnDat22 Library .............................................................................................................. 7
2.1 PM EnDat22 Library Package Contents .............................................................................. 7
3 Module Summary ................................................................................................................. 7
3.1 PM EnDat22 Library Commands ....................................................................................... 7
3.2 PM EnDat22 Library Functions ......................................................................................... 8
3.3 Data Structures ........................................................................................................... 9
3.4 Details of Function Usage ............................................................................................. 10
4 Using PM_ENDAT22 Library ................................................................................................ 28
4.1 Adding EnDat22 Lib to the Project ................................................................................... 28
4.2 Steps for Initialization .................................................................................................. 29
4.3 Using the Library Functions ........................................................................................... 31
5 Resource Requirements ...................................................................................................... 33
6 Test Report ........................................................................................................................ 33
7 FAQs ................................................................................................................................ 34
8 References ........................................................................................................................ 34
List of Figures
1 Industrial Servo Drive With EnDat 2.2 Position Encoder Interface .................................................... 5
2 EnDat Implementation Diagram Inside TMS320F28379D ............................................................. 6
3 Compiler Options for a Project Using PM EnDat22 Library .......................................................... 28
4 Adding PM EnDat22 Library to the Linker Options in CCS Project .................................................. 29
List of Tables
1 Abbreviations/Acronyms .................................................................................................... 4
2 Commands Supported ..................................................................................................... 7
3 PM EnDat22 Library Functions ............................................................................................ 8
4 Module interface Definition ................................................................................................ 10
5 Summary of Function Details ............................................................................................. 10
6 Resource Requirements ................................................................................................... 33
7 Test Report .................................................................................................................. 33
1 Introduction
1.2 Abbreviations/Acronyms
Table 1. Abbreviations/Acronyms
Type Description
C28x Refers to devices with the C28x CPU core
CLB Configurable Logic Block
CRC Cyclic Redundancy Check
EnDat22 2.2 version of EnDat Position encoder interface protocol by Heidenhain
EnDat21 2.1 version of EnDat Position encoder interface protocol by Heidenhain
Position Manager – Foundation hardware and software on C28x devices for position encoder
PM
interfaces
PM_endat22 Prefix used for all the library functions
SPI Serial Peripheral Interface
Subsequent Electronics EnDat Master implementation
Figure 1. Industrial Servo Drive With EnDat 2.2 Position Encoder Interface
The position encoder with EnDat 2.2 is connected to the subsequent electronics, such as an EnDat
Master implemented in an MCU, through a single, 8-wire shielded cable, as shown in Figure 1. Below are
details of each of the eight wires used for communication.
• Two wires for CLOCK+/CLOCK- transmitted in differential format
• Two wires for DATA+/DATA- transmitted in differential format
• Two wires (Up, Un) are used for the encoder power supply and ground
• Two wires (Up*, Un*) are used for battery buffering or for parallel power supply lines to reduce the
cables losses.
ENDAT_CLK GPIO6
SPICLK GPIO7
INPUT
CLB
XBAR
Interface
Block
TxEn OUTPUT GPIO34 ENDAT_DIR
XBAR
SPICLKB GPIO26
Test Setup
SPISMOB GPIO24 ENDAT_DIN
C28x SPI-B
CPU Slave SPISOMIB GPIO25 ENDAT_DOUT
SPISTEB GPIO27
GND
TMS320F28337D GPIO32
PWR CTL
• CLB also generates the direction control signal for data line transceiver. This signal is needed to
change the direction of the data line, after sending the mode command from subsequent electronics, to
receive the data from the encoder.
• CLB also monitors the SPISIMO signal, as needed, for detecting the start pulse and adjusts the phase
of the receive clock accordingly.
• CPU configures CLB to generate continuous clocking for the Encoder while waiting for the Start pulse
from Encoder.
• CPU configures CLB to generate a predefined number of clock pulses needed for the SPI (as per the
current command requirements, and continuous clocking for SPI is disabled while waiting for Start
pulse from encoder).
• CLB also provides hooks to perform cable propagation delay compensation via library functions.
More details on various library functions provided and their usage can be found in the reminder of this
document. For more details on usage and establishing basic communication with the Encoder, see the
examples for using the PM EnDat22 library.
2 PM EnDat22 Library
3 Module Summary
This section describes the contents of PM_endat22_Include.h, the include file for using the EnDat22
library.
(1)
Implies that the CPU cycle data depends on the Encoder under test as well as the commands and data being used along with certain
functions. These numbers could vary significantly depending on the command and corresponding data, additional data, and so forth.
} ENDAT_DATA_STRUCT;
PM_endat22_generateCRCTable — ................................................................................................ 11
PM_endat22_getCrcPos — ........................................................................................................... 12
PM_endat22_getCrcTest — .......................................................................................................... 13
PM_endat22_getCrcNorm — ......................................................................................................... 14
PM_endat22_setupCommand — .................................................................................................... 16
PM_endat22_receiveData — ......................................................................................................... 19
PM_endat22_startOperation — ...................................................................................................... 24
PM_endat22_setupPeriph — ......................................................................................................... 25
PM_endat22_setFreq — ............................................................................................................... 26
PM_endat22_getDelayCompVal — ................................................................................................. 27
PM_endat22_generateCRCTable
Directions This function generates table of 256 entries for a given CRC polynomial (polynomial)
with specified number of bits (nBits). Generated tables are stored at the address
specified by pTable.
Definition void PM_endat22_generateCRCTable(uint16_t nBits, uint16_t polynomial, uint16_t
*pTable)
Parameters
Input
nBits Number of bits of the given polynomial
polynomial Polynomial used for CRC calculations
pTable Pointer to the table where the CRC table values are stored
Return
None
PM_endat22_getCrcPos
Description To get the CRC of each byte, calculate the 5-bit CRC of a message buffer by using the
lookup table. This function should be used for calculating CRC of the position data.
• Encoder send position values (EnDat 2.1)
• Encoder send position values (EnDat 2.2)
Definition uint32_t PM_endat22_getCrcPos(uint32_t total_clocks,uint32_t endat22,uint32_t
lowpos,uint32_t highpos,
uint32_t error1,uint32_t error2, uint16_t *crc_table);
Parameters
Input
total_clocks Word 13 of the parameter area of the encoder manufacturer. Number of clock pulses for transfer of position value.
endat22 1 for EnDat22, 0 for EnDat21 position CRC
lowpos Lower 32 bits of the position data
highpos Upper 32 bits of the position data
error1 Error1 status received in EnDat21
error2 Error2 status received in EnDat22
crc_table Pointer to the table where the CRC table values are stored
Return
crc 5-bit CRC value calculated
Example Code:
Val = PM_endat22_setupCommand(ENCODER_SEND_POSITION_VALUES, 0, 0, 0);
PM_endat22_startOperation();
while (endat22Data.dataReady != 1) {}
Val = PM_endat22_receiveData(ENCODER_SEND_POSITION_VALUES, 0);
crc5_result1 = PM_endat22_getCrcPos(endat22Data.position_clocks, 0,
endat22Data.position_lo, endat22Data.position_hi, endat22Data.error1,
endat22Data.error2, table1);
PM_endat22_getCrcTest
Description To get the CRC of each byte, calculate the 5-bit CRC of a message buffer by using the
lookup table. This function should be used for calculating CRC of the Test data.
• Encoder send test values
Definition uint32_t PM_endat22_getCrcTest(uint32_t lowtest,uint32_t hightest, uint32_t
error1, uint16_t *crc_table);
Parameters
Input
lowtest Lower 32 bits of the test data
hightest Upper 32 bits of the test data
error1 Error1 status received in EnDat21
crc_table Pointer to the table where the CRC table values are stored
Return
crc 5-bit CRC value calculated
This function is exclusively used for calculating the CRC values for
ENCODER_SEND_TEST_VALUES command. This is EnDat2.1 mode command.
Example Code:
Val = PM_endat22_setupCommand(ENCODER_SEND_TEST_VALUES, 0x0, 0x0, 0);
PM_endat22_startOperation();
while (endat22Data.dataReady != 1) {}
Val = PM_endat22_receiveData(ENCODER_SEND_TEST_VALUES, 0);
crc5_result1 = PM_endat22_getCrcTest(endat22Data.test_lo,
endat22Data.test_hi,
endat22Data.error1, table1);
PM_endat22_getCrcNorm
Description To get the CRC of each byte, calculate the 5-bit CRC of a message buffer by using the
lookup table. This function should be used for calculating CRC for the following
commands:
• Selection of memory area
• Encoder receive parameter
• Encoder send parameter
• Encoder receive reset
• Encoder receive test command
• Additional data (EnDat 2.2)
Definition uint32_t PM_endat22_getCrcNorm (uint32_t param8,uint32_t param16, uint16_t
*crc_table);
Parameters
Input
param8 Typically 8-bit Address or MRS code, and so forth, depending on the command
param16 Typically16-bit Data or Acknowledgment, and so forth, depending on the command
crc_table Pointer to the table where the CRC table values are stored
Return
crc 5-bit CRC value calculated
For the details on where the data received, for different EnDat commands, is unpacked
and stored, see the PM_endat22_receiveData function. Below are few examples:
Define Endat Data structure during initialization.
ENDAT_DATA_STRUCT endat22Data;
• ENCODER_SEND_POSITION_VALUES_AND_RECEIVE_ERROR_RESET
crc5_result = PM_endat22_getCrcNorm(
endat22Data.additional_data1 >> 16, // top 8-
bits of additional data 1as param8
endat22Data.additional_data1, // Uses lower 16-
bits of this field as param16
table1); //crc table
PM_endat22_setupCommand
Description Setup a SPI and other modules for a given command to be transmitted. All the
transactions should start with this command. This function call sets up the peripherals for
upcoming EnDat transfer but does not actually perform any transfer or activity on the
EnDat interface. This function call populates the sdata array of ENDAT_DATA_STRUCT
with the data to be transmitted to the Encoder.
Definition void Val = PM_endat22_setupCommand(uint16_t command, uint16_t data1, uint16_t
data2, uint16_t nAddData);
Parameters
Input
command Mode command for the EnDat transfer to be done
data1 Typically18/6-bit Data or Address depending on the mode command
data2 Typically18/6-bit Data or Address depending on the mode command
nAddData Number of additional data enabled (0, 1 or 2 depending on the number of additional data enabled or not)
Return
If incorrect, command value is passed to this function, which would return zero. For all other cases function
Val
returns a value of one.
Below are few examples of how the PM_endat22_setupCommand function is used with
various mode commands. For further details, see the Heidenhain documentation.
Define Endat Data structure during initialization.
ENDAT_DATA_STRUCT endat22Data;
• SELECTION_OF_MEMORY_AREA
In order to send or read parameters, the memory area must first be selected. This is
done with the mode command, followed by a code for the memory area to be
selected: the Memory Range Select (MRS) code. The encoder acknowledges the
command.
Val = PM_endat22_setupCommand(
SELECTION_OF_MEMORY_AREA,
0xA1, // MRS code
0x5555, // Any
0); // No. of additional data – 0 for EnDat21 commands
• ENCODER_SEND_PARAMETER
This mode command is required for reading parameters of encoder. It is read from
the memory area that was last selected as being valid. The encoder acknowledges
the command.
Val = PM_endat22_setupCommand(
ENCODER_SEND_PARAMETER,
0xD, // Address
0x5555, // Any
0); // No. of additional data – 0 for EnDat21 commands
• ENCODER_RECEIVE_PARAMETER
This mode command is required for writing parameters of encoder. It is written to the
memory area that was last selected as being valid. The encoder acknowledges the
command.
Val = PM_endat22_setupCommand(
ENCODER_RECEIVE_PARAMETER,
0xA1, // Address
0x5555, // Parameters
0); // No. of additional data – 0 for EnDat21 commands
• ENCODER_RECEIVE_RESET
This mode command is required for executing encoder reset.
Val = PM_endat22_setupCommand(
ENCODER_RECEIVE_RESET,
0xA1, // Any
0x5555, // Any
0); // No. of additional data – 0 for EnDat21 commands
• ENCODER_SEND_POSITION_VALUES
The following mode command requests position values without additional data.
Val = PM_endat22_setupCommand(
ENCODER_SEND_POSITION_VALUES,
0x0, // Not applicable
0x0, // Not applicable
0); // No. of additional data – 0 for EnDat21 commands
• ENCODER_RECEIVE_TEST_COMMAND
This command is used as first step in interrogating the test values. Encoder receive
test command sent along with the port address will to be interrogated for test values.
Val = PM_endat22_setupCommand(
ENCODER_RECEIVE_TEST_COMMAND,
0x0, // Port address
0x0, // Any
0); // No. of additional data – 0 for EnDat21 commands
• ENCODER_SEND_TEST_VALUES
The following mode is necessary to interrogate test values.
Val = PM_endat22_setupCommand(
ENCODER_SEND_TEST_VALUES,
0x0, // Not applicable
0x0, // Not applicable
0); // No. of additional data – 0 for EnDat21 commands
• ENCODER_SEND_POSITION_VALUES_WITH_ADDITIONAL_DATA
This mode command can be used to request additional data, such as diagnostic
values, commutating values, and acceleration values etc. See the encoder
specifications to determine which additional data are supported by the encoder. This
information is also saved in the encoder memory for parameters according to EnDat
2.2 (word 0 and word 1).
Val = PM_endat22_setupCommand(
ENCODER_SEND_POSITION_VALUES_WITH_ADDITIONAL_DATA,
0x0, // Not applicable
0x0, // Not applicable
0); // No. of additional data (0, 1 or 2 depending on no.of
additional data enabled)
• ENCODER_SEND_POSITION_VALUES_AND_SELECTION_OF_THE_MEMORY_A
REA
This mode command is necessary in order to request a position value and to select
the memory area or block address in the same cycle.
Val = PM_endat22_setupCommand(
ENCODER_SEND_POSITION_VALUES_AND_SELECTION_OF_THE_MEMORY_AREA,
0x0, // MRS code
0x0, // Block address
0); // No. of additional data (0, 1 or 2 depending on no.of
additional data enabled)
• ENCODER_SEND_POSITION_VALUES_AND_RECEIVE_PARAMETER
This mode command is necessary in order to request a position value and write
parameters in the same cycle.
Val = PM_endat22_setupCommand(
ENCODER_SEND_POSITION_VALUES_AND_RECEIVE_PARAMETER,
0x0, // Address
0x0, // Parameters
0); // No. of additional data (0, 1 or 2 depending on no.of
additional data enabled)
• ENCODER_SEND_POSITION_VALUES_AND_SEND_PARAMETER
This mode command is necessary if you want to request a position value and in the
same cycle send parameters necessary for read access.
Val = PM_endat22_setupCommand(
ENCODER_SEND_POSITION_VALUES_AND_SEND_PARAMETER,
0x0, // Address
0x0, // Any
0); // No. of additional data (0, 1 or 2 depending on no.of
additional data enabled)
• ENCODER_SEND_POSITION_VALUES_AND_RECEIVE_TEST_COMMAND
This mode command is necessary in order to request position values and write a test
command in the same cycle.
Val = PM_endat22_setupCommand(
ENCODER_SEND_POSITION_VALUES_AND_RECEIVE_TEST_COMMAND,
0x0, // Port address
0x0, // Any
0); // No. of additional data (0, 1 or 2 depending on no.of
additional data enabled)
• ENCODER_SEND_POSITION_VALUES_AND_RECEIVE_ERROR_RESET
This mode command is necessary in order to request position values and reset errors
in the same cycle.
Val = PM_endat22_setupCommand(
ENCODER_SEND_POSITION_VALUES_AND_RECEIVE_ERROR_RESET,
0x0, // Any
0x0, // Any
0); // No. of additional data (0, 1 or 2 depending on no.of
additional data enabled)
• ENCODER_RECEIVE_COMMUNICATION_COMMAND
This mode command is necessary to send communication data. After the address
has been assigned with the "Write parameters" mode command, all other mode
commands for data exchange can be used. Only the encoder with the previously
selected address reacts to the following mode commands, until a new address is
given.
Val = PM_endat22_setupCommand(
ENCODER_RECEIVE_COMMUNICATION_COMMAND,
0x0, // Address
0x0, // Instructions
0); // Zero
PM_endat22_receiveData
Description Function for unpacking and populating the EnDat data structure with the data received
from Encoder. This function will be called when the data from Encoder is available in the
SPI data buffer and transferred to rdata array of ENDAT_DATA_STRUCT. Upon the
function call, received data is unpacked as per the current command and unpacked
results are stored accordingly.
NOTE: The format for transfer of position values varies in length depending on
the encoder model. The number of clock pulses required for transferring
the position value (without mode, start, error or CRC bits) must be read
from the encoder manufacturer’s memory area. This information should
be stored in ndat22Data.position_clocks. Encoder transmits the position
value with LSB first. The values stored in endat22Data.position_hi and
endat22Data.position_lo however are already bit reversed and right
justified. This is applicable to all the commands that receive position
information in both EnDat21 and EnDat22 formats. For further details,
see the Heidenhain documentation.
Parameters
Input
Mode command for the EnDat transfer done. This function should be called with the same mode command that
command
was used to initiate the transfer.
nAddData Number of additional data enabled (0, 1 or 2 depending on the number of additional data enabled or not)
Return
If the incorrect command value is passed to this function it will return zero. For all other cases, function returns a
val
value of one.
Below are few examples of how the PM_endat22_setupData function is used with
various mode commands. For further details, see the Heidenhain documentation.
Define Endat Data structure during initialization.
ENDAT_DATA_STRUCT endat22Data;
• SELECTION_OF_MEMORY_AREA
In order to send or read parameters, the memory area must first be selected. This is
done with the mode command, followed by a code for the memory area to be
selected: the Memory Range Select (MRS) code. The encoder acknowledges the
command.
Val = PM_endat22_receiveData(
SELECTION_OF_MEMORY_AREA,
0); // No. of additional data – 0 for EnDat21 commands
Unpacked data stored in EnDat Data structure for this command:
endat22Data.address = Any
endat22Data.data = Anyt
endat22Data.data_crc = CRC for the received data
• ENCODER_SEND_POSITION_VALUES
The following mode command requests position values without additional data.
Val = PM_endat22_receiveData(
ENCODER_SEND_POSITION_VALUES,
0); // No. of additional data – 0 for EnDat21 commands
Unpacked data stored in EnDat Data structure for this command:
• ENCODER_RECEIVE_TEST_COMMAND
This command is used as first step in interrogating the test values. The Encoder
receive test command sent along with the port address will to be interrogated for test
values.
Val = PM_endat22_receiveData(
ENCODER_RECEIVE_TEST_COMMAND,
0); // No. of additional data – 0 for EnDat21 commands
Unpacked data stored in EnDat Data structure for this command:
• ENCODER_SEND_POSITION_VALUES_WITH_ADDITIONAL_DATA
This mode command can be used to request additional data, such as diagnostic
values, commutating values, and acceleration values etc. See the encoder
specifications to determine which additional data are supported by the encoder. This
information is also saved in the encoder memory for parameters according to EnDat
2.2 (word 0 and word 1).
Val = PM_endat22_receiveData(
ENCODER_SEND_POSITION_VALUES_WITH_ADDITIONAL_DATA,
0); // No. of additional data (0, 1 or 2 depending on no.of
additional data enabled)
Unpacked data stored in EnDat Data structure for this command:
• ENCODER_SEND_POSITION_VALUES_AND_SELECTION_OF_THE_MEMORY_A
REA
This mode command is necessary in order to request a position value and to select
the memory area or block address in the same cycle.
Val = PM_endat22_receiveData(
ENCODER_SEND_POSITION_VALUES_AND_SELECTION_OF_THE_MEMORY_AREA,
0); // No. of additional data (0, 1 or 2 depending on no.of
additional data enabled)
Unpacked data stored in EnDat Data structure for this command:
• ENCODER_SEND_POSITION_VALUES_AND_RECEIVE_TEST_COMMAND
This mode command is necessary in order to request position values and write a test
command in the same cycle.
Val = PM_endat22_receiveData(
ENCODER_SEND_POSITION_VALUES_AND_RECEIVE_TEST_COMMAND,
0); // No. of additional data (0, 1 or 2 depending on no.of
additional data enabled)
Unpacked data stored in EnDat Data structure for this command:
PM_endat22_startOperation
Description This function initiates the EnDat transfer. This function should only be called after
PM_endat22_setupCommand. Hence the PM_endat22_startOperation function kick
starts the EnDat transaction that was set up earlier by PM_endat22_setupCommand.
Note that the setup up and start operation are separate function calls. User can setup
the EnDat transfer when needed and start the actual transfer using this function call, as
needed, at a different time.
Definition void PM_endat22_startOperation(void);
Parameters
Input
None
Return
None
This function clears the endat22Data.dataReady flag zero when called. This flag should
subsequently be set by the SPI Interrupt service routine when the data is received from
the encoder. You can poll for this flag to know if the data from the encoder is
successfully received after the PM_endat22_startOperation function call.
PM_endat22_setupPeriph
Description Setup for SPI, CLB and other interconnect XBARs for EnDat are performed with this
function during system initialization. This function needed to be called after every system
reset. No EnDat transactions will be performed until the setup peripheral function is
called.
Definition void PM_endat22_setupPeriph (void);
Parameters
Input
None
Return
None
This function clears the endat22Data.dataReady flag zero when called. This flag should
subsequently be set by the SPI Interrupt service routine when the data is received from
the encoder. You can poll for this flag to know if the data from the encoder is
successfully received after the PM_endat22_startOperation function call.
PM_endat22_setFreq
Description Function to set the EnDat clock frequency. EnDat transfers typically start with low
frequency during initialization and switch to higher frequency during runtime.
Typical frequencies used during initialization and runtime:
• Used during initialization (~200 KHz)
• Used during application (~8 MHz) C2000 EnDat implementation currently supports 8
MHz only, irrespective of cable length.
Definition void PM_endat22_setFreq(uint32_t Freq_us);
Endat Clock Frequency = SYSCLK/(4* Freq_us
Parameters
Input
Freq_us: A clock divider for the system clock sets Endat Clock Frequency = SYSCLK/(4* Freq_us)
Return
None
//during runtime
PM_endat22_setFreq(ENDAT_RUNTIME_FREQ_DIVIDER);
PM_endat22_getDelayCompVal
Description This function is used while performing delay compensation when long cables are used.
This function returns the measured delay from rising edge of EnDat Clock to the start bit
received. Please refer to examples provided on usage and performing delay
compensation. Refer to EnDat documentation from Heidenhain for cable delays and
propagation requirements.
Definition uint16_t PM_endat22_getDelayCompVal(void);
Parameters
Input
Freq_us: A clock divider for the system clock sets Endat Clock Frequency = SYSCLK/(4* Freq_us)
Return
None
endat22Data.delay_comp = delay;
NOTE: Propagation delay should be measured using this function multiple times
and the average value needs to be update into endat22Data.delay_comp
field before switching to higher frequency operation. For delay
compensation, see the TI provided examples on usage of this function.
NOTE: Note that the exact location may vary depending on where controlSUITE is installed and
which other libraries the project is using.
2. Figure 4 shows the changes to the linker options that are required to include the EnDat22 library.
NOTE: Note that the exact location may vary depending on where controlSUITE is installed and
which other libraries the project is using.
4. Set the SPI instance to be used for EnDat communication. For usage on TMDXIDDK379D, the SPI
instance has to be set to SpiB and enable the SpiB receive FIFO interrupt.
endat22Data.spi = &SpibRegs;
PieVectTable.SPIB_RX_INT = &spiRxFifoIsr;
PieCtrlRegs.PIECTRL.bit.ENPIE = 1; // Enable the PIE block
PieCtrlRegs.PIEIER6.bit.INTx3 = 1; // Enable PIE Group 6, INT 9
IER = 0x20; // Enable CPU INT6
EINT;
NOTE: Alternatively, users can also poll for the Interrupt Flag and not necessarily use interrupt.
Make sure the SPIRXFIFO contents are copied into endat22Data.rdata after the flag is set.
This is required to be executed before calling PM_endat22_receiveData function. Also,
interrupt flag needs to be cleared to get the SPI ready for next EnDat transaction.
GpioCtrlRegs.GPAGMUX2.bit.GPIO24 = 1;
GpioCtrlRegs.GPAGMUX2.bit.GPIO25 = 1;
GpioCtrlRegs.GPAGMUX2.bit.GPIO26 = 1;
GpioCtrlRegs.GPAGMUX2.bit.GPIO27 = 1;
// Generate table for poly 1 and generated tables are placed in table1
PM_endat22_generateCRCTable(NBITS_POLY1, POLY1, table1);
7. Read the Encoder position values with additional data and selection of memory area - EnDat22
command,
Val = PM_endat22_setupCommand(ENCODER_SEND_POSITION_VALUES_AND_SELECTION_OF_THE_MEMORY_AREA,
0xA1, 0, 0);
PM_endat22_startOperation();
while (endat22Data.dataReady != 1) {}
Val = PM_endat22_receiveData(ENCODER_SEND_POSITION_VALUES_AND_SELECTION_OF_THE_MEMORY_AREA, 0);
crc5_result1 = PM_endat22_getCrcPos(endat22Data.position_clocks, 1,
endat22Data.position_lo, endat22Data.position_hi, endat22Data.error1, endat22Data.error2,
table1);
10. Read the Encoder position values with additional data EnDat22 command.
Val = PM_endat22_setupCommand(ENCODER_SEND_POSITION_VALUES_WITH_ADDITIONAL_DATA, 0, 0, 2);
PM_endat22_startOperation();
while (endat22Data.dataReady != 1) {}
Val = PM_endat22_receiveData(ENCODER_SEND_POSITION_VALUES_WITH_ADDITIONAL_DATA, 2);
crc5_result1 = PM_endat22_getCrcPos(endat22Data.position_clocks, 1,
endat22Data.position_lo, endat22Data.position_hi, endat22Data.error1, endat22Data.error2,
table1);
5 Resource Requirements
The resources of the MCU (see Table 6) are consumed by the PM EnDat22 Library for implementing
EnDat interface.
6 Test Report
Table 7 lists tests with various types of encoders; cable lengths are performed at Heidenhain Labs. Tests
include basic command set exercising and reading position values, with additional data if applicable.
(1)
Cable lengths up to 100m have also been tested with some of the encoders. Users can deploy longer cable lengths, perform delay
compensation, switch to higher EnDat clock frequencies and perform tests.
7 FAQs
1. Question: Why is the position information not received or received incorrectly?
Answer: Perform or cross check the following:
• Make sure the Power-On procedure, specific to the Encoder, is used properly.
• Check for Encoder error messages and warnings
• Clear the Errors and Warnings if any, and perform Encoder Reset
• Check CRC of the received position data
For further help, see the Heidenhain documentation.
2. Question: What are the limitations of the EnDat22 implementation with this library?
Answer: While using the Endat22 library, see the Key things to note ... bulleted list in Section 1.4.
3. Question: I have encountered a CRC failure. What could be the reason for this?
Answer: For details, see the Error Type I, II, III from Heidenhain Endat documentation. CRC errors
can also occur due to noise in transmission path.
4. Question: How is the EnDat22 interface implemented on the TMS320F28379D devices?
Answer: For details, see Section 1.4.
5. Question: Does TI share the source for the PM EnDat22 library to customers?
Answer: TI does not share the source code with customers. For specific requests, contact the TI sales
team.
6. Question: Does TI provide application level interface functions for EnDat22?
Answer: Basic usage examples are provided along with the library. The example has high-level
application layer functions for initialization, running full command set, setting and reading parameters,
performing cable propagation delay compensation, enabling additional data, checking CRC for various
types of received data, and so forth, which are sufficient for most of the applications. Any additional
application layer functionality should be developed by using the basic driver interface commands
provided in the PM EnDat22 Library.
8 References
• Power Supply Reference design for EnDat 2.2 encoder interfaces can be obtained from Texas
Instruments (TIDA-00172): http://www.ti.com/tool/TIDA-00172
• Documentation from Heidenhain:
– Bidirectional Synchronous-Serial Interface for Position Encoders
– EnDat Application notes
• C2000 DesignDRIVE Development Kit for Industrial Motor Control - TMDXIDDK379D:
– DesignDRIVE Development Kit IDDK Hardware Reference Guide (SPRUI23)
– DesignDRIVE Development Kit IDDK User’s Guide (SPRUI24)
– Using Position Manager EnDat22 Library on IDDK Hardware User's Guide (SPRUI34)
Texas Instruments Incorporated (‘TI”) technical, application or other design advice, services or information, including, but not limited to,
reference designs and materials relating to evaluation modules, (collectively, “TI Resources”) are intended to assist designers who are
developing applications that incorporate TI products; by downloading, accessing or using any particular TI Resource in any way, you
(individually or, if you are acting on behalf of a company, your company) agree to use it solely for this purpose and subject to the terms of
this Notice.
TI’s provision of TI Resources does not expand or otherwise alter TI’s applicable published warranties or warranty disclaimers for TI
products, and no additional obligations or liabilities arise from TI providing such TI Resources. TI reserves the right to make corrections,
enhancements, improvements and other changes to its TI Resources.
You understand and agree that you remain responsible for using your independent analysis, evaluation and judgment in designing your
applications and that you have full and exclusive responsibility to assure the safety of your applications and compliance of your applications
(and of all TI products used in or for your applications) with all applicable regulations, laws and other applicable requirements. You
represent that, with respect to your applications, you have all the necessary expertise to create and implement safeguards that (1)
anticipate dangerous consequences of failures, (2) monitor failures and their consequences, and (3) lessen the likelihood of failures that
might cause harm and take appropriate actions. You agree that prior to using or distributing any applications that include TI products, you
will thoroughly test such applications and the functionality of such TI products as used in such applications. TI has not conducted any
testing other than that specifically described in the published documentation for a particular TI Resource.
You are authorized to use, copy and modify any individual TI Resource only in connection with the development of applications that include
the TI product(s) identified in such TI Resource. NO OTHER LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE TO
ANY OTHER TI INTELLECTUAL PROPERTY RIGHT, AND NO LICENSE TO ANY TECHNOLOGY OR INTELLECTUAL PROPERTY
RIGHT OF TI OR ANY THIRD PARTY IS GRANTED HEREIN, including but not limited to any patent right, copyright, mask work right, or
other intellectual property right relating to any combination, machine, or process in which TI products or services are used. Information
regarding or referencing third-party products or services does not constitute a license to use such products or services, or a warranty or
endorsement thereof. Use of TI Resources may require a license from a third party under the patents or other intellectual property of the
third party, or a license from TI under the patents or other intellectual property of TI.
TI RESOURCES ARE PROVIDED “AS IS” AND WITH ALL FAULTS. TI DISCLAIMS ALL OTHER WARRANTIES OR
REPRESENTATIONS, EXPRESS OR IMPLIED, REGARDING TI RESOURCES OR USE THEREOF, INCLUDING BUT NOT LIMITED TO
ACCURACY OR COMPLETENESS, TITLE, ANY EPIDEMIC FAILURE WARRANTY AND ANY IMPLIED WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL
PROPERTY RIGHTS.
TI SHALL NOT BE LIABLE FOR AND SHALL NOT DEFEND OR INDEMNIFY YOU AGAINST ANY CLAIM, INCLUDING BUT NOT
LIMITED TO ANY INFRINGEMENT CLAIM THAT RELATES TO OR IS BASED ON ANY COMBINATION OF PRODUCTS EVEN IF
DESCRIBED IN TI RESOURCES OR OTHERWISE. IN NO EVENT SHALL TI BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL,
COLLATERAL, INDIRECT, PUNITIVE, INCIDENTAL, CONSEQUENTIAL OR EXEMPLARY DAMAGES IN CONNECTION WITH OR
ARISING OUT OF TI RESOURCES OR USE THEREOF, AND REGARDLESS OF WHETHER TI HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
You agree to fully indemnify TI and its representatives against any damages, costs, losses, and/or liabilities arising out of your non-
compliance with the terms and provisions of this Notice.
This Notice applies to TI Resources. Additional terms apply to the use and purchase of certain types of materials, TI products and services.
These include; without limitation, TI’s standard terms for semiconductor products http://www.ti.com/sc/docs/stdterms.htm), evaluation
modules, and samples (http://www.ti.com/sc/docs/sampterms.htm).
Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265
Copyright © 2017, Texas Instruments Incorporated