使用STM32CUBEMX驱动多个VL6180X传感器的实现方法

概述

VL6180X是基于ST FlightSense™专利技术的最新产品。这是一个突破性的技术,实现了独立于目标反射率的绝对距离测量。现有技术通过测量反射光的光量来估算距离,这种方法的最大缺点是被测物体的颜色和表面对测量精度影响很大,而VL6180X则精确测量光线从传感器照射到最近物体然后反射到传感器所用时间(飞行时间),以此计算两者之间的距离。
VL6180X将一个红外发射器,一个红外传感器和一个环境光传感器整合于一个三合一即用型回流焊封装,易于集成,为终端产品制造商缩短了光学和机械设计优化过程并降低了相应的成本。
该模块为低功率操作设计。测距和ALS测量可在用户定义的时间间隔自动执行。支持多门限和中断方案以尽量减少主机操作。
主机控制和结果阅读通过使用I2C接口执行。可选的附加功能(如测量准备和门限中断)由两个可编程的GPIO引脚提供。
最近在弄ST和瑞萨RA的课程,需要样片的可以加群申请:6_15061293 。

所有功能

  • 三合一智能光学模块
  • 接近传感器
  • 环境光传感器
  • VCSEL光源
  • 快速,精确测距
  • 绝对测量范围从0到超过10 cm(10cm以上的测距取决于具体情况)
  • 不受目标反射率影响
  • 环境光抑制
  • 盖片的串扰补偿
  • 盖片的串扰补偿
  • 主机系统可以用距离和信号电平实现手势识别
  • 可用演示系统:P-NUCLEO-6180X1 评估板
  • 环境光传感器
  • 高动态范围
  • 精确/超低光敏感
  • 校准输出值(以勒克斯为单位)
  • 方便集成
  • 单回流焊元件
  • 无附加光学元件
  • 单电源
  • 用于器件控制和数据的I2C接口
  • 提供一个文档化的C可移植 API(应用程序接口)
  • 两个可编程GPIO
  • 测距和ALS的窗口和门限功能
  • 技术规范

    注意供电为2.8V,IIC接口,最大支持快速模式速率,为400k,默认地址为0x29。
    光照强度检测范围为 1 Lux -100 kLux。

    接口

    接口说明

    最小系统图

    初始化


    首先需要检查寄存器SYSTEM__FRESH_OUT_OF_RESET {0x16}是否为0x01.
    之后进行6180初始化。
    初始化如下所示。


     uint8_t ptp_offset;
    uint8_t VL6180X_Init(uint8_t add)
    {
    	ptp_offset=VL6180X_ReadByte(add,VL6180X_REG_SYSTEM_FRESH_OUT_OF_RESET);
    	printf("ptp_offset=%d\n",ptp_offset);
    //	if(VL6180X_Read_ID(add) == VL6180X_DEFAULT_ID)
    	if(ptp_offset==0x01)
    	{	
    		VL6180X_WriteByte(add,0x0207, 0x01);
    		VL6180X_WriteByte(add,0x0208, 0x01);
    		VL6180X_WriteByte(add,0x0096, 0x00);
    		VL6180X_WriteByte(add,0x0097, 0xfd);
    		VL6180X_WriteByte(add,0x00e3, 0x00);
    		VL6180X_WriteByte(add,0x00e4, 0x04);
    		VL6180X_WriteByte(add,0x00e5, 0x02);
    		VL6180X_WriteByte(add,0x00e6, 0x01);
    		VL6180X_WriteByte(add,0x00e7, 0x03);
    		VL6180X_WriteByte(add,0x00f5, 0x02);
    		VL6180X_WriteByte(add,0x00d9, 0x05);
    		VL6180X_WriteByte(add,0x00db, 0xce);
    		VL6180X_WriteByte(add,0x00dc, 0x03);
    		VL6180X_WriteByte(add,0x00dd, 0xf8);
    		VL6180X_WriteByte(add,0x009f, 0x00);
    		VL6180X_WriteByte(add,0x00a3, 0x3c);
    		VL6180X_WriteByte(add,0x00b7, 0x00);
    		VL6180X_WriteByte(add,0x00bb, 0x3c);
    		VL6180X_WriteByte(add,0x00b2, 0x09);
    		VL6180X_WriteByte(add,0x00ca, 0x09);
    		VL6180X_WriteByte(add,0x0198, 0x01);
    		VL6180X_WriteByte(add,0x01b0, 0x17);
    		VL6180X_WriteByte(add,0x01ad, 0x00);
    		VL6180X_WriteByte(add,0x00ff, 0x05);
    		VL6180X_WriteByte(add,0x0100, 0x05);
    		VL6180X_WriteByte(add,0x0199, 0x05);
    		VL6180X_WriteByte(add,0x01a6, 0x1b);
    		VL6180X_WriteByte(add,0x01ac, 0x3e);
    		VL6180X_WriteByte(add,0x01a7, 0x1f);
    		VL6180X_WriteByte(add,0x0030, 0x00);
    		
    		// Recommended : Public registers - See data sheet for more detail
    		VL6180X_WriteByte(add,0x0011, 0x10);       // Enables polling for 'New Sample ready'
    									// when measurement completes
    		VL6180X_WriteByte(add,0x010a, 0x30);       // Set the averaging sample period
    									// (compromise between lower noise and
    									// increased execution time)
    		VL6180X_WriteByte(add,0x003f, 0x46);       // Sets the light and dark gain (upper
    									// nibble). Dark gain should not be
    									// changed. !上半字节要写入0x4	默认增益是1.0
    		VL6180X_WriteByte(add,0x0031, 0xFF);       // sets the # of range measurements after
    									// which auto calibration of system is
    									// performed
    		VL6180X_WriteByte(add,0x0041, 0x63);       // Set ALS integration time to 100ms
    		VL6180X_WriteByte(add,0x002e, 0x01);       // perform a single temperature calibration
    									// of the ranging sensor
    
    		// Optional: Public registers - See data sheet for more detail
    		VL6180X_WriteByte(add,0x001b, 0x09);    //测量间隔	轮询模式
    									// period to 100ms	每步10ms->0-10ms
    		VL6180X_WriteByte(add,0x003e, 0x31);      //测量周期	ALS模式
    									// to 500ms		
    		VL6180X_WriteByte(add,0x0014, 0x24);       // Configures interrupt on 'New Sample
    									// Ready threshold event'
    
    
    //VL6180X_WriteByte(add,VL6180X_REG_SYSTEM_FRESH_OUT_OF_RESET, 0x00); //不发送00那么读出来的数值就是01
    
    		return 0;
    	}
    	else return 1;
    }
    

    还在更新中

    还在更新中还在更新中还在更新中还在更新中还在更新中

    物联沃分享整理
    物联沃-IOTWORD物联网 » 使用STM32CUBEMX驱动多个VL6180X传感器的实现方法

    发表评论