cancel
Showing results for 
Search instead for 
Did you mean: 

Why is the UID changing when accessed to? Also, what are the best ways to debug an I/O error?

FEste.1
Associate II

Hey guys and gals,

I have:

  • Bought the P-NUCLEO-53L3A2 Eval kit which includes: X-NUCLEO-53L3A2 expansion board and NUCLEO-F401RE;
  • Downloaded the sample code for single ToF acquisition;
  • Started to modify code for ToF multi acquisition.

Issues I have encountered:

  • When adding the LEFT and RIGHT ToFs ensure you solder them otherwise the XSHUT pin voltage might not work as intended and you might get an I/O error;
  • The code API documentation has some details not mentioned in the UM2778.pdf e.g. VL53LX_SetDistanceMode should be called after VL53LX_DataInit();
  • After setting the distance mode it does not change said distance mode;
  • device UID seems to change.

What I would need help or tips:

  • Why is the UID changing?
  • How do I properly set the distance mode?
  • When should I run the calibration functions?

The code used is attached. Oh, and I used the STM32Cube IDE just fyi.

Output log>

        VL53L1X Examples...

Setting XSHUT pin ON...

Waiting device to boot...

Reading device UID: 7555855411574540485

Setting Device Address to 0x52

Setting XSHUT pin OFF...

Setting XSHUT pin ON...

Waiting device to boot...

Reading device UID: 34401660361561757125

Setting Device Address to 0x53

Setting XSHUT pin OFF...

Setting XSHUT pin ON...

Waiting device to boot...

Reading device UID: 30870942771574540485

Setting Device Address to 0x54

Setting XSHUT pin OFF...

Setting XSHUT pin ON for ALL DEVICES...

XSHUT set for device UID: 536871480536871512

XSHUT set for device UID: 00

XSHUT set for device UID: 536871480536871512

Ranging loop starts

1342341161561363653 DISTANCE MODE: 1

1342341161561363653 DISTANCE MODE: 1

VL53LX_WaitDeviceBooted failed: error = -13

Thanks in advance,

Francisco

5 REPLIES 5
John E KVAM
ST Employee

looking at this, I'm wonderiing if you are failing to sent the I2C addresses correctly.

Each I2C address requires a read and a write addresses.

As shipped, the I2c address is 0x29 shifted to the left by 1 bit - and the LSB is the write/read bit.

So 29 becomes 0x52 and this is the WRITE adderess. Setting the device to READ you get 0x53.

You changed your addresses to 52, 53 and 54.

And those are too close together. 0x52 and 0x53 are the same address - one write, one read.

I generally use 0x62, 0x72, 0x82... but you can use 0x54, 0x56, 0x58.. if you want.

But just use even numbers please.

This expains the issue of the same UID. Which ever sensor wins the arbitration - which is random - will return a value.

But you are talking to two sensors at once.

  • john

If this or any post solves your issue, please mark them as 'Accept as Solution' It really helps. And if you notice anything wrong do not hesitate to 'Report Inappropriate Content'. Someone will review it.
HElni.1
Associate II

I changed the I2c addresses but still unable to read data through TeraTerm.Another thing I noticed the variable status is always 0

oh ok, I get it. I'll try and change the I2C addresses and see what I it returns.

EDIT: It is returning the -13 IO error when attempting to configure the first address to 0x62

        VL53L1X Examples...

Setting XSHUT pin ON...

Waiting device to boot...

Reading device UID: 7555855411574540485

Setting Device Address to 0x62

VL53LX_SetDeviceAddress failed: error = -13

To me it is failing right after attempting to set the first device address to 0x62.

        VL53L1X Examples...

Setting XSHUT pin ON...

Waiting device to boot...

Reading device UID: 7555855411574540485

Setting Device Address to 0x62

VL53LX_SetDeviceAddress failed: error = -13

John E KVAM
ST Employee

I've had good luck with the following bit of code.

If you want the complete project go to ST.COM and search for 2D-Lidar.

The 2D-Lidar code uses 9 sensors.

	uint16_t DevAddr[9] = {0x62, 0x64, 0x66, 0x68, 0x6A, 0x6C, 0x6E, 0x70, 0x72};
 
	for (i = 0; i < NumOfTOFSensors; i++)
	{
		Dev[i].I2cHandle = &I2C_HANDLE;
		Dev[i].I2cDevAddr = 0x52;
		TurnOnSensor(i);
		HAL_Delay(5);
		do {
			status = VL53L1X_BootState(Dev[i], &temp);
			HAL_Delay(5);
			if (status) {
				UART_Print("BootState returned bad status\n");
			}
 
		} while (temp != 3);
 
 
		status += VL53L1X_SensorInit(Dev[i]);	/* Initialize sensor  */
		status += VL53L1X_SetI2CAddress(Dev[i], DevAddr[i]);	/* Change i2c address Left is now 0x62 and Dev1 */
 
		CHECK_ERROR(status);
 
		Dev[i].I2cDevAddr = DevAddr[i];
		//status += VL53L1X_SensorInit(Dev[i]);	/* Initialize sensor  */
	}
	UART_Print("All Chips booted\n");

Perhaps your issue is the order. Checking for device booted and doing the SensorInit() first might help?

I used the UltraLite driver for this project. If you are using the Full driver the calls might be slightly different.

  • john

If this or any post solves your issue, please mark them as 'Accept as Solution' It really helps. And if you notice anything wrong do not hesitate to 'Report Inappropriate Content'. Someone will review it.