Angle (Magnetic sensor) Forum Discussions
(Reposting in the correct forum)
I'm using the TLE5012B over SPI(SSC) with the STM32H503CB microcontroller. I found the Arduino library here (https://github.com/Infineon/TLE5012-Magnetic-Angle-Sensor/tree/master) and found that by implementing the Platform Abstraction Layer, I could get the same functionality on any microcontroller, so I went ahead and began work on that for the above microcontroller. Primarily, I implemented the SPI sendReceive function, and tested that I could get angles correctly. Since I have the sensor mounted on the back of a motor with a magnet, I verified that rotating the magnet gets me fairly accurate readings to around 0.1 degrees.
Where I'm having issue is the CRC and safety word, but before worrying about the CRC, I noticed that the STAT nibble returned is not all 1s like it should be in the datasheet. The library calls this an INVALID_ANGLE_ERROR, but who knows if that's the issue.
I tried with a more deterministic example than reading an angle, and tried to follow exactly the example given in 5.2.4 on the CRC, where I tried to enable prediction. This involves sending the command "write to mod 2", which is 0x5081, and then the data "enable prediction", which is 0x0804. I expect only the safety word as a response. I got back the following safety word: 0xef13, or 0b1110111100010011. Now notice that the first three bits are 1, but the fourth is 0, hence the INVALID_ANGLE_ERROR response. You may also notice that the CRC is wrong ( it is supposed to be 0x89, not 0x13).
This has me stumped, since by all metrics the angle readings are coming back very accurately. I have evidence that I can write to the chip since I have been able to set the filter settings in MOD1 and noticed a significant decrease in the spread (min-max values when not moving the magnet).
I attached my entire stm32 project for completeness, but I'll try to put what I believe to be the most relevant information here.
Below is my "sendReceive" function, which is the core function used by the library to talk over SSC with the sensor.
// This function is used by the library (and me) to talk to the TLE5012B over SSC. It sends sent_data and waits for the sensor 130ns and then receives a response of a given length.
SPIC::Error_t SPIC::sendReceive(uint16_t* sent_data, uint16_t size_of_sent_data, uint16_t* received_data, uint16_t size_of_received_data){
uint8_t conv_sent_data[2*size_of_sent_data];
uint8_t conv_received_data[2*size_of_received_data];
for (int i = 0; i < size_of_sent_data; i++) {
conv_sent_data[i * 2] = (uint8_t)sent_data[i] & 0xFF; // Low byte
conv_sent_data[i * 2 + 1] = ((uint8_t) (sent_data[i] >> 8)) & 0xFF; // High byte
}
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_RESET);
HAL_SPI_Transmit(this->spi, conv_sent_data, size_of_sent_data, 100);
// Wait the required t_wr period
for (int i = 0; i < 32; i++){
asm("NOP");
}
HAL_SPI_Receive(this->spi, conv_received_data, size_of_received_data, 100);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0, GPIO_PIN_SET);
for (int i = 0; i < size_of_received_data; i++) {
received_data[i] = (conv_received_data[i * 2 + 1] << | conv_received_data[i * 2];
}
return OK;
}
Here I am trying to replicate the safety word response from the datasheet:
// This is copied from the user manual, 5.2.4
uint16_t write_to_mod2 = 0x5081; // Write to the mod2 register
uint16_t enable_prediction = 0x0804;
uint16_t set_prediction_data[2] = {write_to_mod2, enable_prediction};
uint16_t get_prediction_safety;
spic.sendReceive(set_prediction_data, 2, &get_prediction_safety, 1);
// The result, placed in get_prediction_safety, here has the wrong status and CRC values.
// Result here: 0xEF13
// Expected result: 0xFE89
Here is my SPI initialization function. I thought that this was all good since I could read angles from the sensor, but maybe I configured something wrong here?
/**
* @brief SPI2 Initialization Function
* @param None
* @retval None
*/
static void MX_SPI2_Init(void)
{
/* USER CODE BEGIN SPI2_Init 0 */
/* USER CODE END SPI2_Init 0 */
/* USER CODE BEGIN SPI2_Init 1 */
/* USER CODE END SPI2_Init 1 */
/* SPI2 parameter configuration*/
hspi2.Instance = SPI2;
hspi2.Init.Mode = SPI_MODE_MASTER;
hspi2.Init.Direction = SPI_DIRECTION_1LINE;
hspi2.Init.DataSize = SPI_DATASIZE_16BIT;
hspi2.Init.CLKPolarity = SPI_POLARITY_HIGH;
hspi2.Init.CLKPhase = SPI_PHASE_1EDGE;
hspi2.Init.NSS = SPI_NSS_SOFT;
hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32;
hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi2.Init.TIMode = SPI_TIMODE_DISABLE;
hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi2.Init.CRCPolynomial = 0x7;
hspi2.Init.NSSPMode = SPI_NSS_PULSE_DISABLE;
hspi2.Init.NSSPolarity = SPI_NSS_POLARITY_LOW;
hspi2.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA;
hspi2.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE;
hspi2.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE;
hspi2.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE;
hspi2.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE;
hspi2.Init.IOSwap = SPI_IO_SWAP_DISABLE;
hspi2.Init.ReadyMasterManagement = SPI_RDY_MASTER_MANAGEMENT_INTERNALLY;
hspi2.Init.ReadyPolarity = SPI_RDY_POLARITY_HIGH;
if (HAL_SPI_Init(&hspi2) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN SPI2_Init 2 */
/* USER CODE END SPI2_Init 2 */
}
Below are the relevant schematic snippets, basically just showing how the sensor is connected to the microcontroller. Hopefully nothing exciting there.
In case anyone is curious, I tried scaling down the BAUD rate to 976.562kbps (originally it was around 7.8Mbps), with no change. I thought anything under 8Mbps should work, but the datasheet wasn't super clear (it just said 8Mbps typical, with no min or max values).
That's all of the relevant bits I think.
Max
Show Less
Hello, Infineon Team :Currently we are using a program that communicates with the TLE5012BE1000 via the four SPI1 lines on the TC233 and the three SSC lines on the TLE5012BE1000, hoping to read the angle and fault information at an interrupt frequency of 20K. Currently the SPI communication of the TC233 is an interrupt, the spi interrupt communication baud rate is 4M, and the program is a multitasking program, but due to adding a read wait statement to the spi communication function, currently only one register in the adc interrupt can communicate with the TLE5012. However, due to the read wait statement added in the spi communication function, only one register of TLE5012 can be communicated with in the adc interrupt, and adding the statement of communicating with another register in the collaborative task will cause the whole program to be stuck. Currently my requirement is to read the angle value in the 20K adc interrupt, while still communicating with other registers of the TLE5012 in other tasks. Any help on this would be greatly appreciated.
smartconx_target@Q!w2e3r4t5y6u7i8o9p0||/t5/%E8%A7%92%E5%BA%A6-%E7%A3%81%E6%80%A7%E4%BC%A0%E6%84%9F%E5%99%A8/SPI-communication-error-between-TLE5012-and-TC233/td-p/699902
Show LessHello, Infineon team: We are currently using the TLE5012BE1000 for our application. Currently, the solution we are using is to communicate with the three SSC wires on the TLE5012BE1000 through the TLE5012BE1000. TC233 sends a command to the TLE5012BE1000 to capture the data on the bus through the oscilloscope, and found that there is response data, but in the return parameters of the iFXQSPI_spimaster_exchange () function, there is no data. The problem is currently I haven't found a good solution, can you help solve it; in addition, the TLE5012BE1000 captured by the oscilloscope sends the SPI data on the TC233 chip and the TC233's SPI configuration.
smartconx_target@Q!w2e3r4t5y6u7i8o9p0||/t5/%E8%A7%92%E5%BA%A6-%E7%A3%81%E6%80%A7%E4%BC%A0%E6%84%9F%E5%99%A8/SPI-communication-error-between-TLE5012-and-TC233/td-p/663394
Show LessHello, Infineon team: We are currently using the TLE5012BE1000 for our application. Currently, the solution we are using is to communicate with the four SPI1 wires on the TC233 and the three SSC wires on the TLE5012BE1000. Currently, the main chip can read information such as angle values, turn values, angular speed values, etc. through SPI. I still want to read the chip's fault information. If so, can it be read through the SPI method and can it help solve the problem Thank you very much;
smartconx_target@Q!w2e3r4t5y6u7i8o9p0||/t5/%E8%A7%92%E5%BA%A6-%E7%A3%81%E6%80%A7%E4%BC%A0%E6%84%9F%E5%99%A8/Read-the-fault-information-of-the-chip/td-p/684545
Show LessHi All,
Where can i find the IBIS model of TLE5012BE5000 for signal integrity analysis.
To be able to read the data from the register, the default value should be a forward increase of 0, and the flip starts and decreases at 7ffF, but even if you take the register value to 1, it's 128 °/s to calculate it. I don't think this value should be correct and I want to ask about the calculation method in this regard
smartconx_target@Q!w2e3r4t5y6u7i8o9p0||/t5/%E8%A7%92%E5%BA%A6-%E7%A3%81%E6%80%A7%E4%BC%A0%E6%84%9F%E5%99%A8/TLE5012B-E1000%E7%AE%97%E5%87%BA%E7%9A%84%E8%A7%92%E9%80%9F%E5%BA%A6%E4%B8%8D%E6%AD%A3%E7%A1%AE/td-p/670961
Show LessHi experts,
I'm looking for something similar to the magnetic rotation angle sensor ams AS5600.
It produces an analog output similar to that of a potentiometer.
Does infineon have it?
thank you.
Show Less第一:对单个的TLV493D-A1B6,上电是否需要初始化。初始化过程中涉及到发送0x00h,进行复位并重置寄存器,此时iic的频率要求是多少?
第二,初始化时,发送是否一定要发送0xFFh,对探测器进行释放。
第三,对单个的TLV493D-A1B6进行操作,地址是否是确定的的,直接进行操作就行了,不需要初始化流程。
第三,能否提供一下,FPGA的代码,进行参考一下。
Show LessHello Infineon, as shown in the datasheet, user need to check safety word , include "CRC" , the CRC value of safety word will compare with the calculation value by uC, if no equal, CRC error.
I got a problem in our product, there is 1 pcs abnormal product and it will perform as "CRC" error, we never found this problem in our product and we also found the error seems like not relate operating conditions.
The question is : could you please provide some suggestion to figure out the problem?
Show Less
在使用TLE5012时,定位精度误差接近0.8度,在步进电机微步定位时,正向停止,反向走微步时会丢失6-8个脉冲,走到第8或者8步时,会把丢失的脉冲一次性发出来,各位大神是否有解决方案