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

3D Hall (Magnetic sensor)

Michael_K
Level 2
10 replies posted 5 questions asked 10 sign-ins
Level 2

Hello everyone,

For one application I want to use 2 TLE493D Hall sensors.

Arduino 1.8.15

1. Some time ago I used a XMC 2Go with the TLE493D library v1.2 for fast prototyping and everything worked fine. Since there is an update to v1.3 it does not work anymore with the XMC 2Go.
Not even the minimal Cartesian example works anymore and I only get -266,24 for the X, Y and Z values.
Resetting the library to v1.2 did not work either.
What is the reason that it does not work anymore?

Michael_K_0-1637067367767.png

2. secondly I tried the Infineon TLx_generic_lib for the XMC also for Dave.
The problem here is that TLx493D used abstraction level, then it works, status message = 0 -> I2C_INT_SUCCESS
Example code here:

 

int main(void)
{
	// Initialize Kit
	UART_init();
	INT_init_ext_interrupts();
	I2C_INT_init();
	// please note that the value of status should be checked and properly handler
	int32_t status;
	TLx493D_data_frame_t frame;
	int16_t Bx_LSB, By_LSB, Bz_LSB, sensor_temperature_LSB;
	TLE493D_data_t sensor_state = {0} ;
	float bx, by, bz, temperature;
	TLE493D_AW2B6_reset_all();
	// power-cycle the sensor
	// On the 2Go Kit, the sensor may not be powered by default
	// Initialize the sensor
	status = TLx493D_init();
	// set operation mode to Master Control Mode
	status =  TLx493D_set_operation_mode(TLx493D_OP_MODE_MCM);
	// read a data frame
	status = TLx493D_read_frame(&frame);
	while (1U) {
		// read a data frame
		status = TLx493D_read_frame(&frame);
			// Copy Magnetic Field Intensity and temperature values in LSB format
			Bx_LSB = frame.x;
			By_LSB = frame.y;
			Bz_LSB = frame.z;
			sensor_temperature_LSB = frame.temp;
			bx = (float)(Bx_LSB) * TLE493D_B_MULT;
			by = (float)(By_LSB) * TLE493D_B_MULT;
			bz = (float)(Bz_LSB) * TLE493D_B_MULT;
			temperature = (float)(sensor_temperature_LSB - TLE493D_TEMP_OFFSET) * TLE493D_TEMP_MULT + TLE493D_TEMP_25;
	}
}

 

But if I use TLV493D/TLE493D/TLI493D-W2BW abstraction level, then I can't initialize the sensor. I get as status message the value 3 -> I2C_INT_NACK

 

	// Initialize the sensor
	status =  TLE493D_AW2B6_init(&sensor_state, TLE493D_AW2B6_I2C_A0_ADDR);
	// set operation mode to Master Control Mode
	status = TLE493D_AW2B6_set_operation_mode(&sensor_state, TLx493D_OP_MODE_MCM);
	// read a data frame
	status = TLE493D_AW2B6_read_frame(&sensor_state, &frame);

 

What is the reason? I only go by the example. I can change the address of the sensor only in the TLE493D-W2BW layer.  But if the initialization does not work, then the problem is somewhere else

Best Regards

Michael

 

0 Likes
4 Replies
severin9er
Employee
5 sign-ins First reply posted Welcome!
Employee

Hi Michael,

When the console output gives you only -266.24 values, this means, that the sensor is not responding to the I²C communication. This could have several reasons: for example: maybe it is not powered at all, or the wrong I²C address is used.

So for your hardware setup: can I assume you have directly attached the Shield2Go to the XMC2Go?

In order to get a clearer picture of what the problem might be, can you please answer following questions:

  • Is the second sensor already connected, and if yes, how? And which address types (-A0, -A1, -A2, -A3) do your sensors have?
  • Is the power LED at the Shield2Go on?
  • In your Arduino Sketch: Why do you use Pin 0 for powering the sensor? Do you have some custom circuit where you can control the sensor VDD via this Pin?

There were recently some updates to the Arduino Library which enable using multiple sensors. These changes will be released with the future version 1.4, but you can access the changes already via Github.
Even though this will probably not solve your issue with reading one sensor, it might help you for the next development steps when trying to address two sensors. Just download the .ZIP from: https://github.com/Infineon/TLE493D-3DMagnetic-Sensor and install it in the Arduino IDE, in order to have the latest bugfixes.

