Counts points that hit a LIDAR sensor, and includes threshold sensing so a point doesn't get counted twice, much in the same spirit as debouncing.
Dependencies: mbed mbed-rtos 4DGL-uLCD-SE X_NUCLEO_53L0A1
The Object Counter counts the number of objects (in our case, ping pong balls) that pass by the sensor. It features a high water mark that ensures only one ball is counted at any given time, and that a ball will only be counted once.
Partner Program
This is intended to be used with Ping Pong Robot, but can be used by itself if you wish
Installation
We use the following components:
All of these can be purchased from SparkFun with the exception of the VL53L0X sensor, wich is from AdaFruit.
To connect these, use the following pin outs:
Class D Amplifier & Speaker
MBED | Class D Audio Amp | Speaker |
---|---|---|
Gnd | IN- | |
Gnd | PWR- | |
5V | PWR+ | |
p25 | IN+ | |
p20 | S | |
OUT- | Speaker- | |
OUT+ | Speaker+ |
uLCD Screen
MBED | uLCD Header | uLCD |
---|---|---|
Gnd | Gnd | Gnd |
+5V | +5V | +5V |
p13 | TX | RX |
p14 | RX | TX |
p15 | RES | RES |
VL35L0X
MBED | VL35L0X |
---|---|
Gnd | Gnd |
+3.3V | VIN |
p26 | SHDN |
p27 | SDA |
p28 | SCL |
Usage
This is intended to be used to track the number of objects that have been collected. Because of this, the software features a "High Water Mark" mentality - after an object has gotten close enough, a flag is tripped - this flag only resets after the distance increases back past the high water mark. In this way, we ensure we count each object once - much in the same spirit as debouncing.
The VL53L0X is a low cost chip that measures distance via "Time of Flight" - basically how long it takes light to travel to the object and back. Because it uses a single laser, it can be quite precise. This makes it ideal for our purposes - tracking a single object as it falls.
Heads Up!
The largest issue is data collection time - while the chip does collect data quickly, if your object is moving at a high speed, it can sometimes miss the object entirely because it didn't "see" the object in the few fractions of a second that the object was close enough!
If you require more precision, there are plenty of higher quality (and higher cost) LIDAR systems - AdaFruit sells many of these.
As a workaround, ensure your object is not moving quickly - this can be accomplished by setting the LIDAR's side on the floor, so its line of sight is directly above the ground. When the object hits the ground, even if it bounces, it should be on the ground enough time for the LIDAR to pick it up. Slightly tilting the ground will make sure your object will roll away after falling.
As with everything else, experience is the best teacher - you might need to tweak the threshold in the code to get optimal results.
Demonstration
The circuit looks like this:
Revisions of main.cpp
Revision | Date | Message | Actions |
---|---|---|---|
5:b566bcb20d94 | 2019-04-18 | Revise virtual LED | File Diff Annotate |
4:44b4158fc494 | 2019-04-18 | Remove LED completely | File Diff Annotate |
3:efb572ef5f15 | 2019-04-18 | Move LED to be virtual on LCD | File Diff Annotate |
2:54e1a301de72 | 2019-04-14 | Clean up code | File Diff Annotate |
1:e82997c13013 | 2019-04-14 | Add working LIDAR code | File Diff Annotate |
0:fc7ce4e596ff | 2019-04-14 | Initial Commit | File Diff Annotate |