Coder Social home page Coder Social logo

sp_tof's Introduction

SP_TOF Module User Guide

中文

Directory Structure

Directory Description
doc Reference documentation
img Images
script Maixpy script example
src C program example based on the standalone sdk

Introduce

The VL53L0X sensor used in this module is an I2C interface and a long distance single point flight time measurement (ToF) sensor. It has high performance and high reliability, with the longest distance of 4m and the highest refresh rate of 50Hz. With the red laser pointer, the laser is activated through XSHUT and connected by SP_MOD.

See 模块规格书 for more information.

Pin figure

Mode of connection

MCU:FUN(IO) SP_RFID
I2C:SDA(IO_7) SDA
NC(IO_15) NC
NC(IO_20) IRQ
NC(IO_21) NC
GPIOHS(IO_8) SHT
I2C:SCL(IO_6) SCL
2.8~3.5V 3.3V
GND GND

MCU configuration

IO Port configuration

Configure the IO port corresponding to the schematic diagram as I2C function

  • C

      //set io mux
      fpioa_set_function(VL53L0X_SCL, FUNC_I2C0_SCLK + VL53L0X_I2C_DEVICE * 2);
      fpioa_set_function(VL53L0X_SDA, FUNC_I2C0_SDA + VL53L0X_I2C_DEVICE * 2);
      fpioa_set_function(VL53L0X_SHT, FUNC_GPIOHS0 + VL53L0X_SHT);
    
      gpiohs_set_drive_mode(VL53L0X_SHT, GPIO_DM_OUTPUT);
  • MaixPy

      fm.register(VL53L0X_SHT, fm.fpioa.GPIOHS0, force=True)
      XSHUT = GPIO(GPIO.GPIOHS0, GPIO.OUT)  

I2C initalization

  • C

     //i2c init
      maix_i2c_init(VL53L0X_I2C_DEVICE, 7, VL53L0X_I2C_FREQ_KHZ * 1000);
  • MaixPy

      i2c = I2C(VL53L0X_I2C_NUM, freq=VL53L0X_FREQ, scl=VL53L0X_SCL, sda=VL53L0X_SDA)

Method of application

  • Process

    1. Initializatin
    2. Adjust(option)
    3. Get distance
  • C

      while (vl53l0x_init(&vl53l0x_dev)) {
            printf("VL53L0X init error!!!\r\n");
            msleep(500);
      }
    
      printf("VL53L0X init success!\r\n");
    
      // adjusting
      printf("VL53L0X adjusting\r\n");
      vl53l0x_calibration_test(&vl53l0x_dev);
    
      // get distance
      printf("VL53L0X start work\r\n");
      vl53l0x_general_test(&vl53l0x_dev);
  • MaixPy

      # create obj and read distance
        tof = VL53L0X(i2c)
        while True:
        mm = tof.read()
        utime.sleep_ms(100)
        print(mm)

Runtime enviroments

Language Boards SDK/firmware version
C MaixCube kendryte-standalone-sdk v0.5.6
MaixPy MaixCube maixpy v0.5.1

Result

  • C

  • MaixPy

Transplant

Modify the following parameters to fit other K210 boards.

  • C
  // board_config.h
  #define VL53L0X_I2C_DEVICE 0 // i2c device number
  #define VL53L0X_I2C_FREQ_KHZ 100 // i2c frequence
  #define VL53L0X_SCL 6 // scl
  #define VL53L0X_SDA 7 // sda
  #define VL53L0X_SHT 8 // sht
  • MaixPy
  ################### config ###################
  VL53L0X_I2C_NUM = const(I2C.I2C0)
  VL53L0X_FREQ = const(100000)
  VL53L0X_SCL = const(6)
  VL53L0X_SDA = const(7)
  VL53L0X_SHT = const(8)
  ##############################################

LICENSE

See LICENSE file

Othre information

Version Editor Date
v1.0 vamoosebbf 2020.12.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.