For your issues with the lower abstraction levels: 

  • have you setup the "sensor_state" correctly? Most importantly: do you set it to 1-byte-read?
  • Do you try to reconfigure the I²C-address here? If yes, can you try if it works when you only have one sensor connected and leave its address at A0?

@Michael_K wrote:

I can change the address of the sensor only in the TLE493D-W2BW layer.


There is probably a typo: do you mean TLE493D-W2B6 or TLI493D-W2BW?
But nevertheless, do I understand it correctly that changing the address of the sensor works in this layer, but reading the values afterwards still doesn't?

Sorry for answering your questions with that many counter-questions, but I hope, I can help you when having a clearer picture of what's going on.

Best Regards,
Severin

0 Likes
severin9er
Employee
5 sign-ins First reply posted Welcome!
Employee

Hi Michael,

When the console output gives you only -266.24 values, this means, that the sensor is not responding to the I²C communication. This could have several reasons: for example: maybe it is not powered at all, or the wrong I²C address is used.

So for your hardware setup: can I assume you have directly attached the Shield2Go to the XMC2Go?

In order to get a clearer picture of what the problem might be, can you please answer following questions:

Is the second sensor already connected, and if yes, how? And which address types (-A0, -A1, -A2, -A3) do your sensors have?
Is the power LED at the Shield2Go on?
In your Arduino Sketch: Why do you use Pin 0 for powering the sensor? Do you have some custom circuit where you can control the sensor VDD via this Pin?
There were recently some updates to the Arduino Library which enable using multiple sensors. These changes will be released with the future version 1.4, but you can access the changes already via Github.
Even though this will probably not solve your issue with reading one sensor, it might help you for the next development steps when trying to address two sensors. Just download the .ZIP from: https://github.com/Infineon/TLE493D-3DMagnetic-Sensor  and install it in the Arduino IDE, in order to have the latest bugfixes.

For your issues with the lower abstraction levels: 

have you setup the "sensor_state" correctly? Most importantly: do you set it to 1-byte-read?
Do you try to reconfigure the I²C-address here? If yes, can you try if it works when you only have one sensor connected and leave its address at A0?


@Michael_K wrote:

I can change the address of the sensor only in the TLE493D-W2BW layer.


There is probably a typo: do you mean TLE493D-W2B6 or TLI493D-W2BW?
But nevertheless, do I understand it correctly that changing the address of the sensor works in this layer, but reading the values afterwards still doesn't?
Sorry for answering your questions with that many counter-questions, but I hope, I can help you when having a clearer picture of what's going on.

Best Regards,
Severin

0 Likes
Michael_K
Level 2
10 replies posted 5 questions asked 10 sign-ins
Level 2

 

Hello Severin,

sorry for my late reply, but I missed the email that I got a reply.

I have connected the Shield2Go with the XMC2Go via wire cable. The sensor is a TLE493-W2B6 and I have one more PCB, which I soldered myself and there is a TLE493-A2B6 on it. But it is the same as the W2B6 except that it does not have these diagnostic functions.

 I don't think it's a problem with  the wiring, because it works with Infineons generic example library for the DAVE IDE, at least with one sensor and the "high level layer" and the Evaluation Kit Software for 3D Sensors from Infineon works too. If I swap the SDA with the SCL wire, the the software already doesn't work.

 

To answer your questions:

1. at the time I wrote my post, I have not connected a second sensor. All sensors have the address A0, so 0x35 or 0x6A. The red power LED is on. I tried some things and took as VDD the pin with 3,3 V or different other  IO pins.

Since I had the problems with the XMC2Go, I tried it now with an Arduino Nano and went through the Issues of Github 3D-Magnetic-Sensor-2GO repo through the issues. Without the Arduino lib for the TLE493D, I can write manually the MOD and Config registers and change the address of the sensors. Then it works. As I said, it worked some time ago also with the XMC2Go and now it doesn't work at all with the Arudino IDE when it comes toI2C, event if I'll try a different sensor like the MPU6050. But it can't be the board because it works under the DAVE IDE and the generic example lib for the TLE493D. Something might be broken in Arduino for the XMC series. I don't know.

To the generic Lib from Infineon:
have you setup the "sensor_state" correctly?
I followed the example code. There it was also "sensor_state" just declared and I tried to initialize it then later with 0. But I don't know if it is correct. 

If yes, can you try if it works when you only have one sensor connected and leave its address at A0?
I have also tried this, but it comes the same error.

I am using the  1-Byte read protocol

I tried to change the address to A1, but both did not work. Maybe it is really the "sensor_state" variable which is somehow declared wrong.

 

