-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from Lyr3x/add-calibration-code
Add calibration code and all timing budgets
- Loading branch information
Showing
10 changed files
with
517 additions
and
24 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
// See http://go.microsoft.com/fwlink/?LinkId=827846 | ||
// for the documentation about the extensions.json format | ||
"recommendations": [ | ||
"platformio.platformio-ide" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// AUTOMATICALLY GENERATED FILE. PLEASE DO NOT MODIFY IT MANUALLY | ||
// | ||
// PIO Unified Debugger | ||
// | ||
// Documentation: https://docs.platformio.org/page/plus/debugging.html | ||
// Configuration: https://docs.platformio.org/page/projectconf/section_env_debug.html | ||
|
||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "platformio-debug", | ||
"request": "launch", | ||
"name": "PIO Debug", | ||
"executable": "/Users/kaibepperling/dev/Roode/calibration/.pio/build/roode-calibration/firmware.elf", | ||
"projectEnvName": "roode-calibration", | ||
"toolchainBinDir": "/Users/kaibepperling/.platformio/packages/toolchain-xtensa32@2.50200.97/bin", | ||
"internalConsoleOptions": "openOnSessionStart", | ||
"preLaunchTask": { | ||
"type": "PlatformIO", | ||
"task": "Pre-Debug" | ||
} | ||
}, | ||
{ | ||
"type": "platformio-debug", | ||
"request": "launch", | ||
"name": "PIO Debug (skip Pre-Debug)", | ||
"executable": "/Users/kaibepperling/dev/Roode/calibration/.pio/build/roode-calibration/firmware.elf", | ||
"projectEnvName": "roode-calibration", | ||
"toolchainBinDir": "/Users/kaibepperling/.platformio/packages/toolchain-xtensa32@2.50200.97/bin", | ||
"internalConsoleOptions": "openOnSessionStart" | ||
}, | ||
{ | ||
"type": "platformio-debug", | ||
"request": "launch", | ||
"name": "PIO Debug (without uploading)", | ||
"executable": "/Users/kaibepperling/dev/Roode/calibration/.pio/build/roode-calibration/firmware.elf", | ||
"projectEnvName": "roode-calibration", | ||
"toolchainBinDir": "/Users/kaibepperling/.platformio/packages/toolchain-xtensa32@2.50200.97/bin", | ||
"internalConsoleOptions": "openOnSessionStart", | ||
"loadMode": "manual" | ||
} | ||
] | ||
} |
62 changes: 62 additions & 0 deletions
62
calibration/OffsetAndXtalkCalibration/OffsetAndXtalkCalibration.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#include "VL53L1X_ULD.h" | ||
|
||
VL53L1X_ULD sensor; | ||
bool dataReady; | ||
|
||
void setup() | ||
{ | ||
Serial.begin(115200); | ||
Wire.begin(); | ||
|
||
VL53L1_Error sensor_status = sensor.Begin(); | ||
if (sensor_status != VL53L1_ERROR_NONE) | ||
{ | ||
Serial.println("Could not initialize the sensor, error code: " + String(sensor_status)); | ||
while (1) | ||
{ | ||
} | ||
} | ||
Serial.println("Sensor initialized"); | ||
|
||
// Start the offset calibration | ||
Serial.println("Place a target, 17 % grey, at 140 mm from the sensor a"); | ||
Serial.println("The calibration may take a few seconds. The offset correction is applied to the sensor at the end of calibration."); | ||
Serial.readString(); | ||
int16_t foundOffset; | ||
sensor_status = sensor.CalibrateOffset(140, &foundOffset); | ||
|
||
|
||
Serial.println("Calibrated offset: " + String(foundOffset)); | ||
Serial.println("Set this offset in the sensor configuration under offset: <value>"); | ||
|
||
/* The target distance : the distance where the sensor start to "under range" | ||
Crosstalk calibration should be conducted in a dark environment, with no IR contribution. | ||
The crosstalk calibration distance needs to be characterized as it depends on the system environment which | ||
mainly includes: | ||
• The cover glass material and optical properties | ||
• The air gap value i.e. the distance between the sensor and the cover glass | ||
Do a full sweep with the target from near to far, noting the resulting measurement. | ||
At some point, the actual value and the measured value start to diverge. This is the crosstalk calibration | ||
distance. | ||
*/ | ||
uint16_t CalibrationDistance = 140; // crosstalk calibration distance | ||
uint16_t foundXTalk; | ||
sensor_status = sensor.CalibrateXTalk(CalibrationDistance, &foundXTalk); | ||
Serial.println("Calibrated offset: " + String(foundXTalk)); | ||
Serial.println("Set this offset in the sensor configuration under crosstalk: <value>"); | ||
} | ||
void loop() | ||
{ | ||
if (dataReady) | ||
{ | ||
// Get the results | ||
uint16_t distance; | ||
sensor.GetDistanceInMm(&distance); | ||
|
||
// After reading the results reset the interrupt to be able to take another measurement | ||
sensor.ClearInterrupt(); | ||
dataReady = false; | ||
|
||
Serial.println("Distance in mm: " + String(distance)); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
; PlatformIO Project Configuration File | ||
; | ||
; Build options: build flags, source filter | ||
; Upload options: custom upload port, speed and extra flags | ||
; Library options: dependencies, extra library storages | ||
; Advanced options: extra scripting | ||
; | ||
; Please visit documentation for the other options and examples | ||
; https://docs.platformio.org/page/projectconf.html | ||
|
||
[env:roode-calibration] | ||
platform = espressif32 | ||
board = wemos_d1_mini32 | ||
framework = arduino | ||
lib_deps = rneurink/VL53L1X_ULD@^1.2.3 | ||
monitor_speed = 115200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include "VL53L1X_ULD.h" | ||
|
||
VL53L1X_ULD sensor; | ||
bool dataReady; | ||
|
||
void setup() | ||
{ | ||
Serial.begin(115200); | ||
Wire.begin(); | ||
|
||
VL53L1_Error sensor_status = sensor.Begin(); | ||
if (sensor_status != VL53L1_ERROR_NONE) | ||
{ | ||
Serial.println("Could not initialize the sensor, error code: " + String(sensor_status)); | ||
while (1) | ||
{ | ||
} | ||
} | ||
Serial.println("Sensor initialized"); | ||
|
||
// Start the offset calibration | ||
Serial.println("Place a target, 17 % grey, at 140 mm from the sensor a"); | ||
Serial.println("The calibration may take a few seconds. The offset correction is applied to the sensor at the end of calibration."); | ||
Serial.readString(); | ||
int16_t foundOffset; | ||
sensor_status = sensor.CalibrateOffset(140, &foundOffset); | ||
|
||
sensor.SetOffsetInMm(foundOffset); | ||
|
||
Serial.println("Calibrated offset: " + String(foundOffset)); | ||
Serial.printf("Set this offset in the sensor configuration under offset: %d\n", foundOffset); | ||
|
||
/* The target distance : the distance where the sensor start to "under range" | ||
Crosstalk calibration should be conducted in a dark environment, with no IR contribution. | ||
The crosstalk calibration distance needs to be characterized as it depends on the system environment which | ||
mainly includes: | ||
• The cover glass material and optical properties | ||
• The air gap value i.e. the distance between the sensor and the cover glass | ||
Do a full sweep with the target from near to far, noting the resulting measurement. | ||
At some point, the actual value and the measured value start to diverge. This is the crosstalk calibration | ||
distance. | ||
*/ | ||
uint16_t CalibrationDistance = 140; // crosstalk calibration distance | ||
uint16_t foundXTalk; | ||
sensor_status = sensor.CalibrateXTalk(CalibrationDistance, &foundXTalk); | ||
Serial.println("Calibrated offset: " + String(foundXTalk)); | ||
Serial.printf("Set this offset in the sensor configuration under crosstalk: %d\n", foundXTalk); | ||
sensor.SetXTalk(foundXTalk); | ||
sensor.StartRanging(); | ||
} | ||
void loop() | ||
{ | ||
if (dataReady) | ||
{ | ||
// Get the results | ||
uint16_t distance; | ||
sensor.GetDistanceInMm(&distance); | ||
|
||
// After reading the results reset the interrupt to be able to take another measurement | ||
sensor.ClearInterrupt(); | ||
dataReady = false; | ||
|
||
Serial.println("Distance in mm: " + String(distance)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.