Input Devices – ToF-based 2D Location Tracking
Table of contents
Group Assignment for Output Devices
probe an input device’s analog levels and digital signals.
shown in Week 8 of EECS Group Assignments.
Design
I first used D21E18 to design a single-channel I²C board, as shown in the photo below.
Initial design not using the right I²C channel |
Initial board (not using the right I²C channel) |
After pointing out by Anthony, I used the default I²C channel for the main board and the second I²C channel for the breakout board, as shown in the photo below.
Fabrication – Milling and Soldering
Milled PCB before sanding |
Milled PCB after 500-grit sanding |
Since the pins of VL53L0X sensor are all underneath the chip, I have to use the flow technique i.e., hot air to solder it. And it’s super satisfying to see the soldering process using hot air.
I also used the solder paste instead of solder for the rest of the soldering process. The main reason is that so long as the amount of solder paste is enough, the solder paste will be melted by the iron, and the solder paste will be evenly distributed on the PCB. And the solder paste is much easier to clean up than the solder.
Milled PCB |
Soldered PCB |
Milled main and breakout PCBs |
Soldered main and breakout PCBs |
Fabrication Issues
Broken trace issue |
Fixed broken trace with a wire |
MicroUSB peeled off accidentally |
Attempt to fix adding a underneath wire |
MicroUSB fixed but peeled off again |
Finally another one with hard glue |
Programming
After bootloadering the D21E18, I am able to program it using Arduino IDE. One software side thing that Anthony reminded me of is using two channles of I²C, that is setting the Tools
-> Serial Config
-> ONE_UART_TWO_WIRE_ONE_SPI
to use two I²C (wire) channels. And the second I²C channel (&Wire1
) is connected to the OLED display, and the first I²C channel (&Wire
) is connected to the ToF sensor.
Result
Code Snippets
ToF_2D_localization.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// ToF_2D_localization.ino
// Single-object 2D localization based on two-axis ToF Sensors
#include <Wire.h>
#include <VL53L0X.h>
VL53L0X sensorX;
VL53L0X sensorY;
const int pin_shutdown = 15; // Pin of ToF sensor SHUTDOWN
const int pin_shutdown1 = 11; // Pin of ToF sensor SHUTDOWN1
void setup() {
sensorY.setBus(&Wire1);
Serial.begin(9600);
Wire.begin();
Wire1.begin();
pinMode(pin_shutdown, OUTPUT);
pinMode(pin_shutdown1, OUTPUT);
digitalWrite(pin_shutdown, HIGH);
digitalWrite(pin_shutdown1, HIGH);
sensorX.setTimeout(500);
if (!sensorX.init()) {
Serial.println("Failed to detect and initialize sensorX!");
while (1) {}
}
sensorY.setTimeout(500);
if (!sensorY.init()) {
Serial.println("Failed to detect and initialize sensorY!");
while (1) {}
}
}
void loop() {
int rangeX = sensorX.readRangeSingleMillimeters();
int rangeY = sensorY.readRangeSingleMillimeters();
char buffer[40];
sprintf(buffer, "X: %4d mm, Y: %4d mm.", rangeX, rangeY);
Serial.println(buffer);
if (sensorX.timeoutOccurred()) { Serial.print(" SensorX TIMEOUT"); }
if (sensorY.timeoutOccurred()) { Serial.print(" SensorY TIMEOUT"); }
}