There is probably a typo: do you mean TLE493D-W2B6 or TLI493D-W2BW?

Changing the address already did not work. I get a NACK from the sensor.

I don't know if it's a bug, but shouldn't there be a "|"sign before the = operator? Because in the switch statement the address is written into the register variables with the |= operator and then it is overwritten in the next line.

 

data->regmap.MOD1 = TLE493D_AW2B6_MOD1_PR_1BYTE
| TLE493D_AW2B6_MOD1_CA_ENABLE
| TLE493D_AW2B6_MOD1_INT_DISABLE
| TLE493D_AW2B6_MOD1_MODE_MCM;

 

 

 

int32_t TLE493D_AW2B6_init(TLE493D_data_t *data, TLE493D_address_t i2c_addr)
{
	int32_t error = 0;


	if (NULL == data) {
		data = &(_local.data);
	}
	data->IIC_addr = i2c_addr;
	// prepare register
	data->regmap.MOD1 = 0;
	// needed to compute the FP bit
	data->regmap.MOD2 = 0;
	// set address bits to maintain current address
	switch (i2c_addr) {
		case TLE493D_AW2B6_I2C_A0_ADDR:
			data->regmap.MOD1 |= TLE493D_AW2B6_MOD1_IICadr_A0;
			break;
		case TLE493D_AW2B6_I2C_A1_ADDR:
			data->regmap.MOD1 |= TLE493D_AW2B6_MOD1_IICadr_A1;
			break;
		case TLE493D_AW2B6_I2C_A2_ADDR:
			data->regmap.MOD1 |= TLE493D_AW2B6_MOD1_IICadr_A2;
			break;
		case TLE493D_AW2B6_I2C_A3_ADDR:
			data->regmap.MOD1 |= TLE493D_AW2B6_MOD1_IICadr_A3;
			break;
	}
	/* Initial settings:
	 * 1-Byte read protocol
	 * Collision avoidance
	 * Interrupt disabled
	 * Master Control Mode
	 * */
	data->regmap.MOD1 = TLE493D_AW2B6_MOD1_PR_1BYTE
					 | TLE493D_AW2B6_MOD1_CA_ENABLE
					 | TLE493D_AW2B6_MOD1_INT_DISABLE
					 | TLE493D_AW2B6_MOD1_MODE_MCM;
	data->regmap.MOD1 |= (TLE493D_AW2B6_get_FP_bit(data) << TLE493D_AW2B6_MOD1_FP_POS);
	// write registers
	error = TLE493D_AW2B6_write_reg(data->IIC_addr,
					TLE493D_AW2B6_MOD1_REG,
					data->regmap.MOD1
	);

 

I will try to uninstall Arduino completly and reinstall it. Furthermore I will try to program it manually without the ready libs. Maybe it will help.

 

 Best Regards

Michael

0 Likes
severin9er
Employee
5 sign-ins First reply posted Welcome!
Employee

Hi Michael,

sorry for the late reply, I'm still working on this issue and trying to find a good solution.

You are absolutely right with the bug. I got in touch with the responsible persons for the generic C-library and they will fix it with the next update.

With the generic library, I guess, that you probably need to set the sensor_state correctly, than it will probably work.

I'm more focusing on the Arduino Library, there the problem is pretty annoying, as I always thought, the Library would work with XMC2Go+Shield2Go, and I'm pretty sure, I have already seen it working...
But now I have the same issues.

A problem with this Shield2Go is, that the VDD of the sensor cannot be controlled. So when powered up, the sensor sends interrupt pulses right away. When then the USIC interface on the XMC is configured to I²C and the sensor sends the pulse, then the XMC USIC hardware cannot handle this properly.

But this explanation does not entirely fit the symptoms.
Here are some (hardware) tests, that I performed in order to find the issue:

  • Changing the microcontroller: Using an XMC1100 Bootkit + Shield2Go Adapter ("MyIOT Adapter")
    • Result: It worked fine.
  • Putting a scope probe to SCL to see whats going on.
    • Suddenly it worked, which was really annoying as I couldn't see what's wrong without the probe.
  • Closing the solder jumper on the board -> connecting SCL to pin "INT/GPIO3"
    • Result: It works
  • Capacitor 20pF between SCL and GND
    • It worked as well.
  • And then I changed the 10K Pullups to 1K2
    • It worked again.

However, there needs to be a Software-fix as well, because it does work with the official Infineon GUI and also with the generic C drivers.

I will continue to work on this and let you know if I find anything else.

Best Regards,
Severin

0 Likes