试用了一下VL6180激光测距模块,能实现60cm内的精确测距,误差±3mm,用来测距的话,精确性很高。具体的代码和工程可到ST官网下载(链接见最后),感兴趣的朋友可是试下。
核心配置代码:
[mw_shl_code=applescript,true]static int VL6180x_RangeStaticInit(VL6180xDev_t dev)
{
int status;
LOG_FUNCTION_START("");
/* REGISTER_TUNING_SR03_270514_CustomerView.txt */
VL6180x_WrByte(dev, 0x0207, 0x01);
VL6180x_WrByte(dev, 0x0208, 0x01);
VL6180x_WrByte(dev, 0x0096, 0x00);
VL6180x_WrByte(dev, 0x0097, 0xfd);
VL6180x_WrByte(dev, 0x00e3, 0x00);
VL6180x_WrByte(dev, 0x00e4, 0x04);
VL6180x_WrByte(dev, 0x00e5, 0x02);
VL6180x_WrByte(dev, 0x00e6, 0x01);
VL6180x_WrByte(dev, 0x00e7, 0x03);
VL6180x_WrByte(dev, 0x00f5, 0x02);
VL6180x_WrByte(dev, 0x00d9, 0x05);
VL6180x_WrByte(dev, 0x00db, 0xce);
VL6180x_WrByte(dev, 0x00dc, 0x03);
VL6180x_WrByte(dev, 0x00dd, 0xf8);
VL6180x_WrByte(dev, 0x009f, 0x00);
VL6180x_WrByte(dev, 0x00a3, 0x3c);
VL6180x_WrByte(dev, 0x00b7, 0x00);
VL6180x_WrByte(dev, 0x00bb, 0x3c);
VL6180x_WrByte(dev, 0x00b2, 0x09);
VL6180x_WrByte(dev, 0x00ca, 0x09);
VL6180x_WrByte(dev, 0x0198, 0x01);
VL6180x_WrByte(dev, 0x01b0, 0x17);
VL6180x_WrByte(dev, 0x01ad, 0x00);
VL6180x_WrByte(dev, 0x00ff, 0x05);
VL6180x_WrByte(dev, 0x0100, 0x05);
VL6180x_WrByte(dev, 0x0199, 0x05);
VL6180x_WrByte(dev, 0x01a6, 0x1b);
VL6180x_WrByte(dev, 0x01ac, 0x3e);
VL6180x_WrByte(dev, 0x01a7, 0x1f);
VL6180x_WrByte(dev, 0x0030, 0x00);
/* Recommended : Public registers - See data sheet for more detail */
VL6180x_WrByte(dev, 0x0011, 0x10); /* Enables polling for New Sample ready when measurement completes */
VL6180x_WrByte(dev, 0x010a, 0x30); /* Set the averaging sample period (compromise between lower noise and increased execution time) */
VL6180x_WrByte(dev, 0x003f, 0x46); /* Sets the light and dark gain (upper nibble). Dark gain should not be changed.*/
VL6180x_WrByte(dev, 0x0031, 0xFF); /* sets the # of range measurements after which auto calibration of system is performed */
VL6180x_WrByte(dev, 0x0040, 0x63); /* Set ALS integration time to 100ms */
VL6180x_WrByte(dev, 0x002e, 0x01); /* perform a single temperature calibration of the ranging sensor */
/* Optional: Public registers - See data sheet for more detail */
VL6180x_WrByte(dev, 0x001b, 0x09); /* Set default ranging inter-measurement period to 100ms */
VL6180x_WrByte(dev, 0x003e, 0x31); /* Set default ALS inter-measurement period to 500ms */
VL6180x_WrByte(dev, 0x0014, 0x24); /* Configures interrupt on New sample ready */
status = VL6180x_RangeSetMaxConvergenceTime(dev, 50); /* Calculate ece value on initialization (use max conv) */
LOG_FUNCTION_END(status);
return status;
}[/mw_shl_code]
ST官网下载地址:
http://www.st.com/content/st_com/en/products/embedded-software/proximity-sensors-software/stsw-img003.html
因为我没有ST官网的账号,所以下载不了固件
一周热门 更多>