2024-09-30 01:03 AM - edited 2024-09-30 01:15 AM
hello Team,
I am using your sensor VL53L0X distance sensor in my project. The problem is your library not support with this Renesas RX71 microcontroller so i did send the register and receive the register with FIT module function in Renesas provide.
but i don't get the distance value i read the 0x14 register and store in the array and shift LSB to MSB to get range data i get some value as i move my hand from the sensor the value are move means the sensor leaser position is movement is done the value is move is difference is more. so couldn't match actual distance.
i am attaching my code plz see and revert as soon as possible.
i am attaching video just see.
best regard's
Ashish.
this are variable declaration and register
/////VL53L0X/////
#define DATA_LENGTH 14
uint8_t tx_buf[2] = {0x00,0x02};// Command to start a measurement
uint8_t rx_buf1[1]={0x14};
uint8_t rx_buf2[1]={0x1e};
uint8_t rx_buf3[1]={0x1f};
uint8_t tx_buf4[2]={0x80,0x01};
uint8_t tx_buf5[2]={0xff,0x01};
uint8_t tx_buf6[2]={0x00,0x00};
uint8_t tx_buf7[2]={0xff,0x06};
uint8_t tx_buf8[2]={0x83,0x04};
uint8_t tx_buf9[2]={0xff,0x07};
uint8_t tx_buf10[2]={0x81,0x01};
uint8_t tx_buf11[2]={0x80,0x01};
uint8_t tx_buf12[2]={0x94,0x6b};
uint8_t tx_buf13[2]={0x83,0x00};
uint8_t tx_buf14[2]={0x83,0x01};
uint8_t tx_buf15[2]={0x81,0x00};
uint8_t tx_buf16[2]={0xff,0x06};
uint8_t tx_buf17[2]={0xff,0x01};
uint8_t tx_buf18[2]={0x00,0x01};
uint8_t tx_buf19[2]={0xff,0x00};
uint8_t tx_buf20[2]={0x80,0x00};
uint8_t tx_buf21[2]={0x88,0x00};
uint8_t tx_buf22[2]={0x80,0x01};
uint8_t tx_buf23[2]={0xff,0x01};
uint8_t tx_buf24[2]={0x00,0x00};
uint8_t tx_buf25[2]={0x00,0x01};
uint8_t tx_buf26[2]={0xff,0x00};
uint8_t tx_buf27[2]={0x80,0x00};
uint8_t tx_buf28[2]={0x4f,0x00};
uint8_t tx_buf29[2]={0x4e,0x2c};
uint8_t tx_buf30[2]={0xb6,0xb4};
uint8_t tx_buf31[2]={0x0e,0x06};
uint8_t spadcount=0;
uint8_t samples4=0;
uint16_t accumulator=0;
uint16_t average=0;
uint16_t duty=0;
uint8_t gbuf[16];
//uint8_t distance4=0;
uint8_t distance1=0;
uint16_t data[DATA_LENGTH];
uint8_t i4=0;
uint16_t DIST_SCAL=0;
uint16_t sensor_range=0;
uint16_t distance_cm=0;
uint16_t cm_size=0;
uint16_t deverror=0;
uint16_t DIST_COUNT;
MD_STATUS response;
uint8_t j4=0;
uint8_t sz=12;
uint16_t final_scale=0;
uint8_t gbuf1[12];
uint8_t test_buf[5];
uint8_t samples5=0;
//uint16_t accumulator1=0;
uint16_t Updated_scale=0;
//uint16_t duty1=0;
uint8_t data_entry_buf_con1[2] = {0x00,0x00};
uint8_t page1=0;
//how read VL53L0X distance sensor value using i2c in renesas rx71//
uint16_t batteryPercentage=0;
//function prototypes//
//void R_RIIC2_Start(void);
void delay(int t);
void send();
void read_vl53l0x();
void read_block_data_at(uint8_t reg, uint8_t sz);
void vl53l0x();
void user_rebound_no();
uint16_t user_entry_rebound_count();
///////////////main/////////////
this are main function.
2024-09-30 01:13 AM
2024-09-30 07:04 AM
ST recommends that you use the API that you can download from ST.com. Search for the VL53L0X part and click on software. Download that API and you get the C functions you need. It's your job to write the Platform.c to interface the I2C functions of the API to your match your hardware, but it looks like you know how to do that.
But if you are determined to 'roll your own' the VL53L0X is a poor place to start. That sensor uses I2C 8-bit addressing and there are a lot of registers. So most likely you have the page register wrong and your writes are not doing what you want.
Try the VL53L4CD. It ranges to 1.3 meters very effectively. But more, it has 16-bit addressing, so no pages. I'd suggest you use the Ultra-Lite Driver as an example. Or just use the Ultra Lite driver. (Again, download it from ST.com and give it a read.) It was written for people like you who want to talk directly to the hardware. It is very concise.
I think you will be much happier.
Or you get the VL53L4CD from Sparkfun or Pololu or Adafruit. They have the sensor and software that runs in their environments.
- john
2024-09-30 09:16 PM
hello sir,
What is required to initialization to VL53L0X sensor like SPAD,Temperature etc is any another is required to initialization this sensor if yes then tell me.
Best Regard's
Ashish.
2024-10-01 07:46 AM
Ashish -
The only rational way to do this is to download the API from ST's web site and run that. It only requires that you edit the file Platform.c to interface with your processor and call some well-defined API functions. The code is free, if a bit confusing.
If you are bound and determined to NOT to use our code, then I'd reverse engineer it.
Buy the Evaluation kit - P-nucleo-53L0A1. And get it running with the code provided on ST.com. Make the calls to initialize it to your liking.
Then edit the I2C read and write routines to print out the transactions. (You can also use an I2C analyzer, but a print statement is easier - and cheaper. )
Once you have all the I2C traffic, and you put in enough print statements to know from which calls they came, you can write simple code to reproduce the transactions.
If you don't want to use ST's version, you can pull the same trick by getting a sensor from SparkFun and using their environment.
But I'd really recommend you just port the ST code into your project. It would be a lot easier.
- john
2024-10-24 02:30 AM
Hello sir,
i have to do use only this sensor as client suggest so i have no option.so tell me the
1). Does this required to load SPAD
2).i have got this on github in this code there is read this one register which have SPAD count tmp = readReg(0x92) this register. but in my controller i read this i don't get this SPAD count .
but i read this uint8_t spad_tx4[2] = {0x83, 0x00}; get the value.what does this value.
plz provide me all register and data just like {0x83, 0x00}.
i am attching some image of project result of this sensor just see this.
sensor reading form register 0x14 in the array when i move hand from the sensor the will increase and decrease but as you github code this actual sensor distance value is in the array 10 and 11 position but this not get.because i am not able to calculate the SPAD temperature calibration and cross talk offset calibration.
tell me the which registers required to do this calibration .
and second video is the SPAD video.
bool VL53L0X::getSpadInfo(uint8_t * count, bool * type_is_aperture)
{
uint8_t tmp;
writeReg(0x80, 0x01);
writeReg(0xFF, 0x01);
writeReg(0x00, 0x00);
writeReg(0xFF, 0x06);
writeReg(0x83, readReg(0x83) | 0x04);
writeReg(0xFF, 0x07);
writeReg(0x81, 0x01);
writeReg(0x80, 0x01);
writeReg(0x94, 0x6b);
writeReg(0x83, 0x00);
startTimeout();
while (readReg(0x83) == 0x00)
{
if (checkTimeoutExpired()) { return false; }
}
writeReg(0x83, 0x01);
tmp = readReg(0x92);
*count = tmp & 0x7f;
*type_is_aperture = (tmp >> 7) & 0x01;
writeReg(0x81, 0x00);
writeReg(0xFF, 0x06);
writeReg(0x83, readReg(0x83) & ~0x04);
writeReg(0xFF, 0x01);
writeReg(0x00, 0x01);
writeReg(0xFF, 0x00);
writeReg(0x80, 0x00);
return true;
}