tle5012b connected to Arduino MEGA

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User22040
Level 1
Level 1
I am trying to use TLE5012b rotation magnetometer to an Arduino MEGA board.

I cut the sensor from one of the TLE5012b Angle Sensor 2 Go kits, solder cables to the PCB holes
and then I connected it to the MEGA in the following order:

( I checked the TLE5012b Arduino libraries and I use the same PIN numbers used by the default options )
Arudino (SS - pin 53) ------ TLE5012 CSQ
Arudino (MOSI - pin 51) ------ TLE5012 CSQ
Arudino (CLK - pin 52) ------ TLE5012 SCK
Arudino (GND) ------ TLE5012 GND
Arudino (3.3 V) ------ TLE5012 VDD
I run this code (that is basically the libraries' angle reader sample) :


#include

Tle5012Ino Tle5012MagneticAngleSensor = Tle5012Ino();
errorTypes checkError = NO_ERROR;

void setup() {
delay(1000);
Serial.begin(9600);
while (!Serial) {};

checkError = Tle5012MagneticAngleSensor.begin();
Serial.print("checkerror: ");
Serial.println(checkError, HEX);

Serial.println("init done");
Serial.println("SS");
Serial.println(PIN_SPI_SS);
Serial.println("MOSI");
Serial.println(PIN_SPI_MOSI);
Serial.println("MISO");
Serial.println(PIN_SPI_MISO);
Serial.println("SCK");
Serial.println(PIN_SPI_SCK);
delay(1000);

}

errorTypes ch = NO_ERROR;
int16_t rawAnglevalue = 0;
void loop() {
double d = 0.0;

//ch = Tle5012MagneticAngleSensor.getAngleSpeed(d);
ch = Tle5012MagneticAngleSensor.getAngleValue(d, rawAnglevalue, UPD_low, SAFE_low);

Serial.println(ch,HEX);
Serial.println(d);

// remark this for even more speed
delay(10);
}


The sensor initialization function "begin()" is always return 1 as error code.
When the program runs.
getAngleValue()
. Error code always return FF and the angle value is always 0.

I checked the problem and it seems to be related with the Checksum.
So, I used a different version of the same function to avoid the Checksum.

ch = Tle5012MagneticAngleSensor.getAngleValue(d, rawAnglevalue, UPD_low, SAFE_low);


This function always return 0 as error code but the angle value and the raw value never change (always 0 )

It seems that it could be something I am missing to initialize or connect.
0 Likes
1 Reply
User22215
Level 1
Level 1
Hello Java311,
I am also interested in getting these devices working with Arduino devices (promicro probably in my case) and have been reading the data sheets.
I do not yet actually have a tle5012b to experiment with.
From the data sheet - Infineon-Angle_Sensor_TLE5012B-UM-v01_02-en-UM-v01_02-EN.pdf it seems to me that you wiring is not correct.
(a) you have nothing wired to the data pin of the 5012. I don't know if perhaps this is a typing error but you say:-
Arudino (MOSI - pin 51) ------ TLE5012 CSQ
This should surely be TLE5012 DATA
(b) Also, in order to get two way data communication the MOSI and the MISO pins of the Arduino SPI master (your Mega) must be connected together. Page 36 of the data sheet.

I have not looked at the code yet but the 5012 needs to have its registers set correctly each time it starts up. I presume the Begin function does this.
Also, the SPI compatibility of the SSC interface is a little strange since the MOSI and MISO are connected and as the datasheet says:-
When the sensor transmits data the master’s output pin (SDO pin) has to be switched to high ohmic.
Again, at the moment I can only assume that the code is doing this correctly.

I would be very interested to hear how your experiments are progressing.
Do you have some sort of scope to monitor the data lines?
cheers
Glyn Hodges
0 Likes