VL53L0X super high speed mode

Hi, I am at the moment using 2 sensors for my data logger (LowLatencyLogger from SdFat library). It works fine but im trying to get some more speed out of it. I am using the "high_speed" mode which is 20millisecond but my goal is 10=100hz so I found this in the API doc for the sensors but im unsure on how to implement it or if its even usefull to me at all:

execute delay in all polling API call
A typical multi-thread or RTOs implementation is to sleep the task for
some 5ms (with 100Hz max rate faster polling is not needed) if
nothing specific is need you can define it as an empty/void macro
1 #define VL53L0X_PollingDelay(...) (void)0
Parameters
Dev Device Handle
Returns
VL53L0X_ERROR_NONE Success
"Other error code" See VL53L0X_Error

My current code (part of the whole code):

#include "UserTypes.h"
#include <Wire.h>
#include <VL53L0X.h>
#include "RTClib.h"

// User data functions.  Modify these functions for your data items.
RTC_DS1307 rtc;
VL53L0X sensor1, sensor2;// define objects for sensors
// Start time for data
static uint32_t startMicros;
// User data functions.  Modify these functions for your data items.




   
// Acquire a data record.
void acquireData(data_t* data) {
  DateTime now = rtc.now();
  data->time = micros() - startMicros;
 data->adc[0] =  (now.minute());
  data->adc[1] =  (now.second());
  data->adc[2] = sensor1.readRangeContinuousMillimeters();
   data->adc[3] = sensor2.readRangeContinuousMillimeters();
}

// Print a data record.
void printData(Print* pr, data_t* data) {
  if (startMicros == 0) {
    startMicros = data->time;
  }
  pr->print(data->time - startMicros);
  for (int i = 0; i < ADC_DIM; i++) {
    pr->write(',');
    pr->print(data->adc[i]);
  }
  pr->println();
}


// Print data header.
void printHeader(Print* pr) {
  startMicros = 0;
  pr->print(F("micros"));
  for (int i = 0; i < ADC_DIM; i++) {
    pr->print(F(",adc"));
    pr->print(i);
  }
  pr->println();
}

// Sensor setup
void userSetup() {
  Serial.begin(250000);
   rtc.begin();
   Wire.begin();

   
   
    pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  digitalWrite(6, LOW);
  digitalWrite(7, LOW);

 

  //SENSOR
  digitalWrite(6, HIGH);
  sensor1.init(true);
  sensor1.setAddress(0x30);
  Serial.println("set address 0x30 for first sensor");
  delay(10);
sensor1.setMeasurementTimingBudget(20000); //set speed sensor 1
 sensor1.startContinuous();
  digitalWrite(7, HIGH);
  sensor2.init(true);
  sensor2.setAddress(0x31);
  Serial.println("set address 0x31 for second sensor");
  delay(10);


sensor2.setMeasurementTimingBudget(20000); //set speed sensor 2
  sensor2.startContinuous();
  
}

This excerpt doesn't include the sensor reading code. So you either already found a solution for your problem or you have to post the complete code to enable us to find the problem.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.